From: Neil Brown Date: Wed, 27 Aug 2008 21:10:48 +0000 (+1000) Subject: Handle 'newline' to start new line of text. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=3909fb91e63dd6c90371ebe8a3dd40309625ed2d;p=scribble.git Handle 'newline' to start new line of text. 'newline' is a straigth line: to-right to bottom left. --- diff --git a/scribble.py b/scribble.py index e30198a..2707b23 100755 --- a/scribble.py +++ b/scribble.py @@ -172,6 +172,7 @@ def LoadDict(dict): dict.add('_', "S(4)3,5.S(4)5,3.S(4)3,5") dict.add("", "S(4)5,3.S(3)3,5") dict.add("","S(4)3,5.S(5)5,3") + dict.add("", "S(4)2,6") class DictSegment: @@ -866,6 +867,15 @@ class ScribblePad: elif sym == "": if self.textcurs < len(self.textstr): self.textcurs += 1 + elif sym == "": + self.flush_text() + self.textcurs = 0 + self.textstr = "" + ctx = self.page.get_pango_context() + ascent = ctx.get_metrics(ctx.get_font_description()).get_ascent() + descent = ctx.get_metrics(ctx.get_font_description()).get_descent() + self.textpos = [ self.textpos[0], self.textpos[1] + + (ascent + descent) / pango.SCALE ] else: self.textstr = self.textstr[0:self.textcurs] + sym + \ self.textstr[self.textcurs:] @@ -915,7 +925,7 @@ class ScribblePad: if type(l[2]) == str: self.draw_text(st, col, l[2]) - if self.textstr: + if self.textstr != None: self.draw_text(self.textpos, self.colour, self.textstr, self.textcurs)