Subversion Repositories Kolibri OS

Rev

Rev 1467 | Rev 1489 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1464 IgorA 1
struct FileInfoBlock
2
	Function dd ?
3
	Position dd ?
4
	Flags	 dd ?
5
	Count	 dd ?
6
	Buffer	 dd ?
7
		db ?
8
	FileName dd ?
1457 IgorA 9
ends
10
 
11
struct TexColViv
12
  Text rb MAX_COLOR_WORD_LEN ; слово для подсветки
13
  f1 dd 0 ; справка по слову
14
  wwo db ? ; whole words only
15
  endc db ? ; символ конца выделения (wwo&4)
16
  color db ? ; номер цвета
17
ends
18
 
19
struct symbol
20
  c db ?    ;  +0 символ
21
  col db ?  ;  +1 цвет
22
  perv dd ? ;  +2
23
  next dd ? ;  +6 указатели
24
  tc dd ?   ; +10 врем. создания
25
  td dd ?   ; +14 врем. удаления
26
ends
27
 
28
 
1467 IgorA 29
hed db 'TextEditor 27.05.10',0 ;подпись окна
1457 IgorA 30
sc system_colors
31
 
32
fn_icon db 'te_icon.bmp',0
33
bmp_icon dd 0
1464 IgorA 34
run_file_70 FileInfoBlock
1457 IgorA 35
 
36
 
37
;input:
38
; al = код ошибки
1456 IgorA 39
align 4
1457 IgorA 40
ted_on_init_synt_err:
41
	mov byte[msgbox_3.err],al
42
	stdcall [mb_create],msgbox_3,thread ;message: Can-t open color options file!
43
	ret
44
 
45
 
46
;-----------------------------------------------------------------------------
47
;функция для выделения памяти
48
;input:
49
; ecx = size data
50
;otput:
51
; eax = pointer to memory
52
align 4
53
mem_Alloc:
54
  push ebx
55
  mov eax,68
56
  mov ebx,12
57
  int 0x40
58
  pop ebx
59
  ret
60
;-----------------------------------------------------------------------------
61
;функция для освобождения памяти
62
;input:
63
; ecx = pointer to memory
64
align 4
65
mem_Free:
1338 IgorA 66
  push eax ebx
1457 IgorA 67
  cmp ecx,0
68
  jz @f
69
    mov eax,68
70
    mov ebx,13
71
    int 0x40
72
  @@:
73
  pop ebx eax
74
  ret
75
 
76
 
77
align 4
78
ted_but_new_file:
79
  push eax ebx
80
  stdcall [ted_can_save], tedit0
1338 IgorA 81
  cmp al,1
82
  jne @f
1456 IgorA 83
    stdcall [mb_create],msgbox_2,thread ;message: save changes in file?
1338 IgorA 84
    ;mov eax,5
85
    ;mov ebx,50
86
    ;int 0x40
1456 IgorA 87
    stdcall [mb_setfunctions],msgbox_2_funct
1338 IgorA 88
    jmp .ret_f
89
  @@:
90
  call On_NewFile
91
  .ret_f:
92
  pop ebx eax
93
  ret
94
 
1456 IgorA 95
align 4
1338 IgorA 96
On_NewFile:
1457 IgorA 97
  stdcall [ted_clear], tedit0,1
1338 IgorA 98
  call draw_but_toolbar
1457 IgorA 99
  stdcall [ted_draw], tedit0
1338 IgorA 100
  ret
101
 
1456 IgorA 102
align 4
1338 IgorA 103
On_SaveAndNewFile:
1456 IgorA 104
  push edi
105
  mov edi, tedit0
106
 
1457 IgorA 107
  stdcall [ted_but_save_file],edi,run_file_70,[edit1.text]
1456 IgorA 108
  cmp ted_err_save,0
1338 IgorA 109
  jne @f
110
    call On_NewFile
111
  @@:
1456 IgorA 112
  pop edi
1338 IgorA 113
  ret
114
 
1457 IgorA 115
;description:
116
; функция открытия файла без окона сообщения
1456 IgorA 117
align 4
1457 IgorA 118
but_no_msg_OpenFile:
119
	push eax ebx
120
	stdcall [ted_open_file], tedit0,run_file_70,[edit1.text]
121
	call ted_messages_after_open_file
122
	pop ebx eax
123
	ret
1456 IgorA 124
 
1457 IgorA 125
;description:
126
; функция открытия файла с возможным окном сообщения (о возможности отменить открытие)
1456 IgorA 127
align 4
1457 IgorA 128
ted_but_open_file:
1467 IgorA 129
	pushad
130
 
1457 IgorA 131
	stdcall [ted_can_save], tedit0
132
	cmp al,1
133
	jne @f
134
		stdcall [mb_create],msgbox_5,thread ;message: save changes in file?
135
		stdcall [mb_setfunctions],msgbox_5_funct
136
		jmp .ret_f
137
	@@:
1467 IgorA 138
 
1468 IgorA 139
	copy_path open_dialog_name,communication_area_default_path,file_name,0
1467 IgorA 140
	mov [OpenDialog_data.type],0
141
	start_OpenDialog OpenDialog_data
142
	cmp [OpenDialog_data.status],2
143
	jne @f
1468 IgorA 144
		stdcall mem_spac, msgbox_9.fdp,100
145
		mov esi,file_name
146
		call strlen
147
		cmp eax,100
148
		jle .no_crop
149
			mov eax,100
150
		.no_crop:
151
		stdcall mem_copy, esi,msgbox_9.fdp,eax
1467 IgorA 152
		stdcall [mb_create],msgbox_9,thread ;message: error run 'open file dialog'
153
		jmp .ret_f
154
	@@:
155
	mov esi,[OpenDialog_data.openfile_path]
156
	call strlen
157
	mov [edit1.size],eax
158
	mov [edit1.pos],eax
159
	stdcall [edit_box_draw], edit1
1457 IgorA 160
	stdcall [ted_open_file], tedit0,run_file_70,[edit1.text]
161
	call ted_messages_after_open_file
162
	.ret_f:
1467 IgorA 163
	popad
1457 IgorA 164
	ret
1338 IgorA 165
 
1468 IgorA 166
align 4
167
proc mem_copy, source:dword, destination:dword, len:dword
168
  push ecx esi edi
169
    cld
170
    mov esi, dword[source]
171
    mov edi, dword[destination]
172
    mov ecx, dword[len]
173
    rep movsb
174
  pop edi esi ecx
175
  ret
176
endp
177
 
178
align 4
179
proc mem_spac, mem:dword, len:dword
180
  push eax ecx edi
181
    cld
182
    mov al,' '
183
    mov edi, dword[mem]
184
    mov ecx, dword[len]
185
    repne stosb
186
  pop edi ecx eax
187
  ret
188
endp
189
 
1457 IgorA 190
;input:
191
; eax = код ошибки
192
; ebx = колличество прочитанных байт
193
; edi = pointer to tedit struct
1456 IgorA 194
align 4
1457 IgorA 195
ted_messages_after_open_file:
196
	push ecx
197
	cmp eax,0
198
	je @f
199
	cmp eax,6
200
	je @f
201
		cmp ax,10
202
		jl .zifra_0_9
203
			mov al,'?'
204
			sub ax,48
205
		.zifra_0_9:
206
		add ax,48
1456 IgorA 207
 
1457 IgorA 208
		mov byte[msgbox_4.err],al
209
		stdcall [mb_create],msgbox_4,thread ;message: Can-t open text file!
210
		jmp .ret_f
211
	@@:
212
	cmp ebx,-1
213
	je .ret_f
214
		;if open file
215
		mov ecx,ted_max_chars
216
		sub ecx,2 ;ecx = максимальное число байт, для которых была выделена память
217
		cmp ebx,ecx
218
		jl .ret_f
219
			stdcall [mb_create],msgbox_1,thread
220
	.ret_f:
221
	pop ecx
222
	ret
1338 IgorA 223
 
1456 IgorA 224
align 4
1457 IgorA 225
ted_save_err_msg:
226
	mov byte[msgbox_6.err],al
227
	stdcall [mb_create],msgbox_6,thread ;message: Can-t save text file!
228
	ret
1456 IgorA 229
 
230
align 4
231
proc ted_but_open_syntax, edit:dword
1457 IgorA 232
  push ebx edi
1456 IgorA 233
  mov edi,dword[edit]
234
 
1457 IgorA 235
  cmp ted_panel_id,TED_PANEL_SYNTAX
1338 IgorA 236
  jne @f
1456 IgorA 237
    stdcall dword[tl_node_get_data], tree1
1449 IgorA 238
    pop dword[fn_col_option]
1457 IgorA 239
	mov ebx,dword[fn_col_option]
240
	copy_path ebx,fn_syntax_dir,file_name_rez,0x0
241
	copy_path file_name_rez,sys_path,file_name,0x0
242
    stdcall [ted_init_syntax_file],edi,run_file_70,file_name
243
    call [ted_text_colored]
244
    stdcall [ted_draw],edi
1338 IgorA 245
  @@:
1457 IgorA 246
  pop edi ebx
1338 IgorA 247
  ret
1456 IgorA 248
endp
1338 IgorA 249
 
1456 IgorA 250
align 4
1457 IgorA 251
proc ted_but_find ;вызов/скрытие панели поиска
1456 IgorA 252
  push edi
1457 IgorA 253
  mov edi,tedit0
1456 IgorA 254
 
1457 IgorA 255
  cmp ted_panel_id,TED_PANEL_NULL
1338 IgorA 256
  je @f
1457 IgorA 257
    mov ted_panel_id,TED_PANEL_NULL
1449 IgorA 258
    mov ted_wnd_l,0
1338 IgorA 259
    jmp .e_if
260
  @@:
1457 IgorA 261
    mov ted_panel_id,TED_PANEL_FIND
262
    mov ted_wnd_l,TED_PANEL_WIDTH
1338 IgorA 263
  .e_if:
1449 IgorA 264
  stdcall EvSize,edi
1457 IgorA 265
  stdcall [ted_draw],edi
1449 IgorA 266
  pop edi
267
  ret
268
endp
1338 IgorA 269
 
1456 IgorA 270
align 4
1457 IgorA 271
ted_on_find_err:
272
	stdcall [mb_create],msgbox_7,thread ;message: Can not find text
273
	ret
274
 
275
align 4
1338 IgorA 276
but_replace:
1456 IgorA 277
  ret
1338 IgorA 278
 
1456 IgorA 279
align 4
1338 IgorA 280
but_find_key_w:
1456 IgorA 281
  ret
1338 IgorA 282
 
1456 IgorA 283
align 4
284
proc but_sumb_invis, edit:dword
285
  push edi
286
  mov edi,dword[edit]
1338 IgorA 287
 
1456 IgorA 288
  xor ted_mode_invis,1
289
  call draw_but_toolbar
1457 IgorA 290
  stdcall [ted_draw],edi
1456 IgorA 291
  pop edi
292
  ret
293
endp
1338 IgorA 294
 
1456 IgorA 295
align 4
296
proc but_k_words_show, edit:dword
297
  push edi
298
  mov edi,dword[edit]
1338 IgorA 299
 
1456 IgorA 300
  xor ted_mode_color,1
301
  cmp ted_mode_color,0
302
  je @f
1457 IgorA 303
    call [ted_text_colored]
1456 IgorA 304
  @@:
1338 IgorA 305
  call draw_but_toolbar
1457 IgorA 306
  stdcall [ted_draw],edi
1456 IgorA 307
  pop edi
1338 IgorA 308
  ret
1456 IgorA 309
endp
1338 IgorA 310
 
1456 IgorA 311
align 4
1449 IgorA 312
proc but_synt_show, edit:dword
313
  push edi
314
  mov edi,[edit]
315
 
1457 IgorA 316
  cmp ted_panel_id,TED_PANEL_NULL
1338 IgorA 317
  je @f
1457 IgorA 318
    mov ted_panel_id,TED_PANEL_NULL
1449 IgorA 319
    mov ted_wnd_l,0
1338 IgorA 320
    jmp .e_if
321
  @@:
1457 IgorA 322
    mov ted_panel_id,TED_PANEL_SYNTAX
323
    mov ted_wnd_l,TED_PANEL_WIDTH
1338 IgorA 324
  .e_if:
1449 IgorA 325
  stdcall EvSize,edi
1457 IgorA 326
  stdcall [ted_draw],edi
1449 IgorA 327
  pop edi
328
  ret
329
endp