[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tyndur-devel] [PATCH 1/2] vterm: EOF gescheit setzen



* vtem: EOF nur nach Betaetigen von Strg+D setzen
---
 src/modules/vterm/lostio.c |    8 +++++++-
 src/modules/vterm/term.c   |    7 ++++++-
 src/modules/vterm/vterm.h  |    3 +++
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/modules/vterm/lostio.c b/src/modules/vterm/lostio.c
index 92d57fa..428d339 100644
--- a/src/modules/vterm/lostio.c
+++ b/src/modules/vterm/lostio.c
@@ -107,6 +107,13 @@ size_t terminal_read(lostio_filehandle_t* file, void* buf,
     size_t size = blocksize * blockcount;
     vterminal_t* vterm = (vterminal_t*) file->node->data;
 
+    if (vterm->set_eof) {
+        vterm->set_eof = FALSE;
+        file->flags |= LOSTIO_FLAG_EOF;
+        v();
+        return 0;
+    }
+
     if (vterm->in_buffer_size == 0) {
         v();
         return 0;
@@ -119,7 +126,6 @@ size_t terminal_read(lostio_filehandle_t* file, void* buf,
     memcpy(buf, vterm->in_buffer, size);
     
     vterm->in_buffer_size -= size;
-    vterm->in_node->size = vterm->in_buffer_size;
     // Die uebrigen Daten am ende des Buffers an den Anfang schieben
     if (vterm->in_buffer_size != 0) {
         memmove(vterm->in_buffer, vterm->in_buffer + size,
diff --git a/src/modules/vterm/term.c b/src/modules/vterm/term.c
index 5fab963..3e6881f 100644
--- a/src/modules/vterm/term.c
+++ b/src/modules/vterm/term.c
@@ -107,6 +107,8 @@ vterminal_t* vterm_create(char shortcut)
     vfstree_create_node(path, LOSTIO_TYPES_IN, 0, vterm,
         LOSTIO_FLAG_NOAUTOEOF);
     vterm->in_node = vfstree_get_node_by_path(path);
+    // Sonst setzt LIO das EOF
+    vterm->in_node->size = 1;
 
     // Out-Node
     memcpy(path + name_len + 1, "/out", 5);
@@ -149,7 +151,6 @@ static void input_buffer_append(vterminal_t* vterm, char c)
 {
     // FIXME; Ineffizienter konnte ich das nicht loesen. ;-)
     vterm->in_buffer_size += 1;
-    vterm->in_node->size = current_vterm->in_buffer_size;
     vterm->in_buffer = realloc(vterm->in_buffer, vterm->in_buffer_size);
     // Daten in den Puffer kopieren
     vterm->in_buffer[vterm->in_buffer_size - 1] = c;
@@ -237,6 +238,10 @@ bool vterm_process_raw_input(uint8_t keycode, struct modifiers* modifiers)
             case KEYCODE_F11: vterm_switch_to(11); return TRUE;
             case KEYCODE_F12: vterm_switch_to(12); return TRUE;
         }
+    } else if (modifiers->control && (keycode == 32)) {
+        // Strg + D = EOF
+        current_vterm->set_eof = TRUE;
+        return TRUE;
     } else if (keycode == KEYCODE_SCROLL_LOCK) {
         current_vterm->output.scroll_lock = !current_vterm->output.scroll_lock;
         return TRUE;
diff --git a/src/modules/vterm/vterm.h b/src/modules/vterm/vterm.h
index 450252a..d5149da 100644
--- a/src/modules/vterm/vterm.h
+++ b/src/modules/vterm/vterm.h
@@ -163,6 +163,9 @@ typedef struct {
 
     /// Anzahl der Zeichen im utf-8 Puffer
     size_t utf8_buffer_offset;
+
+    /// Beim naechsten Lesen EOF setzen
+    bool set_eof;
 } vterminal_t;
 
 /// Status der Modifiertasten
-- 
1.6.0.6