Notes: pre final version

MouseCfg: optimized version (thans, Lev)
RtfRead: fix hotkeys

git-svn-id: svn://kolibrios.org@7434 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2018-10-04 20:08:44 +00:00
parent e0615bc762
commit 8bd9dd2363
13 changed files with 153 additions and 106 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -1,10 +1,11 @@
// Mouse Configuration Utility ver 1.51 // Mouse Configuration Utility ver 1.6
#ifndef AUTOBUILD #ifndef AUTOBUILD
#include "lang.h--" #include "lang.h--"
#endif #endif
#define MEMSIZE 0x23E80 #define MEMSIZE 4096*11
#include "..\lib\strings.h" #include "..\lib\strings.h"
#include "..\lib\mem.h" #include "..\lib\mem.h"
#include "..\lib\fs.h" #include "..\lib\fs.h"
@ -34,25 +35,18 @@
?define MOUSE_EMULATION "Enable mouse emulation using keyboard NumPad" ?define MOUSE_EMULATION "Enable mouse emulation using keyboard NumPad"
?define MADMOUSE "Through screen sides for pointer" ?define MADMOUSE "Through screen sides for pointer"
#endif #endif
proc_info Form;
block mouse_frame = { 18, 18, NULL, 130 }; :block mouse_frame = { 18, 18, NULL, 130 };
more_less_box pointer_speed = { NULL, 0, 64, POINTER_SPEED }; :more_less_box pointer_speed = { NULL, 0, 64, POINTER_SPEED };
more_less_box acceleration = { NULL, 0, 64, ACCELERATION_TEXT }; :more_less_box acceleration = { NULL, 0, 64, ACCELERATION_TEXT };
more_less_box double_click_delay = { NULL, 0, 999, DOUBLE_CLICK_TEXT, 8 }; :more_less_box double_click_delay = { NULL, 0, 999, DOUBLE_CLICK_TEXT, 8 };
checkbox emulation = { MOUSE_EMULATION, NULL }; :checkbox emulation = { MOUSE_EMULATION, NULL };
checkbox madmouse = { MADMOUSE, NULL }; :checkbox madmouse = { MADMOUSE, NULL };
unsigned char panels_img_data[] = FROM "mouse_image.raw";
raw_image panels_img = { 59, 101, #panels_img_data };
_ini ini = { "/sys/settings/system.ini", "mouse" }; _ini ini = { "/sys/settings/system.ini", "mouse" };
dword click_status;
void main() { void main() {
proc_info Form;
int id; int id;
load_dll(libini, #lib_init,1); load_dll(libini, #lib_init,1);
@ -66,44 +60,36 @@ void main() {
{ {
case evMouse: case evMouse:
mouse.get(); mouse.get();
if (mouse.down) && (click_status==0) && (mouse_frame.hovered()) { IF (mouse_frame.hovered()) DrawMouseImage(mouse.lkm,mouse.pkm,mouse.mkm, mouse.vert);
if (mouse.key&MOUSE_LEFT) click_status = 1; IF (mouse.up) DrawMouseImage(0,0,0,0);
if (mouse.key&MOUSE_RIGHT) click_status = 2;
if (mouse.key&MOUSE_CENTER) click_status = 3;
DrawMouseImage();
}
if (mouse.up) {
click_status=0;
DrawMouseImage();
}
break; break;
case evButton: CASE evButton:
id = GetButtonID(); id = GetButtonID();
if (1 == id) ExitApp(); IF (1 == id) ExitApp();
else if (pointer_speed.click(id)) ApplyCfg(); else IF (pointer_speed.click(id)) ApplyCfg();
else if (acceleration.click(id)) ApplyCfg(); else IF (acceleration.click(id)) ApplyCfg();
else if (double_click_delay.click(id)) ApplyCfg(); else IF (double_click_delay.click(id)) ApplyCfg();
else if (emulation.click(id)) { ELSE IF (emulation.click(id)) {
if (emulation.checked == true) RunProgram("/sys/mousemul", 0); IF (emulation.checked == true) RunProgram("/sys/mousemul", 0);
else KillProcessByName("/sys/mousemul", SINGLE); ELSE KillProcessByName("/sys/mousemul", SINGLE);
break; break;
} }
else if (madmouse.click(id)) { ELSE IF (madmouse.click(id)) {
if (madmouse.checked == true) RunProgram("/sys/madmouse", 0); IF (madmouse.checked == true) RunProgram("/sys/madmouse", 0);
else KillProcessByName("/sys/madmouse", SINGLE); ELSE KillProcessByName("/sys/madmouse", SINGLE);
break; break;
} }
break; break;
case evKey: case evKey:
GetKeys(); GetKeys();
if (key_scancode == SCAN_CODE_ESC) ExitApp(); IF (key_scancode == SCAN_CODE_ESC) ExitApp();
break; break;
case evReDraw: case evReDraw:
system.color.get(); system.color.get();
DefineAndDrawWindow(430, 150, 424, 310+skin_height,0x34,system.color.work,WINDOW_TITLE,0); DefineAndDrawWindow(430, 150, 424, 313+skin_height,0x34,system.color.work,WINDOW_TITLE,0);
GetProcessInfo(#Form, SelfInfo); GetProcessInfo(#Form, SelfInfo);
if (Form.status_window>2) break; if (Form.status_window>2) break;
mouse_frame.w = - mouse_frame.x * 2 + Form.cwidth; mouse_frame.w = - mouse_frame.x * 2 + Form.cwidth;
@ -111,15 +97,37 @@ void main() {
mouse_frame.h, 99+BT_NOFRAME, 0xF0F2F3); //needed to handle mouse_up and refresh mouse image mouse_frame.h, 99+BT_NOFRAME, 0xF0F2F3); //needed to handle mouse_up and refresh mouse image
WriteText(mouse_frame.x + 110, mouse_frame.y + 25, 0x90, 0x2C343C, CHECK_MOUSE_1); WriteText(mouse_frame.x + 110, mouse_frame.y + 25, 0x90, 0x2C343C, CHECK_MOUSE_1);
WriteText(mouse_frame.x + 110, mouse_frame.y + 45, 0x90, 0x2C343C, CHECK_MOUSE_2); WriteText(mouse_frame.x + 110, mouse_frame.y + 45, 0x90, 0x2C343C, CHECK_MOUSE_2);
DrawMouseImage(); DrawMouseImage(0,0,0,0);
DrawControls(); DrawControls();
} }
} }
:byte panels_img_data[] = FROM "mouse_image.raw";
void DrawMouseImage() { #define red 0xff0000
_PutImage(mouse_frame.x+30, mouse_frame.y + 15, panels_img.w, panels_img.h, #define yellow 0xfff600
click_status * panels_img.w * panels_img.h * 3 + panels_img.data); #define white 0xffffff
#define dgrey 0x2d353d
:struct IMG_PAL{ dword back, shad1, mbody, left, right, middle, white; }
pal = { 0xF0F2F3,0xABB0B2, dgrey, white, white, dgrey, white };
void DrawMouseImage(dword l,r,m,v) {
#define IMG_W 59
#define IMG_H 101
IF (l) pal.left = red;
IF (m) pal.middle = red;
IF (r) pal.right = red;
IF (v) pal.middle = yellow;
PutPaletteImage(#panels_img_data,IMG_W,IMG_H,18+30,18+15,8,#pal);
pal.left = pal.right = white;
pal.middle = dgrey;
if (v) {
pause(10);
DrawMouseImage(0,0,0,0);
}
} }
void DrawControls() { void DrawControls() {
@ -153,4 +161,4 @@ void ApplyCfg() {
SetMouseDoubleClickDelay(double_click_delay.value); SetMouseDoubleClickDelay(double_click_delay.value);
} }
stop: stop:

View File

@ -2,7 +2,7 @@
#define CHBOX 12 #define CHBOX 12
#define CHECKBOX_ID 50 #define CHECKBOX_ID 50
unsigned char checkbox[sizeof(file "checkbox.raw")]= FROM "checkbox.raw"; unsigned char checkbox[sizeof(file "img/checkbox.raw")]= FROM "img/checkbox.raw";
#define COL_BG_ACTIVE 0xFFF0A9 #define COL_BG_ACTIVE 0xFFF0A9
#define COL_BG_INACTIVE 0xFFFFFF #define COL_BG_INACTIVE 0xFFFFFF
@ -36,13 +36,13 @@ void NOTE_LINE::Delete()
struct NOTES : llist { struct NOTES : llist {
char txt_path[4096]; char txt_path[4096];
char txt_data[MAX_LINE_CHARS*LINES_COUNT]; char txt_data[MAX_LINE_CHARS*LINES_COUNT];
bool txt_file_exists;
NOTE_LINE lines[LINES_COUNT]; NOTE_LINE lines[LINES_COUNT];
char edit_active; char edit_active;
int OpenTxt(); int OpenTxt();
int SaveTxt(); int SaveTxt();
void DeleteNode();
void DrawList(); void DrawList();
dword DrawLine(int line_n, draw_h); dword DrawLine(int line_n, draw_h);
} notes; } notes;
@ -57,11 +57,13 @@ int NOTES::OpenTxt(dword file_path)
ReadFile(0, 4096, #txt_data, #txt_path); ReadFile(0, 4096, #txt_data, #txt_path);
if (!txt_data) || (strncmp(#txt_data, "notes", 5)!=0) if (!txt_data) || (strncmp(#txt_data, "notes", 5)!=0)
{ {
txt_file_exists = false;
notify("'Notes\nData file does not exists or is not valid' -tE"); notify("'Notes\nData file does not exists or is not valid' -tE");
return 0; return 0;
} }
else else
{ {
txt_file_exists = true;
i+=5; //skip "notes" indefinier i+=5; //skip "notes" indefinier
while (txt_data[i]) while (txt_data[i])
{ {
@ -98,6 +100,7 @@ int NOTES::SaveTxt()
tm = #lines[i].data; tm = #lines[i].data;
strcat(#txt_data, #lines[i].data); strcat(#txt_data, #lines[i].data);
} }
if (!txt_file_exists) CreateFile(0, 0, #txt_path);
WriteFile(0, strlen(#txt_data), #txt_data, #txt_path); WriteFile(0, strlen(#txt_data), #txt_data, #txt_path);
} }

View File

Before

Width:  |  Height:  |  Size: 255 B

After

Width:  |  Height:  |  Size: 255 B

View File

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

BIN
programs/cmm/notes/notes Normal file

Binary file not shown.

View File

@ -1,4 +1,4 @@
// Notes v0.8 ALPHA // Notes v0.9 Beta
#define MEMSIZE 0xDAE80 #define MEMSIZE 0xDAE80
#include "..\lib\kolibri.h" #include "..\lib\kolibri.h"
@ -32,7 +32,7 @@
#define RED_LINE_X 22 #define RED_LINE_X 22
#define COL_RED_LINE 0xF3C9C9 #define COL_RED_LINE 0xF3C9C9
unsigned char edge[sizeof(file "edge.raw")]= FROM "edge.raw"; //292x6 unsigned char edge[sizeof(file "img/edge.raw")]= FROM "img/edge.raw"; //292x6
#define EDGE_H 6 #define EDGE_H 6
#define TITLE_H 24 #define TITLE_H 24
#define HEADER_HEIGHT TITLE_H+EDGE_H #define HEADER_HEIGHT TITLE_H+EDGE_H
@ -47,7 +47,7 @@ unsigned char edge[sizeof(file "edge.raw")]= FROM "edge.raw"; //292x6
#include "engine.h" #include "engine.h"
dword ed_mouse; dword ed_mouse;
edit_box notebox = {0,999,0,COL_BG_ACTIVE,0x94AECE,COL_BG_ACTIVE,0xffffff,0, edit_box notebox = {NULL,NULL,NULL,COL_BG_ACTIVE,0x94AECE,COL_BG_ACTIVE,0xffffff,0,
MAX_LINE_CHARS-1,NULL,#ed_mouse,ed_always_focus+ed_focus}; MAX_LINE_CHARS-1,NULL,#ed_mouse,ed_always_focus+ed_focus};
dword lists[] = { 0xEAEAEA, 0xCDCDCD, 0xF0F0F0, 0xD8D8D8, 0 }; dword lists[] = { 0xEAEAEA, 0xCDCDCD, 0xF0F0F0, 0xD8D8D8, 0 };
@ -63,13 +63,14 @@ block delBtn;
void main() void main()
{ {
int btn; int btn;
bool first_redraw=true;
dword cur_line_offset; dword cur_line_offset;
load_dll(boxlib, #box_lib_init,0); load_dll(boxlib, #box_lib_init,0);
if (param) notes.OpenTxt(#param); else notes.OpenTxt(abspath("notes.txt")); if (param) notes.OpenTxt(#param); else notes.OpenTxt(abspath("notes.txt"));
notes.cur_y = -1; //notes.cur_y = 0;
SetEventMask(0x27); SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
loop() switch(WaitEvent()) loop() switch(WaitEvent())
{ {
@ -90,6 +91,7 @@ void main()
if (mouse.key&MOUSE_LEFT)&&(mouse.up) if (mouse.key&MOUSE_LEFT)&&(mouse.up)
&& (notes.ProcessMouse(mouse.x, mouse.y)) { && (notes.ProcessMouse(mouse.x, mouse.y)) {
notebox.pos = mouse.x - notebox.left / 6;
EventListRedraw(); EventListRedraw();
EventActivateLine(notes.cur_y); EventActivateLine(notes.cur_y);
} }
@ -107,14 +109,21 @@ void main()
EventDeleteCurrentNode(); EventDeleteCurrentNode();
break; break;
default: default:
notes.lines[btn-CHECKBOX_ID].state ^= 1; EventCheckBoxClick(btn-CHECKBOX_ID);
EventListRedraw();
break; break;
} }
break; break;
case evKey: case evKey:
GetKeys(); GetKeys();
if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL)
{
if (key_scancode == SCAN_CODE_SPACE)
{
EventCheckBoxClick(notes.cur_y);
}
break;
}
switch(key_scancode) switch(key_scancode)
{ {
case SCAN_CODE_ESC: case SCAN_CODE_ESC:
@ -137,6 +146,10 @@ void main()
case evReDraw: case evReDraw:
draw_window(); draw_window();
if (first_redraw) {
first_redraw = false;
EventActivateLine(0);
}
} }
} }
@ -172,9 +185,10 @@ void DrawEditBoxN()
{ {
notebox.width = notes.w-notes.x-8; notebox.width = notes.w-notes.x-8;
notebox.left = notes.x+5; notebox.left = notes.x+5;
notebox.pos = notebox.offset = notebox.shift = notebox.shift_old = 0; notebox.offset = notebox.shift = notebox.shift_old = 0;
notebox.cl_curs_x = notebox.cl_curs_y = 0; notebox.cl_curs_x = notebox.cl_curs_y = 0;
notebox.size = strlen(notebox.text); notebox.size = strlen(notebox.text);
if (notebox.pos > notebox.size) notebox.pos = notebox.size;
notebox.top = notes.cur_y*notes.item_h+4+notes.y; notebox.top = notes.cur_y*notes.item_h+4+notes.y;
edit_box_draw stdcall(#notebox); edit_box_draw stdcall(#notebox);
} }
@ -212,7 +226,8 @@ void EventDrawDeleteButton()
void EventDeleteCurrentNode() void EventDeleteCurrentNode()
{ {
notes.lines[notes.cur_y].Delete(); int t = notes.cur_y;
notes.lines[t].Delete();
EventListRedraw(); EventListRedraw();
} }
@ -223,4 +238,10 @@ void EventListRedraw()
notes.DrawList(); notes.DrawList();
} }
void EventCheckBoxClick(int id)
{
notes.lines[id].state ^= 1;
EventListRedraw();
}
stop: stop:

View File

@ -2,15 +2,36 @@
* Template C-- program. * Template C-- program.
*/ */
#define MEMSIZE 4096*5 #define MEMSIZE 4096*10
#include "../lib/kolibri.h" #include "../lib/io.h"
#include "../lib/fs.h" #include "../lib/gui.h"
proc_info Form; proc_info Form;
void main() void main()
{ {
RunProgram("/sys/syspanel", "/sys/settings/games.ini"); word btn;
loop() switch(WaitEvent())
{
case evButton:
btn = GetButtonID();
if (btn == 1) ExitProcess();
break;
case evKey:
GetKeys();
if (key_scancode == SCAN_CODE_ESC) ExitProcess();
break;
case evReDraw:
draw_window();
break;
}
} }
void draw_window()
{
DefineAndDrawWindow(215, 100, 350, 300, 0x34, 0xEEEeee, "Window title",0);
GetProcessInfo(#Form, SelfInfo);
}

View File

@ -154,20 +154,20 @@ _BGIfont_Prepare:
mov dword[.font],edx ; filename mov dword[.font],edx ; filename
mov esi,edi ; esi->FontName mov esi,edi ; esi->FontName
mov [.dest],edi ; ptr to load font mov [.dest],edi ; ptr to load font
mov eax, 70 ; mov eax, 70
mov ebx, .fontattr ; mov ebx, .fontattr
mcall ; mcall
test eax, eax ; test eax, eax
;jnz .fail ; ;jnz .fail
dps2 '1' ; dps2 '1'
mov eax, [.fileattr+32] ; mov eax, [.fileattr+32]
mov [.fsize], litt_end-litt_file ;mov [.fsize], litt_end-litt_file
mov ebx,.fontinfo ;mov ebx,.fontinfo
mov eax,70 ;mov eax,70
mcall ; ebx - file size ;mcall ; ebx - file size
;mov ebx, litt_end-litt_file mov ebx, litt_end-litt_file
;mov edi, litt_file mov edi, litt_file
;mov [.dest],litt_file ; ptr to load font mov [.dest],litt_file ; ptr to load font
cmp dword[edi],0x08084b50 ; 'PK',8,8 cmp dword[edi],0x08084b50 ; 'PK',8,8
jne .fail jne .fail

View File

@ -163,8 +163,8 @@ key: ;
mov dh,ah mov dh,ah
jmp key jmp key
.next: ;]Leency .next:
cmp ah,104 ; HELP cmp ah,'h' ; H - help
jne .nohelp jne .nohelp
.help: .help:
mov [is_scroll_bar_needed], 0 mov [is_scroll_bar_needed], 0
@ -192,15 +192,15 @@ key: ;
; je still ; je still
; jmp prep_load ; jmp prep_load
.nohelp2: .nohelp2:
cmp ah,114 ; R - redraw cmp ah,'r' ; R - redraw
je red je red
cmp ah,99 ; C - color cmp ah,'c' ; C - color
jne .nocolor jne .nocolor
.color: .color:
xor [mode],RTF_COLORLESS xor [mode],RTF_COLORLESS
jmp red jmp red
.nocolor: .nocolor:
cmp ah,97 ; A - alignment cmp ah,'a' ; A - alignment
jne .noalign jne .noalign
.alignment: .alignment:
xor [mode],RTF_ALIGNLESS xor [mode],RTF_ALIGNLESS
@ -212,12 +212,30 @@ key: ;
dec [pitch] dec [pitch]
jmp red jmp red
.nopd: .nopd:
cmp ah,46 ; < - pitch inc cmp ah,46 ; > - pitch inc
jne .nopi jne .nopi
.incp: .incp:
inc [pitch] inc [pitch]
jmp red jmp red
.nopi: .nopi:
cmp ah,43 ;zoom+
je .zplus
cmp ah,61 ;zoom=
jne .noplus
.zplus:
fld [FreeFontscale]
fmul [Zoomscale]
.zoom:
fstp [FreeFontscale]
jmp red
.noplus:
cmp ah,45 ;zoom-
jne .home
.zminus:
fld [FreeFontscale]
fdiv [Zoomscale]
jmp .zoom
.home:
cmp ah,180 ; Home cmp ah,180 ; Home
je top_red je top_red
@ -307,21 +325,7 @@ key: ;
; je still ; je still
jmp red jmp red
.noarup: .noarup:
cmp ah,56 ;zoom+
jne .noplus
.zplus:
fld [FreeFontscale]
fmul [Zoomscale]
.zoom:
fstp [FreeFontscale]
jmp red
.noplus:
cmp ah,54 ;zoom-
jne .nominus
.zminus:
fld [FreeFontscale]
fdiv [Zoomscale]
jmp .zoom
.nominus: .nominus:
cmp ah,0xB5 ; end cmp ah,0xB5 ; end
jne .pre_file_open jne .pre_file_open
@ -336,7 +340,7 @@ key: ;
call Set_position call Set_position
jmp red jmp red
.pre_file_open: .pre_file_open:
cmp ah,108 ; L - load cmp ah,'l' ; L - load
jne still jne still
.file_open: .file_open:
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
@ -351,16 +355,6 @@ key: ;
cmp [OpenDialog_data.status],1 cmp [OpenDialog_data.status],1
je prep_load je prep_load
jmp still jmp still
;---------------------------------------------------------------------
;.sysxtree:
; or [mode],RTF_OPENING
; opendialog draw_window, prep_load, st_1, fname_buf
; st_1:
; and [mode],not RTF_OPENING
; jmp still;red
; stilld:
; jmp still
;---------------------------------------------------------------------
button: button:
mcall 17 ; 17 - ¯®«ãç¨âì ¨¤¥­â¨ä¨ª â®à ­ ¦ â®© ª­®¯ª¨ mcall 17 ; 17 - ¯®«ãç¨âì ¨¤¥­â¨ä¨ª â®à ­ ¦ â®© ª­®¯ª¨
@ -744,7 +738,7 @@ end if
; ¨­â¥àä¥©á ¯à®£à ¬¬ë ¬­®£®ï§ëç­ë© ; ¨­â¥àä¥©á ¯à®£à ¬¬ë ¬­®£®ï§ëç­ë©
; ‚ë ¬®¦¥â¥ § ¤ âì ï§ëª ¢ MACROS.INC (lang fix ï§ëª) ; ‚ë ¬®¦¥â¥ § ¤ âì ï§ëª ¢ MACROS.INC (lang fix ï§ëª)
window_title: db 'RtfRead v1.4',0 window_title: db 'RtfRead v1.5',0
is_scroll_bar_needed dd 0x0 is_scroll_bar_needed dd 0x0
window_width dd 0x0 window_width dd 0x0
window_height dd 0x0 window_height dd 0x0