Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
122 diamond 1
;-----------------------------------------------------------------------------
31 halyavin 2
; project name:      TINYPAD
297 mikedld 3
; compiler:          flat assembler 1.67.18
4
; memory to compile: 3.0/9.0 MBytes (without/with size optimizations)
5
; version:           4.0.4
327 mikedld 6
; last update:       2007-02-08 (Feb 08, 2007)
617 mikedld 7
; minimal kernel:    revision #270 (svn://kolibrios.org/kernel/trunk)
122 diamond 8
;-----------------------------------------------------------------------------
9
; originally by:     Ville Michael Turjanmaa >> villemt@aton.co.jyu.fi
258 mikedld 10
; maintained by:     Mike Semenyako          >> mike.dld@gmail.com
11
;                    Ivan Poddubny           >> ivan-yar@bk.ru
122 diamond 12
;-----------------------------------------------------------------------------
297 mikedld 13
; TODO (4.1.0):
617 mikedld 14
;   - add vertical selection, undo, goto position, overwrite mode, smart tabulation
178 heavyiron 15
;   - improve window drawing with small dimensions
617 mikedld 16
;   - save/load settings to/from ini file, not executable
17
;   - path autocompletion for open/save dialogs
259 mikedld 18
;   - other bug-fixes and speed/size optimizations
122 diamond 19
;-----------------------------------------------------------------------------
617 mikedld 20
; See history.txt for complete changelog
21
;-----------------------------------------------------------------------------
31 halyavin 22
 
178 heavyiron 23
include 'lang.inc'
617 mikedld 24
 
25
include '../../../macros.inc' ; useful stuff
26
include '../../../struct.inc'
27
include '../../../proc32.inc'
28
 
29
include 'external/libio.inc'
30
 
122 diamond 31
include 'tinypad.inc'
617 mikedld 32
 
297 mikedld 33
;purge mov,add,sub            ;  SPEED
31 halyavin 34
 
259 mikedld 35
header '01',1,@CODE,TINYPAD_END,STATIC_MEM_END,MAIN_STACK,@PARAMS,self_path
31 halyavin 36
 
297 mikedld 37
APP_VERSION equ '4.0.4'
258 mikedld 38
 
617 mikedld 39
TRUE = 1
40
FALSE = 0
41
 
122 diamond 42
;include 'debug.inc'
280 mikedld 43
;define __DEBUG__ 1
44
;define __DEBUG_LEVEL__ 1
45
;include 'debug-fdo.inc'
31 halyavin 46
 
280 mikedld 47
ASEPC = '-'  ; separator character (char)
48
ATOPH = 19   ; menu bar height (pixels)
49
SCRLW = 16   ; scrollbar widht/height (pixels)
50
ATABW = 8    ; tab key indent width (chars)
51
LINEH = 10   ; line height (pixels)
52
PATHL = 256  ; maximum path length (chars) !!! don't change !!!
53
AMINS = 8    ; minimal scroll thumb size (pixels)
54
LCHGW = 3    ; changed/saved marker width (pixels)
31 halyavin 55
 
280 mikedld 56
STATH = 16   ; status bar height (pixels)
57
TBARH = 18   ; tab bar height (pixels)
31 halyavin 58
 
59
;-----------------------------------------------------------------------------
122 diamond 60
section @OPTIONS ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
31 halyavin 61
;-----------------------------------------------------------------------------
62
 
122 diamond 63
label color_tbl dword
297 mikedld 64
  .text:       RGB(  0,  0,  0)
65
  .back:       RGB(255,255,255)
66
  .text.sel:   RGB(255,255,255)
67
  .back.sel:   RGB( 10, 36,106)
68
  .symbol:     RGB( 48, 48,240)
69
  .number:     RGB(  0,144,  0)
70
  .string:     RGB(176,  0,  0)
71
  .comment:    RGB(128,128,128)
72
  .line.moded: RGB(255,238, 98)
73
  .line.saved: RGB(108,226,108)
31 halyavin 74
 
122 diamond 75
ins_mode db 1
297 mikedld 76
tab_pos  db 2
31 halyavin 77
 
122 diamond 78
options  db OPTS_AUTOINDENT+OPTS_OPTIMSAVE+OPTS_SMARTTAB
31 halyavin 79
 
122 diamond 80
mainwnd_pos:
267 mikedld 81
  .x dd 250
122 diamond 82
  .y dd 75
280 mikedld 83
  .w dd 6*80+6+SCRLW+5	;- 220
84
  .h dd 402		;- 220
31 halyavin 85
 
122 diamond 86
;-----------------------------------------------------------------------------
87
section @CODE ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
88
;-----------------------------------------------------------------------------
31 halyavin 89
 
122 diamond 90
;       fninit
31 halyavin 91
 
280 mikedld 92
;       stdcall ini.get_int,finfo_ini,ini_sec_window,ini_window_left,50
93
;       mov     [mainwnd_pos.x],eax
94
;       stdcall ini.get_int,finfo_ini,ini_sec_window,ini_window_top,50
95
;       mov     [mainwnd_pos.y],eax
96
;       stdcall ini.get_int,finfo_ini,ini_sec_window,ini_window_right,350
97
;       sub     eax,[mainwnd_pos.x]
98
;       mov     [mainwnd_pos.w],eax
99
;       stdcall ini.get_int,finfo_ini,ini_sec_window,ini_window_bottom,450
100
;       sub     eax,[mainwnd_pos.y]
101
;       mov     [mainwnd_pos.h],eax
178 heavyiron 102
 
258 mikedld 103
	cld
104
	mov	edi,@UDATA
105
	mov	ecx,@PARAMS-@UDATA
106
	mov	al,0
107
	rep	stosb
31 halyavin 108
 
297 mikedld 109
	mov	al,[tab_pos]
110
	mov	[tab_bar.Style],al
259 mikedld 111
 
112
	mcall	68,11
113
	or	eax,eax
114
	jz	key.alt_x.close
115
 
617 mikedld 116
	stdcall dll.Load,@IMPORT
117
	or	eax,eax
118
	jnz	key.alt_x.close
119
 
120
	stdcall mem.Alloc,65536
259 mikedld 121
	mov	[temp_buf],eax
122
 
178 heavyiron 123
	inc	[do_not_draw]
124
 
297 mikedld 125
	mov	dword[app_start],7
126
 
258 mikedld 127
	mov	esi,s_example
128
	mov	edi,tb_opensave.text
129
	mov	ecx,s_example.size
130
	mov	[tb_opensave.length],cl
131
	rep	movsb
31 halyavin 132
 
258 mikedld 133
	mov	esi,s_still
134
	mov	edi,s_search
135
	mov	ecx,s_still.size
136
	mov	[s_search.size],ecx
137
	rep	movsb
31 halyavin 138
 
258 mikedld 139
	cmp	byte[@PARAMS],0
140
	jz	no_params
31 halyavin 141
 
122 diamond 142
;// Willow's code to support DOCPAK [
31 halyavin 143
 
258 mikedld 144
	cmp	byte[@PARAMS],'*'
145
	jne	.noipc
178 heavyiron 146
 
147
;// diamond [ (convert size from decimal representation to dword)
148
;--     mov     edx,dword[@PARAMS+1]
258 mikedld 149
	mov	esi,@PARAMS+1
150
	xor	edx,edx
151
	xor	eax,eax
178 heavyiron 152
    @@: lodsb
258 mikedld 153
	test	al,al
154
	jz	@f
155
	lea	edx,[edx*4+edx]
156
	lea	edx,[edx*2+eax-'0']
157
	jmp	@b
178 heavyiron 158
    @@:
159
;// diamond ]
160
 
258 mikedld 161
	add	edx,20
259 mikedld 162
 
617 mikedld 163
	stdcall mem.Alloc,edx
259 mikedld 164
	mov	ebp,eax
280 mikedld 165
	push	eax
259 mikedld 166
 
280 mikedld 167
	mov	dword[ebp+0],0
168
	mov	dword[ebp+4],8
259 mikedld 169
	mcall	60,1,ebp
258 mikedld 170
	mcall	40,1000000b
280 mikedld 171
 
258 mikedld 172
	mcall	23,200
280 mikedld 173
 
258 mikedld 174
	cmp	eax,7
259 mikedld 175
	jne	key.alt_x.close
176
	mov	byte[ebp],1
177
 
178
	mov	ecx,[ebp+12]
280 mikedld 179
	lea	esi,[ebp+16]
259 mikedld 180
	call	create_tab
181
	call	load_from_memory
182
 
280 mikedld 183
	pop	ebp
617 mikedld 184
	stdcall mem.Free,ebp
259 mikedld 185
 
258 mikedld 186
	jmp	@f
122 diamond 187
  .noipc:
31 halyavin 188
 
122 diamond 189
;// Willow's code to support DOCPAK ]
31 halyavin 190
 
258 mikedld 191
	mov	esi,@PARAMS
192
	mov	edi,tb_opensave.text
193
	mov	ecx,PATHL
194
	rep	movsb
195
	mov	edi,tb_opensave.text
196
	mov	ecx,PATHL
197
	xor	al,al
198
	repne	scasb
199
	jne	key.alt_x.close
200
	lea	eax,[edi-tb_opensave.text-1]
201
	mov	[tb_opensave.length],al
297 mikedld 202
	call	load_file
280 mikedld 203
	jnc	@f
31 halyavin 204
 
122 diamond 205
  no_params:
259 mikedld 206
	call	create_tab
31 halyavin 207
 
208
    @@:
280 mikedld 209
	mov	[s_status],0
178 heavyiron 210
	dec	[do_not_draw]
258 mikedld 211
	mcall	66,1,1
212
	mcall	40,00100111b
178 heavyiron 213
red:
258 mikedld 214
	call	drawwindow
31 halyavin 215
 
122 diamond 216
;-----------------------------------------------------------------------------
31 halyavin 217
 
122 diamond 218
still:
297 mikedld 219
	call	draw_statusbar ; write current position & number of strings
31 halyavin 220
 
122 diamond 221
  .skip_write:
297 mikedld 222
	mcall	10	; wait here until event
258 mikedld 223
	cmp	[main_closed],0
224
	jne	key.alt_x
225
	dec	eax	; redraw ?
226
	jz	red
227
	dec	eax	; key ?
228
	jz	key
229
	dec	eax	; button ?
230
	jz	button
231
	sub	eax,3	; mouse ?
232
	jz	mouse
31 halyavin 233
 
258 mikedld 234
	jmp	still.skip_write
31 halyavin 235
 
122 diamond 236
;-----------------------------------------------------------------------------
617 mikedld 237
proc get_event ctx ;//////////////////////////////////////////////////////////
122 diamond 238
;-----------------------------------------------------------------------------
617 mikedld 239
	mcall	10
240
	dec	eax	; redraw ?
241
	jz	.redraw
242
	dec	eax	; key ?
243
	jz	.key
244
	dec	eax	; button ?
245
	jz	.button
246
	sub	eax,2	; background ?
247
	jz	.background
248
	dec	eax	; mouse ?
249
	jz	.mouse
250
	dec	eax	; ipc ?
251
	jz	.ipc
252
	dec	eax	; network ?
253
	jz	.network
254
	dec	eax	; debug ?
255
	jz	.debug
256
	sub	eax,7	; irq ?
257
	js	.nothing
258
	cmp	eax,15
259
	jg	.nothing
260
	jmp	.irq
261
 
262
  .nothing:
263
	mov	eax,EV_IDLE
264
	ret
265
 
266
  .redraw:
267
	mov	eax,EV_REDRAW
268
	ret
269
 
270
  .key:
271
	mov	eax,EV_KEY
272
	ret
273
 
274
  .button:
275
	mov	eax,EV_BUTTON
276
	ret
277
 
278
  .background:
279
	mov	eax,EV_BACKGROUND
280
	ret
281
 
282
  .mouse:
283
	mov	eax,EV_MOUSE
284
	ret
285
 
286
  .ipc:
287
	mov	eax,EV_IPC
288
	ret
289
 
290
  .network:
291
	mov	eax,EV_NETWORK
292
	ret
293
 
294
  .debug:
295
	mov	eax,EV_DEBUG
296
	ret
297
endp
298
 
299
;-----------------------------------------------------------------------------
300
proc start_fasm ;/////////////////////////////////////////////////////////////
301
;-----------------------------------------------------------------------------
31 halyavin 302
; BL = run after compile
122 diamond 303
;-----------------------------------------------------------------------------
297 mikedld 304
; FASM infile,outfile,/path/to/files[,run]
305
;-----------------------------------------------------------------------------
306
	cmp	[cur_editor.AsmMode],0
258 mikedld 307
	jne	@f
308
	ret
297 mikedld 309
    @@:
310
	mov	eax,[tab_bar.Default.Ptr]
311
	or	eax,eax
312
	jnz	@f
313
	mov	eax,[tab_bar.Current.Ptr]
314
    @@: cmp	byte[eax+TABITEM.Editor.FilePath],'/'
315
	je	@f
316
	ret
317
    @@:
258 mikedld 318
	mov	edi,fasm_parameters
297 mikedld 319
	push	eax
31 halyavin 320
 
297 mikedld 321
	cld
31 halyavin 322
 
297 mikedld 323
	lea	esi,[eax+TABITEM.Editor.FilePath]
324
	add	esi,[eax+TABITEM.Editor.FileName]
325
	push	esi esi
326
    @@: lodsb
327
	cmp	al,0
328
	je	@f
258 mikedld 329
	stosb
297 mikedld 330
	cmp	al,'.'
331
	jne	@b
332
	mov	ecx,esi
333
	jmp	@b
334
    @@:
258 mikedld 335
	mov	al,','
336
	stosb
31 halyavin 337
 
297 mikedld 338
	pop	esi
339
	sub	ecx,esi
340
	dec	ecx
341
	jz	@f
258 mikedld 342
	rep	movsb
297 mikedld 343
    @@:
258 mikedld 344
	mov	al,','
345
	stosb
31 halyavin 346
 
258 mikedld 347
	pop	ecx esi
297 mikedld 348
	add	esi,TABITEM.Editor.FilePath
349
	sub	ecx,esi
258 mikedld 350
	rep	movsb
31 halyavin 351
 
297 mikedld 352
	cmp	bl,0 ; run outfile ?
353
	je	@f
354
	mov	dword[edi],',run'
355
	add	edi,4
356
    @@:
258 mikedld 357
	mov	al,0
358
	stosb
31 halyavin 359
 
297 mikedld 360
	mov	[app_start.filename],app_fasm
361
	mov	[app_start.params],fasm_parameters
178 heavyiron 362
start_ret:
297 mikedld 363
	mcall	70,app_start
258 mikedld 364
	ret
617 mikedld 365
endp
31 halyavin 366
 
122 diamond 367
;-----------------------------------------------------------------------------
617 mikedld 368
proc open_debug_board ;///////////////////////////////////////////////////////
122 diamond 369
;-----------------------------------------------------------------------------
297 mikedld 370
	mov	[app_start.filename],app_board
371
	mov	[app_start.params],0
258 mikedld 372
	jmp	start_ret
617 mikedld 373
endp
31 halyavin 374
 
122 diamond 375
;-----------------------------------------------------------------------------
617 mikedld 376
proc open_sysfuncs_txt ;//////////////////////////////////////////////////////
122 diamond 377
;-----------------------------------------------------------------------------
297 mikedld 378
	mov	[app_start.filename],app_docpak
379
	mov	[app_start.params],sysfuncs_param
258 mikedld 380
	call	start_ret
381
	cmp	eax,0xfffffff0
382
	jb	@f
297 mikedld 383
	mov	[app_start.filename],app_tinypad
384
	mov	[app_start.params],sysfuncs_filename
258 mikedld 385
	call	start_ret
122 diamond 386
    @@: ret
617 mikedld 387
endp
31 halyavin 388
 
297 mikedld 389
set_opt:
178 heavyiron 390
 
297 mikedld 391
  .dialog:
392
	mov	[bot_mode],1
393
	mov	[bot_dlg_height],128
394
	mov	[bot_dlg_handler],optsdlg_handler
395
	mov	[focused_tb],tb_color
396
	mov	al,[tb_color.length]
397
	mov	[tb_color.pos.x],al
398
	mov	[tb_color.sel.x],0
399
	mov	[tb_casesen],1
400
	mov	[cur_part],0
401
	m2m	[cur_color],dword[color_tbl.text]
402
	mov	esi,color_tbl
403
	mov	edi,cur_colors
404
	mov	ecx,10
405
	cld
406
	rep	movsd
407
	call	drawwindow
408
	ret
31 halyavin 409
 
259 mikedld 410
  .line_numbers:
258 mikedld 411
	mov	al,OPTS_LINENUMS
259 mikedld 412
	jmp	.main
413
  .optimal_fill:
258 mikedld 414
	mov	al,OPTS_OPTIMSAVE
259 mikedld 415
	jmp	.main
416
  .auto_indents:
258 mikedld 417
	mov	al,OPTS_AUTOINDENT
259 mikedld 418
	jmp	.main
419
  .auto_braces:
258 mikedld 420
	mov	al,OPTS_AUTOBRACES
259 mikedld 421
	jmp	.main
422
  .secure_sel:
423
	mov	al,OPTS_SECURESEL
31 halyavin 424
 
259 mikedld 425
  .main:
426
	xor	[options],al
258 mikedld 427
	ret
31 halyavin 428
 
122 diamond 429
;-----------------------------------------------------------------------------
31 halyavin 430
 
617 mikedld 431
include 'data/tp-defines.inc'
259 mikedld 432
 
122 diamond 433
include 'tp-draw.asm'
434
include 'tp-key.asm'
258 mikedld 435
include 'tp-button.asm'
122 diamond 436
include 'tp-mouse.asm'
437
include 'tp-files.asm'
258 mikedld 438
include 'tp-common.asm'
439
include 'tp-dialog.asm'
122 diamond 440
include 'tp-popup.asm'
441
include 'tp-tbox.asm'
259 mikedld 442
include 'tp-tabctl.asm'
443
include 'tp-editor.asm'
258 mikedld 444
include 'tp-recode.asm'
31 halyavin 445
 
617 mikedld 446
include 'external/dll.inc'
178 heavyiron 447
 
31 halyavin 448
;-----------------------------------------------------------------------------
122 diamond 449
section @DATA ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
31 halyavin 450
;-----------------------------------------------------------------------------
451
 
617 mikedld 452
include 'data/tp-idata.inc'
31 halyavin 453
 
617 mikedld 454
;-----------------------------------------------------------------------------
455
section @IMPORT ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
456
;-----------------------------------------------------------------------------
457
;align 16
458
;@IMPORT:
31 halyavin 459
 
617 mikedld 460
library \
461
	libini,'libini.obj',\
462
	libio,'libio.obj',\
463
	libgfx,'libgfx.obj'
31 halyavin 464
 
617 mikedld 465
import	libini, \
466
	ini.get_str,'ini.get_str',\
467
	ini.set_str,'ini.set_str',\
468
	ini.get_int,'ini.get_int',\
469
	ini.set_int,'ini.set_int'
31 halyavin 470
 
617 mikedld 471
import	libio, \
472
	file.find_first,'file.find_first',\
473
	file.find_next ,'file.find_next',\
474
	file.find_close,'file.find_close',\
475
	file.size      ,'file.size',\
476
	file.open      ,'file.open',\
477
	file.read      ,'file.read',\
478
	file.write     ,'file.write',\
479
	file.seek      ,'file.seek',\
480
	file.tell      ,'file.tell',\
481
	file.eof?      ,'file.eof?',\
482
	file.truncate  ,'file.truncate',\
483
	file.close     ,'file.close'
31 halyavin 484
 
617 mikedld 485
import	libgfx, \
486
	gfx.open	,'gfx.open',\
487
	gfx.close	,'gfx.close',\
488
	gfx.pen.color	,'gfx.pen.color',\
489
	gfx.brush.color ,'gfx.brush.color',\
490
	gfx.pixel	,'gfx.pixel',\
491
	gfx.move.to	,'gfx.move.to',\
492
	gfx.line.to	,'gfx.line.to',\
493
	gfx.line	,'gfx.line',\
494
	gfx.polyline	,'gfx.polyline',\
495
	gfx.polyline.to ,'gfx.polyline.to',\
496
	gfx.fillrect	,'gfx.fillrect',\
497
	gfx.fillrect.ex ,'gfx.fillrect.ex',\
498
	gfx.framerect	,'gfx.framerect',\
499
	gfx.framerect.ex,'gfx.framerect.ex',\
500
	gfx.rectangle	,'gfx.rectangle',\
501
	gfx.rectangle.ex,'gfx.rectangle.ex'
31 halyavin 502
 
258 mikedld 503
TINYPAD_END:	 ; end of file
122 diamond 504
 
31 halyavin 505
;-----------------------------------------------------------------------------
122 diamond 506
section @UDATA ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
31 halyavin 507
;-----------------------------------------------------------------------------
508
 
617 mikedld 509
include 'data/tp-udata.inc'
297 mikedld 510
 
31 halyavin 511
;-----------------------------------------------------------------------------
122 diamond 512
section @PARAMS ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
31 halyavin 513
;-----------------------------------------------------------------------------
514
 
515
fasm_parameters:
516
 
258 mikedld 517
p_info	process_information
122 diamond 518
p_info2 process_information
258 mikedld 519
sc	system_colors
122 diamond 520
 
259 mikedld 521
rb 1024*4
522
MAIN_STACK:
523
rb 1024*4
524
POPUP_STACK:
525
 
526
STATIC_MEM_END:
527
 
528
diff10 'Main memory size',0,$