reply_status = self.cc.get_status_by_id(reply_id)
self.visibility = reply_status['visibility']
+ def layout(self, wrapwidth):
+ # Layout during rendering, abstracted into its own function
+ # for standalone testing.
+ self.dtext = self.DisplayText(self.text)
+ self.dtext.layout(wrapwidth, self.char_limit, self.url_cost)
+ self.cy, self.cx = self.dtext.yx[self.point]
+
def render(self):
y = 0
self.cc.print_at(y, 0, line)
y += 1
- self.dtext = self.DisplayText(self.text)
- self.dtext.layout(self.cc.scr_w - 1, self.char_limit, self.url_cost)
+ self.layout(self.cc.scr_w - 1)
ytop = y
-
for line in self.dtext.lines:
self.cc.print_at(y, 0, line)
y += 1
- self.cy, self.cx = self.dtext.yx[self.point]
self.cc.move_cursor_to(self.cy + ytop, self.cx)
def word_boundary(self, pos):
self.assertEqual(t.yx, ([(0,i) for i in range(8)] +
[(1,i) for i in range(2)]))
+ def testCtrlY(self):
+ def setup(point):
+ class FakeCC:
+ def get(self, str): return {}
+
+ t = Composer(FakeCC(), "abc def ghi jkl\nmno pqr stu vwx")
+ t.point = point
+ t.layout(10)
+ self.assertEqual(t.dtext.lines, [text.ColouredString("abc def "),
+ text.ColouredString("ghi jkl"),
+ text.ColouredString("mno pqr "),
+ text.ColouredString("stu vwx")])
+ return t
+
+ # On the last line of a paragraph: delete up to the next
+ # newline, but not including it
+ t = setup(12)
+ t.handle_key(ctrl('k'))
+ self.assertEqual(t.text, "abc def ghi \nmno pqr stu vwx")
+
+ # Same, but the paragraph in question is at the end of the
+ # buffer and has no trailing newline. Do the same, without
+ # tripping over the newline
+ t = setup(28)
+ t.handle_key(ctrl('k'))
+ self.assertEqual(t.text, "abc def ghi jkl\nmno pqr stu ")
+
+ # Sitting on a newline: delete just the newline itself
+ t = setup(15)
+ t.handle_key(ctrl('k'))
+ self.assertEqual(t.text, "abc def ghi jklmno pqr stu vwx")
+
+ # At the very end of the buffer: do nothing, including not
+ # crashing
+ t = setup(31)
+ t.handle_key(ctrl('k'))
+ self.assertEqual(t.text, "abc def ghi jkl\nmno pqr stu vwx")