WikiPad

Check-in [60fdc677a1]
Login

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

Overview
Comment:First fully functional version. One can edit read files with it. :)
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:60fdc677a18ad524aeb1159039eb65e8b0e8eee8
User & Date: JohnFound 2011-03-15 22:31:47
Context
2011-03-16
06:53
Removed WS_DISABLE from the listbox. check-in: a2aa4f44b4 user: JohnFound tags: trunk
2011-03-15
22:31
First fully functional version. One can edit read files with it. :) check-in: 60fdc677a1 user: JohnFound tags: trunk
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
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to MainForm.frm.

1
2
3
4
5
6
7
8
9
10
11
..
15
16
17
18
19
20
21




22
23
24
25
26
27
28
..
40
41
42
43
44
45
46

47
48
49
50
51
52
53
..
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
...
102
103
104
105
106
107
108
























































































109
110
111
112
113
114
115
;<ff
Window Form1, 3, 0, 'TForm', 'Wiki editor:', $16CF0000, $0, 0, 247, 95, 550, 409, Form1WinProc;
Window NONE, 0, 5, 'EDIT', '', $56201104, $200, 100, 120, 0, 422, 382, EditWinProc;
Window NONE, 2, 1, 'LISTBOX', 'Listbox', $508005C3, $200, 200, 0, 0, 120, 382, 0;
;ff>
idEdit = 100
idShortcuts = 200

cEditorFontFace text 'FreshBold'


................................................................................
  hMainToolbar dd ?

  hEditorFont dd ?

  hShortcuts dd ?
  hEditor dd ?
endg






winproc Form1WinProc
begin

ondefault
        stc
................................................................................
        imul    esi,sizeof.TAction
        add     esi,MainActionList

        stdcall [esi+TAction.OnExecute], [.wparam], [.lparam]
        xor     eax, eax
        clc
        return


onmessage AM_INITWINDOW
        stdcall ImageList_LoadGif, [hInstance], resMainToolbar, 16, FALSE
        mov     [hIml], eax

        stdcall ImageList_LoadGif, [hInstance], resMainToolbar, 16, TRUE
        mov     [hImlGray],eax
................................................................................
        mov     [hMainMenu], eax
        invoke  SetMenu, [.hwnd], eax

        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_SETFOCUS

        invoke  SetFocus, [hEditor]
        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
................................................................................

winproc EditWinProc
begin

ondefault
        stc
        return

























































































onmessage AM_INITWINDOW
        invoke  SetProp, [.hwnd], [propOwnFont], 1

        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
        invoke  SendMessage, [.hwnd], WM_SETFONT, [hEditorFont], 1


|
|







 







>
>
>
>







 







>







 







>
>
>


>












|
<







 







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







1
2
3
4
5
6
7
8
9
10
11
..
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
..
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
..
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
...
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
;<ff
Window Form1, 3, 0, 'TForm', 'Wiki editor:', $16CF0000, $0, 0, 247, 95, 550, 409, Form1WinProc;
Window NONE, 0, 5, 'EDIT', '', $56301104, $200, 100, 120, 0, 422, 382, EditWinProc;
Window NONE, 2, 1, 'LISTBOX', 'Listbox', $588005C3, $200, 200, 0, 0, 120, 382, 0;
;ff>
idEdit = 100
idShortcuts = 200

cEditorFontFace text 'FreshBold'


................................................................................
  hMainToolbar dd ?

  hEditorFont dd ?

  hShortcuts dd ?
  hEditor dd ?
endg

iglobal
  property propIgnoreNext, 'IGNORENEXT'
endg


winproc Form1WinProc
begin

ondefault
        stc
................................................................................
        imul    esi,sizeof.TAction
        add     esi,MainActionList

        stdcall [esi+TAction.OnExecute], [.wparam], [.lparam]
        xor     eax, eax
        clc
        return


onmessage AM_INITWINDOW
        stdcall ImageList_LoadGif, [hInstance], resMainToolbar, 16, FALSE
        mov     [hIml], eax

        stdcall ImageList_LoadGif, [hInstance], resMainToolbar, 16, TRUE
        mov     [hImlGray],eax
................................................................................
        mov     [hMainMenu], eax
        invoke  SetMenu, [.hwnd], eax

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

        invoke  CreateAcceleratorTable, MainAccels, [MainAccels.Count]
        invoke  SetProp, [hApplication], [propAccelerators], eax

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


        clc
        return

onmessage WM_SETFOCUS

        invoke  SetFocus, [hEditor]
        clc
        return


onmessage WM_CLOSE
        stdcall OnExit, 0, 0

        clc
        return


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

winproc EditWinProc
begin

ondefault
        stc
        return

onmessage WM_CHAR

        invoke  GetProp, [.hwnd], [propIgnoreNext]
        test    eax, eax
        jz      .ondefault

        invoke  SetProp, [.hwnd], [propIgnoreNext], 0

        xor     eax, eax
        clc
        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
; now insert the tag...

locals
  .beg dd ?
  .end dd ?
  .ins dd ?
endl
        lea     eax, [.beg]
        lea     ecx, [.end]
        invoke  SendMessage, [.hwnd], EM_GETSEL, eax, ecx

        mov     eax, [.beg]
        cmp     eax, [.end]

        invoke  SendMessage, [.hwnd], 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, [.hwnd], EM_REPLACESEL, TRUE, eax

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

        stdcall StrPtr, [esi+TShortcutItem.hOpenTag]
        invoke  SendMessage, [.hwnd], EM_REPLACESEL, TRUE, eax

        mov     eax, [.beg]
        cmp     eax, [.end]
        je      .posok

        mov     eax, [.end]
        add     eax, [.ins]
        invoke  SendMessage, [.hwnd], EM_SETSEL, eax, eax

.posok:
        invoke  SetProp, [.hwnd], [propIgnoreNext], 1

        xor     eax,eax
        clc
        return

onmessage AM_INITWINDOW
        invoke  SetProp, [.hwnd], [propOwnFont], 1

        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
        invoke  SendMessage, [.hwnd], WM_SETFONT, [hEditorFont], 1

Changes to ShortcutEngine.asm.

2
3
4
5
6
7
8



























9
10
11
12
13
14
15
...
383
384
385
386
387
388
389




  .hCaption    dd ?
  .hOpenTag    dd ?
  .hCloseTag   dd ?
  .HotKey      dd ?
ends






























proc DestroyShortcuts
begin
        invoke  SendMessage, [hShortcuts], LB_GETCOUNT, 0, 0
        mov     ebx, eax
.loop:
        dec     ebx
................................................................................
        stdcall StrPtr, ebx
        invoke  SendMessage, [hShortcuts], LB_ADDSTRING, 0, eax
        stdcall StrDel, ebx

        pop     ebx esi
        return
endp











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







 







>
>
>
>
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
...
410
411
412
413
414
415
416
417
418
419
420
  .hCaption    dd ?
  .hOpenTag    dd ?
  .hCloseTag   dd ?
  .HotKey      dd ?
ends



proc SearchHotKey, .hotkey
begin

        invoke  SendMessage, [hShortcuts], LB_GETCOUNT, 0, 0
        mov     ebx, eax

.loop:  dec     ebx
        js      .finish

        invoke  SendMessage, [hShortcuts], LB_GETITEMDATA, ebx, 0
        test    eax, eax
        jz      .loop

        mov     ecx, [eax+TShortcutItem.HotKey]
        cmp     ecx, [.hotkey]
        jne     .loop

        clc
        return

.finish:
        stc
        return
endp



proc DestroyShortcuts
begin
        invoke  SendMessage, [hShortcuts], LB_GETCOUNT, 0, 0
        mov     ebx, eax
.loop:
        dec     ebx
................................................................................
        stdcall StrPtr, ebx
        invoke  SendMessage, [hShortcuts], LB_ADDSTRING, 0, eax
        stdcall StrDel, ebx

        pop     ebx esi
        return
endp




Changes to WikiPad.asm.

42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
..
62
63
64
65
66
67
68


69
70
71
72
73
74
75
  hHeap           dd 0

  hIml            dd 0
  hImlGray        dd 0
endg

iglobal
  cMainTitle db 'Visual test',0
endg

resAppIcon = 1
resMainToolbar = 2

start:
        invoke  GetModuleHandle,0
................................................................................
        invoke  InitCommonControls      ;Ex, ComCtrlsFlags

        InitializeAll
        stdcall InitApplication, resAppIcon, cMainTitle

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



;----------------------------------------------
; Main message loop
;----------------------------------------------
Run:
        call    ProcessMessages
        jc      .terminate







|







 







>
>







42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
..
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
  hHeap           dd 0

  hIml            dd 0
  hImlGray        dd 0
endg

iglobal
  cMainTitle db 'WikiPad editor',0
endg

resAppIcon = 1
resMainToolbar = 2

start:
        invoke  GetModuleHandle,0
................................................................................
        invoke  InitCommonControls      ;Ex, ComCtrlsFlags

        InitializeAll
        stdcall InitApplication, resAppIcon, cMainTitle

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

        invoke  SetProp, [hApplication], [propOnIdle], OnIdle

;----------------------------------------------
; Main message loop
;----------------------------------------------
Run:
        call    ProcessMessages
        jc      .terminate

Changes to WikiPad.exe.

cannot compute difference between binary files

Changes to actions.asm.

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
...
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
...
188
189
190
191
192
193
194
195
196
197
198
199
200
201
  bfSeparator, NONE,                    \
  bfButton, actCut,                     \
  bfButton, actCopy,                    \
  bfButton, actPaste,                   \
  bfSeparator, NONE
endg



proc OnNew, .wparam, .lparam
begin
        invoke  SendDlgItemMessage, [hMainForm], 1, WM_SETTEXT, 0, 0











        return
endp































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

        stdcall LoadBinaryFile, [.name]
        mov     esi, eax
        push    eax
................................................................................
        dec     ecx
@@:
        stdcall StrCat, [.src], ebx
        stdcall StrCharCat, [.src], $0a0d
        jmp     .parseline

.endparse:





        stdcall FreeMem ; from the stack.

        stdcall StrPtr, [.src]
        invoke  SendDlgItemMessage, [hMainForm], idEdit, WM_SETTEXT, 0, eax
        stdcall StrDel, [.src]
        return
endp






















proc OnSave, .wparam, .lparam
begin
        invoke  MessageBox, [hMainForm], cMessageAction, cMessageTitle, MB_ICONINFORMATION or MB_OK





        return
endp



proc OnSaveAs, .wparam, .lparam
begin
        invoke  MessageBox, [hMainForm], cMessageAction, cMessageTitle, MB_ICONINFORMATION or MB_OK











        return
endp



proc OnExit, .wparam, .lparam
begin







        invoke  PostMessage, [hApplication], WM_CLOSE, 0, 0
        return
endp



















proc OnUndo, .wparam, .lparam
begin
        invoke  SendDlgItemMessage, [hMainForm], idEdit, EM_UNDO, 0, 0
        return
endp

................................................................................

proc OnPaste, .wparam, .lparam
begin
        invoke  SendDlgItemMessage, [hMainForm], idEdit, WM_PASTE, 0, 0
        return
endp




iglobal
  cMessageTitle  db 'Just example.', 0
  cMessageAction db 'So, this is simply example. You have to write this action handler yourself. Check "actions.asm" to see where you should code it.', 0
endg







>



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





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












>







 







>
>
>
>
>



|







>
>
>
>

>
>
>

>
>
>

>
>
>
>

<
<
<
>
>
>
>
>







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







>
>
>
>
>
>
>


<

>
>
>
>

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







 







<
<
<
<
<
<
<
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
...
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
...
281
282
283
284
285
286
287







  bfSeparator, NONE,                    \
  bfButton, actCut,                     \
  bfButton, actCopy,                    \
  bfButton, actPaste,                   \
  bfSeparator, NONE
endg



proc OnNew, .wparam, .lparam
begin
        invoke  SendMessage, [hEditor], WM_SETTEXT, 0, 0
        stdcall StrDel, [hLoadedFilename]
        mov     [hLoadedFilename], 0
        stdcall UpdateTitle
        return
endp



proc OnIdle
begin
        stdcall UpdateTitle
        return
endp




cEditorTitle text 'Wikipad: '
cModified    text ' [modified]'

proc UpdateTitle
begin
        stdcall StrDup, cEditorTitle
        mov     ebx, eax

        cmp     [hLoadedFilename], 0
        je      @f

        stdcall StrCat, ebx, [hLoadedFilename]

@@:
        invoke  SendMessage, [hEditor], EM_GETMODIFY, 0, 0
        test    eax, eax
        jz      @f
        stdcall StrCat, ebx, cModified
@@:
        stdcall StrPtr, ebx
        invoke  SendMessage, [hMainForm], WM_SETTEXT, 0, eax
        stdcall StrDel, ebx

        return
endp


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 UpdateTitle

        stdcall StrNew
        mov     [.src], eax

        stdcall LoadBinaryFile, [.name]
        mov     esi, eax
        push    eax
................................................................................
        dec     ecx
@@:
        stdcall StrCat, [.src], ebx
        stdcall StrCharCat, [.src], $0a0d
        jmp     .parseline

.endparse:
        cmp     esi, ebx
        je      .lastok
        mov     byte [esi], 0
        stdcall StrCat, [.src], ebx
.lastok:
        stdcall FreeMem ; from the stack.

        stdcall StrPtr, [.src]
        invoke  SendMessage, [hEditor], WM_SETTEXT, 0, eax
        stdcall StrDel, [.src]
        return
endp




proc OnSave, .wparam, .lparam
begin
        cmp     [hLoadedFilename], 0
        jne     .save

        stdcall OnSaveAs, 1, 0
        cmp     [hLoadedFilename], 0
        je      .nosave

.save:
        stdcall GetControlText, [hEditor], 0
        push    eax

        stdcall StrPtr, eax
        mov     ecx, eax
        stdcall StrPtr, [hLoadedFilename]
        stdcall SaveBinaryFile, eax, ecx, [ecx+string.len]




        stdcall StrDel ; from the stack.

        invoke  SendMessage, [hEditor], EM_SETMODIFY, 0, 0

.nosave:
        return
endp



proc OnSaveAs, .wparam, .lparam
begin
        stdcall SaveFileDialog, cSaveFileTitle, WikiFilter, [hLoadedFilename]
        test    eax, eax
        jz      .exit

        stdcall SetString, hLoadedFilename, eax
        stdcall StrDel, eax
        stdcall UpdateTitle

        cmp     [.wparam], 1
        je      .exit
        stdcall OnSave, 0, 0
.exit:
        return
endp



proc OnExit, .wparam, .lparam
begin

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

.exit:
        invoke  PostMessage, [hApplication], WM_CLOSE, 0, 0
        return


.noexit:
        invoke  MessageBox, [hMainForm], cErrorNotSaved, cTitleNotSaved, MB_YESNOCANCEL or MB_ICONQUESTION
        cmp     eax, MR_NO
        je      .exit

        cmp     eax, MR_CANCEL
        je      .finish

        stdcall OnSave, 0, 0
        jmp     .check

.finish:
        return
endp

cErrorNotSaved text 'The current file is not saved. Do you want to save it before exit?',0
cTitleNotSaved text 'Do you want to save?'

proc OnUndo, .wparam, .lparam
begin
        invoke  SendDlgItemMessage, [hMainForm], idEdit, EM_UNDO, 0, 0
        return
endp

................................................................................

proc OnPaste, .wparam, .lparam
begin
        invoke  SendDlgItemMessage, [hMainForm], idEdit, WM_PASTE, 0, 0
        return
endp