diff --git a/programs/cmm/tmpdisk/t_gui.c b/programs/cmm/tmpdisk/t_gui.c index e874fb4415..790c71467b 100644 --- a/programs/cmm/tmpdisk/t_gui.c +++ b/programs/cmm/tmpdisk/t_gui.c @@ -85,10 +85,10 @@ void Main_Window() case evKey: GetKeys(); // PROCESS KEYS WHEN EDIT BOX INACTIVE - if ( !asm test edit_disk_size.flags, 2) switch(key_scancode) + if ( ! edit_disk_size.flags&ed_focus) switch(key_scancode) { case SCAN_CODE_TAB: - edit_disk_size.flags=1000000000000010b; + edit_disk_size.flags = ed_figure_only + ed_focus; edit_box_draw stdcall (#edit_disk_size); DrawTmpDisks(); break; @@ -126,7 +126,7 @@ void Main_Window() else switch(key_scancode) { case SCAN_CODE_TAB: - edit_disk_size.flags=1000000000000000b; + edit_disk_size.flags = ed_figure_only; edit_box_draw stdcall (#edit_disk_size); DrawTmpDisks(); break; diff --git a/programs/develop/libraries/box_lib/trunk/editbox.asm b/programs/develop/libraries/box_lib/trunk/editbox.asm index ea0e8da6d9..90eb1f6181 100644 --- a/programs/develop/libraries/box_lib/trunk/editbox.asm +++ b/programs/develop/libraries/box_lib/trunk/editbox.asm @@ -1,4 +1,4 @@ -macro use_key_no_process up,down,esc,enter,tab,numl,capsl,scrolll +macro use_key_no_process up,down,esc,enter,tab,numl,capsl,scrolll,pgup,pgdown { if up eq else @@ -40,6 +40,16 @@ else cmp ah,1 ;Scroll Lock - клавиша )) jz edit_box.editbox_exit end if +if pgup eq +else + cmp ah,184 ;Page Up - клавиша )) + jz edit_box.editbox_exit +end if +if pgdown eq +else + cmp ah,183 ;Page Dwon - клавиша )) + jz edit_box.editbox_exit +end if } SCAN_LWIN_RELEASE = 0xDB @@ -157,10 +167,10 @@ edit_box_key: ;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;Заглушка на обработку клавиш вверх и вниз т.е. при обнаружении этих кодов происходит выход из обработчика ;;;;;;;;;;;;;;;;;;;;;;;;;;;; -use_key_no_process up,down,esc,enter,tab,numl,capsl,scrolll +use_key_no_process up,down,esc,enter,tab,numl,capsl,scrolll,pgup,pgdown ;--- нажата другая клавиша --- ;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;Проверка установлен ли флаг при котором нужно выводить только цифры в нужном боксе, если такой необходимости нет, нужно закоментировать макрос +;Проверка установлен ли флаг при котором нужно выводить только цифры в нужном боксе ;;;;;;;;;;;;;;;;;;;;;;;;;;;; test word ed_flags,ed_figure_only ; только цифры? jz @f @@ -241,7 +251,7 @@ edit_box_key.In_k: jmp edit_box_key.shift ;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;Обработка клавиш insert,delete.backspace,home,end,left,right +;Обработка клавиш insert,delete,backspace,home,end,left,right ;;;;;;;;;;;;;;;;;;;;;;;;;;;; edit_box_key.insert: test word ed_flags,ed_insert diff --git a/programs/develop/libraries/box_lib/trunk/run.bat b/programs/develop/libraries/box_lib/trunk/run.bat index 551c174cc1..1824488d57 100644 --- a/programs/develop/libraries/box_lib/trunk/run.bat +++ b/programs/develop/libraries/box_lib/trunk/run.bat @@ -1,4 +1,2 @@ -if not exist bin mkdir bin -@fasm.exe -m 16384 box_lib.asm bin\box_lib.obj -@kpack bin\box_lib.obj +@fasm.exe -m 16384 box_lib.asm box_lib.obj pause \ No newline at end of file diff --git a/programs/network/ftpc/ftpc.asm b/programs/network/ftpc/ftpc.asm index c4480c6f85..e7d70c015e 100644 --- a/programs/network/ftpc/ftpc.asm +++ b/programs/network/ftpc/ftpc.asm @@ -750,7 +750,7 @@ exit2: ; data str_title db 'FTP client for KolibriOS',0 -str_welcome db 'FTP client for KolibriOS v0.15',10 +str_welcome db 'FTP client for KolibriOS v0.15a',10 db 10,0 str_srv_addr db 'Please enter ftp server address.',10,0 diff --git a/programs/network/ftpc/login_gui.inc b/programs/network/ftpc/login_gui.inc index 4153f23e36..81d3864a37 100755 --- a/programs/network/ftpc/login_gui.inc +++ b/programs/network/ftpc/login_gui.inc @@ -166,7 +166,9 @@ login_gui: ;//////////////////////////////////////////////////////////////////// je @f sub word [edit_path.flags],ed_focus add word [edit_usr.flags],ed_focus - ;jmp .tab_end + jmp .tab_end + @@: + add word [edit_usr.flags],ed_focus .tab_end: call .draw_editboxes diff --git a/programs/other/table/hello.cpp b/programs/other/table/hello.cpp index 8064ae138c..dc7046046f 100644 --- a/programs/other/table/hello.cpp +++ b/programs/other/table/hello.cpp @@ -6,7 +6,7 @@ #include "calc.h" #include "use_library.h" -#define TABLE_VERSION "0.98.9" +#define TABLE_VERSION "0.99" // strings const char *sFileSign = "KolibriTable File\n"; @@ -61,7 +61,7 @@ scroll_bar scroll_v = { SCROLL_SIZE,200,398, NULL, SCROLL_SIZE,0,115,15,0,0xeeee scroll_bar scroll_h = { 200,NULL,SCROLL_SIZE, NULL, SCROLL_SIZE,0,115,15,0,0xeeeeee,0xD2CED0,0x555555,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}; // ╤П╤З╨╡╨╣╨║╨╕ - ╨╕╤Е ╨┐╨░╤А╨░╨╝╨╡╤В╤А╤Л ╨╕ ╤В╨╡╨║╤Б╤В -DWORD col_count = 101, row_count = 101; +DWORD col_count = 100, row_count = 100; DWORD *cell_w, *cell_h; char ***cells; @@ -101,8 +101,6 @@ bool sel_end_move = 0; DWORD nx = 0, ny = 0; // ╤Д╨╗╨░╨│ ╤А╨╡╨░╨┤╨║╤В╨╕╤А╨╛╨▓╨░╨╜╨╕╤П ╤П╤З╨╡╨╣╨║╨╕ -//bool is_edit = 0; -#define ed_focus 2 #define is_edit (cell_box.flags & ed_focus) // ╤А╨╡╨┤╨░╨║╤В╨╕╤А╨╛╨▓╨░╨╜╨╕╨╡ ╨╕╨╝╨╡╨╜╨╕ ╤Д╨░╨╣╨╗╨░ @@ -121,7 +119,6 @@ int size_mouse_x, size_mouse_y, size_id, size_state = 0; int drag_x, drag_y; int old_end_x, old_end_y; -void draw_window(); void draw_grid(); void DrawSelectedFrame(int x, int y, int w, int h, DWORD col) @@ -173,12 +170,12 @@ void start_edit(int x, int y) if (ch) { sel_moved = 1; - draw_window(); + draw_grid(); } file_box.flags &= ~ed_focus; - cell_box.flags |= ed_focus; + cell_box.flags = ed_focus; cell_box.left = cell_x[x] + 1; cell_box.top = cell_y[y]; cell_box.width = cell_w[x] - 2; @@ -186,12 +183,12 @@ void start_edit(int x, int y) if (cells[x][y]) { strcpy(edit_text, cells[x][y]); - edit_text[strlen(cells[x][y]) - 1] = '\0'; } + cell_box.offset = cell_box.shift = cell_box.shift_old = 0; cell_box.pos = cell_box.size = strlen(edit_text); - cell_box.offset = 0; - draw_window(); + edit_box_draw((DWORD)&cell_box); + edit_box_draw((DWORD)&file_box); } void stop_edit() @@ -219,7 +216,7 @@ void cancel_edit() return; cell_box.flags &= ~ed_focus; memset((Byte*)edit_text,0, 256); - draw_window(); + draw_grid(); } void check_sel() @@ -434,8 +431,8 @@ void draw_grid() } DrawCell(x+1, y+1, cell_w[j]-1, cell_h[i]-1, 0, bg_color, text, false); - if (draw_frame_selection) { - DrawSelectedFrame(x+1,y, cell_w[j]-1, cell_h[i], TEXT_COLOR); + if (draw_frame_selection && j=cell_box.left && mouse_x<=cell_box.left+cell_box.width + && mouse_y>=cell_box.top && mouse_y<=cell_box.top+22) return; + mouse_btn &= 0x0001; if (mouse_btn) @@ -799,200 +786,9 @@ void process_mouse() size_mouse_y = mouse_y; } -void process_key() + +void shift_selection(int dx, int dy, Dword shift) { - Dword mouse_btn, ckeys, shift, ctrl; - int mouse_x, mouse_y, dx = 0, dy = 0; - - // key pressed, read it - Byte keyCode; - ckeys = kos_GetSpecialKeyState(); - shift = ckeys & 0x3; - ctrl = ckeys & 0x0c; - sel_moved = 0; - sel_end_move = 0; - kos_GetKey(keyCode); - - __asm - { - mov ah, keyCode - } - edit_box_key((dword)&cell_box); - edit_box_key((dword)&file_box); - - - switch (keyCode) - { - case 178: - dy = -1; - break; - case 176: - dx = -1; - break; - case 179: - dx = 1; - break; - case 177: - dy = 1; - break; - case 183: - dy = ny - grid.firsty-1; - break; - case 184: - dy = - (ny - grid.firsty); - break; - case 180: //home - dx = -sel_x + 1; - dy = 0; - draw_grid(); - break; - case 181: //end - dx = col_count - (nx - grid.firstx) - 1 - sel_x; - dy = 0; - draw_grid(); - break; - case 27: // escape - cancel_edit(); - break; - case 182: // delete - { - int i,j,n0,n1,k0,k1; - n0 = min(sel_x, sel_end_x); - n1 = max(sel_x, sel_end_x); - k0 = min(sel_y, sel_end_y); - k1 = max(sel_y, sel_end_y); - - for (i = n0; i <= n1; i++) - for (j = k0; j <= k1; j++) - { - if (cells[i][j]) - { - freemem(cells[i][j]); - cells[i][j] = NULL; - } - } - calculate_values(); - draw_grid(); - break; - } - case 0x0D: // enter - if (is_edit) - { - stop_edit(); - draw_grid(); - } - break; - case 22: // contol-v - { - if (ctrl) - { - int i, j, x0, y0; - x0 = min(sel_x, sel_end_x); - y0 = min(sel_y, sel_end_y); - int delta_x = x0 - buf_old_x; - int delta_y = y0 - buf_old_y; - - for (i = 0; i < buf_col; i++) - for (j = 0; j < buf_row; j++) - { - if (i + x0 >= col_count || j + y0 >= row_count) - continue; - if (cells[i + x0][j + y0]) - freemem(cells[i + x0][j + y0]); - if (buffer[i][j]) - { - cf_x0 = buf_old_x; cf_y0 = buf_old_y; - cf_x1 = buf_old_x + buf_col; - cf_y1 = buf_old_y + buf_row; - cells[i + x0][j + y0] = change_formula(buffer[i][j], delta_x, delta_y); - //cells[i + x0][j + y0] = (char*)allocmem(strlen(buffer[i][j])); - //strcpy(cells[i + x0][j + y0], buffer[i][j]); - } - else - cells[i + x0][j + y0] = NULL; - } - - calculate_values(); - draw_grid(); - break; - } - } - case 24: // control-x - case 03: // control-c - { - if (ctrl) - { - //rtlDebugOutString("control-c!"); - int i, j, x0, y0; - - freeBuffer(); - - buf_col = abs(sel_end_x - sel_x) + 1; - buf_row = abs(sel_end_y - sel_y) + 1; - x0 = min(sel_x, sel_end_x); - y0 = min(sel_y, sel_end_y); - buf_old_x = x0; - buf_old_y = y0; - - //sprintf(debuf, "%U %U %U %U", buf_col, buf_row, x0, y0); - //rtlDebugOutString(debuf); - - buffer = (char***)allocmem(buf_col * sizeof(char**)); - for (i = 0; i < buf_col; i++) - { - buffer[i] = (char**)allocmem(buf_row * sizeof(char*)); - for (j = 0; j < buf_row; j++) - { - if (cells[i + x0][j + y0]) - { - if (keyCode == 03) // ctrl-c - { - buffer[i][j] = (char*)allocmem(strlen(cells[i + x0][j + y0])); - strcpy(buffer[i][j], cells[i + x0][j + y0]); - } - else - { - buffer[i][j] = cells[i + x0][j + y0]; - cells[i + x0][j + y0] = NULL; - } - } - else - buffer[i][j] = NULL; - } - } - if (keyCode == 24) - calculate_values(); - draw_grid(); - break; - } - } - case 06: // control-f - { - display_formulas = !display_formulas; - draw_grid(); - break; - } - default: - if (!is_edit && !(file_box.flags & ed_focus)) - { - start_edit(sel_x, sel_y); - if (keyCode == 8) - { - cell_box.pos = strlen(edit_text); - } - else - { - __asm - { - mov ah, keyCode - } - edit_box_key((dword)&cell_box); - } - } - if (is_edit) - edit_box_draw((dword)&cell_box); - break; - } if (dx != 0) { if (shift) @@ -1057,6 +853,196 @@ void process_key() } } + +void process_key() +{ + Dword ckeys, shift, ctrl; + dword key_editbox; + Byte key_ascii, key_scancode; + + // key pressed, read it + ckeys = kos_GetSpecialKeyState(); + shift = ckeys & 0x3; + ctrl = ckeys & 0x0c; + sel_moved = 0; + sel_end_move = 0; + + kos_GetKeys(key_editbox, key_ascii, key_scancode); + + if (cell_box.flags & ed_focus) { + if (SCAN_CODE_ENTER == key_scancode) { + stop_edit(); + draw_grid(); + } + else if (SCAN_CODE_ESC == key_scancode) { + cancel_edit(); + } + else { + __asm + { + mov eax, key_editbox + } + edit_box_key((dword)&cell_box); + } + } + else if (file_box.flags & ed_focus) { + __asm + { + mov eax, key_editbox + } + edit_box_key((dword)&file_box); + return; + } + else if (ctrl) { + switch (key_scancode) + { + case SCAN_CODE_KEY_V: + { + int i, j, x0, y0; + x0 = min(sel_x, sel_end_x); + y0 = min(sel_y, sel_end_y); + int delta_x = x0 - buf_old_x; + int delta_y = y0 - buf_old_y; + + for (i = 0; i < buf_col; i++) + for (j = 0; j < buf_row; j++) + { + if (i + x0 >= col_count || j + y0 >= row_count) + continue; + if (cells[i + x0][j + y0]) + freemem(cells[i + x0][j + y0]); + if (buffer[i][j]) + { + cf_x0 = buf_old_x; cf_y0 = buf_old_y; + cf_x1 = buf_old_x + buf_col; + cf_y1 = buf_old_y + buf_row; + cells[i + x0][j + y0] = change_formula(buffer[i][j], delta_x, delta_y); + //cells[i + x0][j + y0] = (char*)allocmem(strlen(buffer[i][j])); + //strcpy(cells[i + x0][j + y0], buffer[i][j]); + } + else + cells[i + x0][j + y0] = NULL; + } + + calculate_values(); + draw_grid(); + break; + } + case SCAN_CODE_KEY_X: + case SCAN_CODE_KEY_C: + { + int i, j, x0, y0; + + freeBuffer(); + + buf_col = abs(sel_end_x - sel_x) + 1; + buf_row = abs(sel_end_y - sel_y) + 1; + x0 = min(sel_x, sel_end_x); + y0 = min(sel_y, sel_end_y); + buf_old_x = x0; + buf_old_y = y0; + + //sprintf(debuf, "%U %U %U %U", buf_col, buf_row, x0, y0); + //rtlDebugOutString(debuf); + + buffer = (char***)allocmem(buf_col * sizeof(char**)); + for (i = 0; i < buf_col; i++) + { + buffer[i] = (char**)allocmem(buf_row * sizeof(char*)); + for (j = 0; j < buf_row; j++) + { + if (cells[i + x0][j + y0]) + { + if (SCAN_CODE_KEY_C == key_scancode) + { + buffer[i][j] = (char*)allocmem(strlen(cells[i + x0][j + y0])); + strcpy(buffer[i][j], cells[i + x0][j + y0]); + } + else + { + buffer[i][j] = cells[i + x0][j + y0]; + cells[i + x0][j + y0] = NULL; + } + } + else + buffer[i][j] = NULL; + } + } + if (key_ascii == 24) ///////WTF???? + calculate_values(); + draw_grid(); + break; + } + case SCAN_CODE_KEY_F: + display_formulas = !display_formulas; + draw_grid(); + break; + } + } + else switch (key_scancode) + { + case SCAN_CODE_UP: + shift_selection(0, -1, shift); + break; + case SCAN_CODE_LEFT: + shift_selection(-1, 0, shift); + break; + case SCAN_CODE_RIGHT: + shift_selection(1, 0, shift); + break; + case SCAN_CODE_DOWN: + shift_selection(0, 1, shift); + break; + case SCAN_CODE_PGDN: + shift_selection(0, ny-grid.firsty-1, shift); + break; + case SCAN_CODE_PGUP: + shift_selection(0, -(ny-grid.firsty), shift); + break; + case SCAN_CODE_HOME: + shift_selection(-sel_x + 1, 0, shift); + break; + case SCAN_CODE_END: + shift_selection(col_count - (nx - grid.firstx) - 1 - sel_x, 0, shift); + break; + case SCAN_CODE_DEL: + { + int n0 = min(sel_x, sel_end_x); + int n1 = max(sel_x, sel_end_x); + int k0 = min(sel_y, sel_end_y); + int k1 = max(sel_y, sel_end_y); + + for (int i = n0; i <= n1; i++) + for (int j = k0; j <= k1; j++) + { + if (cells[i][j]) + { + freemem(cells[i][j]); + cells[i][j] = NULL; + } + } + calculate_values(); + draw_grid(); + break; + } + break; + case SCAN_CODE_F2: + start_edit(sel_x, sel_y); + break; + case SCAN_CODE_F5: + draw_grid(); + break; + default: + start_edit(sel_x, sel_y); + __asm + { + mov eax, key_editbox + } + edit_box_key((dword)&cell_box); + break; + } +} + void process_button() { Dword button; @@ -1134,7 +1120,7 @@ void kos_Main() break; case EM_WINDOW_REDRAW: - if (draw_and_define_window()) draw_window(); + draw_window(); break; } } diff --git a/programs/other/table/kosSyst.cpp b/programs/other/table/kosSyst.cpp index f5aa7deaf4..742367b5fc 100644 --- a/programs/other/table/kosSyst.cpp +++ b/programs/other/table/kosSyst.cpp @@ -484,25 +484,20 @@ void kos_PutPixel( Dword x, Dword y, Dword colour ) } } - -// function 2 яюыєўшЄ№ ъюф эрцрЄющ ъыртш°ш -bool kos_GetKey( Byte &keyCode ) +bool kos_GetKeys( Dword &key_editbox, Byte &key_ascii, Byte &key_scancode ) { Dword result; - - // __asm{ mov eax, 2 int 0x40 mov result, eax } - // - keyCode = result >> 8; - // - return ( result & 0xFF ) == 0; + key_editbox = result; + key_ascii = result >> 8; + key_scancode = result >> 16; + return ( key_ascii ) == 0; } - // function 3 яюыєўшЄ№ тЁхь  Dword kos_GetSystemClock() { diff --git a/programs/other/table/kosSyst.h b/programs/other/table/kosSyst.h index af8a48ac43..0b4fc89dca 100644 --- a/programs/other/table/kosSyst.h +++ b/programs/other/table/kosSyst.h @@ -187,6 +187,7 @@ void kos_DefineAndDrawWindow( void kos_PutPixel( Dword x, Dword y, Dword colour ); // function 2 яюыєўшЄ№ ъюф эрцрЄющ ъыртш°ш bool kos_GetKey( Byte &keyCode ); +bool kos_GetKeys( Dword &key_editbox, Byte &key_ascii, Byte &key_scancode ); // function 3 яюыєўшЄ№ тЁхь  Dword kos_GetSystemClock(); // function 4 @@ -264,3 +265,60 @@ Dword kos_FileSystemAccess( kosFileInfo *fileInfo ); int kos_AppRun(char* app_path, char* param); // void kos_Main(); + +//SCAN CODE KEYS +#define SCAN_CODE_BS 14 +#define SCAN_CODE_TAB 15 +#define SCAN_CODE_ENTER 28 +#define SCAN_CODE_ESC 1 +#define SCAN_CODE_DEL 83 +#define SCAN_CODE_INS 82 +#define SCAN_CODE_SPACE 57 +#define SCAN_CODE_MENU 93 + +#define SCAN_CODE_LEFT 75 +#define SCAN_CODE_RIGHT 77 +#define SCAN_CODE_DOWN 80 +#define SCAN_CODE_UP 72 +#define SCAN_CODE_HOME 71 +#define SCAN_CODE_END 79 +#define SCAN_CODE_PGDN 81 +#define SCAN_CODE_PGUP 73 + +#define SCAN_CODE_MINUS 12 +#define SCAN_CODE_PLUS 13 + +#define SCAN_CODE_F1 59 +#define SCAN_CODE_F2 60 +#define SCAN_CODE_F3 61 +#define SCAN_CODE_F4 62 +#define SCAN_CODE_F5 63 +#define SCAN_CODE_F6 64 +#define SCAN_CODE_F7 65 +#define SCAN_CODE_F8 66 +#define SCAN_CODE_F9 67 +#define SCAN_CODE_F10 68 +#define SCAN_CODE_F11 87 +#define SCAN_CODE_F12 88 + +#define SCAN_CODE_KEY_A 30 +#define SCAN_CODE_KEY_B 48 +#define SCAN_CODE_KEY_C 46 +#define SCAN_CODE_KEY_D 32 +#define SCAN_CODE_KEY_E 18 +#define SCAN_CODE_KEY_F 33 +#define SCAN_CODE_KEY_H 35 +#define SCAN_CODE_KEY_I 23 +#define SCAN_CODE_KEY_L 38 +#define SCAN_CODE_KEY_M 50 +#define SCAN_CODE_KEY_N 49 +#define SCAN_CODE_KEY_O 24 +#define SCAN_CODE_KEY_P 25 +#define SCAN_CODE_KEY_R 19 +#define SCAN_CODE_KEY_S 31 +#define SCAN_CODE_KEY_T 20 +#define SCAN_CODE_KEY_U 22 +#define SCAN_CODE_KEY_V 47 +#define SCAN_CODE_KEY_X 45 +#define SCAN_CODE_KEY_Y 21 +#define SCAN_CODE_KEY_Z 44 \ No newline at end of file diff --git a/programs/other/table/use_library.h b/programs/other/table/use_library.h index 7060732607..edf7a56e84 100644 --- a/programs/other/table/use_library.h +++ b/programs/other/table/use_library.h @@ -41,6 +41,30 @@ char lib_path[] = "/sys/lib/box_lib.obj"; dword lib_path_addr = (dword)lib_path; dword dummy = 0; +//editbox flags +#define ed_pass 1 +#define ed_focus 2 //focused +#define ed_shift 4 //flag is set when Shift is pressed +#define ed_shift_on 8 +#define ed_shift_bac 16 //bit for Shift reset, if set the smth is selected +#define ed_left_fl 32 +#define ed_offset_fl 64 +#define ed_insert 128 +#define ed_mouse_on 256 +#define ed_mouse_adn_b 280 +#define ed_disabled 2048 +#define ed_always_focus 16384 +#define ed_figure_only 32768 //numbers only +#define ed_shift_cl 65507 +#define ed_shift_mcl 65531 +#define ed_shift_off 65531 +#define ed_shift_on_off 65527 +#define ed_shift_bac_cl 65519 +#define ed_right_fl 65503 +#define ed_offset_cl 65471 +#define ed_insert_cl 65407 +#define ed_mouse_on_off 65279 + struct edit_box{ dword width, left, @@ -61,7 +85,7 @@ dword width, cl_curs_y, shift, shift_old, - ed_height, + height, ed_char_width; };