WikiPad

Check-in [93562586dc]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Uses AsmEdit for the text editing. Opens the file specified in the command line. On exit save the current configuration of the shortcuts. Can insert multiline texts. New icon to be used for .wiki document association.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:93562586dc7430ce0a9a9c105005cc3bed5a5763
User & Date: lhmnai0 2011-04-08 13:50:29
Context
2011-04-10
06:40
Fixed the title bar filename update - now it does not blink. Fixed "modified status" in AsmEdit. Leaf check-in: 01f69714ef user: JohnFound tags: trunk
2011-04-08
13:50
Uses AsmEdit for the text editing. Opens the file specified in the command line. On exit save the current configuration of the shortcuts. Can insert multiline texts. New icon to be used for .wiki document association. check-in: 93562586dc user: lhmnai0 tags: trunk
08:48
Some missing files added. check-in: d9bc02361d user: JohnFound tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to MainForm.frm.

1
2
3
4
5
6
7
8
9


10
11
12
13
14
15
16
..
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
..
71
72
73
74
75
76
77


78
79
80
81
82
83
84
..
98
99
100
101
102
103
104



105
106
107
108
109
110
111
...
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177



























































178
179
180
181
182
183
184
;<ff
Window Form1, 3, 0, 'TForm', 'Wiki editor:', $16CF0000, $10000, 0, 296, 91, 550, 409, Form1WinProc;
Window NONE, 0, 1, 'LISTBOX', 'Listbox', $508105C3, $200, 200, 0, 0, 120, 382, 0;
Window NONE, 2, 5, 'ASMEDIT', '', $50300124, $200, 100, 120, 0, 422, 382, 0;
;ff>
idEdit = 100
idShortcuts = 200

cEditorFontFace text 'FreshBold'




uglobal
  hAppPath dd ?

  hMainForm dd ?
  hMainMenu dd ?
................................................................................
  hShortcuts dd ?
  hEditor dd ?

  hAccelerators dd ?
endg

iglobal
  property propIgnoreNext, 'IGNORENEXT'

  EditorTheme AETHEME $000000, $ffffff, $ffffff, $800000,               \
                      $e8e8e8, $000000, 16,      1,                      \
                      $000000, $ffff00,                                 \
                      procSyntax,  $c0c0c0, $c0c0c0                     ; syntax proc and colors.
endg


winproc Form1WinProc
begin

ondefault
................................................................................

        invoke  SendMessage, [.lparam], LB_GETITEMDATA, eax, 0
        test    eax, eax
        jz      .listbox_exit

        stdcall InsertShortcut, eax



.listbox_exit:
        clc
        return


onmessage AM_INITWINDOW
        stdcall ImageList_LoadGif, [hInstance], resMainToolbar, 16, FALSE
................................................................................
        invoke  CreateAcceleratorTable, MainAccels, [MainAccels.Count]
        mov     [hAccelerators], eax

        invoke  LoadIcon, [hInstance], resAppIcon
        push    eax
        invoke  SendMessage, [.hwnd], WM_SETICON, ICON_SMALL, eax
        invoke  SendMessage, [.hwnd], WM_SETICON, ICON_BIG ; from the stack




        clc
        return


onmessage WM_ACTIVATE
        movzx   eax, word [.wparam]
................................................................................

        stdcall StrDup, [hAppPath]
        push    eax
        stdcall StrCat, eax, cDefaultShortcuts
        stdcall LoadShortcuts, eax
        stdcall StrDel ; from the stack

cDefaultShortcuts text 'wikipad.cfg'

        stdcall CreateSplitter, [hShortcuts], TRUE, $80000000 or IDC_SIZEWE, $80000000 or IDC_SIZENS

        invoke  SendMessage, [hEditor], WM_SETFONT, [hEditorFont], TRUE
        invoke  SendMessage, [hEditor], AEM_SETTHEME, 0, EditorTheme

        clc
        return

endwp
































































proc procSyntax, .ptrLine, .ptrColors
begin
        pushad


|

|





>
>







 







<
<



|







 







>
>







 







>
>
>







 







<
<











>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
..
23
24
25
26
27
28
29


30
31
32
33
34
35
36
37
38
39
40
..
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
...
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
...
163
164
165
166
167
168
169


170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
;<ff
Window Form1, 3, 0, 'TForm', 'Wiki editor:', $16CF0000, $10000, 0, 516, 476, 550, 409, Form1WinProc;
Window NONE, 0, 1, 'LISTBOX', 'Listbox', $508105C3, $200, 200, 0, 0, 120, 382, 0;
Window NONE, 2, 5, 'ASMEDIT', '', $50300124, $200, 100, 120, 0, 422, 382, EditWinProc;
;ff>
idEdit = 100
idShortcuts = 200

cEditorFontFace text 'FreshBold'

cDefaultShortcuts text 'wikipad.cfg'


uglobal
  hAppPath dd ?

  hMainForm dd ?
  hMainMenu dd ?
................................................................................
  hShortcuts dd ?
  hEditor dd ?

  hAccelerators dd ?
endg

iglobal


  EditorTheme AETHEME $000000, $ffffff, $ffffff, $800000,               \
                      $e8e8e8, $000000, 16,      1,                      \
                      $000000, $ffff00,                                 \
                      procSyntax,  $a0a0a0, $a0a0a0                     ; syntax proc and colors.
endg


winproc Form1WinProc
begin

ondefault
................................................................................

        invoke  SendMessage, [.lparam], LB_GETITEMDATA, eax, 0
        test    eax, eax
        jz      .listbox_exit

        stdcall InsertShortcut, eax

        invoke  SetFocus, [hEditor]

.listbox_exit:
        clc
        return


onmessage AM_INITWINDOW
        stdcall ImageList_LoadGif, [hInstance], resMainToolbar, 16, FALSE
................................................................................
        invoke  CreateAcceleratorTable, MainAccels, [MainAccels.Count]
        mov     [hAccelerators], eax

        invoke  LoadIcon, [hInstance], resAppIcon
        push    eax
        invoke  SendMessage, [.hwnd], WM_SETICON, ICON_SMALL, eax
        invoke  SendMessage, [.hwnd], WM_SETICON, ICON_BIG ; from the stack

        invoke  CreateFont, -13, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, RUSSIAN_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, FIXED_PITCH or FF_DONTCARE, cEditorFontFace
        mov     [hEditorFont], eax

        clc
        return


onmessage WM_ACTIVATE
        movzx   eax, word [.wparam]
................................................................................

        stdcall StrDup, [hAppPath]
        push    eax
        stdcall StrCat, eax, cDefaultShortcuts
        stdcall LoadShortcuts, eax
        stdcall StrDel ; from the stack



        stdcall CreateSplitter, [hShortcuts], TRUE, $80000000 or IDC_SIZEWE, $80000000 or IDC_SIZENS

        invoke  SendMessage, [hEditor], WM_SETFONT, [hEditorFont], TRUE
        invoke  SendMessage, [hEditor], AEM_SETTHEME, 0, EditorTheme

        clc
        return

endwp







winproc EditWinProc
begin

ondefault
        stc
        return


onmessage WM_KEYDOWN

        mov     eax, [.wparam]
        mov     ecx, [.lparam]

        cmp     eax, $20
        jb      .ondefault

        xor     ebx, ebx

        invoke  GetKeyState, VK_CONTROL
        test    ax, ax
        jns     @f
        or      ebx, HOTKEYF_CONTROL
@@:
        invoke  GetKeyState, VK_SHIFT
        test    ax, ax
        jns     @f
        or      ebx, HOTKEYF_SHIFT
@@:
        invoke  GetKeyState, VK_MENU
        test    ax, ax
        jns     @f
        or      ebx, HOTKEYF_ALT
@@:
        shl     ebx, 8
        mov     bl, byte [.wparam]

        stdcall SearchHotKey, ebx
        jc      .ondefault

        mov     esi, eax        ; pointer to TShortcutItem
        stdcall InsertShortcut, eax

        xor     eax,eax
        clc
        return


onmessage WM_DESTROY
        invoke  DeleteObject, [hEditorFont]
        clc
        return

endwp




proc procSyntax, .ptrLine, .ptrColors
begin
        pushad

Changes to ShortcutEngine.asm.

4
5
6
7
8
9
10


11
12

13
14
15
16
17









18








19
20




21
22
23
24
25



26
27
28


29

30
31
32
33


34

35






36






















37
38

39





40
41
42
43

44
45
46
47
48
49
50
51
52
...
378
379
380
381
382
383
384
385
386
387
388
389

390
391
392
393
394
395
396
397
  .hCloseTag   dd ?
  .HotKey      dd ?
ends


proc InsertShortcut, .ptrShortcut
  .pos AEPOS


begin
        push    esi

        mov     esi, [.ptrShortcut]

        lea     eax, [.pos]
        invoke  SendMessage, [hEditor], AEM_GETPOS, eax, 0




















        invoke  SendMessage, [hEditor], EM_SETSEL, [.end], [.end]





        stdcall StrLen, [esi+TShortcutItem.hCloseTag]
        mov     [.ins], eax
        stdcall StrLen, [esi+TShortcutItem.hOpenTag]
        add     [.ins], eax




        stdcall StrPtr, [esi+TShortcutItem.hCloseTag]
        invoke  SendMessage, [hEditor], EM_REPLACESEL, TRUE, eax




        invoke  SendMessage, [hEditor], EM_SETSEL, [.beg], [.beg]

        stdcall StrPtr, [esi+TShortcutItem.hOpenTag]
        invoke  SendMessage, [hEditor], EM_REPLACESEL, 0, eax




        mov     eax, [.beg]






        cmp     eax, [.end]






















        je      .posok


        mov     eax, [.end]





        add     eax, [.ins]
        invoke  SendMessage, [hEditor], EM_SETSEL, eax, eax

.posok:

        invoke  SetProp, [hEditor], [propIgnoreNext], 1
        pop     esi
        return
endp



proc SearchHotKey, .hotkey
begin
................................................................................
.file_closed:
        stdcall SetTabstop
        return
endp



proc SaveShortcuts, .ptrFileName
.count dd ?
.index dd ?
begin
        xor     ebx, ebx

        stdcall FileCreate, [.ptrFileName]
        jc      .error_save
        mov     ebx, eax

        mov     dword [file_buffer], 'wpSC'
        stdcall FileWrite, ebx, file_buffer, 4
        jc      .error_save








>
>

|
>


|
|

>
>
>
>
>
>
>
>
>

>
>
>
>
>
>
>
>

<
>
>
>
>

<
<
<
<
>
>
>



>
>

>
|


|
>
>

>
|
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|

>
|
>
>
>
>
>
|
|

<
>
|
|







 







|




>
|







4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

40
41
42
43
44




45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104

105
106
107
108
109
110
111
112
113
114
...
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
  .hCloseTag   dd ?
  .HotKey      dd ?
ends


proc InsertShortcut, .ptrShortcut
  .pos AEPOS
  .beg AEPOS
  .end AEPOS
begin
        push    edi esi ebx

        mov     esi, [.ptrShortcut]

        lea     ebx, [.pos]
        invoke  SendMessage, [hEditor], AEM_GETPOS, ebx, 0

        mov     eax, [ebx+AEPOS.selectionPosition]
        mov     ecx, [ebx+AEPOS.selectionLine]
        mov     edx, [ebx+AEPOS.caretPosition]
        mov     edi, [ebx+AEPOS.caretLine]
        cmp     edi, ecx
        ja      .sorted
        jb      .xchg
        cmp     edx, eax
        ja      .sorted

.xchg:
        xchg    edi, ecx
        xchg    edx, eax
.sorted:
        mov     [.beg.selectionPosition], eax
        mov     [.beg.selectionLine], ecx
        mov     [.beg.caretPosition], eax
        mov     [.beg.caretLine], ecx


        mov     [.end.selectionPosition], edx
        mov     [.end.selectionLine], edi
        mov     [.end.caretPosition], edx
        mov     [.end.caretLine], edi






        lea     eax, [.end]
        invoke  SendMessage, [hEditor], AEM_SETPOS, eax, 0

        stdcall StrPtr, [esi+TShortcutItem.hCloseTag]
        invoke  SendMessage, [hEditor], EM_REPLACESEL, TRUE, eax
        lea     eax, [.end]
        invoke  SendMessage, [hEditor], AEM_GETPOS, eax, 0

        lea     eax, [.beg]
        invoke  SendMessage, [hEditor], AEM_SETPOS, eax, 0

        stdcall StrPtr, [esi+TShortcutItem.hOpenTag]
        invoke  SendMessage, [hEditor], EM_REPLACESEL, FALSE, eax
        lea     eax, [.beg]
        invoke  SendMessage, [hEditor], AEM_GETPOS, eax, 0


        mov     eax, [.beg.selectionLine]
        sub     eax, [.beg.caretLine]

        add     [.end.selectionLine], eax
        add     [.end.caretLine], eax

        mov     eax, [.beg.selectionLine]
        cmp     eax, [.end.caretLine]
        jne     .offsetok

        mov     eax, [.beg.selectionPosition]
        sub     eax, [.beg.caretPosition]

        add     [.end.selectionPosition], eax
        add     [.end.caretPosition], eax

.offsetok:
        mov     eax, [.beg.selectionLine]
        cmp     eax, [.end.caretLine]
        jne     .notempty

        mov     eax, [.end.caretPosition]
        sub     eax, [.beg.selectionPosition]
        jnz     .notempty

; empty
        mov     eax, [.end.caretPosition]
        mov     ecx, [.end.caretLine]
        mov     [.end.selectionPosition], eax
        mov     [.end.selectionLine], ecx
        jmp     .posit

.notempty:
        mov     eax, [.end.selectionPosition]
        mov     ecx, [.end.selectionLine]
        mov     [.end.caretPosition], eax
        mov     [.end.caretLine], ecx

.posit:
        lea     eax, [.end]
        invoke  SendMessage, [hEditor], AEM_SETPOS, eax, 0



;        invoke  SetProp, [hEditor], [propIgnoreNext], 1
        pop     ebx esi edi
        return
endp



proc SearchHotKey, .hotkey
begin
................................................................................
.file_closed:
        stdcall SetTabstop
        return
endp



proc SaveShortcuts, .hFileName
.count dd ?
.index dd ?
begin
        xor     ebx, ebx
        stdcall StrPtr, [.hFileName]
        stdcall FileCreate, eax
        jc      .error_save
        mov     ebx, eax

        mov     dword [file_buffer], 'wpSC'
        stdcall FileWrite, ebx, file_buffer, 4
        jc      .error_save

Changes to WikiPad.asm.

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
..
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

include '%finc%/libs/gui.inc'
include '%finc%/libs/parents.inc'
include '%finc%/libs/msgutils.inc'
include '%finc%/libs/templates.inc'
include '%finc%/libs/tform.inc'
include '%finc%/libs/splitter.inc'
include '%finc%/libs/asmedit/asmedit.inc'


section '.code' code readable executable

include '%finc%/libs/gui.asm'
include '%finc%/libs/parents.asm'
include '%finc%/libs/msgutils.asm'
................................................................................
include '%finc%/libs/templates.asm'
include '%finc%/libs/tform.asm'
include '%lib%/system/memory.asm'
include '%lib%/system/files.asm'

include 'giflib.asm'
include '%finc%/libs/splitter.asm'
include '%finc%/libs/asmedit/asmedit.asm'

include '%lib%/data/arrays.asm'
include '%lib%/data/strlib.asm'
include 'StrLibOS.asm'

include 'opendialog.asm'
include 'actions.asm'







|







 







|







5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
..
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

include '%finc%/libs/gui.inc'
include '%finc%/libs/parents.inc'
include '%finc%/libs/msgutils.inc'
include '%finc%/libs/templates.inc'
include '%finc%/libs/tform.inc'
include '%finc%/libs/splitter.inc'
include 'asmedit/asmedit.inc'


section '.code' code readable executable

include '%finc%/libs/gui.asm'
include '%finc%/libs/parents.asm'
include '%finc%/libs/msgutils.asm'
................................................................................
include '%finc%/libs/templates.asm'
include '%finc%/libs/tform.asm'
include '%lib%/system/memory.asm'
include '%lib%/system/files.asm'

include 'giflib.asm'
include '%finc%/libs/splitter.asm'
include 'asmedit/asmedit.asm'

include '%lib%/data/arrays.asm'
include '%lib%/data/strlib.asm'
include 'StrLibOS.asm'

include 'opendialog.asm'
include 'actions.asm'

Changes to WikiPad.exe.

cannot compute difference between binary files

Changes to actions.asm.

76
77
78
79
80
81
82





83
84
85
86
87
88
89
...
171
172
173
174
175
176
177





178
179
180
181
182
183
184
endp




proc OnExit, .wparam, .lparam
begin






.check:
        invoke  SendMessage, [hEditor], EM_GETMODIFY, 0, 0
        test    eax, eax
        jnz     .noexit

.exit:
................................................................................

proc OnOpen, .wparam, .lparam
begin
        stdcall OpenFilesDialog, cOpenFileTitle, FALSE, WikiFilter, _openFileCallback, [hLoadedFilename], 0
        return
endp






proc _openFileCallback, .name, .lparam
.src dd ?
begin
        stdcall SetString, hLoadedFilename, [.name]

        stdcall StrNew
        mov     [.src], eax







>
>
>
>
>







 







>
>
>
>
>







76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
...
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
endp




proc OnExit, .wparam, .lparam
begin
        stdcall StrDup, [hAppPath]
        push    eax
        stdcall StrCat, eax, cDefaultShortcuts
        stdcall SaveShortcuts, eax
        stdcall StrDel ; from the stack

.check:
        invoke  SendMessage, [hEditor], EM_GETMODIFY, 0, 0
        test    eax, eax
        jnz     .noexit

.exit:
................................................................................

proc OnOpen, .wparam, .lparam
begin
        stdcall OpenFilesDialog, cOpenFileTitle, FALSE, WikiFilter, _openFileCallback, [hLoadedFilename], 0
        return
endp



; TODO: Check for 256 chars boundaries and split the lines in this case.
;

proc _openFileCallback, .name, .lparam
.src dd ?
begin
        stdcall SetString, hLoadedFilename, [.name]

        stdcall StrNew
        mov     [.src], eax

Changes to doc/WikiPad.wiki.

4
5
6
7
8
9
10

that to insert the tag in the text.

The set of tags can be saved in configuration file. This way one can use different tag sets for different
formats - wiki pages, BBCode, HTML or any other tag based markup language.

Besides tags, one can use the same approach to define snipets of text that to be insert with shortcut or
one mouse click - for example, signatures, ASCII art, smiles, etc.








>
4
5
6
7
8
9
10
11
that to insert the tag in the text.

The set of tags can be saved in configuration file. This way one can use different tag sets for different
formats - wiki pages, BBCode, HTML or any other tag based markup language.

Besides tags, one can use the same approach to define snipets of text that to be insert with shortcut or
one mouse click - for example, signatures, ASCII art, smiles, etc.

Changes to resources/resources.res.

cannot compute difference between binary files

Added resources/wikidoc.ico.

cannot compute difference between binary files

Name change from resources/turtlemini.ico to resources/wikipad.ico.

cannot compute difference between binary files