diff options
Diffstat (limited to 'programs/c-ports/subeditor.c')
-rw-r--r-- | programs/c-ports/subeditor.c | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/programs/c-ports/subeditor.c b/programs/c-ports/subeditor.c index 313c49a..76ee544 100644 --- a/programs/c-ports/subeditor.c +++ b/programs/c-ports/subeditor.c @@ -1,4 +1,3 @@ -#include <curses.h> #include "subeditor.h" #define clr_bitabl() {\ bitabl[0x00] = 0;\ @@ -45,6 +44,7 @@ uint8_t scr_col = 0; uint8_t scr_trow = 0; uint8_t scr_tcol = 0; uint16_t scr_ptr = 0; +uint16_t scr_ptr2 = 0; uint8_t byte = 0; uint8_t mask = 0; @@ -202,7 +202,7 @@ void bitpos(uint8_t row) { mask = bits[bit]; byte = bitmask >> 3; #if debug - mvwprintw(scr, 2, 0, "bit: $%02X, row: $%02X, byte: $%02X, mask: $%02X, bitmask: $%02X\r", bit, row, byte, mask, bitmask); + /*mvwprintw(scr, 2, 0, "bit: $%02X, row: $%02X, byte: $%02X, mask: $%02X, bitmask: $%02X\r", bit, row, byte, mask, bitmask);*/ #endif } @@ -240,11 +240,28 @@ void findst() { } } +void shftln(uint16_t src, uint16_t dst, uint8_t flag) { + if (!flag) { + while (buffer[src] != '\0') { + buffer[dst++] = buffer[src]; + buffer[src++] = '\0'; + } + } else { + while (scr_ptr <= src) { + mvwprintw(scr, 2, 0, "buffer[0x%04X]: $%02X, buffer[0x%04X]: $%02X, src: $%04X, dst: $%04X, scr_ptr: $%04X\r", src, buffer[src], dst, buffer[dst], src, dst, scr_ptr); + wrefresh(scr); + buffer[dst--] = buffer[src]; + buffer[src--] = '\0'; + } + } +} + void print_char(char ch) { uint8_t is_wrap = 0; uint8_t is_scroll = 0; uint8_t is_esc = 0; uint8_t done = 0; + uint16_t i = 0; a = ch; switch (ch) { case 0x1B: @@ -286,11 +303,9 @@ void print_char(char ch) { ++scr_row; if (getbit()) { scr_col = 0; - if (scr_row >= 23) { - if (scr_str) { - wrapped = 1; - scrl_down(); - } + if (scr_row > 23) { + wrapped = 1; + scrl_down(); is_wrap = 0; done = 1; } else { @@ -405,11 +420,18 @@ void print_char(char ch) { scr_col--; update_pos(); buffer[scr_ptr] = 0; + shftln(scr_ptr+1, scr_ptr, 0); #if !debug wdelch(scr); #endif break; default: + if (buffer[scr_ptr] != '\0') { + for (i = scr_ptr; buffer[i] != '\0'; i++); + scr_ptr2 = scr_ptr-1; + shftln(i-1, i, 1); + i = 0; + } a = ch; buffer[scr_ptr] = ch; scr_col++; @@ -557,7 +579,7 @@ int main() { continue; } if (!getkey(ch)) { - if (dabbed()) { + if (subasm()) { print_str(string2); print_str(cmd_buf); print_char('\n'); |