WikiPad

Check-in [f1cb0a952a]
Login

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

Overview
Comment:Almost working program. The shortcuts was separated in listbox aligned left, for easy access.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:f1cb0a952afa8469f621d7ede40a89afb3b40585
User & Date: lhmnai0 2011-03-15 15:08:14
Context
2011-03-15
19:50
The editor for the shortcut keys works. Same for save and load config files. Now, remains only to make shortcuts to work. check-in: 73056687ed user: JohnFound tags: trunk
15:08
Almost working program. The shortcuts was separated in listbox aligned left, for easy access. check-in: f1cb0a952a user: lhmnai0 tags: trunk
2011-03-14
14:44
First version of WikiPad. check-in: 65d5049a14 user: lhmnai0 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
17
18
19
20
21
22
..
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
..
91
92
93
94
95
96
97





































;<ff
Window Form1, 3, 0, 'TForm', 'Wiki editor:', $16CF0000, $0, 0, 415, 301, 492, 409, Form1WinProc;
Window NONE, 2, 5, 'EDIT', '', $56201104, $200, 100, 0, 0, 484, 382, EditWinProc;

;ff>
idEdit = 100


cEditorFontFace text 'FreshBold'


uglobal
  hMainForm dd ?
  hMainMenu dd ?
  hMainToolbar dd ?

  hEditorFont dd ?


endg


winproc Form1WinProc
begin

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

        stdcall CreateCoolToolbar, MainActionList, MainToolbar, [.hwnd], 11, [hIml], [hImlGray]
        mov     [hMainToolbar],eax
        stdcall SetAlign, eax, waTop

;        stdcall SetAutoSize, [hMainToolbar], TRUE
        invoke  SetProp, [hApplication], [propMainForm], [.hwnd]

        clc
        return

onmessage WM_CLOSE
        invoke  GetWindow, [.hwnd], GW_OWNER
        invoke  SendMessage, eax, [.wmsg], [.wparam], [.lparam]
        clc
        return

onmessage WM_INITDIALOG







        clc
        return

endwp




winproc EditWinProc
begin

ondefault
        stc
................................................................................

onmessage WM_DESTROY
        invoke  DeleteObject, [hEditorFont]
        clc
        return

endwp






































|
|
>


>










>
>







 







>









|
>
>
>
>
>
>
>




>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
..
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
...
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
;<ff
Window Form1, 3, 0, 'TForm', 'Wiki editor:', $16CF0000, $0, 0, 370, 301, 550, 409, Form1WinProc;
Window NONE, 0, 5, 'EDIT', '', $56201104, $200, 100, 120, 0, 422, 382, EditWinProc;
Window NONE, 2, 1, 'LISTBOX', 'Listbox', $50800541, $200, 200, 0, 0, 120, 382, 0;
;ff>
idEdit = 100
idShortcuts = 200

cEditorFontFace text 'FreshBold'


uglobal
  hMainForm dd ?
  hMainMenu dd ?
  hMainToolbar dd ?

  hEditorFont dd ?

  hShortcuts dd ?
endg


winproc Form1WinProc
begin

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

        stdcall CreateCoolToolbar, MainActionList, MainToolbar, [.hwnd], 11, [hIml], [hImlGray]
        mov     [hMainToolbar],eax
        stdcall SetAlign, eax, waTop

;        stdcall SetAutoSize, [hMainToolbar], TRUE
        invoke  SetProp, [hApplication], [propMainForm], [.hwnd]

        clc
        return

onmessage WM_CLOSE
        invoke  GetWindow, [.hwnd], GW_OWNER
        invoke  SendMessage, eax, [.wmsg], [.wparam], [.lparam]
        clc
        return

onmessage FM_AFTERCREATE

        invoke  GetDlgItem, [.hwnd], idShortcuts
        mov     [hShortcuts], eax

        stdcall LoadShortcuts, cDefaultShortcuts
cDefaultShortcuts text 'wikipad.cfg'

        clc
        return

endwp




winproc EditWinProc
begin

ondefault
        stc
................................................................................

onmessage WM_DESTROY
        invoke  DeleteObject, [hEditorFont]
        clc
        return

endwp






;proc RefreshShortcutList
;.list dd ?
;begin
;        invoke  GetDlgItem, [hMainForm], 200            ; ID of the listbox with the shortcuts.
;        mov     [.list], eax
;
;        invoke  SendMessage, [.list], LB_RESETCONTENT, 0, 0
;
;        mov     esi, [ptrShortcuts]
;        test    esi, esi
;        jz      .exit
;
;        mov     ebx, [esi+TArray.count]
;        lea     esi, [esi+TArray.array]
;
;.listloop:
;        stdcall StrPtr, [esi+TShortcutItem.hCaption]
;        invoke  SendMessage, [.list], LB_ADDSTRING, 0, eax
;        invoke  SendMessage, [.list], LB_SETITEMDATA, eax, esi
;
;        add     esi, sizeof.TShortcutItem
;        dec     ebx
;        jnz     .listloop
;
;
;.exit:
;        return
;endp



Changes to ShortcutEngine.asm.

1
2
3
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
115






116
117



118
119
120




121
122
123




124
125


126
127





128
129
130
131
132
133
134
135









136
137
138
139
140
141
142
143


144







145
146
147
148





149


150
151
152
153












154
155
156
157







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

























struct TShortcutItem
  .hCaption    dd ?
  .hOpenTag    dd ?
  .hCloseTag   dd ?
  .accelerator ACCEL
  .openCnt     dd ?
ends


uglobal
  ptrShortcuts dd ?
endg


proc DestroyShortcuts
begin
        cmp     [ptrShortcuts], 0
        je      .finish

        mov     esi, [ptrShortcuts]
        mov     ecx, [esi+TArray.count]
        xor     ebx, ebx


.loop   dec     ecx
        js      .endfree

        stdcall StrDel, [esi+TArray.array+ebx+TShortcutItem.hCaption]
        stdcall StrDel, [esi+TArray.array+ebx+TShortcutItem.hOpenTag]
        stdcall StrDel, [esi+TArray.array+ebx+TShortcutItem.hCloseTag]

        add     ebx, sizeof.TShortcutItem
        jmp     .loop

.endfree:
        stdcall FreeMem, esi
        mov     [ptrShortcuts], 0




.finish:
        return
endp




proc OnLoadShortcuts, .wparam, .lparam
.file dd ?
.size dd ?
begin






        cmp     [.lparam], 0
        jne     .nameok

        stdcall StrNew

        mov     [.lparam], eax

        lea     eax, [.lparam]
        stdcall OpenFilesDialog, cOpenFileTitle, FALSE, ShortcutFilter, _returnNameCallback, 0, eax
        test    eax, eax
        jz      .finish

        stdcall DestroyShortcuts


.nameok:
        stdcall StrPtr, [.lparam]
        stdcall LoadBinaryFile, eax
        jc      .error_load
        mov     [.file], eax
        mov     [.size], ecx

        stdcall CreateArray, sizeof.TShortcutItem
        mov     [ptrShortcuts], eax







        mov     esi, [.file]
        mov     ebx, [.size]

.scanloop:


        dec     ebx
        js      .endfile




















.endfile:
        stdcall FreeMem, [.file]




.finish:
        stdcall StrDel, [.lparam]


        return
endp


proc _returnNameCallback, .name, .hRetString



begin
        stdcall StrCopy, [.hRetString], [.name]
        mov     eax, 1   ; the file is assigned...


        return
endp








proc AppendShortCutMenu, .hMenu,
.mii  MENUITEMINFO



begin
        push    esi edi ebx


        mov     [.mii.cbSize], sizeof.MENUITEMINFO
        mov     [.mii.fMask], MIIM_TYPE or MIIM_ID




        xor     edi, edi

        invoke  GetMenuItemCount, [.hMenu]






        mov     ebx, eax
        test    ebx, ebx



        jz      .endscan

.scanloop:




        lea     ecx, [.mii]
        invoke  GetMenuItemInfo, [.hMenu], edi, TRUE, ecx
        cmp     [.mii.fType], MF_SEPARATOR




        jne     .next
        dec     [.fromSeparator]


        jz      .delloop
.next:





        inc     edi
        cmp     edi, ebx
        jae     .endscan
        jmp     .scanloop

; found needed separator, delete to the next separator.
.delloop:
        invoke  DeleteMenu, [.hMenu], edi, MF_BYPOSITION









        dec     ebx
        cmp     edi, ebx
        jae     .endscan

        lea     ecx, [.mii]
        invoke  GetMenuItemInfo, [.hMenu], edi, TRUE, ecx
        cmp     [.mii.fType], MF_SEPARATOR
        jne     .delloop










.endscan:
        mov     [.mii.fType], MFT_STRING

        mov     esi, [.ptrList]





        xor     ebx, ebx


        mov     eax, [esi+4]
        add     [.ItemID], eax
        stc                     ; One for the separator.
        adc     [.ItemID], edi












.loop:
        cmp     ebx, [esi+4]
        jae     .endinsert








        stdcall StrPtr, [esi+4*ebx+8]
        mov     [.mii.dwTypeData], eax







        dec     [.ItemID]
        push    [.ItemID]
        pop     [.mii.wID]




        lea     eax, [.mii]
        invoke  InsertMenuItem, [.hMenu], edi, TRUE, eax


        inc     ebx
        jmp     .loop










.endinsert:
; Put separator at the begin.
        mov     [.mii.fMask], MIIM_TYPE
        mov     [.mii.fType], MFT_SEPARATOR
        mov     [.mii.wID], NULL







        lea     eax, [.mii]
        invoke  InsertMenuItem, [.hMenu], edi, TRUE, eax






.finish:
        pop     ebx edi esi
        return
endp































|




<
<
<
<



|
|

|
|
<

>
|
<

|
|
|

<
<
<
<

<

>
>
>







|
|
<

>
>
>
>
>
>
|
|

<
>
|

<
<
|
|

|
>

<
|
|
<
<
<

<
<
>

>
>
>
>

|
|

|
>
>
|
|

>
>

>
>
>
>

>
>
>

>
>
>

>
>

<
<
>
>
>

<
<
>
>




<
>
>
>

<
<
>
>






>
>
>

<
<
>
>
>

<
>

<
<
>

>
>
|

<
>
>
>
>
>
>
|
<
>
>
>
|

<
>
>
>
>
|
<
<
>
>
>
>
|
<
>
>
|
<
>
>
>
>
>
|
|
|
<

<
<
<
>
>
>
>
>
>
>
>
>
|
|
<

<
<
<
<
>
>

>
>
>
>
>
>
>
|
<

<
>
>
>
>
>

>
>
|
<
<
<
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|

>
>
>
>
>
>
>
|
<
>
>
>

>
>
>
|
<
|
>

>
>
|
<
>
>
|
|

>
>
>
>
>
>
>
>
>
|
<
<
<
<
>
>
>
>
>
>
>
|
<
>

>
>
>
>

<




>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
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
115
116
117
118
119
120
121
122


123
124
125
126

127
128


129
130
131
132
133
134

135
136
137
138
139
140
141

142
143
144
145
146

147
148
149
150
151


152
153
154
155
156

157
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
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
247
248
249
250
251
252
253
254




255
256
257
258
259
260
261
262

263
264
265
266
267
268
269

270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
struct TShortcutItem
  .hCaption    dd ?
  .hOpenTag    dd ?
  .hCloseTag   dd ?
  .HotKey      dd ?
  .openCnt     dd ?
ends







proc DestroyShortcuts
begin
        invoke  SendMessage, [hShortcuts], LB_GETCOUNT, 0, 0
        mov     ebx, eax

.loop:  dec     ebx
        js      .finish


        invoke  SendMessage, [hShortcuts], LB_GETITEMDATA, ebx, 0
        mov     esi, eax


        stdcall StrDel, [esi+TShortcutItem.hCaption]
        stdcall StrDel, [esi+TShortcutItem.hOpenTag]
        stdcall StrDel, [esi+TShortcutItem.hCloseTag]





        stdcall FreeMem, esi


        invoke  SendMessage, [hShortcuts], LB_DELETESTRING, ebx, 0
        jmp     .loop

.finish:
        return
endp




proc OnEditShortcut, .wparam, .lparam
.index dd ?

begin
        xor     esi, esi

        stdcall CreateForm, frmEditShortcuts, [hMainForm]

        invoke  SendMessage, [hShortcuts], LB_GETCURSEL, 0, 0
        mov     [.index], eax
        cmp     eax, LB_ERR
        je      .edit


        invoke  SendMessage, ebx, LB_GETITEMDATA, eax, 0
        mov     esi, eax



        stdcall StrPtr, [esi+TShortcutItem.hCaption]
        invoke  SendDlgItemMessage, ebx, idCaptionEdit, WM_SETTEXT, 0, eax

        stdcall StrPtr, [esi+TShortcutItem.hOpenTag]
        invoke  SendDlgItemMessage, ebx, idOpenTagEdit, WM_SETTEXT, 0, eax


        stdcall StrPtr, [esi+TShortcutItem.hCloseTag]
        invoke  SendDlgItemMessage, ebx, idCloseTagEdit, WM_SETTEXT, 0, eax






        invoke  SendDlgItemMessage, ebx, HKM_SETHOTKEY, [esi+TShortcutItem.HotKey], 0

.edit:
        stdcall ShowModal, ebx, MSF_CENTER
        cmp     eax, MR_OK
        jne     .exit

        cmp     [.index], LB_ERR
        je      .itemok

        invoke  SendMessage, [hShortcuts], LB_DELETESTRING, [.index], 0

.itemok:
        test    esi, esi
        jnz     .dataok

        stdcall GetMem, sizeof.TShortcutItem
        mov     esi, eax

.dataok:
        invoke  GetDlgItem, ebx, idCaptionEdit
        stdcall GetControlText, eax, [esi+TShortcutItem.hCaption]
        mov     [esi+TShortcutItem.hCaption], eax

        invoke  GetDlgItem, ebx, idOpenTagEdit
        stdcall GetControlText, eax, [esi+TShortcutItem.hOpenTag]
        mov     [esi+TShortcutItem.hOpenTag], eax

        invoke  GetDlgItem, ebx, idCloseTagEdit
        stdcall GetControlText, eax, [esi+TShortcutItem.hCloseTag]
        mov     [esi+TShortcutItem.hCloseTag], eax

        invoke  SendMessage, ebx, idKeyEdit, HKM_GETHOTKEY, 0, 0
        mov     [esi+TShortcutItem.HotKey], eax



        stdcall StrPtr, [esi+TShortcutItem.hCaption]
        invoke  SendMessage, [hShortcuts], LB_ADDSTRING, 0, eax
        invoke  SendMessage, [hShortcuts], LB_SETITEMDATA, eax, esi



.exit:
        invoke  DestroyWindow, ebx
        return
endp





proc OnNewShortcut, .wparam, .lparam
begin


        invoke  SendMessage, [hShortcuts], LB_SELITEMRANGE, 0, -1
        stdcall OnEditShortcut, [.wparam], [.lparam]
        return
endp




uglobal
  file_buffer rb 1024
endg




proc LoadShortcuts, .ptrFileName
.count dd ?
begin

        xor     ebx, ebx



        stdcall DestroyShortcuts

        stdcall FileOpen, [.ptrFileName]
        jc      .error_load
        mov     ebx, eax


        stdcall FileRead, ebx, file_buffer, 4   ; how many records
        cmp     dword [file_buffer], 'wpSC'
        jne     .error_load

        stdcall FileRead, ebx, file_buffer, 4   ; how many records
        mov     eax, dword [file_buffer]
        mov     [.count], eax


.main_loop:
        cmp     [.count], 0
        jle     .end_file


        stdcall GetMem, sizeof.TShortcutItem
        mov     edi, eax        ; pointer to the TShortcutItem

; read 3 strings.
        xor     ecx, ecx



.strings_loop:
        stdcall FileRead, ebx, file_buffer, 4   ; length of the string.capacity
        cmp     eax, 1000
        ja      .error_load


        stdcall FileRead, ebx, file_buffer, eax
        jc      .error_load


        mov     [file_buffer+eax], 0
        stdcall StrDup, file_buffer
        mov     [edi+TShortcutItem.hCaption+ 4*ecx], eax

        inc     ecx
        cmp     ecx, 3
        jne     .strings_loop





; then read shortcut keys

        lea     eax, [edi+TShortcutItem.HotKey]
        stdcall FileRead, ebx, eax, 4   ; dword for flags and dword for the key.

        stdcall StrPtr, [edi+TShortcutItem.hCaption]
        invoke  SendMessage, [hShortcuts], LB_ADDSTRING, 0, eax
        invoke  SendMessage, [hShortcuts], LB_SETITEMDATA, eax, edi

        dec     [.count]
        jmp     .main_loop






.error_load:
        stdcall DestroyShortcuts

.end_file:
        test    ebx, ebx
        jz      .file_closed
        stdcall FileClose, ebx

.file_closed:
        return
endp





proc SaveShortcuts, .ptrFileName
.count 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

        invoke  SendMessage, [hShortcuts], LB_GETCOUNT, 0, 0

        mov     [.count], eax
        mov     dword [file_buffer], eax
        stdcall FileWrite, ebx, file_buffer, 4
        jc      .error_save

.main_loop:
        cmp     [.count], 0
        jle     .end_file

        invoke  SendMessage, [hShortcuts], LB_GETITEMDATA, [.count], 0
        mov     esi, eax

; write 3 strings.
        xor     ecx, ecx

.strings_loop:
        stdcall StrPtr, [esi+TShortcutItem.hCaption + 4*ecx]

        lea     edx, [eax+string.len]
        mov     eax, [eax+string.len]
        add     eax, 4

        stdcall FileWrite, ebx, edx, eax
        jc      .error_save

        inc     ecx

        cmp     ecx, 3
        jne     .strings_loop

; then write shortcut keys

        lea     eax, [esi+TShortcutItem.HotKey]

        stdcall FileWrite, ebx, eax, 4   ; dword for flags and dword for the key.

        dec     [.count]
        jmp     .main_loop

.error_save:

.end_file:
        test    ebx, ebx
        jz      .file_closed
        stdcall FileClose, ebx

.file_closed:
        return
endp







proc OnLoadShortcuts, .wparam, .lparam
begin

        stdcall OpenFilesDialog, cOpenFileTitle, FALSE, ShortcutFilter, _returnNameCallback, 0, 0
        test    eax, eax

        jz      .finish

        push    eax
        stdcall StrPtr, eax
        stdcall LoadShortcuts, eax
        stdcall StrDel ; from the stack
.finish:

        return
endp


proc _returnNameCallback, .name, .lparam
begin
        stdcall StrDup, [.name]
        return
endp



proc OnSaveShortcuts, .wparam, .lparam
begin
        stdcall SaveFileDialog, cSaveFileTitle, ShortcutFilter, 0
        test    eax, eax
        jz      .finish

        push    eax
        stdcall StrPtr, eax
        stdcall SaveShortcuts, eax
        stdcall StrDel ; from the stack
.finish:
        return
endp




Added StrLibOS.asm.











































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
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
;*******************************************************************************
; Get the text of the [Control] using WM_GETTEXT and put it to the string with
; handle (only) in [string].
;
; if [string] = NULL creates new string and returns the handle.
; if [string] <> NULL just copyes the text.
;*******************************************************************************
proc GetControlText, .Control, .string
.len dd ?
begin
        push    ebx ecx edx

        mov     eax, [.string]
        test    eax,eax
        jnz     @f
        stdcall StrNew
@@:
        mov     ebx, eax

        invoke  SendMessage, [.Control], WM_GETTEXTLENGTH, 0, 0
        mov     [.len], eax
        stdcall StrSetCapacity, ebx, eax
        jc      .error

        push    eax
        add     [.len], 1
        invoke  SendMessage, [.Control], WM_GETTEXT, [.len], eax
        pop     ecx
        mov     [ecx+string.len], eax
        mov     eax, ebx
        clc

.error:
        pop     edx ecx ebx
        return
endp





;*******************************************************************************
; Sets the text in control using WM_SETTEXT from string with handle or pointer
; in [string].
;*******************************************************************************
proc SetControlText, .Control, .string
begin
        push    eax ecx edx
        stdcall StrPtr, [.string]
        invoke  SendMessage, [.Control], WM_SETTEXT, 0, eax
        pop     edx ecx eax
        return
endp

Changes to WikiPad.asm.

22
23
24
25
26
27
28

29
30
31
32

33
34
35
36
37
38
39
..
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
include '%lib%/system/files.asm'

include '%lib%/GUI/Win32/giflib.asm'
include '%finc%/libs/application.asm'

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


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


include 'MainForm.frm'
include 'ShortcutEngine.asm'

uglobal
  hInstance       dd 0  ; Instance handle for common use.
  hHeap           dd 0

................................................................................
start:
        invoke  GetModuleHandle,0
        mov     [hInstance],eax
        invoke  GetProcessHeap
        mov     [hHeap], eax

; Init common controls
        invoke  InitCommonControls      ;Ex,ComCtrlsFlags

        InitializeAll
        stdcall InitApplication, resAppIcon, cMainTitle

        stdcall CreateForm, Form1, [hApplication]
        mov     [hMainForm], ebx








>




>







 







|







22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
..
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
include '%lib%/system/files.asm'

include '%lib%/GUI/Win32/giflib.asm'
include '%finc%/libs/application.asm'

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

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

include 'dlgShortcuts.frm'
include 'MainForm.frm'
include 'ShortcutEngine.asm'

uglobal
  hInstance       dd 0  ; Instance handle for common use.
  hHeap           dd 0

................................................................................
start:
        invoke  GetModuleHandle,0
        mov     [hInstance],eax
        invoke  GetProcessHeap
        mov     [hHeap], eax

; Init common controls
        invoke  InitCommonControls      ;Ex, ComCtrlsFlags

        InitializeAll
        stdcall InitApplication, resAppIcon, cMainTitle

        stdcall CreateForm, Form1, [hApplication]
        mov     [hMainForm], ebx

Changes to WikiPad.exe.

cannot compute difference between binary files

Changes to WikiPad.fpr.

cannot compute difference between binary files

Changes to actions.asm.

16
17
18
19
20
21
22
23





24
25
26
27
28
29
30
..
36
37
38
39
40
41
42
43
44

45



46
47
48
49
50
51
52
  actExit,       -1, '&Exit',           <Alt,  'X'>,         'Exit program',               OnExit,              \
\
  actUndo,        3, '&Undo',           <Ctrl, 'Z'>,         'Undo last change',           OnUndo,              \
  actCut ,        4, 'Cu&t',            <Ctrl, 'X'>,         'Cut to clipboard',           OnCut,               \
  actCopy,        5, '&Copy',           <Ctrl, 'C'>,         'Copy to clipboard',          OnCopy,              \
  actPaste,       6, '&Paste',          <Ctrl, 'V'>,         'Paste from clipboard',       OnPaste,             \
\
  actLoadShortcuts, -1, 'Load format shortcuts', <Ctrl+Shift, 'L'>, 'Load new format shortcuts file.',  OnLoadShortcuts








CoolMenu MainMenu,                      \
  mfSubmenu, '&File',                   \
    mfNormal, actNew,                   \
    mfNormal, actOpen,                  \
................................................................................
  mfSubmenu, '&Edit',                   \
    mfNormal, actUndo,                  \
    mfSeparator, NONE,                  \
    mfNormal, actCut,                   \
    mfNormal, actCopy,                  \
    mfNormal, actPaste,                 \
  mfEnd, NONE,                          \
  mfSubmenu, '&Mark',                   \
    mfNormal, actLoadShortcuts,         \

    mfSeparator, NONE,                  \



  mfEnd, NONE

CoolToolbar MainToolbar,                \
  bfButton, actNew,                     \
  bfButton, actOpen,                    \
  bfButton, actSave,                    \
  bfSeparator, NONE,                    \







|
>
>
>
>
>







 







|

>

>
>
>







16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
..
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
  actExit,       -1, '&Exit',           <Alt,  'X'>,         'Exit program',               OnExit,              \
\
  actUndo,        3, '&Undo',           <Ctrl, 'Z'>,         'Undo last change',           OnUndo,              \
  actCut ,        4, 'Cu&t',            <Ctrl, 'X'>,         'Cut to clipboard',           OnCut,               \
  actCopy,        5, '&Copy',           <Ctrl, 'C'>,         'Copy to clipboard',          OnCopy,              \
  actPaste,       6, '&Paste',          <Ctrl, 'V'>,         'Paste from clipboard',       OnPaste,             \
\
  actLoadShortcuts, -1, 'Load shortcuts', <NONE>, 'Load shortcuts from a file.',   OnLoadShortcuts,    \
  actSaveShortcuts, -1, 'Save shortcuts', <NONE>, 'Save the shortcuts to a file.', OnSaveShortcuts,  \
  actEditShortcut, -1, 'Edit shortcut',   <NONE>, 'Edit shortcut.',                OnEditShortcut,                   \
  actNewShortcut, -1, 'New shortcut',     <NONE>, 'Add new shortcut.',             OnNewShortcut,                    \
  actDelShortcut, -1, 'Del shortcut',     <NONE>, 'Delete a shortcut.',            OnDelShortcut




CoolMenu MainMenu,                      \
  mfSubmenu, '&File',                   \
    mfNormal, actNew,                   \
    mfNormal, actOpen,                  \
................................................................................
  mfSubmenu, '&Edit',                   \
    mfNormal, actUndo,                  \
    mfSeparator, NONE,                  \
    mfNormal, actCut,                   \
    mfNormal, actCopy,                  \
    mfNormal, actPaste,                 \
  mfEnd, NONE,                          \
  mfSubmenu, '&Markup',                 \
    mfNormal, actLoadShortcuts,         \
    mfNormal, actSaveShortcuts,         \
    mfSeparator, NONE,                  \
    mfNormal, actNewShortcut,           \
    mfNormal, actEditShortcut,          \
    mfNormal, actDelShortcut,           \
  mfEnd, NONE

CoolToolbar MainToolbar,                \
  bfButton, actNew,                     \
  bfButton, actOpen,                    \
  bfButton, actSave,                    \
  bfSeparator, NONE,                    \

Added dlgShortcuts.frm.





































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
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
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
247
248
249
250
251
252
253
254
255
256
257
258
;<ff
Window frmEditShortcuts, 3, 0, 'TForm', 'Edit shortcut', $16480000, $10000, 0, 553, 340, 320, 299, CustomWinProc;
Window NONE, 0, 0, 'EDIT', '', $50010080, $200, 104, 8, 176, 297, 21, 0;
Window NONE, 0, 0, 'EDIT', '', $50010080, $200, 101, 8, 32, 297, 21, 0;
Window NONE, 0, 0, 'STATIC', 'Shortcut key:', $50000000, $0, 0, 8, 160, 64, 16, 0;
Window NONE, 0, 0, 'STATIC', 'Open tag:', $50000000, $0, 0, 8, 64, 64, 16, 0;
Window NONE, 0, 0, 'EDIT', '', $50010080, $200, 102, 8, 80, 297, 21, 0;
Window NONE, 0, 0, 'STATIC', 'Caption:', $50000000, $0, 0, 8, 16, 64, 16, 0;
Window NONE, 0, 0, 'STATIC', 'Close tag:', $50000000, $0, 0, 8, 112, 64, 16, 0;
Window NONE, 0, 0, 'EDIT', '', $50010080, $200, 103, 8, 128, 297, 21, 0;
Window NONE, 0, 0, 'BUTTON', 'OK', $50010000, $0, 1, 88, 232, 64, 25, 0;
Window NONE, 2, 0, 'BUTTON', 'Cancel', $50010000, $0, 2, 160, 232, 64, 25, 0;
;ff>
idCaptionEdit  = 101
idOpenTagEdit  = 102
idCloseTagEdit = 103
idKeyEdit      = 104

idBtnCancel   = MR_CANCEL
idBtnOK       = MR_OK



cHotkeyEditClassName text HOTKEY_CLASS


;-----------------------------------------------------------------------
; Window procedure for the form.
; Arguments:
;   .hwnd - handle of the window
;   .wmsg - code of the message
;   .wparam \ Parameters of the message
;   .lparam /
;-----------------------------------------------------------------------
winproc CustomWinProc
begin
;-----------------------------------------------------------------------
; Write here the code that have to be executed before
; message dispathing.
;-----------------------------------------------------------------------


ondefault
;-----------------------------------------------------------------------
; Write here the code that have to be executed if message
; was not processed by this procedure.
;-----------------------------------------------------------------------
        stc
        return


onmessage FM_AFTERCREATE
locals
  .rect RECT
endl

        invoke  GetDlgItem, [.hwnd], idKeyEdit
        push    eax
        lea     ecx, [.rect]
        invoke  GetWindowRect, eax, ecx

        invoke  DestroyWindow ; from the stack

        lea     eax, [.rect.left]
        invoke  ScreenToClient, [.hwnd], eax
        lea     eax, [.rect.right]
        invoke  ScreenToClient, [.hwnd], eax

        mov     ecx, [.rect.right]
        mov     eax, [.rect.bottom]
        sub     ecx, [.rect.left]
        sub     eax, [.rect.top]

        invoke  CreateWindowEx, 0, cHotkeyEditClassName, 0, WS_CHILD or WS_CLIPSIBLINGS or WS_VISIBLE, [.rect.left], [.rect.top], ecx, eax, [.hwnd], idKeyEdit, [hInstance], 0

        clc
        return


endwp








;
;
;
;        cmp     [.lparam], 0
;        jne     .nameok
;
;        stdcall StrNew
;        mov     [.lparam], eax
;
;        lea     eax, [.lparam]
;        stdcall OpenFilesDialog, cOpenFileTitle, FALSE, ShortcutFilter, _returnNameCallback, 0, eax
;        test    eax, eax
;        jz      .finish
;
;        stdcall DestroyShortcuts
;
;.nameok:
;        stdcall StrPtr, [.lparam]
;        stdcall LoadBinaryFile, eax
;        jc      .error_load
;
;        mov     [.file], eax
;        mov     [.size], ecx
;
;        stdcall CreateArray, sizeof.TShortcutItem
;        mov     [ptrShortcuts], eax
;
;        mov     esi, [.file]
;        mov     ebx, [.size]
;
;.scanloop:
;        stdcall AddArrayItem , [ptrShortcuts]
;        mov     [ptrShortcuts], edx
;        mov     edi, eax
;
;        xor     ecx, ecx
;
;.strloop:
;        call    .scantoseparator
;;        jc      .error_format
;
;        stdcall StrDup, eax     ; caption
;        mov     [edi+TShortcutItem.hCaption+4*ecx], eax
;
;        inc     ecx
;        cmp     ecx, 3
;        jne     .strloop
;
;; shortcut
;        call    .scantoseparator
;;        jc      .error_format
;
;
;
;
;
;
;.error_load:
;.end_of_file:
;
;.endfile:
;        stdcall FreeMem, [.file]
;
;.finish:
;        stdcall StrDel, [.lparam]
;        return
;
;.scantoseparator:
;        retn
;
;.skiptoeol:
;        retn
;
;endp
;
;

;
;
;proc _returnNameCallback, .name, .hRetString
;begin
;        stdcall StrCopy, [.hRetString], [.name]
;        mov     eax, 1   ; the file is assigned...
;        return
;endp
;
;
;
;
;
;proc AppendShortCutMenu, .hMenu, .ptrShortcutsArray, .fromSeparator
;.mii  MENUITEMINFO
;begin
;        push    esi edi ebx
;
;        mov     [.mii.cbSize], sizeof.MENUITEMINFO
;        mov     [.mii.fMask], MIIM_TYPE or MIIM_ID
;
;        xor     edi, edi
;
;        invoke  GetMenuItemCount, [.hMenu]
;        mov     ebx, eax
;        test    ebx, ebx
;        jz      .endscan
;
;.scanloop:
;        lea     ecx, [.mii]
;        invoke  GetMenuItemInfo, [.hMenu], edi, TRUE, ecx
;        cmp     [.mii.fType], MF_SEPARATOR
;        jne     .next
;        dec     [.fromSeparator]
;        jz      .delloop
;.next:
;        inc     edi
;        cmp     edi, ebx
;        jae     .endscan
;        jmp     .scanloop
;
;; found needed separator, delete to the next separator.
;.delloop:
;        invoke  DeleteMenu, [.hMenu], edi, MF_BYPOSITION
;        dec     ebx
;        cmp     edi, ebx
;        jae     .endscan
;
;        lea     ecx, [.mii]
;        invoke  GetMenuItemInfo, [.hMenu], edi, TRUE, ecx
;        cmp     [.mii.fType], MF_SEPARATOR
;        jne     .delloop
;
;.endscan:
;        mov     [.mii.fType], MFT_STRING
;
;        mov     esi, [.ptrList]
;        xor     ebx, ebx
;        mov     eax, [esi+4]
;        add     [.ItemID], eax
;        stc                     ; One for the separator.
;        adc     [.ItemID], edi
;.loop:
;        cmp     ebx, [esi+4]
;        jae     .endinsert
;
;        stdcall StrPtr, [esi+4*ebx+8]
;        mov     [.mii.dwTypeData], eax
;
;        dec     [.ItemID]
;        push    [.ItemID]
;        pop     [.mii.wID]
;
;        lea     eax, [.mii]
;        invoke  InsertMenuItem, [.hMenu], edi, TRUE, eax
;        inc     ebx
;        jmp     .loop
;
;.endinsert:
;; Put separator at the begin.
;        mov     [.mii.fMask], MIIM_TYPE
;        mov     [.mii.fType], MFT_SEPARATOR
;        mov     [.mii.wID], NULL
;        lea     eax, [.mii]
;        invoke  InsertMenuItem, [.hMenu], edi, TRUE, eax
;
;.finish:
;        pop     ebx edi esi
;        return
;endp
;
;
;

Changes to opendialog.asm.

171
172
173
174
175
176
177


178
179

180
181
182
183
184
185
186
        stdcall   StrNew
        mov       ebx, eax
        stdcall   StrSetCapacity, ebx, 1024
        test      eax, eax
        jz        .finish

        mov       edi, eax


        stdcall   StrCopy, ebx, [.hFileName]


        xor     edx, edx
        mov     [.opn.lStructSize], sizeof.OPENFILENAME
        mov     eax, [hApplication]
        mov     [.opn.hwndOwner], eax
        mov     [.opn.hInstance], edx
        mov     eax, [.ptrFilter]
        mov     [.opn.lpstrFilter], eax







>
>

<
>







171
172
173
174
175
176
177
178
179
180

181
182
183
184
185
186
187
188
        stdcall   StrNew
        mov       ebx, eax
        stdcall   StrSetCapacity, ebx, 1024
        test      eax, eax
        jz        .finish

        mov       edi, eax
        cmp       [.hFileName], 0
        je        @f
        stdcall   StrCopy, ebx, [.hFileName]

@@:
        xor     edx, edx
        mov     [.opn.lStructSize], sizeof.OPENFILENAME
        mov     eax, [hApplication]
        mov     [.opn.hwndOwner], eax
        mov     [.opn.hInstance], edx
        mov     eax, [.ptrFilter]
        mov     [.opn.lpstrFilter], eax

Added wikipad.cfg.

cannot compute difference between binary files