about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--saneterm/terminal.py6
-rw-r--r--saneterm/termview.py6
2 files changed, 11 insertions, 1 deletions
diff --git a/saneterm/terminal.py b/saneterm/terminal.py
index 60d1b24..da41590 100644
--- a/saneterm/terminal.py
+++ b/saneterm/terminal.py
@@ -95,7 +95,11 @@ class Terminal(Gtk.Window):
         os.write(self.pty.master, line.encode("UTF-8"))
 
     def termios_ctrl(self, termview, cidx):
-        if cidx == termios.VEOF:
+        # termios ctrl keys are ignored if the cursor is not at the
+        # buffer position where the next character would appear.
+        if not termview.cursor_at_end():
+            return
+        elif cidx == termios.VEOF:
             termview.flush()
 
         # TODO: Employ some heuristic to cache tcgetattr result.
diff --git a/saneterm/termview.py b/saneterm/termview.py
index 0b8a16c..6c2ce14 100644
--- a/saneterm/termview.py
+++ b/saneterm/termview.py
@@ -83,6 +83,12 @@ class TermView(Gtk.TextView):
 
         return cur.compare(out) == 0
 
+    def cursor_at_end(self):
+        cur = self._textbuffer.get_iter_at_offset(self._textbuffer.props.cursor_position)
+        end = self._textbuffer.get_iter_at_mark(self._last_mark)
+
+        return cur.compare(end) == 0
+
     def do_backspace(self):
         # If current position is output positon ignore backspace.
         if not self.cursor_at_out():