boxlib edit_box: do not display pgup, pgdown press

fptc: fix for Tab press when no field selected
table 0.99: proper behaviour when cell is edited, use scancodes

git-svn-id: svn://kolibrios.org@7507 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2018-10-29 18:16:01 +00:00
parent ad662d3962
commit 8a77c84962
9 changed files with 330 additions and 257 deletions

View File

@ -85,10 +85,10 @@ void Main_Window()
case evKey: case evKey:
GetKeys(); GetKeys();
// PROCESS KEYS WHEN EDIT BOX INACTIVE // 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: 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); edit_box_draw stdcall (#edit_disk_size);
DrawTmpDisks(); DrawTmpDisks();
break; break;
@ -126,7 +126,7 @@ void Main_Window()
else switch(key_scancode) else switch(key_scancode)
{ {
case SCAN_CODE_TAB: case SCAN_CODE_TAB:
edit_disk_size.flags=1000000000000000b; edit_disk_size.flags = ed_figure_only;
edit_box_draw stdcall (#edit_disk_size); edit_box_draw stdcall (#edit_disk_size);
DrawTmpDisks(); DrawTmpDisks();
break; break;

View File

@ -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 if up eq
else else
@ -40,6 +40,16 @@ else
cmp ah,1 ;Scroll Lock - ª« ¢¨è  )) cmp ah,1 ;Scroll Lock - ª« ¢¨è  ))
jz edit_box.editbox_exit jz edit_box.editbox_exit
end if 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 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
;--- ­ ¦ â  ¤àã£ ï ª« ¢¨è  --- ;--- ­ ¦ â  ¤àã£ ï ª« ¢¨è  ---
;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;<3B>஢¥àª  ãáâ ­®¢«¥­ «¨ ä« £ ¯à¨ ª®â®à®¬ ­ã¦­® ¢ë¢®¤¨âì ⮫쪮 æ¨äàë ¢ ­ã¦­®¬ ¡®ªá¥, ¥á«¨ â ª®© ­¥®¡å®¤¨¬®á⨠­¥â, ­ã¦­® § ª®¬¥­â¨à®¢ âì ¬ ªà®á ;<3B>஢¥àª  ãáâ ­®¢«¥­ «¨ ä« £ ¯à¨ ª®â®à®¬ ­ã¦­® ¢ë¢®¤¨âì ⮫쪮 æ¨äàë ¢ ­ã¦­®¬ ¡®ªá¥
;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
test word ed_flags,ed_figure_only ; ⮫쪮 æ¨äàë? test word ed_flags,ed_figure_only ; ⮫쪮 æ¨äàë?
jz @f jz @f
@ -241,7 +251,7 @@ edit_box_key.In_k:
jmp edit_box_key.shift jmp edit_box_key.shift
;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Ž¡à ¡®âª  ª« ¢¨è insert,delete.backspace,home,end,left,right ;Ž¡à ¡®âª  ª« ¢¨è insert,delete,backspace,home,end,left,right
;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
edit_box_key.insert: edit_box_key.insert:
test word ed_flags,ed_insert test word ed_flags,ed_insert

View File

@ -1,4 +1,2 @@
if not exist bin mkdir bin @fasm.exe -m 16384 box_lib.asm box_lib.obj
@fasm.exe -m 16384 box_lib.asm bin\box_lib.obj
@kpack bin\box_lib.obj
pause pause

View File

@ -750,7 +750,7 @@ exit2:
; data ; data
str_title db 'FTP client for KolibriOS',0 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 db 10,0
str_srv_addr db 'Please enter ftp server address.',10,0 str_srv_addr db 'Please enter ftp server address.',10,0

View File

@ -166,7 +166,9 @@ login_gui: ;////////////////////////////////////////////////////////////////////
je @f je @f
sub word [edit_path.flags],ed_focus sub word [edit_path.flags],ed_focus
add word [edit_usr.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: .tab_end:
call .draw_editboxes call .draw_editboxes

View File

@ -6,7 +6,7 @@
#include "calc.h" #include "calc.h"
#include "use_library.h" #include "use_library.h"
#define TABLE_VERSION "0.98.9" #define TABLE_VERSION "0.99"
// strings // strings
const char *sFileSign = "KolibriTable File\n"; 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}; 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; DWORD *cell_w, *cell_h;
char ***cells; char ***cells;
@ -101,8 +101,6 @@ bool sel_end_move = 0;
DWORD nx = 0, ny = 0; DWORD nx = 0, ny = 0;
// флаг реадктирования ячейки // флаг реадктирования ячейки
//bool is_edit = 0;
#define ed_focus 2
#define is_edit (cell_box.flags & ed_focus) #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 drag_x, drag_y;
int old_end_x, old_end_y; int old_end_x, old_end_y;
void draw_window();
void draw_grid(); void draw_grid();
void DrawSelectedFrame(int x, int y, int w, int h, DWORD col) 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) if (ch)
{ {
sel_moved = 1; sel_moved = 1;
draw_window(); draw_grid();
} }
file_box.flags &= ~ed_focus; file_box.flags &= ~ed_focus;
cell_box.flags |= ed_focus; cell_box.flags = ed_focus;
cell_box.left = cell_x[x] + 1; cell_box.left = cell_x[x] + 1;
cell_box.top = cell_y[y]; cell_box.top = cell_y[y];
cell_box.width = cell_w[x] - 2; cell_box.width = cell_w[x] - 2;
@ -186,12 +183,12 @@ void start_edit(int x, int y)
if (cells[x][y]) if (cells[x][y])
{ {
strcpy(edit_text, 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.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() void stop_edit()
@ -219,7 +216,7 @@ void cancel_edit()
return; return;
cell_box.flags &= ~ed_focus; cell_box.flags &= ~ed_focus;
memset((Byte*)edit_text,0, 256); memset((Byte*)edit_text,0, 256);
draw_window(); draw_grid();
} }
void check_sel() 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); DrawCell(x+1, y+1, cell_w[j]-1, cell_h[i]-1, 0, bg_color, text, false);
if (draw_frame_selection) { if (draw_frame_selection && j<nx-1 && i<ny-1) {
DrawSelectedFrame(x+1,y, cell_w[j]-1, cell_h[i], TEXT_COLOR); DrawSelectedFrame(x+1,y, cell_w[j]-1, cell_h[i]+1, TEXT_COLOR);
} }
else if (error) kos_DrawRegion(x+1, y+1, cell_w[j]-1, cell_h[i]-1, 0xff0000, 0); else if (error) kos_DrawRegion(x+1, y+1, cell_w[j]-1, cell_h[i]-1, 0xff0000, 0);
} }
@ -523,7 +520,7 @@ void draw_drag()
kos_DrawLine(x0, y1, x1, y1, DCOLOR, DINVERT); kos_DrawLine(x0, y1, x1, y1, DCOLOR, DINVERT);
} }
bool draw_and_define_window() void draw_window()
{ {
kos_WindowRedrawStatus(1); kos_WindowRedrawStatus(1);
kos_DefineAndDrawWindow(110,40,WND_W,WND_H,0x73,0x40FFFFFF,0,0,(Dword)"Table v" TABLE_VERSION); kos_DefineAndDrawWindow(110,40,WND_W,WND_H,0x73,0x40FFFFFF,0,0,(Dword)"Table v" TABLE_VERSION);
@ -541,51 +538,36 @@ bool draw_and_define_window()
grid.w = cWidth - SCROLL_SIZE - 1; grid.w = cWidth - SCROLL_SIZE - 1;
grid.h = cHeight - MENU_PANEL_HEIGHT - SCROLL_SIZE; grid.h = cHeight - MENU_PANEL_HEIGHT - SCROLL_SIZE;
if (info.processInfo.status_window&0x04) return false; //draw nothing if window is rolled-up if (info.processInfo.status_window&0x04) return; //draw nothing if window is rolled-up
if (cWidth < 430) { kos_ChangeWindow( -1, -1, 450, -1 ); return false; } if (cWidth < 430) { kos_ChangeWindow( -1, -1, 450, -1 ); return; }
if (cHeight < 250) { kos_ChangeWindow( -1, -1, -1, 300 ); return false; } if (cHeight < 250) { kos_ChangeWindow( -1, -1, -1, 300 ); return; }
sel_moved = 0; sel_moved = 0;
if (is_edit) stop_edit();
return true;
}
void draw_window()
{
int panel_y = cHeight - MENU_PANEL_HEIGHT + 1; int panel_y = cHeight - MENU_PANEL_HEIGHT + 1;
kos_DrawBar(0, panel_y, cWidth, MENU_PANEL_HEIGHT-1, sc.work); kos_DrawBar(0, panel_y, cWidth, MENU_PANEL_HEIGHT-1, sc.work);
kos_WriteTextToWindow(3 + 1, panel_y + 14, 0x90, sc.work_text, (char*)sFilename, 0); kos_WriteTextToWindow(3 + 1, panel_y + 14, 0x90, sc.work_text, (char*)sFilename, 0);
file_box.top = panel_y + 10; file_box.top = panel_y + 10;
#define BTX 230 #define BTX 230
#define BTW 70 #define BTW 70
//save //save
kos_DefineButton(BTX + 25, file_box.top, BTW, 21, SAVE_BUTTON, sc.work); kos_DefineButton(BTX + 25, file_box.top, BTW, 21, SAVE_BUTTON, sc.work);
kos_WriteTextToWindow(BTX + 25 + (BTW - strlen(sSave) * 8) / 2, panel_y + 14, 0x90, sc.work_text, (char*)sSave, 0); kos_WriteTextToWindow(BTX + 25 + (BTW - strlen(sSave) * 8) / 2, panel_y + 14, 0x90, sc.work_text, (char*)sSave, 0);
//load //load
kos_DefineButton(BTX + 25+BTW+5, file_box.top, BTW, 21, LOAD_BUTTON, sc.work); kos_DefineButton(BTX + 25+BTW+5, file_box.top, BTW, 21, LOAD_BUTTON, sc.work);
kos_WriteTextToWindow(BTX + 25+BTW+5 + (BTW - strlen(sLoad) * 8) / 2, panel_y + 14, 0x90, sc.work_text, (char*)sLoad, 0); kos_WriteTextToWindow(BTX + 25+BTW+5 + (BTW - strlen(sLoad) * 8) / 2, panel_y + 14, 0x90, sc.work_text, (char*)sLoad, 0);
// // new (clean)
//new (clean) // kos_DefineButton(90 + 160 + 70, panel_y + 9, 60, 20, NEW_BUTTON, sc.work);
/* // kos_WriteTextToWindow(92 + 160 + 10 + 70, panel_y + 16, 0, sc.work_text, (char*)sNew, strlen(sNew));
kos_DefineButton(90 + 160 + 70, panel_y + 9, 60, 20, NEW_BUTTON, sc.work);
kos_WriteTextToWindow(92 + 160 + 10 + 70, panel_y + 16, 0, sc.work_text, (char*)sNew, strlen(sNew));
*/
if ((void*)edit_box_draw != NULL)
{
if (is_edit)
edit_box_draw((DWORD)&cell_box);
edit_box_draw((DWORD)&file_box);
}
if (sel_end_move) sel_moved = 0; if (sel_end_move) sel_moved = 0;
draw_grid(); draw_grid();
sel_moved = 0; sel_moved = 0;
if (is_edit) edit_box_draw((DWORD)&cell_box);
edit_box_draw((DWORD)&file_box);
} }
void process_mouse() void process_mouse()
@ -609,6 +591,7 @@ void process_mouse()
if (!scroll_h.delta2) scrollbar_v_mouse((DWORD)&scroll_v); if (!scroll_h.delta2) scrollbar_v_mouse((DWORD)&scroll_v);
if (scroll_v.position != grid.firsty-1) if (scroll_v.position != grid.firsty-1)
{ {
stop_edit();
grid.firsty = scroll_v.position + 1; grid.firsty = scroll_v.position + 1;
draw_grid(); draw_grid();
} }
@ -616,13 +599,14 @@ void process_mouse()
if (!scroll_v.delta2) scrollbar_h_mouse((DWORD)&scroll_h); if (!scroll_v.delta2) scrollbar_h_mouse((DWORD)&scroll_h);
if (scroll_h.position != grid.firstx-1) if (scroll_h.position != grid.firstx-1)
{ {
stop_edit();
grid.firstx = scroll_h.position + 1; grid.firstx = scroll_h.position + 1;
draw_grid(); draw_grid();
} }
} }
if (scroll_v.delta2 || scroll_h.delta2) return; if (scroll_v.delta2 || scroll_h.delta2) return;
edit_box_mouse((dword)&cell_box); if (is_edit) edit_box_mouse((dword)&cell_box);
edit_box_mouse((dword)&file_box); edit_box_mouse((dword)&file_box);
int mouse_x, mouse_y, i; int mouse_x, mouse_y, i;
@ -630,6 +614,9 @@ void process_mouse()
mouse_x -= 5; mouse_x -= 5;
mouse_y -= kos_GetSkinHeight(); mouse_y -= kos_GetSkinHeight();
if (is_edit && mouse_x>=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; mouse_btn &= 0x0001;
if (mouse_btn) if (mouse_btn)
@ -799,200 +786,9 @@ void process_mouse()
size_mouse_y = mouse_y; 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 (dx != 0)
{ {
if (shift) 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() void process_button()
{ {
Dword button; Dword button;
@ -1134,7 +1120,7 @@ void kos_Main()
break; break;
case EM_WINDOW_REDRAW: case EM_WINDOW_REDRAW:
if (draw_and_define_window()) draw_window(); draw_window();
break; break;
} }
} }

View File

@ -484,25 +484,20 @@ void kos_PutPixel( Dword x, Dword y, Dword colour )
} }
} }
bool kos_GetKeys( Dword &key_editbox, Byte &key_ascii, Byte &key_scancode )
// function 2 ïîëó÷èòü êîä íàæàòîé êëàâèøè
bool kos_GetKey( Byte &keyCode )
{ {
Dword result; Dword result;
//
__asm{ __asm{
mov eax, 2 mov eax, 2
int 0x40 int 0x40
mov result, eax mov result, eax
} }
// key_editbox = result;
keyCode = result >> 8; key_ascii = result >> 8;
// key_scancode = result >> 16;
return ( result & 0xFF ) == 0; return ( key_ascii ) == 0;
} }
// function 3 ïîëó÷èòü âðåìÿ // function 3 ïîëó÷èòü âðåìÿ
Dword kos_GetSystemClock() Dword kos_GetSystemClock()
{ {

View File

@ -187,6 +187,7 @@ void kos_DefineAndDrawWindow(
void kos_PutPixel( Dword x, Dword y, Dword colour ); void kos_PutPixel( Dword x, Dword y, Dword colour );
// function 2 ïîëó÷èòü êîä íàæàòîé êëàâèøè // function 2 ïîëó÷èòü êîä íàæàòîé êëàâèøè
bool kos_GetKey( Byte &keyCode ); bool kos_GetKey( Byte &keyCode );
bool kos_GetKeys( Dword &key_editbox, Byte &key_ascii, Byte &key_scancode );
// function 3 ïîëó÷èòü âðåìÿ // function 3 ïîëó÷èòü âðåìÿ
Dword kos_GetSystemClock(); Dword kos_GetSystemClock();
// function 4 // function 4
@ -264,3 +265,60 @@ Dword kos_FileSystemAccess( kosFileInfo *fileInfo );
int kos_AppRun(char* app_path, char* param); int kos_AppRun(char* app_path, char* param);
// //
void kos_Main(); 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

View File

@ -41,6 +41,30 @@ char lib_path[] = "/sys/lib/box_lib.obj";
dword lib_path_addr = (dword)lib_path; dword lib_path_addr = (dword)lib_path;
dword dummy = 0; 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{ struct edit_box{
dword width, dword width,
left, left,
@ -61,7 +85,7 @@ dword width,
cl_curs_y, cl_curs_y,
shift, shift,
shift_old, shift_old,
ed_height, height,
ed_char_width; ed_char_width;
}; };