Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorolpc <olpc@xo-12-34-56.localdomain>2008-11-17 22:52:48 (GMT)
committer olpc <olpc@xo-12-34-56.localdomain>2008-11-17 22:52:48 (GMT)
commit0f64fe1984496579ea6cb3dadeafd1c6a346c5fe (patch)
tree7a4e0cf4c6b5127fa07af1b248ad5f9b125591d2
parenta0a41dcfa18821a53bb51b029d7dfea9bfd35af1 (diff)
Word wrap in lesson screen.
-rw-r--r--lessons/en_US/homerow_intro.lesson146
-rw-r--r--lessons/en_US/long.lesson3
-rwxr-xr-xtypingturtle.py36
3 files changed, 112 insertions, 73 deletions
diff --git a/lessons/en_US/homerow_intro.lesson b/lessons/en_US/homerow_intro.lesson
index 4bc5907..008de2c 100644
--- a/lessons/en_US/homerow_intro.lesson
+++ b/lessons/en_US/homerow_intro.lesson
@@ -1,67 +1,81 @@
- {
- "name": "Home Row",
- "description": "Teaches the middle row of keys on the keyboard.",
- "medals": {
- "bronze": { "wpm": 0, "accuracy": 60 },
- "silver": { "wpm": 0, "accuracy": 60 },
- "gold": { "wpm": 0, "accuracy": 90 }
+{
+ "name": "Home Row",
+ "description": "Teaches the middle row of keys on the keyboard.",
+ "medals": {
+ "bronze": { "wpm": 0, "accuracy": 60 },
+ "silver": { "wpm": 0, "accuracy": 60 },
+ "gold": { "wpm": 0, "accuracy": 90 }
+ },
+ "steps": [
+ {
+ "type": "key",
+ "instructions": "Welcome to the first Typing Turtle lesson! Please place your fingers on the keyboard.\n\nWhen you are ready to begin, press the f key with your left index finger.",
+ "text": "f"
},
- "steps": [
- {
- "instructions": "Welcome to the first Typing Turtle lesson! Please place your fingers on the keyboard.\n\nWhen you are ready to begin, press the <b>f</b> key with your left index finger.",
- "text": "f"
- },
- {
- "instructions": "Good job! Now press the <b>d</b> key with your left middle finger.",
- "text": "d"
- },
- {
- "instructions": "Now the <b>s</b> key with your left ring finger.",
- "text": "s"
- },
- {
- "instructions": "And the <b>a</b> key with your left pinky finger.",
- "text": "a"
- },
- {
- "instructions": "Great work! We will now move on to the right hand. As shown in the picture below, press the <b>j</b> key with your right index finger.",
- "text": "j"
- },
- {
- "instructions": "The <b>k</b> key with your right middle finger.",
- "text": "k"
- },
- {
- "instructions": "The <b>l</b> key with your right ring finger.",
- "text": "l"
- },
- {
- "instructions": "The <b>;</b> (semicolon) key with your right pinky finger.",
- "text": ";"
- },
- {
- "instructions": "Excellent! These keys are known as the <i>home row</i>. Your fingers should always return to them after typing each letter.\n\nType all of the letters below. Press down with your fingertips, but do not move your hands.",
- "text": "fdsajkl;"
- },
- {
- "instructions": "Again, from left to right!",
- "text": "asdfjkl;"
- },
- {
- "instructions": "Keep it up, you are doing great! Now, from right to left!",
- "text": ";lkjfdsa"
- },
- {
- "instructions": "Okay, you are done with that. Now to begin moving your fingers. Without moving any <i>other</i> fingers, move your left index finger over and press the <b>g</b> key.",
- "text": "g"
- },
- {
- "instructions": "Now do the same with your right hand. Move your right index finger <i>only</i> and press the <b>h</b> key.",
- "text": "h"
- },
- {
- "instructions": "Now for the final two keys of the home row. Move your right pinky finger over and press the <b>'</b> key.",
- "text": "'"
- }
- ]
- }
+ {
+ "type": "key",
+ "instructions": "Good job! Now press the d key with your left middle finger.",
+ "text": "d"
+ },
+ {
+ "type": "key",
+ "instructions": "Now the s key with your left ring finger.",
+ "text": "s"
+ },
+ {
+ "type": "key",
+ "instructions": "And the a key with your left pinky finger.",
+ "text": "a"
+ },
+ {
+ "type": "key",
+ "instructions": "Great work! We will now move on to the right hand. As shown in the picture below, press the j key with your right index finger.",
+ "text": "j"
+ },
+ {
+ "type": "key",
+ "instructions": "The k key with your right middle finger.",
+ "text": "k"
+ },
+ {
+ "type": "key",
+ "instructions": "The l key with your right ring finger.",
+ "text": "l"
+ },
+ {
+ "type": "key",
+ "instructions": "The ; (semicolon) key with your right pinky finger.",
+ "text": ";"
+ },
+ {
+ "type": "key",
+ "instructions": "Excellent! These keys are known as the <i>home row</i>. Your fingers should always return to them after typing each letter.\n\nType all of the letters below. Press down with your fingertips, but do not move your hands.",
+ "text": "fdsajkl;"
+ },
+ {
+ "type": "key",
+ "instructions": "Again, from left to right!",
+ "text": "asdfjkl;"
+ },
+ {
+ "type": "key",
+ "instructions": "Keep it up, you are doing great! Now, from right to left!",
+ "text": ";lkjfdsa"
+ },
+ {
+ "type": "key",
+ "instructions": "Okay, you are done with that. Now to begin moving your fingers. Without moving any <i>other</i> fingers, move your left index finger over and press the g key.",
+ "text": "g"
+ },
+ {
+ "type": "key",
+ "instructions": "Now do the same with your right hand. Move your right index finger <i>only</i> and press the h key.",
+ "text": "h"
+ },
+ {
+ "type": "key",
+ "instructions": "Now for the final two keys of the home row. Move your right pinky finger over and press the ' key.",
+ "text": "'"
+ }
+ ]
+}
diff --git a/lessons/en_US/long.lesson b/lessons/en_US/long.lesson
index 47e6c59..512b3c0 100644
--- a/lessons/en_US/long.lesson
+++ b/lessons/en_US/long.lesson
@@ -8,8 +8,9 @@
},
"steps": [
{
+ "type": "text",
"instructions": "Please copy out the following text.",
- "text": "It is a truth universally acknowledged, that a single man in posession\nof a good fortune, must be in want of a wife.\n\nHowever little known the feelings or views of such a man may be on his\nfirst entering a neighbourhood, this truth is so well fixed in the minds\nof the surrounding families, that he is considered the rightful property\nof some one or other of their daughters.\n\n\"My dear Mr. Bennet,\" said his lady to him one day, \"have you heard that\nNetherfield Park is let at last?\"\n\nMr. Bennet replied that he had not.\n\n\"But it is,\" returned she; \"for Mrs. Long has just been here, and she told me all about it.\"\n\nMr. Bennet made no answer.\n\n\"Do you not want to know who has taken it?\" cried his wife impatiently.\n\n\"You want to tell me, and I have no objection to hearing it.\"\n\nThis was invitation enough."
+ "text": "It is a truth universally acknowledged, that a single man in posession of a good fortune, must be in want of a wife.\n\nHowever little known the feelings or views of such a man may be on his first entering a neighbourhood, this truth is so well fixed in the minds of the surrounding families, that he is considered the rightful property of some one or other of their daughters.\n\n\"My dear Mr. Bennet,\" said his lady to him one day, \"have you heard that\nNetherfield Park is let at last?\"\n\nMr. Bennet replied that he had not.\n\n\"But it is,\" returned she; \"for Mrs. Long has just been here, and she told me all about it.\"\n\nMr. Bennet made no answer.\n\n\"Do you not want to know who has taken it?\" cried his wife impatiently.\n\n\"You want to tell me, and I have no objection to hearing it.\"\n\nThis was invitation enough."
}
]
}
diff --git a/typingturtle.py b/typingturtle.py
index 0f2156b..9c93037 100755
--- a/typingturtle.py
+++ b/typingturtle.py
@@ -202,8 +202,32 @@ class LessonScreen(gtk.VBox):
self.wpmlabel.set_markup(_('<b>WPM:</b> %(wpm)d') % { 'wpm': int(self.wpm) } )
def wrap_line(self, line):
- #return [line[:10], line[10:]]
- return [line]
+ LINE_LENGTH = 80
+
+ words = line.split(' ')
+ new_lines = []
+ cur_line = ''
+ for w in words:
+ # TODO: Handle single word longer than a line.
+ #if len(w) > LINE_LENGTH:
+ # new_lines.append(cur_line)
+ # while len(w):
+ # new_lines.append(w[:LINE_LENGTH])
+ # w = w[LINE_LENGTH:]
+ # cur_line = ''
+ if len(cur_line) + len(w) + 1 > LINE_LENGTH:
+ if len(cur_line):
+ new_lines.append(cur_line)
+ cur_line = ''
+ cur_line += w + ' '
+
+ if len(cur_line):
+ # Remove trailing spaces from last line before adding.
+ while cur_line[-1] == ' ':
+ cur_line = cur_line[:-1]
+ new_lines.append(cur_line)
+
+ return new_lines
def advance_step(self):
if self.next_step_idx < len(self.lesson['steps']):
@@ -323,11 +347,11 @@ class LessonScreen(gtk.VBox):
# Advance to the next character (or else).
self.char_idx += 1
if self.char_idx >= len(self.line):
- if self.line_idx < len(self.lines):
- self.line_idx += 1
- self.begin_line()
- else:
+ self.line_idx += 1
+ if self.line_idx >= len(self.lines):
self.advance_step()
+ else:
+ self.begin_line()
self.update_stats()