Subversion Repositories Kolibri OS

Rev

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