Subversion Repositories Kolibri OS

Rev

Rev 1464 | Rev 1468 | 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
 
139
	copy_path open_dialog_name,sys_path,file_name,0
140
	mov [OpenDialog_data.type],0
141
	start_OpenDialog OpenDialog_data
142
	cmp [OpenDialog_data.status],2
143
	jne @f
144
		stdcall [mb_create],msgbox_9,thread ;message: error run 'open file dialog'
145
		jmp .ret_f
146
	@@:
147
	mov esi,[OpenDialog_data.openfile_path]
148
	call strlen
149
	mov [edit1.size],eax
150
	mov [edit1.pos],eax
151
	stdcall [edit_box_draw], edit1
1457 IgorA 152
	stdcall [ted_open_file], tedit0,run_file_70,[edit1.text]
153
	call ted_messages_after_open_file
154
	.ret_f:
1467 IgorA 155
	popad
1457 IgorA 156
	ret
1338 IgorA 157
 
1457 IgorA 158
;input:
159
; eax = код ошибки
160
; ebx = колличество прочитанных байт
161
; edi = pointer to tedit struct
1456 IgorA 162
align 4
1457 IgorA 163
ted_messages_after_open_file:
164
	push ecx
165
	cmp eax,0
166
	je @f
167
	cmp eax,6
168
	je @f
169
		cmp ax,10
170
		jl .zifra_0_9
171
			mov al,'?'
172
			sub ax,48
173
		.zifra_0_9:
174
		add ax,48
1456 IgorA 175
 
1457 IgorA 176
		mov byte[msgbox_4.err],al
177
		stdcall [mb_create],msgbox_4,thread ;message: Can-t open text file!
178
		jmp .ret_f
179
	@@:
180
	cmp ebx,-1
181
	je .ret_f
182
		;if open file
183
		mov ecx,ted_max_chars
184
		sub ecx,2 ;ecx = максимальное число байт, для которых была выделена память
185
		cmp ebx,ecx
186
		jl .ret_f
187
			stdcall [mb_create],msgbox_1,thread
188
	.ret_f:
189
	pop ecx
190
	ret
1338 IgorA 191
 
1456 IgorA 192
align 4
1457 IgorA 193
ted_save_err_msg:
194
	mov byte[msgbox_6.err],al
195
	stdcall [mb_create],msgbox_6,thread ;message: Can-t save text file!
196
	ret
1456 IgorA 197
 
198
align 4
199
proc ted_but_open_syntax, edit:dword
1457 IgorA 200
  push ebx edi
1456 IgorA 201
  mov edi,dword[edit]
202
 
1457 IgorA 203
  cmp ted_panel_id,TED_PANEL_SYNTAX
1338 IgorA 204
  jne @f
1456 IgorA 205
    stdcall dword[tl_node_get_data], tree1
1449 IgorA 206
    pop dword[fn_col_option]
1457 IgorA 207
	mov ebx,dword[fn_col_option]
208
	copy_path ebx,fn_syntax_dir,file_name_rez,0x0
209
	copy_path file_name_rez,sys_path,file_name,0x0
210
    stdcall [ted_init_syntax_file],edi,run_file_70,file_name
211
    call [ted_text_colored]
212
    stdcall [ted_draw],edi
1338 IgorA 213
  @@:
1457 IgorA 214
  pop edi ebx
1338 IgorA 215
  ret
1456 IgorA 216
endp
1338 IgorA 217
 
1456 IgorA 218
align 4
1457 IgorA 219
proc ted_but_find ;вызов/скрытие панели поиска
1456 IgorA 220
  push edi
1457 IgorA 221
  mov edi,tedit0
1456 IgorA 222
 
1457 IgorA 223
  cmp ted_panel_id,TED_PANEL_NULL
1338 IgorA 224
  je @f
1457 IgorA 225
    mov ted_panel_id,TED_PANEL_NULL
1449 IgorA 226
    mov ted_wnd_l,0
1338 IgorA 227
    jmp .e_if
228
  @@:
1457 IgorA 229
    mov ted_panel_id,TED_PANEL_FIND
230
    mov ted_wnd_l,TED_PANEL_WIDTH
1338 IgorA 231
  .e_if:
1449 IgorA 232
  stdcall EvSize,edi
1457 IgorA 233
  stdcall [ted_draw],edi
1449 IgorA 234
  pop edi
235
  ret
236
endp
1338 IgorA 237
 
1456 IgorA 238
align 4
1457 IgorA 239
ted_on_find_err:
240
	stdcall [mb_create],msgbox_7,thread ;message: Can not find text
241
	ret
242
 
243
align 4
1338 IgorA 244
but_replace:
1456 IgorA 245
  ret
1338 IgorA 246
 
1456 IgorA 247
align 4
1338 IgorA 248
but_find_key_w:
1456 IgorA 249
  ret
1338 IgorA 250
 
1456 IgorA 251
align 4
252
proc but_sumb_invis, edit:dword
253
  push edi
254
  mov edi,dword[edit]
1338 IgorA 255
 
1456 IgorA 256
  xor ted_mode_invis,1
257
  call draw_but_toolbar
1457 IgorA 258
  stdcall [ted_draw],edi
1456 IgorA 259
  pop edi
260
  ret
261
endp
1338 IgorA 262
 
1456 IgorA 263
align 4
264
proc but_k_words_show, edit:dword
265
  push edi
266
  mov edi,dword[edit]
1338 IgorA 267
 
1456 IgorA 268
  xor ted_mode_color,1
269
  cmp ted_mode_color,0
270
  je @f
1457 IgorA 271
    call [ted_text_colored]
1456 IgorA 272
  @@:
1338 IgorA 273
  call draw_but_toolbar
1457 IgorA 274
  stdcall [ted_draw],edi
1456 IgorA 275
  pop edi
1338 IgorA 276
  ret
1456 IgorA 277
endp
1338 IgorA 278
 
1456 IgorA 279
align 4
1449 IgorA 280
proc but_synt_show, edit:dword
281
  push edi
282
  mov edi,[edit]
283
 
1457 IgorA 284
  cmp ted_panel_id,TED_PANEL_NULL
1338 IgorA 285
  je @f
1457 IgorA 286
    mov ted_panel_id,TED_PANEL_NULL
1449 IgorA 287
    mov ted_wnd_l,0
1338 IgorA 288
    jmp .e_if
289
  @@:
1457 IgorA 290
    mov ted_panel_id,TED_PANEL_SYNTAX
291
    mov ted_wnd_l,TED_PANEL_WIDTH
1338 IgorA 292
  .e_if:
1449 IgorA 293
  stdcall EvSize,edi
1457 IgorA 294
  stdcall [ted_draw],edi
1449 IgorA 295
  pop edi
296
  ret
297
endp