diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | ce599e4f9f94b4eb00c1b5edb85bce5431ab3df2 (patch) | |
tree | d3bb9f5d25a2dc09ca81adecf39621d871534297 /doc/kturtle | |
download | tdeedu-ce599e4f9f94b4eb00c1b5edb85bce5431ab3df2.tar.gz tdeedu-ce599e4f9f94b4eb00c1b5edb85bce5431ab3df2.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeedu@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'doc/kturtle')
-rw-r--r-- | doc/kturtle/Makefile.am | 3 | ||||
-rw-r--r-- | doc/kturtle/forward.png | bin | 0 -> 17797 bytes | |||
-rw-r--r-- | doc/kturtle/getting-started.docbook | 147 | ||||
-rw-r--r-- | doc/kturtle/glossary.docbook | 173 | ||||
-rw-r--r-- | doc/kturtle/index.docbook | 243 | ||||
-rw-r--r-- | doc/kturtle/mainwindow.png | bin | 0 -> 27605 bytes | |||
-rw-r--r-- | doc/kturtle/mainwindow_flower_nrs.png | bin | 0 -> 45281 bytes | |||
-rw-r--r-- | doc/kturtle/print.png | bin | 0 -> 23274 bytes | |||
-rw-r--r-- | doc/kturtle/programming-reference.docbook | 822 | ||||
-rw-r--r-- | doc/kturtle/translator-guide.docbook | 128 | ||||
-rw-r--r-- | doc/kturtle/using-kturtle.docbook | 590 | ||||
-rw-r--r-- | doc/kturtle/wrapping.png | bin | 0 -> 31697 bytes |
12 files changed, 2106 insertions, 0 deletions
diff --git a/doc/kturtle/Makefile.am b/doc/kturtle/Makefile.am new file mode 100644 index 00000000..41691557 --- /dev/null +++ b/doc/kturtle/Makefile.am @@ -0,0 +1,3 @@ +KDE_LANG = en +KDE_DOCS = AUTO + diff --git a/doc/kturtle/forward.png b/doc/kturtle/forward.png Binary files differnew file mode 100644 index 00000000..1dfc6c2e --- /dev/null +++ b/doc/kturtle/forward.png diff --git a/doc/kturtle/getting-started.docbook b/doc/kturtle/getting-started.docbook new file mode 100644 index 00000000..8d8ed12f --- /dev/null +++ b/doc/kturtle/getting-started.docbook @@ -0,0 +1,147 @@ +<!--Dear translator: please NEVER translate the id or anything inside the tags as they are needed in english by the application + Thanks a lot in advance.--> +<chapter id="getting-started"> +<title>Getting Started</title> +<para>When you start &kturtle; you will see something like this: +<screenshot> + <screeninfo>Here is a screenshot of &kturtle; when you start it for the first time</screeninfo> + <mediaobject> + <imageobject> + <imagedata fileref="mainwindow.png" format="PNG"/> + </imageobject> + <textobject> + <phrase>&kturtle; Main window</phrase> + </textobject> + </mediaobject> +</screenshot> +In this Getting Started guide we assume that the language of the &logo; commands is English. You can change this language in <menuchoice><guimenu>Settings</guimenu><guimenuitem>Configure &kturtle;...</guimenuitem></menuchoice> in the <guilabel>Language</guilabel> section. Be aware that the language you set here for &kturtle; is the one you use to type the &logo; commands.</para> + +<sect1 id="first-steps"> +<title>First steps with &logo;: meet the Turtle!</title> +<para>You must have noticed the turtle in the middle of the canvas: you are just about to learn how to control it using commands in the code editor.</para> + +<sect2 id="the-turtle-moves"> +<title>The Turtle Moves</title> +<para>Let us start by getting the turtle moving. Our turtle can do 3 types of moves, (1) it can go forwards and backwards, (2) it can turn left and right and (3) it can go directly to a position on the screen. Try this for example:</para> +<para> +<screen> +forward 100 +turnleft 90 +</screen> +Type or copy-paste the code to the code editor and execute it (using <link linkend="file-execute"><menuchoice><guimenu>File</guimenu><guimenuitem>Execute Commands</guimenuitem></menuchoice></link>) to see the result.</para> + +<para>When you typed and executed the commands like above in the code editor you might have noticed one or more of the following things:</para> +<orderedlist> +<listitem><para>That — after executing the commands — the turtle moves up, draws a line, and then turns a quarter turn to the left. This because you have used the <link linkend="forward"><userinput>forward</userinput></link> and the <link linkend="turnleft"><userinput>turnleft</userinput></link> commands.</para> +</listitem> +<listitem> +<para>That the color of the code changed while you where typing it: this feature is called <emphasis>intuitive highlighting</emphasis> — different types of commands are highlighted differently. This makes reading large blocks of code more easy.</para> +</listitem> +<listitem> +<para>That the turtle draws a thin black line.</para> +</listitem> +<listitem> +<para>Maybe you got an error message. This could simply mean two things: you could have made a mistake while copying the commands, or you should still set the correct language for the &logo; commands (you can do that by choosing <menuchoice><guimenu>Settings</guimenu><guimenuitem>Configure &kturtle;...</guimenuitem></menuchoice>, in the <guilabel>Language</guilabel> section).</para> +</listitem> +</orderedlist> + +<para>You will likely understand that <userinput>forward 100</userinput> commanded the turtle to move forward leaving a line, and that <userinput>turnleft 90</userinput> commanded the turtle to turn 90 <glossterm linkend="degrees">degrees</glossterm> to the left.</para> + +<para>Please see the following links to the reference manual for a complete explanation of the new commands: <userinput>forward</userinput>, <userinput>backward</userinput>, <userinput>turnleft</userinput>, and <userinput>turnright</userinput>.</para> +</sect2> + +<sect2 id="more-examples"> +<title>More examples</title> +<para>The first example was very simple, so let us go on!</para> + +<para> +<!--translators: if it's not already there, you can copy/paste the translated code below and save it in arrow.logo in your examples folder: kde-i18n/language-code/data/kdeedu/kturtle/ --> +<screen> +canvassize 200,200 +canvascolor 0,0,0 +pencolor 255,0,0 +penwidth 5 +clear + +go 20,20 +direction 135 + +forward 200 +turnleft 135 +forward 100 +turnleft 135 +forward 141 +turnleft 135 +forward 100 +turnleft 45 + +go 40, 100 +</screen> +Again you can type or copy-paste the code to the code editor or open the <filename>arrow.logo</filename> file in the <guimenu>Open Examples</guimenu> folder and execute it (using <link linkend="file-execute"><menuchoice><guimenu>File</guimenu><guimenuitem>Execute Commands</guimenuitem></menuchoice></link>) to see the result. In the next examples you are expected to know the drill.</para> + +<para>You might have noticed that this second example uses a lot more code. You have also seen a couple of new commands. Here a short explanation of all the new commands:</para> + +<para><userinput>canvassize 200,200</userinput> sets the canvas width and height to 200 <glossterm linkend="pixels">pixels</glossterm>. The width and the height are equal, so the canvas will be a square.</para> + +<para><userinput>canvascolor 0,0,0</userinput> makes the canvas black. <userinput>0,0,0</userinput> is a <glossterm linkend="rgb">RGB-combination</glossterm> where all values are set to <userinput>0</userinput>, which results in black.</para> + +<para><userinput>pencolor 255,0,0</userinput> sets the color of the pen to red. <userinput>255,0,0</userinput> is a <glossterm linkend="rgb">RGB-combination</glossterm> where only the red value is set to <userinput>255</userinput> (fully on) while the others (green and blue) are set to <userinput>0</userinput> (fully off). This results in a bright shade of red.</para> + +<para>If you do not understand the color values, be sure to read the glossary on <glossterm linkend="rgb">RGB-combination</glossterm>s</para> + +<para><userinput>penwidth 5</userinput> sets the width (the size) of the pen to <userinput>5</userinput> <glossterm linkend="pixels">pixels</glossterm>. From now on every line the turtle draw will have a thickness of <userinput>5</userinput>, until we change the <userinput>penwidth</userinput> to something else.</para> + +<para><userinput>clear</userinput> clear the canvas, that is all it does.</para> + +<para><userinput>go 20,20</userinput> commands the turtle to go to a certain place on the canvas. Counted from the upper left corner, this place is 20 <glossterm linkend="pixels">pixels</glossterm> across from the left, and 20 <glossterm linkend="pixels">pixels</glossterm> down from the top of the canvas. Note that using the <userinput>go</userinput> command the turtle will not draw a line.</para> + +<para><userinput>direction 135</userinput> set the turtle's direction. The <userinput>turnleft</userinput> and <userinput>turnright</userinput> commands change the turtle's angle starting from its current direction. The <userinput>direction</userinput> command changes the turtle's angle from zero, and thus is not relative to the turtle previous direction.</para> + +<para>After the <userinput>direction</userinput> command a lot of <userinput>forward</userinput> and <userinput>turnleft</userinput> commands follow. These command do the actual drawing.</para> + +<para>At last another <userinput>go</userinput> command is used to move the turtle aside.</para> + +<para>Make sure you follow the links to the reference. The reference explains each command more thoroughly.</para> + + +</sect2> +</sect1> + + + +<!-- EXTRA SECTIONS CAN BE ADDED TO THE "GETTING STARTED" + +<sect1 id="calculations"> +<title>Simple Calculations</title> +<para> +Not yet written +</para> +</sect1> +<sect1 id="using_variables"> +<title>Using Variables: creating 'number containers'</title> +<para> +Not yet written +</para> +</sect1> +<sect1 id="using_strings"> +<title>Using strings: creating 'text containers'</title> +<para> +Not yet written +</para> +</sect1> +<sect1 id="logic"> +<title>Logic: asking the computer simple questions</title> +<para> +Not yet written +</para> +</sect1> +<sect1 id="recursion"> +<title>Recursion: the Turtle is using itself</title> +<para> +Draw a maze for example +</para> +</sect1> +--> + + +</chapter> diff --git a/doc/kturtle/glossary.docbook b/doc/kturtle/glossary.docbook new file mode 100644 index 00000000..c4405fe6 --- /dev/null +++ b/doc/kturtle/glossary.docbook @@ -0,0 +1,173 @@ +<!--Dear translator: please NEVER translate the id or anything inside the tags as they are needed in english by the application + Thanks a lot in advance.--> +<chapter id="Glossary"> +<title>Glossary</title> + +<para>In this chapter you will find an explanation of most of the <quote>uncommon</quote> words that are used in the handbook.</para> + +<glosslist> +<glossentry id="degrees"> +<glossterm>degrees</glossterm> +<glossdef><para>Degrees are units to measure angles or turns. A full turn is 360 degrees, a half turn 180 degrees and a quarter turn 90 degrees. The commands <userinput>turnleft</userinput>, <userinput>turnright</userinput> and <userinput>direction</userinput> need an input in degrees.</para></glossdef> +</glossentry> + +<glossentry id="input-output"> +<glossterm>input and output of commands</glossterm> +<glossdef><para>Some commands take input, some commands give output, some commands take input <emphasis>and</emphasis> give output and some commands neither take input nor give output.</para> +<para>Some examples of commands that only take input are: +<screen> +forward 50 +pencolor 255,0,0 +print "Hello!" +</screen> +The <userinput>forward</userinput> command takes <userinput>50</userinput> as input. <userinput>forward</userinput> needs this input to know how many <glossterm linkend="pixels">pixels</glossterm> it should go forward. <userinput>pencolor</userinput> takes a color as input and <userinput>print</userinput> takes a string (a piece of text) as input. Please note that the input can also be a container. The next example illustrates this: +<screen> +x = 50 +print x +str = "hello!" +print str +</screen></para> + +<para>Now some examples of commands that give output: +<screen> +x = inputwindow "Please type something and press OK... thanks!" +r = random 1,100 +</screen> +The <userinput>inputwindow</userinput> command takes a string as input, and outputs the number or string that is entered. As you can see, the output of <userinput>inputwindow</userinput> is stored in the container <userinput>x</userinput>. The <userinput>random</userinput> command also gives output. In this case it outputs a number between 1 and 100. The output of the random is again stored in a container, named <userinput>r</userinput>. Note that the containers <userinput>x</userinput> and <userinput>r</userinput> are not used in the example code above.</para> + +<para>There are also commands that neither need input nor give output. Here are some examples: +<screen> +clear +penup +wrapon +hide +</screen> +</para></glossdef> +</glossentry> + +<glossentry id="intuitive-highlighting"> +<glossterm>intuitive highlighting</glossterm> +<glossdef><para>This is a feature of &kturtle; that makes coding even easier. With intuitive highlighting the code that you write gets a color that indicates what type of code it is. In the next list you will find the different types of code and the color they get in <link linkend="the-code-editor">the code editor</link>. +<table> +<title>Different types of code and their highlight color</title> +<tgroup cols="3"> +<tbody> +<row> +<entry>regular commands</entry> +<entry>dark green</entry> +<entry>The regular commands are described <link linkend="commands">here</link>.</entry> +</row> +<row> +<entry>execution controllers</entry> +<entry>black (bold)</entry> +<entry>The special commands control execution, read more on them <link linkend="controlling-execution">here</link>.</entry> +</row> +<row> +<entry>comments</entry> +<entry>dark yellow</entry> +<entry>Lines that are commented start with a comment characters (#). These lines are ignored when the code is executed. Comments allow the programmer to explain a bit about his code or can be used to temporarily prevent a certain piece of code from executing.</entry> +</row> +<row> +<entry>brackets [, ]</entry> +<entry>light green (bold)</entry> +<entry>Brackets are used to group portions of code. Brackets are often used together with <link linkend="controlling-execution">execution controllers</link>.</entry> +</row> +<row> +<entry>the <link linkend="learn">learn</link> command</entry> +<entry>light green (bold)</entry> +<entry>The <link linkend="learn">learn</link> command is used to create new commands.</entry> +</row> +<row> +<entry>numbers</entry> +<entry>blue</entry> +<entry>Numbers, well not much to say about them.</entry> +</row> +<row> +<entry>strings</entry> +<entry>dark red</entry> +<entry>Not much to say about (text) strings either, except that they always start and end with the double quotes (").</entry> +</row> +<row> +<entry>mathematical characters</entry> +<entry>grey</entry> +<entry>These are the mathematical characters: +, -, *, /, (, and ). Read more about them <link linkend="math">here</link>.</entry> +</row> +<row> +<entry>questions characters</entry> +<entry>blue (bold)</entry> +<entry>Read more about questions <link linkend="questions">here</link>.</entry> +</row> +<row> +<entry>question glue-words</entry> +<entry>pink</entry> +<entry>Read more about the question glue-words (and, or, not) <link linkend="question-glue">here</link>.</entry> +</row> +<row> +<entry>regular text</entry> +<entry>black</entry> +<entry></entry> +</row> +</tbody> +</tgroup> +</table> +</para></glossdef> +</glossentry> + +<glossentry id="pixels"> +<glossterm>pixels</glossterm> +<glossdef><para>A pixel is a dot on the screen. If you look very close you will see that the screen of your monitor uses pixels. All images on the screen are built with these pixels. A pixel is the smallest thing that can be drawn on the screen.</para> +<para>A lot of commands need a number of pixels as input. These commands are: <userinput>forward</userinput>, <userinput>backward</userinput>, <userinput>go</userinput>, <userinput>gox</userinput>, <userinput>goy</userinput>, <userinput>canvassize</userinput> and <userinput>penwidth</userinput>.</para></glossdef> +</glossentry> + +<glossentry id="rgb"> +<glossterm>RGB combinations (color codes)</glossterm> +<glossdef><para>RGB combinations are used to describe colors. The <quote>R</quote> stand for <quote>red</quote>, the <quote>G</quote> stands for <quote>green</quote> and the <quote>B</quote> stands for <quote>blue</quote>. An example of an RGB combination is <userinput>255,0,0</userinput>: the first value (<quote>red</quote>) is 255 and the others are 0, so this represents a bright shade of red. Each value of an RGB combination has to be in the range 0 to 255. Here a small list of some often used colors: +<table frame="none"> +<title>Often used RGB combinations</title> +<tgroup cols="2" colsep="5" rowsep="1"> +<colspec colname="c1"/> +<tbody> +<row><entry><userinput>0,0,0</userinput></entry><entry>black</entry></row> +<row><entry><userinput>255,255,255</userinput></entry><entry>white</entry></row> +<row><entry><userinput>255,0,0</userinput></entry><entry>red</entry></row> +<row><entry><userinput>150,0,0</userinput></entry><entry>dark red</entry></row> +<row><entry><userinput>0,255,0</userinput></entry><entry>green</entry></row> +<row><entry><userinput>0,0,255</userinput></entry><entry>blue</entry></row> +<row><entry><userinput>0,255,255</userinput></entry><entry>light blue</entry></row> +<row><entry><userinput>255,0,255</userinput></entry><entry>pink</entry></row> +<row><entry><userinput>255,255,0</userinput></entry><entry>yellow</entry></row> +</tbody> +</tgroup> +</table> +</para> +<para>To easily find the RGB combinations of a color you should try the color picker! You can open the color picker using <link linkend="tools-color-picker"><menuchoice><guimenu>Tools</guimenu><guimenuitem>Color Picker</guimenuitem></menuchoice></link>.</para> +<para>Two commands need an RGB combination as input: these commands are <userinput>canvascolor</userinput> and <userinput>pencolor</userinput>.</para></glossdef> +</glossentry> + +<glossentry id="sprite"> +<glossterm>sprite</glossterm> +<glossdef><para>A sprite is a small picture that can be moved around the screen. Our beloved turtle, for instance, is a sprite.</para> +<para>Note: with this version of &kturtle; the sprite cannot be changed from a turtle into something else. Future versions of &kturtle; will be able to do this.</para></glossdef> +</glossentry> + +<glossentry id="wrapping"> +<glossterm>wrapping</glossterm> +<glossdef><para>Wrapping is what happens when the turtle draws something that is to big to fix in on the canvas and wrapping is set <quote>on</quote>. +<screenshot> + <screeninfo>This is what happens when wrapping is <quote>on</quote></screeninfo> + <mediaobject> + <imageobject> + <imagedata fileref="wrapping.png" format="PNG"/> + </imageobject> + <textobject> + <phrase>An example of wrapping</phrase> + </textobject> + </mediaobject> +</screenshot> +When the turtle moves off a border of the canvas it is instantly taken to the opposite border so it can continue its move. This way the turtle will always stay on the screen while it moves. This happens when wrapping is on.</para> +<para>Wrapping can be turned on and off with the <userinput>wrapon</userinput> and <userinput>wrapoff</userinput> commands. When &kturtle; starts wrapping is turned on by default.</para></glossdef> +</glossentry> + +</glosslist> + +</chapter>
\ No newline at end of file diff --git a/doc/kturtle/index.docbook b/doc/kturtle/index.docbook new file mode 100644 index 00000000..79477b3c --- /dev/null +++ b/doc/kturtle/index.docbook @@ -0,0 +1,243 @@ +<?xml version="1.0" ?> +<!DOCTYPE book PUBLIC "-//KDE//DTD DocBook XML V4.2-Based Variant V1.1//EN" +"dtd/kdex.dtd" [ + <!ENTITY kappname "&kturtle;"> + <!ENTITY package "kdeedu"> + <!ENTITY logo "Logo"> + <!ENTITY % addindex "IGNORE"> + <!ENTITY % English "INCLUDE"><!-- change language only here --> + <!ENTITY using-kturtle SYSTEM "using-kturtle.docbook"> + <!ENTITY getting-started SYSTEM "getting-started.docbook"> + <!ENTITY programming-reference SYSTEM "programming-reference.docbook"> + <!ENTITY translator-guide SYSTEM "translator-guide.docbook"> + <!ENTITY glossary SYSTEM "glossary.docbook"> +]> + +<book lang="&language;"> + +<bookinfo> +<title>The &kturtle; Handbook</title> + +<authorgroup> +<author> +<firstname>Cies</firstname> +<surname>Breijs</surname> +<affiliation> +<address><email>cies AT kde DOT nl</email></address> +</affiliation> +</author> +<author> +<firstname>Anne-Marie</firstname> +<surname>Mahfouf</surname> +<affiliation> +<address><email>annma AT kde DOT org</email></address> +</affiliation> +</author> +<!-- TRANS:ROLES_OF_TRANSLATORS --> +</authorgroup> + + +<copyright> +<year>2004</year> +<holder>Cies Breijs</holder> +</copyright> + +<legalnotice>&FDLNotice;</legalnotice> + +<date>2005-12-10</date> +<releaseinfo>0.6</releaseinfo> + +<abstract> +<para> +&kturtle; is an educational programming environment using the &logo; programming language. The unique quality of LOGO is that the programming commands are translated to the language of the 'programmer' so he/she can program in his/her native language. +</para> +</abstract> + +<keywordset> +<keyword>KDE</keyword> +<keyword>kdeedu</keyword> +<keyword>KTurtle</keyword> +<keyword>education</keyword> +<keyword>language</keyword> +<keyword>native</keyword> +<keyword>programming</keyword> +<keyword>code</keyword> +<keyword>&logo;</keyword> +<keyword>instructions</keyword> +<keyword>turtle</keyword> +</keywordset> + +</bookinfo> + +<chapter id="introduction"> +<title>Introduction</title> + +<para>&kturtle; is an educational programming environment using the +<link linkend="what-is-logo">&logo;</link> programming language. The goal of &kturtle; is to make programming as easy and accessible as possible. This makes &kturtle; suitable for teaching kids the basics of math, geometry and... programming. The commands used to program are in the style of the &logo; programming language. The unique feature of the &logo; programming language is that the commands are often translated into the speaking language of the programmer.</para> + +<para>&kturtle; is named after <quote>the turtle</quote> that plays a central role in the programming environment. The user programs the turtle, using the &logo; commands, to draw a picture on <link linkend="the-canvas">the canvas</link>.</para> + +<sect1 id="what-is-logo"> +<title>What is &logo;?</title> +<para>The first version &logo; programming language was created by Seymour +Papert of MIT Artificial Intelligence Laboratory in 1967 as an offshoot of the +LISP programming language. From then many versions of &logo; have been released. +By 1980 &logo; was gaining momentum, with versions for MSX, Commodore, Atari, +Apple II and IBM PC systems. These versions were mainly for educational +purposes. LCSI released <application>&Mac;&logo;</application> in 1985 as a tool +for professional programmers, but it never caught on. MIT is still maintaining a +site on &logo; which can be found on <ulink +url="http://el.media.mit.edu/logo-foundation/">http://el.media.mit.edu/logo- +foundation/</ulink>.</para> + +<para>Today there are several versions of &logo; around which can easily be found on <ulink url="http://el.media.mit.edu/logo-foundation/">MIT's &logo; site</ulink> and by a simple <ulink url="http://www.google.com/search?q=logo+programming+kids">Google search</ulink>. This version of &logo; (&kturtle;) is only focused on the educational qualities of the programming language and will not try to suit professional programmers' needs.</para> +</sect1> + +<sect1 id="features-of-kturtle"> +<title>Features of &kturtle;</title> +<para>&kturtle; has some nice features that make starting to program a breeze. See here some of the highlights of &kturtle; feature set: +<itemizedlist> +<listitem><para> +An integrated &logo; interpreter (no extra dependencies) that uses &XML; files for the command translations, supports user defined functions and dynamic type switching. +</para></listitem> +<listitem><para> +The execution can be slown down, paused or stopped at any time. +</para></listitem> +<listitem><para> +A powerful editor for the &logo; commands with intuitive syntax highlighting, line numbering and more. +</para></listitem> +<listitem><para> +<link linkend="the-canvas">The canvas</link> can be saved as an image or printed. +</para></listitem> +<listitem><para> +<link linkend="the-canvas">The canvas</link> has a wrapping mode (which is on by default) so the turtle cannot get lost too easily. +</para></listitem> +<listitem><para> +Context help for all &logo; commands: Just press <keysym>F2</keysym>. +</para></listitem> +<listitem><para> +The &logo; commands are fully translatable (at the moment of writing Brazilian Portuguese, Dutch, French, German, Italian, Slovenian, Serbian (Cyrillic and Latin), Spanish and Swedish are in &kde;). +</para></listitem> +<listitem><para> +An error dialog that links the error messages to the mistakes in the program. +</para></listitem> +<listitem><para> +Simplified programming terminology. +</para></listitem> +<listitem><para> +Full-screen mode. +</para></listitem> +<listitem><para> +Many integrated, internationalized example &logo; programs make it easy to get started. +</para></listitem> +</itemizedlist> +</para> +</sect1> +</chapter> + +&using-kturtle; + +&getting-started; + +&programming-reference; + +&glossary; + +&translator-guide; + +<chapter id="credits"> + +<title>Credits and License</title> + +<para> +&kturtle; +</para> +<para>Program copyright 2003-2005 Cies Breijs <email>cies AT kde DOT nl</email></para> +<para> +Contributors: +<itemizedlist> +<listitem><para>Coding help, editor part: &Anne-Marie.Mahfouf; &Anne-Marie.Mahfouf.mail;</para> +</listitem> +<listitem><para>Author of <application>WSBASIC</application> (<ulink url="http://wsbasic.sourceforge.net">http://wsbasic.sourceforge.net</ulink>) which is the base for the interpreter of &kturtle;: Walter Schreppers <email>Walter DOT Schreppers AT ua DOT ac DOT be</email></para> +</listitem> +<listitem><para>German Data Files: Matthias Meßmer <email>bmlmessmer AT web DOT de</email></para> +</listitem> +<listitem><para>German Data Files: Burkhard Lück <email>lueck AT hube-lueck DOT de</email></para> +</listitem> +<listitem><para>Swedish Data Files: Stefan Asserhäll <email>stefan DOT asserhal AT telia DOT com</email></para> +</listitem> +<listitem><para>Slovenian Data Files: Jure Repinc <email>jlp@holodeck1.com</email></para> +</listitem> +<listitem><para>Serbian (Cyrillic and Latin) Data Files: Chusslove Illich <email>caslav.ilic@gmx.net</email></para> +</listitem> +<listitem><para>Italian Data Files: Pino Toscano <email>toscano.pino@tiscali.it</email></para> +</listitem> +<listitem><para>English GB Data Files: Andy Potter <email>A.J.Potter@rhul.ac.uk</email></para> +</listitem> +<listitem><para>Spanish Data Files: Rafael Beccar <email>rafael.beccar@kdemail.net</email></para> +</listitem> +<listitem><para>Brazilian Portuguese Data Files: Riverson Rios <email>riverson@ccv.ufc.br</email></para> +</listitem> +<listitem><para>Norwegian Nynorsk and BokmÃ¥l Data Files: Karl Ove Hufthammer <email>karl@huftis.org</email></para> +</listitem> +<listitem><para>Parser Cyrillic support: Albert Astals Cid <email>astals11@terra.es</email></para> +</listitem> +</itemizedlist> +</para> + +<para> +Documentation copyright 2004 +<itemizedlist> +<listitem><para> +Cies Breijs <email>cies AT kde DOT nl</email> +</para></listitem> +<listitem><para> +&Anne-Marie.Mahfouf; <email>annma AT kde DOT org</email> +</para></listitem> +<listitem><para>Some proofreading changes by &Philip.Rodrigues; &Philip.Rodrigues.mail;</para> +</listitem> +<listitem><para>Updated translation how-to and some proofreading changes by Andrew Coles <email>andrew_coles AT yahoo DOT co DOT uk</email></para> +</listitem> + +</itemizedlist> +</para> +<!-- TRANS:CREDIT_FOR_TRANSLATORS --> + +&underFDL; + +&underGPL; <!-- GPL License --> + +</chapter> + + + +<appendix id="installation"> +<title>Installation</title> + +<sect1 id="getting-kturtle"> +<title>How to obtain &kturtle;</title> + +&install.intro.documentation; + +</sect1> + +<sect1 id="compilation"> +<title>Compilation and Installation</title> + +&install.compile.documentation; + +</sect1> + +</appendix> + +&documentation.index; +</book> +<!-- +Local Variables: +mode: sgml +sgml-minimize-attributes:nil +sgml-general-insert-case:lower +sgml-indent-step:0 +sgml-indent-data:nil +End: +--> diff --git a/doc/kturtle/mainwindow.png b/doc/kturtle/mainwindow.png Binary files differnew file mode 100644 index 00000000..86a2d37f --- /dev/null +++ b/doc/kturtle/mainwindow.png diff --git a/doc/kturtle/mainwindow_flower_nrs.png b/doc/kturtle/mainwindow_flower_nrs.png Binary files differnew file mode 100644 index 00000000..fdf2e7c9 --- /dev/null +++ b/doc/kturtle/mainwindow_flower_nrs.png diff --git a/doc/kturtle/print.png b/doc/kturtle/print.png Binary files differnew file mode 100644 index 00000000..cdd61e7e --- /dev/null +++ b/doc/kturtle/print.png diff --git a/doc/kturtle/programming-reference.docbook b/doc/kturtle/programming-reference.docbook new file mode 100644 index 00000000..12cd86db --- /dev/null +++ b/doc/kturtle/programming-reference.docbook @@ -0,0 +1,822 @@ +<!--Dear translator: please NEVER translate the id or anything inside the tags as they are needed in english by the application + Thanks a lot in advance.--> +<chapter id="reference"> +<title>&kturtle;'s &logo; Programming Reference</title> +<para>This is the reference for the &kturtle;'s &logo;. In this chapter we first briefly touch all the <link linkend="different-instructions">different instruction types</link>. Then the <link linkend="commands">commands</link> are explained one by one. Then <link linkend="containers">containers</link>, <link linkend="math">math</link>, <link linkend="questions">questions</link> and <link linkend="controlling-execution">execution controllers</link> are explained. At last you are shown how to create you own commands with <link linkend="learn">learn</link>.</para> + +<sect1 id="different-instructions"> +<title>Different Instruction Types</title> +<para>As in any language, LOGO has different types of words and symbols. Here the differences between the types are briefly explained.</para> + +<sect2 id="command"> +<title>Commands</title> +<para>Using commands you tell the turtle or &kturtle; to do something. Some commands need input, some give output. +<screen> +# forward is a command that needs input, in this case the number 100: +forward 100 +</screen> +</para> +<para>For a detailed overview of all commands that &kturtle; supports go <link linkend="commands">here</link>.</para> +</sect2> + +<sect2 id="number"> +<title>Numbers</title> +<para>Most likely you already know quite a bit about numbers. The way numbers are used in &kturtle; is not much different from spoken language, or math. </para> +<para>We have the so called natural numbers: <userinput>0</userinput>, <userinput>1</userinput>, <userinput>2</userinput>, <userinput>3</userinput>, <userinput>4</userinput>, <userinput>5</userinput>, etc. The negative numbers: <userinput>-1</userinput>, <userinput>-2</userinput>, <userinput>-3</userinput>, etc. And the numbers with decimals, or dot-numbers, for example: <userinput>0.1</userinput>, <userinput>3.14</userinput>, <userinput>33.3333</userinput>, <userinput>-5.05</userinput>, <userinput>-1.0</userinput>. +</para> +<para>Numbers can be used in <link linkend="math">mathematical calculations</link> and <link linkend="questions">questions</link>. They can also be put in <link linkend="containers">containers</link>.</para> +<para>Numbers are <glossterm>highlighted</glossterm> with blue in the <link linkend="the-code-editor">code editor</link>.</para> +</sect2> + +<sect2 id="string"> +<title>Strings</title> +<para>First an example: +<screen> +print "Hello, I'm a string." +</screen> +In this example <userinput>print</userinput> is a command where <userinput>"Hello, I'm a string."</userinput> is a string. Strings start and end with the <userinput>"</userinput> mark, by these marks &kturtle; knows it is a string.</para> +<para>Strings can be put in <link linkend="containers">containers</link>. Yet they cannot be used in <link linkend="math">mathematical calculations</link> and <link linkend="questions">questions</link>.</para> +<para>Strings are <glossterm>highlighted</glossterm> with dark red in the <link linkend="the-code-editor">code editor</link>.</para> +</sect2> + + +<sect2 id="name"> +<title>Names</title> +<para>When using the &logo; programming language you create new things. If you write a program you will often need <link linkend="containers">containers</link> and in some cases you need <link linkend="learn">learn</link> to create new commands. When making a <link linkend="containers">container</link> or a new command with <link linkend="learn">learn</link> you will have to specify a name.</para> +<para>You can choose any name, as long as it does not already have a meaning. For instance you cannot name a container <link linkend="forward">forward</link>, since that name is already used for a command, and thus has a meaning. +<screen> +# here forward is used as a container, but it already has a meaning +# so this will produce an error: +forward = 20 + +# this works: +forward 20 +</screen> +Names can contain only letters, numbers and underscores (_). Yet they have to start with a letter. +</para> +<para> +Please read the documentation on <link linkend="containers">containers</link> and the <link linkend="learn">learn</link> command for a better explanation and more examples. +</para> +</sect2> + +<sect2 id="assignment"> +<title>Assignments</title> +<para>Assignment are done with the <userinput>=</userinput> symbol. In programming languages it is better to read the single <userinput>=</userinput> not as 'equals' but as 'becomes'. The word 'equals' is more appropriate for the <userinput>==</userinput> which is a <link linkend="questions">question</link>.</para> +<para>Assignments are generally use for two reasons, (1) to add content <link linkend="containers">containers</link>, and (2) to modify the content of a container. For example: +<screen> +x = 10 +# the container x now contains the number 10 +W = "My age is: " +# the container W now contains the string "My age is: " +# this prints the content of the containers 'W' and 'x' on the canvas +print W + x +</screen> +</para> +<para>For more examples see the section that explains <link linkend="containers">containers</link>.</para> +</sect2> + +<sect2 id="math-symbols"> +<title>Math Symbols</title> +<para>&kturtle; supports all basic math symbols: add (<userinput>+</userinput>), substract (<userinput>-</userinput>), multiply (<userinput>*</userinput>), divide (<userinput>/</userinput>) and the brackets <userinput>(</userinput> and <userinput>)</userinput>.</para> +<para>For a complete explanation and more examples see the <link linkend="math">math</link> section.</para> +</sect2> + +<sect2 id="question"> +<title>Questions</title> +<para>We can ask simple questions on which the answer will be 'true' or 'false'.</para> +<para>Using questions is extensively explained in the <link linkend="questions">questions</link> section.</para> +</sect2> + +<sect2 id="questions-glue"> +<title>Question Glue-Words</title> +<para>Questions can be glued together with so called 'question glue'. The glue words are <userinput>and</userinput>, <userinput>or</userinput>, and a special glue-word: <userinput>not</userinput>.</para> +<para>Using question-glue is explained in the <link linkend="question-glue">Question Glue</link> section.</para> +</sect2> + + +<sect2 id="comment"> +<title>Comments</title> +<para>Comments are lines that start with a <userinput>#</userinput>. For example: +<screen> +# this is a comment! +print "this is not a comment" +# the previous line is not a comment, but the next line is: +# print "this is not a comment" +</screen> +We can add comments to the code for ourselves or for someone else to read. Comments are used for: (1) adding a small description to the program, (2) explaining how a piece of code works if it is a bit cryptic, and (3) to 'comment-out' lines of code that should be (temporarily) ignored (see the last line of the example).</para> +<para>Commented lines are <glossterm>highlighted</glossterm> with dark yellow in the <link linkend="the-code-editor">code editor</link>.</para> +</sect2> + +</sect1> + + +<sect1 id="commands"> +<title>Commands</title> +<para>Using commands you tell the turtle or &kturtle; to do something. Some commands need input, some give output. In this section we explain all the commands that can be used in &kturtle;. Please note that all build in commands we discuss here are <glossterm>highlighted</glossterm> with dark green in the <link linkend="the-code-editor">code editor</link>, this can help you to distinguish them.</para> + +<sect2 id="moving-the-turtle"> +<title>Moving the turtle</title> +<para>There are several commands to move the turtle over the screen.</para> + +<sect3 id="forward"> + <title>forward (fw)</title> + <variablelist> + <varlistentry> + <term>forward</term> + <listitem><para><screen>forward X</screen> + <userinput>forward</userinput> moves the turtle forward by the amount of X pixels. When the pen is down the turtle will leave a trail. <userinput>forward</userinput> can be abbreviated to <userinput>fw</userinput></para></listitem> + </varlistentry> + </variablelist> +</sect3> +<sect3 id="backward"> + <title>backward (bw)</title> + <variablelist> + <varlistentry> + <term>backward</term> + <listitem><para><screen>backward X</screen> + <userinput>backward</userinput> moves the turtle backward by the amount of X pixels. When the pen is down the turtle will leave a trail. <userinput>backward</userinput> can be abbreviated to <userinput>bw</userinput>.</para></listitem> + </varlistentry> + </variablelist> +</sect3> +<sect3 id="turnleft"> + <title>turnleft (tl)</title> + <variablelist> + <varlistentry> + <term>turnleft</term> + <listitem><para><screen>turnleft X</screen> + <userinput>turnleft</userinput> commands the turtle to turn an amount of X degrees to the left. <userinput>turnleft</userinput> can be abbreviated to <userinput>tl</userinput>.</para></listitem> + </varlistentry> + </variablelist> +</sect3> +<sect3 id="turnright"> + <title>turnright (tr)</title> + <variablelist> + <varlistentry> + <term>turnright</term> + <listitem><para><screen>turnright X</screen> + <userinput>turnright</userinput>the turtle to turn an amount of X degrees to the right. <userinput>turnright</userinput> can be abbreviated to <userinput>tr</userinput>.</para></listitem> + </varlistentry> + </variablelist> +</sect3> +<sect3 id="direction"> + <title>direction (dir)</title> + <variablelist> + <varlistentry> + <term>direction</term> + <listitem><para><screen>direction X</screen> + <userinput>direction</userinput> set the turtle's direction to an amount of X degrees counting from zero, and thus is not relative to the turtle's previous direction. <userinput>direction</userinput> can be abbreviated to <userinput>dir</userinput>.</para></listitem> + </varlistentry> + </variablelist> +</sect3> +<sect3 id="center"> + <title>center</title> + <variablelist> + <varlistentry> + <term>center</term> + <listitem><para><screen>center</screen> + <userinput>center</userinput> moves the turtle to the center on the canvas.</para></listitem> + </varlistentry> + </variablelist> +</sect3> +<sect3 id="go"> + <title>go</title> + <variablelist> + <varlistentry> + <term>go</term> + <listitem><para><screen>go X,Y</screen> + <userinput>go</userinput> commands the turtle to go to a certain place on the canvas. This place is X <glossterm linkend="pixels">pixels</glossterm> from the left of the canvas, and Y <glossterm linkend="pixels">pixels</glossterm> form the top of the canvas. Note that using the <userinput>go</userinput> command the turtle will not draw a line.</para></listitem> + </varlistentry> + </variablelist> +</sect3> +<sect3 id="gox"> + <title>gox</title> + <variablelist> + <varlistentry> + <term>gox</term> + <listitem><para><screen>gox X</screen> + <userinput>gox</userinput> using this command the turtle will move to X <glossterm linkend="pixels">pixels</glossterm> from the left of the canvas whilst staying at the same height.</para></listitem> + </varlistentry> + </variablelist> +</sect3> +<sect3 id="goy"> + <title>goy</title> + <variablelist> + <varlistentry> + <term>goy</term> + <listitem><para><screen>goy Y</screen> + <userinput>gox</userinput> using this command the turtle will move to Y <glossterm linkend="pixels">pixels</glossterm> from the top of the canvas whilst staying at the same distance from the left border of the canvas.</para></listitem> + </varlistentry> + </variablelist> +</sect3> +</sect2> + +<sect2 id="pen"> +<title>The turtle has a pen</title> +<para>The turtle has a pen that draws a line when the turtle moves. There are a few commands to control the pen. In this section we explain these commands.</para> +<sect3 id="penup"> + <title>penup (pu)</title> + <variablelist> + <varlistentry> + <term>penup</term> + <listitem><para><screen>penup</screen> + <userinput>penup</userinput> lifts the pen from the canvas. When the pen is <quote>up</quote> no line will be drawn when the turtle moves. See also <userinput>pendown</userinput>. <userinput>penup</userinput> can be abbreviated to <userinput>pu</userinput>.</para></listitem> + </varlistentry> + </variablelist> +</sect3> +<sect3 id="pendown"> + <title>pendown (pd)</title> + <variablelist> + <varlistentry> + <term>pendown</term> + <listitem><para><screen>pendown</screen> + <userinput>pendown</userinput> presses the pen down on the canvas. When the pen is press <quote>down</quote> on the canvas a line will be drawn when the turtle moves. See also <userinput>penup</userinput>. <userinput>pendown</userinput> can be abbreviated to <userinput>pd</userinput>.</para></listitem> + </varlistentry> + </variablelist> +</sect3> +<sect3 id="setpenwidth"> + <title>penwidth (pw)</title> + <variablelist> + <varlistentry> + <term>penwidth</term> + <listitem><para><screen>penwidth X</screen> + <userinput>penwidth</userinput> sets the width of the pen (the line width) to an amount of X <glossterm linkend="pixels">pixels</glossterm>. <userinput>penwidth</userinput> can be abbreviated to <userinput>pw</userinput>.</para></listitem> + </varlistentry> + </variablelist> +</sect3> +<sect3 id="setfgcolor"> + <title>pencolor (pc)</title> + <variablelist> + <varlistentry> + <term>pencolor</term> + <listitem><para><screen>pencolor R,G,B</screen> + <userinput>pencolor</userinput> sets the color of the pen. <userinput>pencolor</userinput> takes an <glossterm linkend="rgb">RGB combination</glossterm> as input. <userinput>pencolor</userinput> can be abbreviated to <userinput>pc</userinput>.</para></listitem> + </varlistentry> + </variablelist> +</sect3> +</sect2> + +<sect2 id="canvas"> +<title>Commands to control the canvas</title> +<para>There are several commands to control the canvas.</para> +<sect3 id="resizecanvas"> + <title>canvassize (cs)</title> + <variablelist> + <varlistentry> + <term>canvassize</term> + <listitem><para><screen>canvassize X,Y</screen> + With the <userinput>canvassize</userinput> command you can set the size of the canvas. It takes X and Y as input, where X is the new canvas width in <glossterm linkend="pixels">pixels</glossterm>, and Y is the new height of the canvas in <glossterm linkend="pixels">pixels</glossterm>. <userinput>canvassize</userinput> can be abbreviated to <userinput>cs</userinput>.</para></listitem> + </varlistentry> + </variablelist> +</sect3> +<sect3 id="setbgcolor"> + <title>canvascolor (cc)</title> + <variablelist> + <varlistentry> + <term>canvascolor</term> + <listitem><para><screen>canvascolor R,G,B</screen> + <userinput>canvascolor</userinput> set the color of the canvas. <userinput>canvascolor</userinput> takes an <glossterm linkend="rgb">RGB combination</glossterm> as input. <userinput>canvascolor</userinput> can be abbreviated to <userinput>cc</userinput>.</para></listitem> + </varlistentry> + </variablelist> +</sect3> +<sect3 id="wrapon"> + <title>wrapon</title> + <variablelist> + <varlistentry> + <term>wrapon</term> + <listitem><para><screen>wrapon</screen> + With the <userinput>wrapon</userinput> command you can set <glossterm linkend="wrapping">wrapping</glossterm> <quote>on</quote> for the canvas. Please see the glossary if you want to know what <glossterm linkend="wrapping">wrapping</glossterm> is.</para></listitem> + </varlistentry> + </variablelist> +</sect3> +<sect3 id="wrapoff"> + <title>wrapoff</title> + <variablelist> + <varlistentry> + <term>wrapoff</term> + <listitem><para><screen>wrapoff</screen> + With the <userinput>wrapoff</userinput> command you can set <glossterm linkend="wrapping">wrapping</glossterm> <quote>off</quote> for the canvas: this means the turtle can move off the canvas and can get <quote>lost</quote>. Please see the glossary if you want to know what <glossterm linkend="wrapping">wrapping</glossterm> is.</para></listitem> + </varlistentry> + </variablelist> +</sect3> +</sect2> + +<sect2 id="clean"> +<title>Commands to clean up</title> +<para>There are two commands to clean up the canvas after you have made a mess.</para> +<sect3 id="clear"> + <title>clear (cr)</title> + <variablelist> + <varlistentry> + <term>clear</term> + <listitem><para><screen>clear</screen> + With <userinput>clear</userinput> you can clean all drawings from the canvas. All other things remain: the position and angle of the turtle, the canvascolor, the visibility of the turtle, and the canvas size. <userinput>clear</userinput> can be abbreviated to <userinput>cr</userinput>.</para></listitem> + </varlistentry> + </variablelist> +</sect3> +<sect3 id="reset"> + <title>reset</title> + <variablelist> + <varlistentry> + <term>reset</term> + <listitem><para><screen>reset</screen> + <userinput>reset</userinput> cleans much more thoroughly than the <userinput>clear</userinput> command. After a <userinput>reset</userinput> command everything is like is was when you had just started &kturtle;. The turtle is positioned at the middle of the screen, the canvas color is white, and the turtle draws a black line on the canvas.</para></listitem> + </varlistentry> + </variablelist> +</sect3> +</sect2> + +<sect2 id="sprites"> +<title>The turtle is a sprite</title> +<para>First a brief explanation of what sprites are: sprites are small pictures that can be moved around the screen, like we often see in computer games. Our turtle is also a sprite. For more info see the glossary on <glossterm linkend="sprites">sprites</glossterm>. </para> +<para>Next you will find a full overview on all commands to work with sprites.</para> +<para>[The current version of &kturtle; does not yet support the use of sprites other than the turtle. With future versions you will be able to change the turtle into something of your own design]</para> +<sect3 id="spriteshow"> + <title>show</title> + <variablelist> + <varlistentry> + <term>show (ss)</term> + <listitem><para><screen>show</screen> + <userinput>show</userinput> makes the turtle visible again after it has been hidden. <userinput>show</userinput> can be abbreviated to <userinput>ss</userinput>.</para></listitem> + </varlistentry> + </variablelist> +</sect3> +<sect3 id="spritehide"> + <title>hide (sh)</title> + <variablelist> + <varlistentry> + <term>hide</term> + <listitem><para><screen>hide</screen> + <userinput>hide</userinput> hides the turtle. This can be used if the turtle does not fit in your drawing. <userinput>hide</userinput> can be abbreviated to <userinput>sh</userinput>.</para></listitem> + </varlistentry> + </variablelist> +</sect3> +</sect2> + +<sect2 id="writing"> +<title>Can the turtles write?</title> +<para>The answer is: <quote>yes</quote>. The turtle can write: it writes just about everything you command it to.</para> +<sect3 id="print"> + <title>print</title> + <variablelist> + <varlistentry> + <term>print</term> + <listitem><para><screen>print X</screen> + The <userinput>print</userinput> command is used to command the turtle to write something on the canvas. <userinput>print</userinput> takes numbers and strings as input. You can <userinput>print</userinput> various numbers and strings using the <quote>+</quote> symbol. See here a small example: +<screen> +year = 2003 +author = "Cies" +print author + " started the KTurtle project in " + year + " and still enjoys working on it!" +</screen> + </para></listitem> + </varlistentry> + </variablelist> +</sect3> +<sect3 id="fontsize"> + <title>fontsize</title> + <variablelist> + <varlistentry> + <term>fontsize</term> + <listitem><para><screen>fontsize X</screen> + <userinput>fontsize</userinput> sets the size of the font that is used by <userinput>print</userinput>. <userinput>fontsize</userinput> takes one input which should be a number. The size is set in <glossterm linkend="pixels">pixels</glossterm>.</para></listitem> + </varlistentry> + </variablelist> +</sect3> +</sect2> + +<sect2 id="random"> +<title>A command that rolls dice for you</title> +<para>There is one command that rolls dice for you, it is called <userinput>random</userinput>, and it is very useful for some unexpected results.</para> + <variablelist> + <varlistentry> + <term>random</term> + <listitem><para><screen>random X,Y</screen> + <userinput>random</userinput> is a command that takes input and gives output. As input are required two numbers, the first (X) sets the minimum output, the second (Y) sets the maximum. The output is a randomly chosen number that is equal or greater then the minimum and equal or smaller than the maximum. Here a small example: + <screen> +repeat 500 [ + x = random 1,20 + forward x + turnleft 10 - x +] +</screen> + Using the <userinput>random</userinput> command you can add a bit of chaos to your program.</para></listitem> + </varlistentry> + </variablelist> +</sect2> + +<sect2 id="dialogs"> +<title>Input and feedback though dialogs</title> +<para>A dialog is a small pop-up window that provides some feedback or asks for some input. &kturtle; has two commands for dialogs, namely: <userinput>message</userinput> and <userinput>inputwindow</userinput></para> +<sect3 id="message"> + <title>message</title> + <variablelist> + <varlistentry> + <term>message</term> + <listitem><para><screen>message X</screen> + The <userinput>message</userinput> command takes a <link linkend="string">string</link> as input. It shows a pop-up dialog containing the text from the <link linkend="string">string</link>. +<screen> +year = 2003 +author = "Cies" +print author + " started the KTurtle project in " + year + " and still enjoys working on it!" +</screen> + </para></listitem> + </varlistentry> + </variablelist> +</sect3> +<sect3 id="inputwindow"> + <title>inputwindow</title> + <variablelist> + <varlistentry> + <term>inputwindow</term> + <listitem><para><screen>inputwindow X</screen> + <userinput>inputwindow</userinput> takes a <link linkend="string">string</link> as input. It shows a pop-up dialog containing the text from the string, just like the <link linkend="message">message</link>. But in addition to it also puts an input field on the dialog. Through this input filed the user can enter a <link linkend="number">number</link> or a <link linkend="string">string</link> which can be stored in a <link linkend="containers">container</link>. For example +<screen> +in = inputwindow "What is you age?" +out = 2003 - in +print "In 2003 you where " + out + " years old at some point." +</screen> + When a user cancels the input dialog, or does not enter anything at all the <link linkend="containers">container</link> is emptied.</para></listitem> + </varlistentry> + </variablelist> +</sect3> +</sect2> + +</sect1> + + + +<sect1 id="containers"> +<title>Containers</title> +<para>Containers are letters or words that can be used by the programmer to store a number or a text. Containers that contain a number are called <link linkend="variables">variables</link>, containers that can contain text are called <link linkend="string">string</link>.</para> + +<para>Containers that are not used contain nothing. An example: +<screen> +print N +</screen> +This will print nothing. If we try to do <link linkend="math">math</link> with empty containers we will get errors. +</para> + +<sect2 id="variables"> +<title>Variables: number containers</title> +<para>Let us start with an example: +<screen> +x = 3 +print x +</screen> +In the first line the letter <userinput>x</userinput> made into a variable (number container). As you see the value of the variable <userinput>x</userinput> is set to 3. On the second line the value is printed.</para> +<para> Note that if we wanted to print an <quote>x</quote> that we should have written +<screen> +print "x" +</screen> +</para> +<para>That was easy, now a bit harder example: +<screen> +A = 2004 +B = 25 +C = A + B + +# the next command prints "2029" +print C +backward 30 +# the next command prints "2004 plus 25" +print A + " plus " + B +backward 30 +# the next command prints "1979" +print A - B +</screen> +In the first two lines the variables <userinput>A</userinput> and <userinput>B</userinput> are set to 2004 and 25. On the third line the variable <userinput>C</userinput> is set to <userinput>A + B</userinput>, which is 2029. The rest of the example consists of 3 <userinput>print</userinput> commands with <userinput>backward 30</userinput> in between. The <userinput>backward 30</userinput> is there to make sure every output is on a new line. In this example you also see that variables can be used in <link linkend="math">mathematical calculations</link>.</para> +</sect2> + +<sect2 id="strings"> +<title>Containers that contain text (strings)</title> +<para>In programming code the regular text is usually started and ended with quotes. As we have already seen: +<screen> +print "Hello programmer!" +</screen> +The regular is delimited with quotes. These pieces of regular text we call <link linkend="strings">strings</link>.</para> +<para>Strings can also be stored in <link linkend="containers">containers</link> just like <link linkend="number">numbers</link> +Strings are a lot like variables. The biggest difference is that they contain text in stead of numbers. For this reason strings cannot be used in <link linkend="math">mathematical calculations</link> and <link linkend="questions">questions</link>. An example of the use of strings: +<screen> +x = "Hello " +name = inputwindow "Please enter your name..." +print x + name + ", how are you?" +</screen> +On the first line the string <userinput>x</userinput> is set to <quote>Hello </quote>. On the second line the string <userinput>name</userinput> is set to the output of the <userinput>inputwindow</userinput> command. On the third line the program prints a composition of three strings on the canvas.</para> +<para>This program ask you to enter your name. When you, for instance, enter the name <quote>Paul</quote>, the program prints <quote>Hello Paul, how are you?</quote>. Please note that the plus (+) is the only math symbol that you can use with strings.</para> +</sect2> +</sect1> + +<sect1 id="math"> +<title>Can the Turtle do math?</title> +<para>Yes, &kturtle; will do your math. You can add (+), substract (-), multiply (*), and divide (/). Here is an example in which we use all of them: +<screen> +a = 20 - 5 +b = 15 * 2 +c = 30 / 30 +d = 1 + 1 +print "a: "+a+", b: "+b+", c: "+c+", d: "+d +</screen> +Do you know what value a, b, c and d have? Please note the use of the <link linkend="assignment">assignment</link> symbol <userinput>=</userinput>.</para> +<para>If you just want a simple calculation to be done you can do something like this: +<screen> +print 2004-12 +</screen></para> +<para>Now an example with parentheses: +<screen> +print ( ( 20 - 5 ) * 2 / 30 ) + 1 +</screen> +The expressions inside parentheses will be calculated first. In this example, 20-5 will be calculated, then multiplied by 2, divided by 30, and then 1 is added (giving 2).</para> +</sect1> + +<sect1 id="questions"> +<title>Asking questions, getting answers...</title> +<para><link linkend="if"><userinput>if</userinput></link> and <link linkend="while"><userinput>while</userinput></link> are <link linkend="controlling-execution">execution controllers</link> that we will discuss in the next section. In this section we use the <link linkend="if"><userinput>if</userinput></link> command to explain questions.</para> +<sect2 id="q"> +<title>Questions</title> +<para>A simple example of a question: +<screen> +x = 6 +if x > 5 [ + print "hello" +] +</screen> + +In this example the question is the <userinput>x > 5</userinput> part. If the answer to this question is 'true' the code between the brackets will be executed. Questions are an important part of programming and often used together with <link linkend="controlling-execution">execution controllers</link>, like <link linkend="if"><userinput>if</userinput></link>. All numbers and <link linkend="variables">variables</link> (number containers) can be compared to each other with questions.</para> +<para> +Here are all possible questions: +<table> +<title>Types of questions</title> +<tgroup cols="3"> +<tbody> +<row> +<entry><userinput>a == b</userinput></entry> +<entry>equals</entry> +<entry>answer is <quote>true</quote> if <userinput>a</userinput> equals <userinput>b</userinput></entry> +</row> +<row> +<entry><userinput>a != b</userinput></entry> +<entry>not-equal</entry> +<entry>answer is <quote>true</quote> if <userinput>a</userinput> does not equal <userinput>b</userinput></entry> +</row> +<row> +<entry><userinput>a > b</userinput></entry> +<entry>greater than</entry> +<entry>answer is <quote>true</quote> if <userinput>a</userinput> is greater than <userinput>b</userinput></entry> +</row> +<row> +<entry><userinput>a < b</userinput></entry> +<entry>smaller than</entry> +<entry>answer is <quote>true</quote> if <userinput>a</userinput> is smaller than <userinput>b</userinput></entry> +</row> +<row> +<entry><userinput>a >= b</userinput></entry> +<entry>greater than or equals</entry> +<entry>answer is <quote>true</quote> if <userinput>a</userinput> is greater than or equals <userinput>b</userinput></entry> +</row> +<row> +<entry><userinput>a <= b</userinput></entry> +<entry>smaller than or equals</entry> +<entry>answer is <quote>true</quote> if <userinput>a</userinput> is smaller than or equals <userinput>b</userinput></entry> +</row> +</tbody> +</tgroup> +</table> +</para> +<para>Questions are <glossterm>highlighted</glossterm> with light blue in the <link linkend="the-code-editor">code editor</link>.</para> +</sect2> + +<sect2 id="question-glue"> +<title>Question Glue</title> +<para> +Question glue-words enable us to glue questions into one big question. +<screen> +a = 1 +b = 5 +if (a < 5) and (b == 5) [ + print "hello" +] +</screen> +In this example the glue-word <userinput>and</userinput> is used to glue 2 questions (<userinput>a < 5</userinput>, <userinput>b == 5</userinput>) together. If one side of the <userinput>and</userinput> would answer <quote>false</quote> the whole question would answer <quote>false</quote>, because with the glue-word <userinput>and</userinput> both sides need to be <quote>true</quote> in order to answer <quote>true</quote>. Please do not forget to use the brackets around the questions!</para> + +<para> +Here is a schematic overview; a more detailed explanation follows below: +<table> +<title>Question glue-words</title> +<tgroup cols="2"> +<tbody> +<row> +<entry><userinput>and</userinput></entry> +<entry>Both sides need to be 'true' in order to answer 'true'</entry> +</row> +<row> +<entry><userinput>or</userinput></entry> +<entry>If one of the sides is 'true' the answer is 'true'</entry> +</row> +<row> +<entry><userinput>not</userinput></entry> +<entry>Special case: only works on one question! Changes 'true' into 'false' and 'false' into 'true'.</entry> +</row> +</tbody> +</tgroup> +</table> +</para> +<para>Question glue-words are <glossterm>highlighted</glossterm> with purple in the <link linkend="the-code-editor">code editor</link>.</para> + +<sect3 id="and"> +<title>and</title> +<para>When two questions are glued together with <userinput>and</userinput>, both sides of the <userinput>and</userinput> have to be 'true' in order to result in 'true'. An example: +<screen> +a = 1 +b = 5 +if ((a < 10) and (b == 5)) and (a < b) [ + print "hello" +] +</screen> +In this example you see a glued question glued onto an other question.</para> +</sect3> + +<sect3 id="or"> +<title>or</title> +<para>If one of the two questions that are glued together with <userinput>or</userinput> is 'true' the result will be 'true'. An example: +<screen> +a = 1 +b = 5 +if ((a < 10) or (b == 10)) or (a == 0) [ + print "hello" +] +</screen> +In this example you see a glued question glued onto an other question.</para> +</sect3> + +<sect3 id="not"> +<title>not</title> +<para><userinput>not</userinput> is a special question glue-word because it only works for one question at the time. <userinput>not</userinput> changes 'true' into 'false' and 'false' into 'true'. An example: +<screen> +a = 1 +b = 5 +if not ((a < 10) and (b == 5)) [ + print "hello" +] +else +[ + print "not hello ;-)" +] +</screen> +In this example the glued question is 'true' yet the <userinput>not</userinput> changes it to 'false'. So in the end <userinput>"not hello ;-)"</userinput> is printed on the <link linkend="the-canvas">canvas</link>.</para> +</sect3> + +</sect2> + +</sect1> + +<sect1 id="controlling-execution"> +<title>Controlling execution</title> +<para>The execution controllers enable you — as their name implies — to control execution.</para> +<para>Execution controlling commands are <glossterm>highlighted</glossterm> with dark green in a bold font type. The square brackets are mostly used together with execution controllers and they are <glossterm>highlighted</glossterm> with light green.</para> + +<sect2 id="wait"> +<title>Have the turtle wait</title> +<para>If you have done some programming in &kturtle; you have might noticed that the turtle can be very quick at drawing. This command makes the turtle wait for a given amount of time.</para> + <variablelist> + <varlistentry> + <term>wait</term> + <listitem><para><screen>wait X</screen> + <userinput>wait</userinput> makes the turtle wait for X seconds. +<screen> +repeat 36 [ + forward 5 + turnright 10 + wait 0.5 +] +</screen> + This code draws a circle, but the turtle will wait half a second + after each step. This gives the impression of a slow-moving turtle.</para></listitem> + </varlistentry> + </variablelist> +</sect2> + +<sect2 id="if"> +<title>Execute "if"</title> + <variablelist> + <varlistentry> + <term>if</term> + <listitem><para><screen>if <link linkend="questions">question</link> [ ... ]</screen> + The code that is placed between the brackets will only be executed <userinput>if</userinput> the answer to the <link linkend="questions">question</link> is <quote>true</quote>. Please read for more information on <link linkend="questions">questions</link> in the <link linkend="questions">question section</link>. + <screen> +x = 6 +if x > 5 [ + print "x is greater than five!" +] +</screen> + On the first line <userinput>x</userinput> is set to 6. On the second line the <link linkend="questions">question</link> <userinput>x > 5</userinput> is asked. Since the answer to this question is <quote>true</quote> the execution controller <userinput>if</userinput> will allow the code between the brackets to be executed</para></listitem> + </varlistentry> + </variablelist> +</sect2> + +<sect2 id="while"> +<title>The "while" loop</title> + <variablelist> + <varlistentry> + <term>while</term> + <listitem><para><screen>while <link linkend="questions">question</link> [ ... ]</screen> + The execution controller <userinput>while</userinput> is a lot like <link linkend="if"><userinput>if</userinput></link>. The difference is that <userinput>while</userinput> keeps repeating (looping) the code between the brackets until the answer to the <link linkend="questions">question</link> is <quote>false</quote>. + <screen> +x = 1 +while x < 5 [ + forward 10 + wait 1 + x = x + 1 +] +</screen> + On the first line <userinput>x</userinput> is set to 1. On the second line the <link linkend="questions">question</link> <userinput>x < 5</userinput> is asked. Since the answer to this question is <quote>true</quote> the execution controller <userinput>while</userinput> starts executing the code between the brackets until the answer to the <link linkend="questions">question</link> is <quote>false</quote>. In this case the code between the brackets will be executed 4 times, because every time the fifth line is executed <userinput>x</userinput> increases by 1.</para></listitem> + </varlistentry> + </variablelist> +</sect2> + +<sect2 id="else"> +<title>If not, in other words: "else"</title> + <variablelist> + <varlistentry> + <term>else</term> + <listitem><para><screen>if question [ ... ] else [ ... ]</screen> + <userinput>else</userinput> can be used in addition to the execution controller <link linkend="if"><userinput>if</userinput></link>. The code between the brackets after <userinput>else</userinput> is only executed if the answer to the <link linkend="questions">question</link> that is asked is <quote>false</quote>. + <screen> +reset +x = 4 +if x > 5 [ + print "x is greater than five!" +] +else +[ + print "x is smaller than six!" +] +</screen> + The <link linkend="questions">question</link> asks if <userinput>x</userinput> is greater than 5. Since <userinput>x</userinput> is set to 4 on the first line the answer to the question is <quote>false</quote>. This means the code between the brackets after <userinput>else</userinput> gets executed.</para></listitem> + </varlistentry> + </variablelist> +</sect2> + +<sect2 id="for"> +<title>The "for" loop, a counting loop</title> + <variablelist> + <varlistentry> + <term>for</term> + <listitem><para><screen>for <userinput>start point</userinput> to <userinput>end point</userinput> [ ... ]</screen> + The <userinput>for</userinput> loop is a <quote>counting loop</quote>, &ie; it keeps count for you. + <screen> +for x = 1 to 10 [ + print x * 7 + forward 15 +] +</screen> + Every time the code between the brackets is executed the <userinput>x</userinput> is increased by 1, until <userinput>x</userinput> reaches the value of 10. The code between the brackets prints the <userinput>x</userinput> multiplied by 7. After this program finishes its execution you will see the times table of 7 on the canvas.</para></listitem> + </varlistentry> + </variablelist> +</sect2> + +</sect1> + + +<sect1 id="learn"> +<title>Create your own commands with <quote>learn</quote></title> +<para><userinput>learn</userinput> is a very special command, because it is used to create your own commands. The command you create can take <glossterm linkend="input-output">input</glossterm> and return <glossterm linkend="input-output">output</glossterm>. Let us take a look at how a new command is created: +<screen> +learn circle x [ + repeat 36 [ + forward x + turnleft 10 + ] +] +</screen> +The new command is called <userinput>circle</userinput>. <userinput>circle</userinput> takes one <glossterm linkend="input-output">input</glossterm>, a number, to set the size of the circle. <userinput>circle</userinput> returns no <glossterm linkend="input-output">output</glossterm>. The <userinput>circle</userinput> command can now be used like a normal command in the rest of the code. See this example: +<screen> +learn circle X [ + repeat 36 [ + forward X + turnleft 10 + ] +] + +go 30,30 +circle 20 + +go 40,40 +circle 50 +</screen> +</para> +<para>In the next example, a command with a return value is created. +<screen> +reset + +learn multiplyBySelf n [ + r = n * 1 + r = n * n + return r +] +i = inputwindow "Please enter a number and press OK" +print i + " multiplied by itself is: " + multiplyBySelf i +</screen> +In this example a new command called <userinput>multiplyBySelf</userinput> is created. The input of this command is multiplied by itself and then returned, using the <anchor id="return" /><userinput>return</userinput> command. The <userinput>return</userinput> command is the way to output a value from a function you have created. +</para> +</sect1> + +</chapter> diff --git a/doc/kturtle/translator-guide.docbook b/doc/kturtle/translator-guide.docbook new file mode 100644 index 00000000..4a257998 --- /dev/null +++ b/doc/kturtle/translator-guide.docbook @@ -0,0 +1,128 @@ +<chapter id="translators"> +<title>Translator's Guide to &kturtle;</title> +<para>As you probably already know, the unique feature of the &logo; programming language is that the &logo; commands are often translated to language of the programmer. This takes away a barrier for some learners to understand the basics of programming. +When translating &kturtle; to a new language some more files have to be translated in addition to the usual strings and documentation. Yet most it is autogenerated by Rafael Beccar's scripts. These scripts can be found in <userinput>kdeedu/kturtle/scripts</userinput>, the files that needs translation can be found in <userinput>kdeedu/kturtle/data</userinput>, in those directories you also find README files which contains instructions for using/translating them. +</para> +<para> + +</para> +<sect1 id="make_directory"> +<title>Creating a Directory to hold the Translated Files</title> +<para> +First, you need to create a directory to store the translated files. + +Create a directory called + +<filename class="directory">kde-i18n/<replaceable>code</replaceable>/data/kdeedu/kturtle/</filename> + +in your KDE CVS directory, where <replaceable>code</replaceable> is your country code (the 2- or 4- letter <acronym>ISO</acronym> code). +</para> +<para> +Copy the <filename>Makefile.am</filename> file from <filename class="directory">kdeedu/kturtle/data/</filename> into this directory. Open it using your favorite text editor, replace all instances of <quote>en_US</quote> in the file with your country code (the one used above), and save the file. +</para> +</sect1> +<sect1 id="commands_trans"> +<title>How To Translate the &logo; Keywords (commands)</title> +<para> +<itemizedlist> +<listitem><para> +Copy the <filename>logokeywords.en_US.xml</filename> file from <filename class="directory">kdeedu/kturtle/data/</filename> to the directory you have just created, and rename it to <filename>logokeywords.<replaceable>code</replaceable>.xml</filename> +where <replaceable>code</replaceable> is your country code (the 2- or 4- letter <acronym>ISO</acronym> code). +</para> +</listitem> +<listitem><para>Translate the contents of the <sgmltag class="starttag">keyword</sgmltag> tag (&ie; +the information between <sgmltag class="starttag">keyword</sgmltag> +and <sgmltag class="endtag">keyword</sgmltag>) into your own language +wherever possible. Also, translate the contents of the <sgmltag class="starttag">alias</sgmltag> tag, (&ie; the information between the <sgmltag class="starttag">alias</sgmltag> and <sgmltag class="endtag">alias</sgmltag>): these are used as shortcuts for the keyword.</para> +<para> +For example, translate <quote>while</quote> in: <sgmltag class="starttag">keyword</sgmltag>while<sgmltag class="endtag">keyword</sgmltag> +</para> +<para> +Please do not translate anything else and do not translate the English words in <sgmltag class="starttag">command name="english_word"</sgmltag>: these must stay in English. +</para> +<para> +Last bit: do not change the order of this file, this is needed for Rafael Beccar's automatic translation generation scripts. +</para> +</listitem> +<listitem><para>Save your file as <acronym>UTF-8</acronym> (in &kate;, use <guimenuitem>Save As...</guimenuitem> and change to <guilabel>utf8</guilabel> in the box on the right of the file name). +</para> +</listitem> +<listitem><para>Commit your file (add your filename in the <filename>Makefile.am</filename>) or send it to Anne-Marie. +</para> +</listitem> +<listitem><para>In case of any doubt, please contact Anne-Marie Mahfouf <email>annemarie.mahfouf@free.fr</email> for more information.</para> +</listitem> +</itemizedlist> +</para> +</sect1> + +<sect1 id="examples_syntax"> +<title>How To Translate the Syntax Highlighting Files</title> +<para> +Translating the <filename>logohighlightstyle.en_US.xml</filename> is a breeze when using Rafael Beccar's script in <filename class="directory">kdeedu/kturtle/data/</filename>. Please make sure to read the README file in that directory. +</para> +<para> +For backward compatibility with all people who do not want to the perl scripted blessing mentioned in the previous paragraph, here the old fashioned way of doing it: +<itemizedlist> +<listitem><para>Copy the <filename>logohighlightstyle.en_US.xml</filename> file from <filename class="directory">kdeedu/kturtle/data/</filename> to the directory you created to store the translated keywords file, and rename it to <filename>logohighlightstyle.<replaceable>code</replaceable>.xml</filename> +where <replaceable>code</replaceable> is your country code (the 2- or 4- letter <acronym>ISO</acronym> code). +</para> +</listitem> +<listitem><para>In line 4 of the file, there is +<sgmltag class="starttag">language name="en_US"</sgmltag>...: here you change <quote>en_US</quote> to your language's <acronym>ISO</acronym> code (2 or 4 letters). +</para></listitem> +<listitem><para>Translate into your own language the content of the <sgmltag class="starttag">item</sgmltag> tag (&ie; the information between <sgmltag class="starttag">item</sgmltag> and <sgmltag class="endtag">item</sgmltag>). This content must match the <filename>logokeyword</filename> file. +For example, translate <quote>while</quote> in: <sgmltag class="starttag">item</sgmltag> while <sgmltag class="endtag">item</sgmltag> and leave the spaces as they are (one at the beginning and one at the end). +Please do not translate anything else. +</para></listitem> +<listitem><para>Save your file as <acronym>UTF-8</acronym> (in &kate;, use <guimenuitem>Save As...</guimenuitem> and change to <guilabel>utf8</guilabel> in the box on the right of the file name). +</para></listitem> +<listitem><para>Commit your file (add your filename in the <filename>Makefile.am</filename>) or send it to Anne-Marie. +</para></listitem> +<listitem><para>In case of any doubt, please contact Anne-Marie Mahfouf <email>annemarie.mahfouf@free.fr</email> for more information. +</para></listitem> +</itemizedlist> +</para> +</sect1> + +<sect1 id="examples_trans"> +<title>How To Translate the Examples</title> +<para> +Again this task is simplified a lot by Rafael Beccar's script in <filename class="directory">kdeedu/kturtle/data/</filename>. Please make sure to read the README file in that directory, since some work still has to be done after the example logo files are autotranslated. +</para> +<para> +When you followed the instructions, given in the README file that you found in the scripts directory, you should now be almost ready. Please do not forget to test the translated example logo code you created, since it is very common that an error sneaks in. Also make sure the <userinput>Makefile.am</userinput> in <filename class="directory">kde-i18n/<replaceable>code</replaceable>/data/kdeedu/kturtle/</filename> is updated according to the new files. For the Dutch the <userinput>Makefile.am</userinput> should look like this: +<screen> +txt_DATA = advertentie.logo driehoeken.logo krullen.logo tafels.logo \ +bloem.logo driehoek.logo logohighlightstyle.nl.xml pijl.logo vierkanten.logo \ +kleuren.logo logokeywords.nl.xml randomnaam.logo vierkant.logo +txtdir = $(kde_datadir)/kturtle/examples/nl + +xml_DATA = logohighlightstyle.nl.xml +xmldir = $(kde_datadir)/katepart/syntax + +keywords_DATA = logokeywords.nl.xml +keywordsdir = $(kde_datadir)/kturtle/data +EXTRA_DIST = $(txt_DATA) $(xml_DATA) $(keywords_DATA) +</screen> +</para> +<para> +Here a description of how to do the translation WITHOUT the use of Rafael's perl scripts: +<itemizedlist> +<listitem><para>Copy the English example files from <filename class="directory">kdeedu/kturtle/data/</filename> to the directory used to store the translated keyword and hilighting files. Translate the filenames of the examples in your directory: this will allow users to easily and quickly understand what the example is about.</para> +</listitem> +<listitem><para>Translate the keywords in the examples, using those in the <filename>logokeywords.xml</filename> for your language. The keywords file file must be done, first, before translating the examples.</para> +</listitem> +<listitem><para>Save your file as <acronym>UTF-8</acronym> (in &kate;, use <guimenuitem>Save As...</guimenuitem> and change to <guilabel>utf8</guilabel> in the box on the right of the file name)</para> +</listitem> +<listitem><para>Commit your folder (add a <filename>Makefile.am</filename> inside) or send it to Anne-Marie.</para> +</listitem> +<listitem><para>In case of any doubt, please contact Anne-Marie Mahfouf, <email>annemarie.mahfouf@free.fr</email> for more information.</para> +</listitem> +<listitem><para>Finally, if you want, you can add your own examples in this folder.</para> +</listitem> +</itemizedlist> +</para> +</sect1> + +</chapter> diff --git a/doc/kturtle/using-kturtle.docbook b/doc/kturtle/using-kturtle.docbook new file mode 100644 index 00000000..2fb49547 --- /dev/null +++ b/doc/kturtle/using-kturtle.docbook @@ -0,0 +1,590 @@ +<!--Dear translator: please NEVER translate the id or anything inside the tags as they are needed in english by the application + Thanks a lot in advance.--> +<chapter id="using-kturtle"> +<title>Using &kturtle;</title> + +<screenshot> + <screeninfo>Here is a screenshot of &kturtle; in action</screeninfo> + <mediaobject> + <imageobject> + <imagedata fileref="mainwindow_flower_nrs.png" format="PNG"/> + </imageobject> + <textobject> + <phrase>&kturtle; Main Window</phrase> + </textobject> + </mediaobject> +</screenshot> + +<para>The main window of &kturtle; has two main parts: <link linkend="the-code-editor">the code editor</link> (3) on the left where you type the &logo; commands, and <link linkend="the-canvas">the canvas</link> (4) on the right where the instructions are visualized. <link linkend="the-canvas">The canvas</link> is the turtle's playground: it is on the canvas that the turtle actually moves and draws. The three other places on the main window are: <link linkend="the-menubar">the menu bar</link> (1) from where all the actions can be reached, <link linkend="the-toolbar">the toolbar</link> (2) that allows you to quickly select the most used actions, and <link linkend="the-statusbar">the statusbar</link> (5) where you will find feedback on the state of &kturtle;.</para> + +<sect1 id="the-code-editor"> +<title>The Code Editor</title> +<para>In the code editor you type the &logo; commands. It has all of the features you would expect from a modern editor. Most of its features are found in the <link linkend="the-edit-menu">Edit</link> and the <link linkend="the-tools-menu">Tools</link> menus. The code editor can be docked on each border of the main window or it can be detached and placed anywhere on your desktop.</para> +<para> +You have several ways to get some code in the editor. The easiest way is to use an already-made example: choose <menuchoice><guimenu>File</guimenu><guimenuitem>Open Examples</guimenuitem> +</menuchoice> in the <link linkend="the-file-menu">File menu</link> and click on a file. The filename will tell you what the example is about (⪚ <filename>square.logo</filename> will draw a square). The file you choose will be opened in the <link linkend="the-code-editor">the code editor</link>, you can then use <menuchoice><guimenu>File</guimenu><guimenuitem>Execute Commands</guimenuitem> +</menuchoice> to run the code if you like.</para> +<para>You can open &logo; files by choosing <menuchoice><guimenu>File</guimenu><guimenuitem>Open...</guimenuitem> +</menuchoice>.</para> +<para>The third way is to directly type your own code in the editor or to copy/paste some code from this user guide. +</para> +<para> +The cursor position is indicated in <link linkend="the-statusbar">the statusbar</link>, on the right with the Line number and Column number. +</para> +</sect1> + +<sect1 id="the-canvas"> +<title>The Canvas</title> +<para> +The canvas is the area where the commands are visualized, where the commands <quote>draw</quote> a picture. In other words, it is the turtle's playground. After getting some code in the <link linkend="the-code-editor">the code editor</link>, and executing it using <menuchoice><guimenu>File</guimenu><guimenuitem>Execute Commands</guimenuitem> +</menuchoice>, two things can happen: either the code executes fine, and will you most likely see something change on the canvas; or you have made an error in your code and there will be a message telling you what error you made.</para> +<para>This message should help you to resolve the error.</para> +<para>The picture that is drawn can be saved as an image (using <menuchoice><guimenu>File</guimenu><guimenuitem>Save Canvas</guimenuitem> +</menuchoice>) or printed (using <menuchoice><guimenu>File</guimenu><guimenuitem>Print...</guimenuitem> +</menuchoice>).</para> +</sect1> + +<sect1 id="the-menubar"> +<title>The Menubar</title> +<para>In the menubar you find all the actions of &kturtle;. They are in the following groups: <guimenu>File</guimenu>, <guimenu>Edit</guimenu>, <guimenu>View</guimenu>, <guimenu>Tools</guimenu>, <guimenu>Settings</guimenu>, and <guimenu>Help</guimenu>. This section describes them all.</para> + +<sect2 id="the-file-menu"> +<title>The <guimenu>File</guimenu> Menu</title> + +<sect3 id="file-new"> +<title>New</title> + <variablelist> + <varlistentry> + <term><menuchoice> + <shortcut> + <keycombo>&Ctrl;<keycap>N</keycap></keycombo> + </shortcut> + <guimenu>File</guimenu> + <guimenuitem>New</guimenuitem> + </menuchoice></term> + <listitem><para>Creates a new, empty &logo; file.</para></listitem> + </varlistentry> + </variablelist> +</sect3> +<sect3 id="file-open"> +<title>Open</title> + <variablelist> + <varlistentry> + <term><menuchoice> + <shortcut> + <keycombo>&Ctrl;<keycap>O</keycap></keycombo> + </shortcut> + <guimenu>File</guimenu> + <guimenuitem>Open...</guimenuitem> + </menuchoice></term> + <listitem><para>Opens a &logo; file.</para></listitem> + </varlistentry> + </variablelist> +</sect3> +<sect3 id="file-open-recent"> +<title>Open Recent</title> + <variablelist> + <varlistentry> + <term><menuchoice> + <guimenu>File</guimenu> + <guimenuitem>Open Recent</guimenuitem> + </menuchoice></term> + <listitem><para>Opens a &logo; file that has been opened recently.</para></listitem> + </varlistentry> + </variablelist> +</sect3> +<sect3 id="file-open-examples"> +<title>Open Examples</title> + <variablelist> + <varlistentry> + <term><menuchoice> + <shortcut> + <keycombo>&Ctrl;<keycap>E</keycap></keycombo> + </shortcut> + <guimenu>File</guimenu> + <guimenuitem>Open Examples</guimenuitem> + </menuchoice></term> + <listitem><para>Show the folder with examples &logo; programs. The examples should be in your favorite language that you can choose in <menuchoice><guimenu>Settings</guimenu><guimenuitem>Configure &kturtle;...</guimenuitem> +</menuchoice>.</para></listitem> + </varlistentry> + </variablelist> +</sect3> +<sect3 id="file-save"> +<title>Save</title> + <variablelist> + <varlistentry> + <term><menuchoice> + <shortcut> + <keycombo>&Ctrl;<keycap>S</keycap></keycombo> + </shortcut> + <guimenu>File</guimenu> + <guimenuitem>Save</guimenuitem> + </menuchoice></term> + <listitem><para>Saves the currently opened &logo; file.</para></listitem> + </varlistentry> + </variablelist> +</sect3> +<sect3 id="file-save-as"> +<title>Save As</title> + <variablelist> + <varlistentry> + <term><menuchoice> + <guimenu>File</guimenu> + <guimenuitem>Save As...</guimenuitem> + </menuchoice></term> + <listitem><para>Saves the currently opened &logo; file on a specified location.</para></listitem> + </varlistentry> + </variablelist> +</sect3> +<sect3 id="file-save-canvas"> +<title>Save Canvas</title> + <variablelist> + <varlistentry> + <term><menuchoice> + <guimenu>File</guimenu> + <guimenuitem>Save Canvas</guimenuitem> + </menuchoice></term> + <listitem><para>Saves the current drawing on canvas into an image.</para></listitem> + </varlistentry> + </variablelist> +</sect3> +<sect3 id="file-speed"> +<title>Execution Speed</title> + <variablelist> + <varlistentry> + <term><menuchoice> + <guimenu>File</guimenu> + <guimenuitem>Execution Speed</guimenuitem> + </menuchoice></term> + <listitem><para>Present a list of possible execution speeds, consisting of: Full Speed, Slow, Slower and Slowest. When the execution speed is set to 'Full Speed' (default) we can barely keep up with what is happening. Sometimes this behavior is wanted, but sometimes we want to keep track of the execution. In the latter case you want to set the execution speed to 'Slow', 'Slower' or 'Slowest'. When one of the slow modes is selected the current position of the executor will be shown in the editor.</para></listitem> + </varlistentry> + </variablelist> +</sect3> +<sect3 id="file-execute"> +<title>Execute</title> + <variablelist> + <varlistentry> + <term><menuchoice> + <shortcut> + <keycombo>&Alt;<keysym>Return</keysym></keycombo> + </shortcut> + <guimenu>File</guimenu> + <guimenuitem>Execute Commands</guimenuitem> + </menuchoice></term> + <listitem><para>Starts the execution of the commands in the code editor.</para></listitem> + </varlistentry> + </variablelist> +</sect3> +<sect3 id="file-pause"> +<title>Pause</title> + <variablelist> + <varlistentry> + <term><menuchoice> + <shortcut> + <keycombo><keysym>Pause</keysym></keycombo> + </shortcut> + <guimenu>File</guimenu> + <guimenuitem>Pause Execution</guimenuitem> + </menuchoice></term> + <listitem><para>Pauses the execution. This action is only enabled when the commands are actually executing.</para></listitem> + </varlistentry> + </variablelist> +</sect3> +<sect3 id="file-stop"> +<title>Stop</title> + <variablelist> + <varlistentry> + <term><menuchoice> + <shortcut> + <keycombo><keysym>Escape</keysym></keycombo> + </shortcut> + <guimenu>File</guimenu> + <guimenuitem>Stop Execution</guimenuitem> + </menuchoice></term> + <listitem><para>Stops the execution. This action is only enabled when the commands are actually executing.</para></listitem> + </varlistentry> + </variablelist> +</sect3> +<sect3 id="file-print"> +<title>Print</title> + <variablelist> + <varlistentry> + <term><menuchoice> + <shortcut> + <keycombo>&Ctrl;<keycap>P</keycap></keycombo> + </shortcut> + <guimenu>File</guimenu> + <guimenuitem>Print...</guimenuitem> + </menuchoice></term> + <listitem><para>Prints either the current code in the editor or the current drawing on the canvas.</para></listitem> + </varlistentry> + </variablelist> +</sect3> +<sect3 id="file-quit"> +<title>Quit</title> + <variablelist> + <varlistentry> + <term><menuchoice> + <shortcut> + <keycombo>&Ctrl;<keycap>Q</keycap></keycombo> + </shortcut> + <guimenu>File</guimenu> + <guimenuitem>Quit</guimenuitem> + </menuchoice></term> + <listitem><para>Quits &kturtle;.</para></listitem> + </varlistentry> + </variablelist> +</sect3> +</sect2> + +<sect2 id="the-edit-menu"> + <title>The <guimenu>Edit</guimenu> Menu</title> + <variablelist> + <anchor id="edit-undo" /> + <varlistentry> + <term><menuchoice> + <shortcut> + <keycombo>&Ctrl;<keycap>Z</keycap></keycombo> + </shortcut> + <guimenu>Edit</guimenu> + <guimenuitem>Undo</guimenuitem> + </menuchoice></term> + <listitem><para>Undoes the last change to code. &kturtle; has unlimited undos.</para></listitem> + </varlistentry> + </variablelist> + <variablelist> + <anchor id="edit-redo" /> + <varlistentry> + <term><menuchoice> + <shortcut> + <keycombo>&Ctrl;&Shift;<keycap>Z</keycap></keycombo> + </shortcut> + <guimenu>Edit</guimenu> + <guimenuitem>Redo</guimenuitem> + </menuchoice></term> + <listitem><para>Redoes an undone change to the code.</para></listitem> + </varlistentry> + </variablelist> + <variablelist> + <anchor id="edit-cut" /> + <varlistentry> + <term><menuchoice> + <shortcut> + <keycombo>&Ctrl;<keycap>X</keycap></keycombo> + </shortcut> + <guimenu>Edit</guimenu> + <guimenuitem>Cut</guimenuitem> + </menuchoice></term> + <listitem><para>Cuts the selected text from the code editor to the clipboard.</para></listitem> + </varlistentry> + </variablelist> + <variablelist> + <anchor id="edit-copy" /> + <varlistentry> + <term><menuchoice> + <shortcut> + <keycombo>&Ctrl;<keycap>C</keycap></keycombo> + </shortcut> + <guimenu>Edit</guimenu> + <guimenuitem>Copy</guimenuitem> + </menuchoice></term> + <listitem><para>Copies the selected text from the code editor to the clipboard.</para></listitem> + </varlistentry> + </variablelist> + <variablelist> + <anchor id="edit-paste" /> + <varlistentry> + <term><menuchoice> + <shortcut> + <keycombo>&Ctrl;<keycap>V</keycap></keycombo> + </shortcut> + <guimenu>Edit</guimenu> + <guimenuitem>Paste</guimenuitem> + </menuchoice></term> + <listitem><para>Pastes the text from the clipboard to the editor.</para></listitem> + </varlistentry> + </variablelist> + <variablelist> + <anchor id="edit-find" /> + <varlistentry> + <term><menuchoice> + <shortcut> + <keycombo>&Ctrl;<keycap>F</keycap></keycombo> + </shortcut> + <guimenu>Edit</guimenu> + <guimenuitem>Find...</guimenuitem> + </menuchoice></term> + <listitem><para>With this action you can find phrases in the code.</para></listitem> + </varlistentry> + </variablelist> + <variablelist> + <anchor id="edit-find-next" /> + <varlistentry> + <term><menuchoice> + <shortcut> + <keycombo><keysym>F3</keysym></keycombo> + </shortcut> + <guimenu>Edit</guimenu> + <guimenuitem>Find Next</guimenuitem> + </menuchoice></term> + <listitem><para>Use this to find the next occurrence of the phrase.</para></listitem> + </varlistentry> + </variablelist> + <variablelist> + <anchor id="edit-replace" /> + <varlistentry> + <term><menuchoice> + <shortcut> + <keycombo>&Ctrl;<keycap>R</keycap></keycombo> + </shortcut> + <guimenu>Edit</guimenu> + <guimenuitem>Replace...</guimenuitem> + </menuchoice></term> + <listitem><para>With this action you can replace phrases in the code.</para></listitem> + </varlistentry> + </variablelist> +</sect2> + +<sect2 id="the-view-menu"> + <title>The <guimenu>View</guimenu> Menu</title> + <variablelist> + <anchor id="view-fullscreen" /> + <varlistentry> + <term><menuchoice> + <shortcut> + <keycombo>&Ctrl;&Shift;<keycap>F</keycap></keycombo> + </shortcut> + <guimenu>View</guimenu> + <guimenuitem>Full Screen Mode</guimenuitem> + </menuchoice></term> + <listitem><para>With this action you toggle the full screen mode.</para> + <para>Note: When code is executed while in full screen mode everything but the canvas is hidden. This makes it possible to write <quote>full screen</quote> programs in &kturtle;.</para></listitem> + </varlistentry> + </variablelist> + <variablelist> + <anchor id="view-linenumbers" /> + <varlistentry> + <term><menuchoice> + <shortcut> + <keycombo><keysym>F11</keysym></keycombo> + </shortcut> + <guimenu>View</guimenu> + <guimenuitem>Show Line Numbers</guimenuitem> + </menuchoice></term> + <listitem><para>With this action you can show the line numbers in the code editor. This can be handy for finding errors.</para></listitem> + </varlistentry> + </variablelist> +</sect2> + +<sect2 id="the-tools-menu"> + <title>The <guimenu>Tools</guimenu> Menu</title> + <variablelist> + <anchor id="tools-color-picker" /> + <varlistentry> + <term><menuchoice> + <shortcut> + <keycombo>&Alt;<keycap>C</keycap></keycombo> + </shortcut> + <guimenu>Tools</guimenu> + <guimenuitem>Color Picker</guimenuitem> + </menuchoice></term> + <listitem><para>This action opens the color picker. Using the color picker you can easily select a <glossterm linkend="rgb">color code</glossterm> and insert it in <link linkend="the-code-editor">the code editor</link>.</para></listitem> + </varlistentry> + </variablelist> + <variablelist> + <anchor id="tools-indent" /> + <varlistentry> + <term><menuchoice> + <shortcut> + <keycombo>&Ctrl;<keycap>I</keycap></keycombo> + </shortcut> + <guimenu>Tools</guimenu> + <guimenuitem>Indent</guimenuitem> + </menuchoice></term> + <listitem><para>This action <quote>indents</quote> (adds white space at the beginning of) the lines that are selected. When <quote>indentation</quote> is used properly this can make code much easier to read. All examples use indentation, please check them out.</para></listitem> + </varlistentry> + </variablelist> + <variablelist> + <anchor id="tools-unindent" /> + <varlistentry> + <term><menuchoice> + <shortcut> + <keycombo>&Ctrl;&Shift;<keycap>I</keycap></keycombo> + </shortcut> + <guimenu>Tools</guimenu> + <guimenuitem>Unindent</guimenuitem> + </menuchoice></term> + <listitem><para>This action <quote>unindents</quote> (removes the white space at the beginning of) the lines that are selected.</para></listitem> + </varlistentry> + </variablelist> + <variablelist> + <anchor id="tools-clean-indent" /> + <varlistentry> + <term><menuchoice> + <guimenu>Tools</guimenu> + <guimenuitem>Clean Indentation</guimenuitem> + </menuchoice></term> + <listitem><para>This action cleans <quote>indentation</quote> (removes all the white space at the beginning of) the lines that are selected.</para></listitem> + </varlistentry> + </variablelist> + <variablelist> + <anchor id="tools-comment" /> + <varlistentry> + <term><menuchoice> + <shortcut> + <keycombo>&Ctrl;<keycap>D</keycap></keycombo> + </shortcut> + <guimenu>Tools</guimenu> + <guimenuitem>Comment</guimenuitem> + </menuchoice></term> + <listitem><para>This action add comment characters (#) in from of the lines that are selected. Lines that start with a comment character are ignored when the code is executed. Comments allow the programmer to explain a bit about his code or they can be used to temporarily prevent a certain piece of code from being executed.</para></listitem> + </varlistentry> + </variablelist> + <variablelist> + <anchor id="tools-uncomment" /> + <varlistentry> + <term><menuchoice> + <shortcut> + <keycombo>&Ctrl;&Shift;<keycap>D</keycap></keycombo> + </shortcut> + <guimenu>Tools</guimenu> + <guimenuitem>Uncomment</guimenuitem> + </menuchoice></term> + <listitem><para>This action removes the comment characters from the selected lines.</para></listitem> + </varlistentry> + </variablelist> +</sect2> + +<sect2 id="the-setting-menu"> + <title>The <guimenu>Settings</guimenu> Menu</title> + <variablelist> + <anchor id="toggle-toolbar" /> + <varlistentry> +<term><menuchoice> +<guimenu>Settings</guimenu> +<guimenuitem>Show/Hide Toolbar</guimenuitem> +</menuchoice></term> +<listitem><para><action>Toggle</action> the Main Toolbar</para></listitem> +</varlistentry> + </variablelist> + <variablelist> + <anchor id="toggle-statusbar" /> + <varlistentry> +<term><menuchoice> +<guimenu>Settings</guimenu> +<guimenuitem>Show/Hide Statusbar</guimenuitem> +</menuchoice></term> +<listitem><para><action>Toggle</action> the Statusbar</para></listitem> +</varlistentry> + </variablelist> + <variablelist> + <anchor id="tools-advanced" /> + <varlistentry> + <term><menuchoice> + <guimenu>Settings</guimenu> + <guisubmenu>Advanced Settings</guisubmenu> + </menuchoice></term> + <listitem><para>Here you can change things you normally do not need to change. The <guisubmenu>Advanced Settings</guisubmenu> submenu has three items: <guimenuitem>Configure Editor...</guimenuitem> (the standard &kate; editor settings dialog), <guimenuitem>Configure Shortcuts...</guimenuitem> (the standard &kde; shortcut settings dialog), and <guimenuitem>Configure Toolbars...</guimenuitem> (the standard &kde; toolbars setting dialog).</para></listitem> + </varlistentry> + </variablelist> + <variablelist> + <anchor id="settings-configure" /> + <varlistentry> + <term><menuchoice> + <guimenu>Settings</guimenu> + <guimenuitem>Configure &kturtle;...</guimenuitem> + </menuchoice></term> + <listitem><para>This is used to configure &kturtle;. Here you can change the language of the &logo; commands or set a new initial canvas size.</para></listitem> + </varlistentry> + </variablelist> + +</sect2> + +<sect2 id="the-help-menu"> + <title>The <guimenu>Help</guimenu> Menu</title> + <variablelist> + <anchor id="help-handbook" /> + <varlistentry> + <term><menuchoice> + <shortcut> + <keycombo><keysym>F1</keysym></keycombo> + </shortcut> + <guimenu>Help</guimenu> + <guimenuitem>&kturtle; Handbook</guimenuitem> + </menuchoice></term> + <listitem><para>This action shows the handbook that you are currently reading.</para></listitem> + </varlistentry> + </variablelist> + <variablelist> + <anchor id="help-whats-this" /> + <varlistentry> + <term><menuchoice> + <shortcut> + <keycombo>&Shift;<keysym>F1</keysym></keycombo> + </shortcut> + <guimenu>Help</guimenu> + <guimenuitem>What's This?</guimenuitem> + </menuchoice></term> + <listitem><para>After activating this action the mouse arrow will be changed into a <quote>question mark arrow</quote>. When this arrow is used to click on parts of &kturtle; main window, a description of the particular part pops-up.</para></listitem> + </varlistentry> + </variablelist> + <variablelist> + <anchor id="help-context-help" /> + <varlistentry> + <term><menuchoice> + <shortcut> + <keycombo><keysym>F2</keysym></keycombo> + </shortcut> + <guimenu>Help</guimenu> + <guimenuitem>Help on: ...</guimenuitem> + </menuchoice></term> + <listitem><para>This is a very useful function: it provides help on the code where the cursor in the code editor is at. So, ⪚, you have used the <userinput>print</userinput> command in your code, and you want to read and to know what the handbook says on this command. You just move your cursor so it is in the <userinput>print</userinput> command and you press <keysym>F2</keysym>. The handbook will then show all info on the <userinput>print</userinput> command.</para> + <para>This function is very important while learning programming.</para></listitem> + </varlistentry> + </variablelist> + <variablelist> + <anchor id="help-report-bug" /> + <varlistentry> + <term><menuchoice> + <guimenu>Help</guimenu> + <guimenuitem>Report Bug...</guimenuitem> + </menuchoice></term> + <listitem><para>Use this to report a problem with &kturtle; to the developers. These reports can be used to make future versions of &kturtle; even better.</para></listitem> + </varlistentry> + </variablelist> + <variablelist> + <anchor id="help-about-kturtle" /> + <varlistentry> + <term><menuchoice> + <guimenu>Help</guimenu> + <guimenuitem>About &kturtle;</guimenuitem> + </menuchoice></term> + <listitem><para>Here you find information on &kturtle;, like the authors and the license it comes with.</para></listitem> + </varlistentry> + </variablelist> + <variablelist> + <anchor id="help-about-kde" /> + <varlistentry> + <term><menuchoice> + <guimenu>Help</guimenu> + <guimenuitem>About &kde;</guimenuitem> + </menuchoice></term> + <listitem><para>Here you can find information on &kde;. If you do not know yet what &kde; is, this is a place you should not miss.</para></listitem> + </varlistentry> + </variablelist> +</sect2> + +</sect1> + +<sect1 id="the-toolbar"> +<title>The Toolbar</title> +<para>Here you can quickly reach the most used actions. By default, you will find here all main useful commands ending with the <guiicon>Execute Commands</guiicon> and <guiicon>Stop Execution</guiicon> icons.</para> +<para>You can configure the toolbar using <menuchoice><guimenu>Settings</guimenu><guimenuitem>Advanced Settings</guimenuitem><guimenuitem>Configure Toolbars...</guimenuitem></menuchoice></para> +</sect1> + +<sect1 id="the-statusbar"> +<title>The Statusbar</title> +<para>On the status bar you get feedback of the state of &kturtle;. On the left side it shows the feedback on the last action. On the right side you find the current location of the cursor (line and column numbers). In the middle of the Status bar is indicated the current language used for the commands.</para> +</sect1> + +</chapter> diff --git a/doc/kturtle/wrapping.png b/doc/kturtle/wrapping.png Binary files differnew file mode 100644 index 00000000..55aa4069 --- /dev/null +++ b/doc/kturtle/wrapping.png |