chiark / gitweb /
Proper old-fashioned [RET][.][RET] to finish a post
authorSimon Tatham <anakin@pobox.com>
Fri, 8 Dec 2023 08:42:56 +0000 (08:42 +0000)
committerSimon Tatham <anakin@pobox.com>
Fri, 8 Dec 2023 08:42:56 +0000 (08:42 +0000)
cursesclient.py

index 381b473ddcf8a2e94c4968255b8bb3826f9742c2..19fb35890e9b9eb8f032455a3896c5a0ced5c47b 100644 (file)
@@ -959,6 +959,12 @@ class Composer:
                 self.text = (self.text[:self.point] + '\n' +
                              self.text[self.point:])
                 self.point += 1
+                if self.text[self.point-3:self.point] == '\n.\n':
+                    self.text = (self.text[:self.point-2] +
+                                 self.text[self.point:])
+                    self.post()
+                    self.cc.composer = None
+                    self.cc.activity_stack.pop()
             elif ch in {ctrl('o')}:
                 self.mode = 'ctrlo'
             elif isinstance(ch, str) and (' ' <= ch < '\x7F' or '\xA0' <= ch):
@@ -982,7 +988,7 @@ class Composer:
 
     def post(self):
         params = {
-            "status": self.text,
+            "status": self.text.rstrip("\n"),
             "visibility": "public",
             "language": "en", # FIXME
         }