Subversion Repositories Kolibri OS

Rev

Rev 1489 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1476 IgorA 1
use32
2
  org 0x0
3
  db 'MENUET01' ;идентиф. исполняемого файла всегда 8 байт
4
  dd 0x01
5
  dd start
6
  dd i_end ; размер приложения
7
  dd mem
8
  dd stacktop
9
  dd file_name;buf_cmd_lin
10
  dd sys_path
11
 
12
MAX_COLOR_WORD_LEN equ 40
13
BUF_SIZE equ 1000 ;buffer for copy|paste
14
maxSyntaxFileSize equ 310000
15
 
16
include '../../macros.inc'
17
include '../../proc32.inc'
18
include '../../develop/libraries/box_lib/load_lib.mac'
19
include '../../develop/libraries/box_lib/trunk/box_lib.mac'
20
 
21
include 'te_data.inc'
22
include 'te_work.inc' ;text work functions
23
 
24
@use_library
25
 
26
align 4
27
start:
28
  mov eax,48
29
  mov ebx,3
30
  mov ecx,sc
31
  mov edx,sizeof.system_colors
32
  mcall
33
 
34
  mcall 68,11
35
  or eax,eax
36
  jz button.exit
37
 
38
  mcall 40,0x27
39
 
40
;-------------------------------------------------
41
  mov ecx,maxSyntaxFileSize
42
  call mem_Alloc
43
  mov [options_file],eax
44
  mov [options_file_end],eax
45
  add [options_file_end],ecx
46
 
47
 
48
load_libraries l_libs_start,load_lib_end
49
 
50
;проверка на сколько удачно загузилась наша либа
51
	mov	ebp,lib0
52
	cmp	dword [ebp+ll_struc_size-4],0
53
	jz	@f
54
	mcall	-1	;exit not correct
55
@@:
56
 
57
;---------------------------------------------------------------------
58
  stdcall dword[tl_data_init],dword tree1
59
  copy_path fn_icon_tl_sys,sys_path,file_name,0
60
 
61
  mov ecx,3*256*13
62
  call mem_Alloc
63
  mov dword[tree1.data_img_sys],eax
64
 
65
  mov [run_file_70.Function], 0
66
  mov [run_file_70.Position], 54
67
  mov [run_file_70.Flags], 0
68
  mov [run_file_70.Count], 3*256*13
69
  mov [run_file_70.Buffer], eax
70
  mov byte[run_file_70+20], 0
71
  mov [run_file_70.FileName], file_name
72
 
73
  mov eax,70 ;load icon file
74
  mov ebx,run_file_70
75
  int 0x40
76
  cmp ebx,0
77
  jg @f
78
    mov dword[tree1.data_img_sys],0
79
  @@:
80
;---------------------------------------------------------------------
81
; читаем bmp файл с иконками узлов
82
  copy_path fn_icon_tl_nod,sys_path,file_name,0
83
 
84
  mov ecx,3*256*2
85
  call mem_Alloc
86
  mov dword[tree1.data_img],eax
87
 
88
;  mov [run_file_70.Function], 0
89
;  mov [run_file_70.Position], 54
90
;  mov [run_file_70.Flags], 0
91
  mov [run_file_70.Count], 3*256*2
92
  mov [run_file_70.Buffer], eax
93
;  mov byte[run_file_70+20], 0
94
;  mov [run_file_70.FileName], file_name
95
 
96
  mov eax,70 ;load icon file
97
  mov ebx,run_file_70
98
  int 0x40
99
  cmp ebx,0
100
  jg @f
101
    mov dword[tree1.data_img],0
102
  @@:
103
;------------------------------------------------------------------------------
104
  copy_path fn_syntax_dir,sys_path,file_name,0 ;берем путь к папке с файлами синтаксиса
105
  mov eax,70
106
  mov ebx,tree_file_struct
107
  int 0x40
108
 
109
cmp ebx,-1
110
je .end_dir_init
111
 
112
  mov eax,dir_mem
113
  add eax,32+4+1+3+4*6+8
114
mov ecx,ebx
115
@@:
116
  cmp byte[eax],'.' ;фильтруем файлы с именами '.' и '..'
117
  je .filter
118
    push dword tree1
119
    push dword 0x10000 ;1*2^16 - где 1 номер иконки с книгой
120
    push dword eax
121
    call dword[tl_node_add]
122
 
123
    stdcall dword[tl_cur_next],tree1
124
  .filter:
125
  add eax,304
126
  loop @b
127
.end_dir_init:
128
 
129
;--- load color option file ---
130
stdcall [ted_init], tedit0
131
 
132
align 4
133
red_win:
134
  pushad
135
  mcall 12,1
136
 
137
  xor eax,eax
138
  mov ebx,10*65536+555
139
  mov ecx,10*65536+333
140
  mov edx,[sc.work]
141
  or  edx,0x33000000
142
  mov edi,hed
143
  mcall
144
 
145
  mcall 9,procinfo,-1
146
 
147
  mov eax,8 ;кнопка
148
  mov ebx,5*65536+90
149
  mov ecx,195*65536+20
150
  mov edx,200
151
  mov esi,[sc.work_button];0xd0
152
  mcall
153
 
154
;  mov eax,8
155
  mov ebx,100*65536+85
156
  mov ecx,195*65536+20
157
  mov edx,201
158
  mov esi,0xd00000
159
  mcall
160
 
161
  mov eax,4 ;рисование текста
162
  mov ebx,10*65536+200
163
  mov ecx,[sc.work_button_text]
164
  or  ecx,0x80000000
165
  mov edx,txt122
166
  mcall
167
 
168
  mov ebx,105*65536+200
169
  mov ecx,0xffff00
170
  or  ecx,0x80000000
171
  mov edx,txt148
172
  mcall
173
 
174
  mov ebx,195*65536+10
175
  mov ecx,[sc.work_text]
176
  or  ecx,0x80000000
177
  mov edx,txt_out_file
178
  mcall
179
 
180
  stdcall [edit_box_draw],dword edit1
181
  stdcall [tl_draw],dword tree1
182
 
183
  ;scroll 1
184
  mov [ws_dir_lbox.all_redraw],1
185
  stdcall [scrollbar_ver_draw],dword ws_dir_lbox
186
  stdcall [ted_draw], tedit0
187
 
188
  mcall 12,2
189
  popad
190
 
191
align 4
192
still:
193
  mcall 10
194
 
195
  cmp al,1 ;изм. положение окна
196
  jz red_win
197
  cmp al,2
198
  jz key
199
  cmp al,3
200
  jz button
201
  cmp al,6
202
  jz mouse
203
 
204
  jmp still
205
 
206
 
207
align 4
208
mouse:
209
	stdcall [tl_mouse],tree1
210
	stdcall [edit_box_mouse],edit1
211
	stdcall [ted_mouse], tedit0
212
	jmp still
213
 
214
 
215
align 4
216
key:
217
	mcall 2
218
	stdcall [tl_key],tree1
219
	stdcall [edit_box_key],edit1
220
;;;stdcall [ted_key], tedit0, conv_tabl,esi
221
	jmp still
222
 
223
align 4
224
button:
225
;  cmp [menu_active],1 ;если нажали меню, то сначала реакция на меню
226
;  jne @f ;mouse.menu_bar_1
227
;    mov [menu_active],0
228
;    jmp still
229
;  @@:
230
 
231
  mcall 17 ;получить код нажатой кнопки
232
 
233
  cmp ah,200
234
  jne @f
235
    call but_OpenSyntax
236
  @@:
237
  cmp ah,201
238
  jne @f
239
    call but_SaveSyntax
240
  @@:
241
 
242
  cmp ah,1
243
  jne still
244
.exit:
245
  ;push eax
246
 
247
  mov ecx,[options_file]
248
  call mem_Free
249
 
250
  stdcall [tl_data_clear], tree1
251
  stdcall [ted_delete], tedit0
252
  mcall -1 ;выход из программы
253
 
254
align 4
255
but_OpenSyntax:
256
  stdcall [tl_node_get_data],tree1
257
  pop dword [fn_col_option]
258
  call InitColText
259
  ret
260
 
261
align 4
262
but_SaveSyntax:
263
	stdcall [ted_but_save_file], tedit0,run_file_70,[edit1.text]
264
	ret
265
 
266
align 4
267
but_ctrl_o:
268
	push eax
269
	call get_wnd_in_focus
270
	cmp eax,0
271
	je @f
272
		stdcall [ted_open_file], eax,str_file_70,[edit1.text]
273
	@@:
274
	pop eax
275
	ret
276
 
277
;создание нового файла
278
align 4
279
but_ctrl_n:
280
	push eax
281
	call get_wnd_in_focus
282
	cmp eax,0
283
	je @f
284
		stdcall [ted_clear], eax,1
285
		stdcall [ted_draw], eax
286
	@@:
287
	pop eax
288
	ret
289
 
290
;определяем какое из окон редактора в фокусе
291
align 4
292
get_wnd_in_focus:
293
	xor eax,eax
294
	cmp dword[el_focus],tedit0
295
	jne @f
296
		mov eax,tedit0
297
	@@:
298
	;cmp dword[el_focus],tedit1
299
	;jne @f
300
	;       mov eax,tedit1
301
	;@@:
302
	ret
303
 
304
hed db 'TextEditor syntax file converter 31.05.10',0 ;подпись окна
305
 
306
txtErrOpen db 'Не найден файл, проверьте правильность имени',0
307
txtErrIni0 db 'Не открылся файл с иконками',0
308
err_ini0 db 0
309
 
310
txt122 db 'Загр. файл',0
311
txt148 db 'Сохр. файл',0
312
txt_out_file db 'Вых. файл:',0
313
 
314
CAPT_PATH_WIDTH equ 50
315
edit1 edit_box 305+16-CAPT_PATH_WIDTH, 215+CAPT_PATH_WIDTH, 5, 0xffffff, 0xff, 0xff0000, 0, 0x80, MAX_COLOR_WORD_LEN, ed_buffer.127, mouse_dd, 0
316
 
317
ed_buffer: ;текст для edit
318
  .127: rb MAX_COLOR_WORD_LEN+2
319
 
320
err_message_found_lib0	 db 'Sorry I cannot found library box_lib.obj',0
321
head_f_i0:
322
head_f_l0	  db 'System error',0
323
err_message_import0	 db 'Error on load import library box_lib.obj',0
324
err_message_found_lib1	db 'Sorry I cannot found library msgbox.obj',0
325
 
326
;library structures
327
l_libs_start:
328
  lib0 l_libs boxlib_name, sys_path, file_name, system_dir0, err_message_found_lib0, head_f_l0, myimport,err_message_import0, head_f_i0
329
load_lib_end:
330
 
331
;-----------------------------------------------------------------------------
332
;функция для выделения памяти
333
;input:
334
; ecx = size data
335
;otput:
336
; eax = pointer to memory
337
align 4
338
mem_Alloc:
339
  push ebx
340
  mov eax,68
341
  mov ebx,12
342
  int 0x40
343
  pop ebx
344
  ret
345
;-----------------------------------------------------------------------------
346
;функция для освобождения памяти
347
;input:
348
; ecx = pointer to memory
349
align 4
350
mem_Free:
351
  push eax ebx
352
  cmp ecx,0
353
  jz @f
354
    mov eax,68
355
    mov ebx,13
356
    int 0x40
357
  @@:
358
  pop ebx eax
359
  ret
360
 
361
i_end:
362
	rb 1024
363
	align 16
364
	procinfo process_information
365
	thread:
366
		rb 1024
367
stacktop:
368
  sys_path:
369
    rb 4096
370
  file_name:
371
    rb 4096
372
  file_name_rez:
373
    rb 4096
374
  file_info:
375
    rb 40
376
mem: