add edit_box.

git-svn-id: svn://kolibrios.org@1205 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Alexey Teplov ( 2009-10-12 10:51:22 +00:00
parent 8aad28db2a
commit 78ba1dbcaa

View File

@ -3,12 +3,15 @@
; ;
; VTurjanmaa ; VTurjanmaa
; additions by M.Lisovin lisovin@26.ru ; additions by M.Lisovin lisovin@26.ru
; integrated with load_lib.obj by <Lrz>
; Compile with FASM for Menuet ; Compile with FASM for Menuet
; ;
use32 use32
org 0x0 org 0x0
STACK_SIZE=1024 STACK_SIZE=1024
offset_y=22
offset_x=5
db 'MENUET01' ; 8 byte id db 'MENUET01' ; 8 byte id
dd 0x01 ; header version dd 0x01 ; header version
dd START ; start of code dd START ; start of code
@ -19,9 +22,17 @@ STACK_SIZE=1024
include 'lang.inc' include 'lang.inc'
include '..\..\..\macros.inc' include '..\..\..\macros.inc'
include '..\..\..\develop\libraries\box_lib\asm\trunk\editbox_ex.mac'
include '..\..\..\develop\libraries\box_lib\load_lib.mac'
display_processes=32 ; number of processes to show display_processes=32 ; number of processes to show
@use_library ;use load lib macros
align 4 align 4
START: ; start of execution START: ; start of execution
sys_load_library library_name, cur_dir_path, library_path, system_path, \
err_message_found_lib, head_f_l, myimport, err_message_import, head_f_i
inc eax
jz close
; calculate window position ; calculate window position
; at the center of the screen ; at the center of the screen
call calculate_window_pos call calculate_window_pos
@ -36,7 +47,7 @@ red:
align 4 align 4
still: still:
mov eax,23 ; wait here for event mov eax,23 ; wait here for event
mov ebx,200 ; 2 sec. mov ebx,100 ; 2 sec.
mcall mcall
dec eax ; redraw request ? dec eax ; redraw request ?
@ -45,6 +56,10 @@ still:
jz key jz key
dec eax ; button in buffer ? dec eax ; button in buffer ?
jz button jz button
push dword edit1
call [edit_box_mouse]
align 4 align 4
still_end: still_end:
xor ebp,ebp ; draw new state of processes xor ebp,ebp ; draw new state of processes
@ -55,12 +70,17 @@ align 4
key: ; key key: ; key
mov eax,2 mov eax,2
mcall mcall
cmp ah,184 ; PageUp cmp ah,184 ; PageUp
je pgdn je pgdn
cmp ah,183 cmp ah,183
je pgup ; PageDown je pgup ; PageDown
cmp ah,27 cmp ah,27
je close ; Esc je close ; Esc
push dword edit1
call [edit_box_key]
jmp still_end jmp still_end
align 4 align 4
button: button:
@ -101,8 +121,8 @@ align 4
dec eax dec eax
jz pgup jz pgup
dec eax dec eax
jz read_string ; jz read_string
dec eax ; dec eax
jz program_start jz program_start
dec eax dec eax
jz reboot jz reboot
@ -158,7 +178,7 @@ align 4
.nodelete: .nodelete:
;create terminate process button ;create terminate process button
mov eax,8 mov eax,8
mov ebx,15*65536+100 mov ebx,(15-offset_x)*65536+100-offset_y
mov ecx,[curposy] mov ecx,[curposy]
shl ecx,16 shl ecx,16
mov cx,10 mov cx,10
@ -175,7 +195,7 @@ align 4
;draw background for proccess information ;draw background for proccess information
mov eax,13 mov eax,13
mov ebx,115*65536+395 mov ebx,(115-offset_x)*65536+395
;ecx was already set ;ecx was already set
mov edx,0x88ff88 mov edx,0x88ff88
;contrast ;contrast
@ -222,7 +242,7 @@ align 4
jmp .find_loop jmp .find_loop
align 4 align 4
.no_processes: .no_processes:
mov edi,-1 or edi,-1
ret ret
align 4 align 4
.process_found: .process_found:
@ -275,14 +295,14 @@ align 4
;ecx haven't changed since .process_found ;ecx haven't changed since .process_found
; mov ecx,edi ; mov ecx,edi
mov edx,[curposy] mov edx,[curposy]
add edx,20*65536+1 add edx,(20-offset_x)*65536+1
mov esi,[tcolor] mov esi,[tcolor]
mcall mcall
;show process name ;show process name
mov eax,4 mov eax,4
mov ebx,[curposy] mov ebx,[curposy]
add ebx,50*65536+1 add ebx,(50-offset_x)*65536+1
mov ecx,[tcolor] mov ecx,[tcolor]
mov edx,process_info_buffer.process_name mov edx,process_info_buffer.process_name
mov esi,11 mov esi,11
@ -293,7 +313,7 @@ align 4
mov ebx,8*65536+1*256 mov ebx,8*65536+1*256
mov ecx,[process_info_buffer.PID] mov ecx,[process_info_buffer.PID]
mov edx,[curposy] mov edx,[curposy]
add edx,130*65536+1 add edx,(130-offset_x)*65536+1
mov esi,[tcolor] mov esi,[tcolor]
mcall mcall
@ -338,114 +358,115 @@ align 4
mov [tasklist+4*eax],edi mov [tasklist+4*eax],edi
ret ret
align 4 align 4
read_string: ;read_string:
;clean string ;clean string
mov edi,start_application ; mov edi,start_application
xor eax,eax ; xor eax,eax
mov ecx,60 ; mov ecx,60
cld ; cld
rep stosb ; rep stosb
call print_text ; call print_text
mov edi,start_application ; mov edi,start_application
;edi now contains pointer to last symbol ;edi now contains pointer to last symbol
jmp still1 ; jmp still1
;read string main loop ;read string main loop
align 4 align 4
f11: f11:
;full update ;full update
push edi push edi
mov ebp,1 xor ebp,ebp
inc ebp
; mov ebp,1
call draw_window call draw_window
pop edi pop edi
align 4 ;align 4
still1: ; still1:
;wait for message ;wait for message
mov eax,23 ; mov eax,23
mov ebx,100 ; mov ebx,100
mcall ; mcall
cmp eax,1 ; cmp eax,1
je f11 ; je f11
;if no message - update process information ;if no message - update process information
cmp eax,0 ; cmp eax,0
jnz .message_received ; jnz .message_received
push edi ;edi should be saved since draw_window ; push edi ;edi should be saved since draw_window
xor ebp,ebp ;corrupt registers ; xor ebp,ebp ;corrupt registers
call draw_window ; call draw_window
pop edi ; pop edi
jmp still1 ; jmp still1
align 4 ;align 4
.message_received: ;.message_received:
cmp eax,2 ; cmp eax,2
jne read_done ;buttons message ; jne read_done ;buttons message
;read char ;read char
mov eax,2 ; mov eax,2
mcall ; mcall
shr eax,8 ; shr eax,8
;if enter pressed, exit read string loop ;if enter pressed, exit read string loop
cmp eax,13 ; cmp eax,13
je read_done ; je read_done
;if backslash pressed? ;if backslash pressed?
cmp eax,8 ; cmp eax,8
jnz nobsl ; jnz nobsl
;decrease pointer to last symbol ;decrease pointer to last symbol
cmp edi,start_application ; cmp edi,start_application
jz still1 ; jz still1
dec edi ; dec edi
;fill last symbol with space because ;fill last symbol with space because
;print_text show all symbols ;print_text show all symbols
mov [edi],byte 32 ; mov [edi],byte 32
call print_text ; call print_text
jmp still1 ; jmp still1
align 4 ;align 4
nobsl: ; nobsl:
;write new symbol ;write new symbol
mov [edi],al ; mov [edi],al
;display new text ;display new text
call print_text ; call print_text
;increment pointer to last symbol ;increment pointer to last symbol
inc edi ; inc edi
;compare with end of string ;compare with end of string
mov esi,start_application ; mov esi,start_application
add esi,60 ; add esi,60
cmp esi,edi ; cmp esi,edi
jnz still1 ; jnz still1
;exiting from read string loop ;exiting from read string loop
align 4 ;align 4
read_done: ; read_done:
;terminate string for file functions ;terminate string for file functions
mov [edi],byte 0 ; mov [edi],byte 0
call print_text ; call print_text
jmp still ; jmp still
align 4 ;align 4
print_text: ;print_text:
;display start_application string ;display start_application string
pushad ; pushad
;display text background ;display text background
mov eax,13 ; mov eax,13
mov ebx,64*65536+62*6 ; mov ebx,64*65536+62*6
mov ecx,400*65536+12 ; mov ecx,400*65536+12
mov edx,0xffffcc ;0xeeeeee ; mov edx,0xffffcc ;0xeeeeee
mcall ; mcall
;display text ;display text
mov eax,4 ; mov eax,4
mov edx,start_application ;from start_application string ; mov edx,start_application ;from start_application string
mov ebx,70*65536+402 ;text center-aligned ; mov ebx,70*65536+402 ;text center-aligned
xor ecx,ecx ;black text ; xor ecx,ecx ;black text
mov esi,60 ;60 symbols ; mov esi,60 ;60 symbols
mcall ; mcall
popad ; popad
ret ; ret
window_x_size=524 window_x_size=524
window_y_size=430 window_y_size=430
@ -500,23 +521,27 @@ draw_window:
xor eax,eax ; function 0 : define and draw window xor eax,eax ; function 0 : define and draw window
mov ebx,[winxpos] ; [x start] *65536 + [x size] mov ebx,[winxpos] ; [x start] *65536 + [x size]
mov ecx,[winypos] ; [y start] *65536 + [y size] mov ecx,[winypos] ; [y start] *65536 + [y size]
mov edx,0x14ddffdd ;ffffff ; color of work area RRGGBB,8->color mov edx,0x34ddffdd ;ffffff ; color of work area RRGGBB,8->color
mov edi,title ; WINDOW CAPTION; mov edi,title ; WINDOW CAPTION;
mcall mcall
mov eax,4 ; function 4 : write text to window add eax,4 ; function 4 : write text to window
mov ebx,22*65536+35 ; draw info text with function 4 mov ebx,(22-offset_x)*65536+35-offset_y ; draw info text with function 4
xor ecx,ecx xor ecx,ecx
mov edx,text mov edx,text
mov esi,text_len mov esi,text_len
mcall mcall
push dword edit1
call [edit_box_draw]
align 4 align 4
.show_process_info: .show_process_info:
mov edi,[list_start] mov edi,[list_start]
mov [list_add],edi mov [list_add],edi
mov dword [index],0 mov dword [index],0
mov dword [curposy],54 mov dword [curposy],54-offset_y
align 4 align 4
.loop_draw: .loop_draw:
call draw_next_process call draw_next_process
@ -531,24 +556,24 @@ align 4
mov esi,0xaabbcc mov esi,0xaabbcc
; previous page button ; previous page button
mov ebx,30*65536+96 mov ebx,(30-offset_x)*65536+96
mov ecx,380*65536+10 mov ecx,(380-offset_y)*65536+10
mov edx,51 mov edx,51
mcall mcall
; next page button ; next page button
mov ebx,130*65536+96 mov ebx,(130-offset_x)*65536+96
inc edx inc edx
mcall mcall
; ">" (text enter) button ; ">" (text enter) button
mov ebx,30*65536+20 ; mov ebx,30*65536+20
add ecx,20 shl 16 add ecx,20 shl 16
inc edx ; inc edx
mcall ; mcall
; run button ; run button
mov ebx,456*65536+50 mov ebx,(456-offset_x)*65536+50
inc edx inc edx
mcall mcall
@ -561,30 +586,30 @@ align 4
;"PREV PAGE", "NEXT PAGE" and "REBOOT" labels ;"PREV PAGE", "NEXT PAGE" and "REBOOT" labels
mov eax,4 mov eax,4
mov ebx,50*65536+382 mov ebx,(50-offset_x)*65536+382-offset_y
xor ecx,ecx xor ecx,ecx
mov edx,tbts mov edx,tbts
mov esi,tbte-tbts mov esi,tbte-tbts
mcall mcall
;">" labels ;">" labels
mov eax,4 ; mov eax,4
mov ebx,40*65536+402 ; mov ebx,40*65536+402
xor ecx,ecx ; xor ecx,ecx
mov edx,tbts_2 ; mov edx,tbts_2
mov esi,1 ; mov esi,1
mcall ; mcall
;"RUN" labels ;"RUN" labels
mov eax,4 ; mov eax,4
mov ebx,475*65536+402 mov ebx,(475-offset_x)*65536+402-offset_y
xor ecx,ecx xor ecx,ecx
mov edx,tbts_3 mov edx,tbts_3
mov esi,tbte_2-tbts_3 mov esi,tbte_2-tbts_3
mcall mcall
;print application name in text box ;print application name in text box
call print_text ; call print_text
mov eax,12 ; function 12:tell os about windowdraw mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw mov ebx,2 ; 2, end of draw
@ -595,14 +620,52 @@ align 4
; DATA AREA ; DATA AREA
system_path db '/sys/lib/'
library_name db 'box_lib.obj',0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
err_message_found_lib db 'Sorry I cannot load library box_lib.obj',0
head_f_i:
head_f_l db 'System error',0
err_message_import db 'Error on load import library box_lib.obj',0
myimport:
edit_box_draw dd aEdit_box_draw
edit_box_key dd aEdit_box_key
edit_box_mouse dd aEdit_box_mouse
;version_ed dd aVersion_ed
;check_box_draw dd aCheck_box_draw
;check_box_mouse dd aCheck_box_mouse
;version_ch dd aVersion_ch
;option_box_draw dd aOption_box_draw
;option_box_mouse dd aOption_box_mouse
;version_op dd aVersion_op
dd 0
dd 0
aEdit_box_draw db 'edit_box',0
aEdit_box_key db 'edit_box_key',0
aEdit_box_mouse db 'edit_box_mouse',0
;aVersion_ed db 'version_ed',0
;aCheck_box_draw db 'check_box_draw',0
;aCheck_box_mouse db 'check_box_mouse',0
;aVersion_ch db 'version_ch',0
;aOption_box_draw db 'option_box_draw',0
;aOption_box_mouse db 'option_box_mouse',0
;aVersion_op db 'version_op',0
edit1 edit_box 350,(64-offset_x),(398-offset_y),0xffffff,0x6f9480,0,0xAABBCC,0,start_application_c,start_application,ed_focus,start_application_e,start_application_e
list_start dd 0 list_start dd 0
file_start: dd 7 file_start: dd 7
dd 0,0,0,0 dd 0,0,0,0
start_application: db '/sys/LAUNCHER',0
times 60 db 32
sys_reboot: sys_reboot:
dd 7 dd 7
dd 0 dd 0
@ -619,7 +682,7 @@ text_len = $-text
tbts: db 'SEITE ZURUECK SEITE VOR REBOOT SYSTEM' tbts: db 'SEITE ZURUECK SEITE VOR REBOOT SYSTEM'
tbte: tbte:
tbts_2 db '>' ;tbts_2 db '>'
tbts_3 db 'START' tbts_3 db 'START'
tbte_2: tbte_2:
@ -633,7 +696,7 @@ text_len = $-text
tbts: db 'EELMINE LEHT JÄRGMINE LEHT REBOODI SÜSTEEM' tbts: db 'EELMINE LEHT JÄRGMINE LEHT REBOODI SÜSTEEM'
tbte: tbte:
tbts_2 db '>' ;tbts_2 db '>'
tbts_3 db 'START' tbts_3 db 'START'
tbte_2: tbte_2:
@ -647,16 +710,20 @@ text_len = $-text
tbts: db 'PREV PAGE NEXT PAGE REBOOT SYSTEM' tbts: db 'PREV PAGE NEXT PAGE REBOOT SYSTEM'
tbte: tbte:
tbts_2 db '>' ;tbts_2 db '>'
tbts_3 db 'RUN' tbts_3 db 'RUN'
tbte_2: tbte_2:
title db 'Processes - Ctrl/Alt/Del',0 title db 'Processes - Ctrl/Alt/Del',0
end if end if
start_application: db '/sys/LAUNCHER',0
start_application_e=$-start_application-1
; times 60 db 0
rb 60
start_application_c=$-start_application-1
align 4
I_END: I_END:
winxpos rd 1 winxpos rd 1
winypos rd 1 winypos rd 1
@ -667,4 +734,7 @@ curposy rd 1
index rd 1 index rd 1
tasklist rd display_processes tasklist rd display_processes
process_info_buffer process_information process_info_buffer process_information
cur_dir_path rb 1024
library_path rb 1024
align 4
U_END: U_END: