From ca57554ec3e3b25439fe3845689ba024b8a7d596 Mon Sep 17 00:00:00 2001 From: Fortunate-MAN Date: Tue, 31 Jan 2017 19:51:58 +0530 Subject: [PATCH] Some work on Control + W #159 --- platform/pc/drv/ps2/kbd/kbd.c | 43 +++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/platform/pc/drv/ps2/kbd/kbd.c b/platform/pc/drv/ps2/kbd/kbd.c index 052930a..3530c64 100644 --- a/platform/pc/drv/ps2/kbd/kbd.c +++ b/platform/pc/drv/ps2/kbd/kbd.c @@ -338,6 +338,49 @@ void key_handler_util(int key) ,__crsr_start,__crsr_end); return; + } + else if (key == 'w' || key == 'W') + { + if (buffer_scank [0] == 0) + { + return; + } + + bool is_space = false; + int loc_space = 0; loc_space ++; + + //First see if there is a backspace in the variable `buffer_scank` + for (int i = 0; i < virtual_index_scank; i ++) + { + if (buffer_scank [i] == ' ') + { + is_space = true; + loc_space = i; + } + } + + if (is_space == false) + { + buffer_scank [0] = 0; + virtual_cursor_pos = 0; + virtual_index_scank = 0; + index_scank = 0; + + while (LENGTH_INPUT > 0) {printk ("\b"); LENGTH_INPUT --;} + return; + } + + if (virtual_index_scank == (int) index_scank) + { + buffer_scank [loc_space] = 0; + int temp = (int)index_scank; + index_scank = index_scank - (index_scank - loc_space); + virtual_index_scank = index_scank; + + while ((int)temp - loc_space >= 0) {printk ("\b"); loc_space ++;} + + return; + } } }