WikiPad

Check-in [65d5049a14]
Login

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

Overview
Comment:First version of WikiPad.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:65d5049a14c093987c5f1ce7417be0e0b173091a
User & Date: lhmnai0 2011-03-14 14:44:42
Context
2011-03-15
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
14:42
initial empty check-in check-in: f0cccafed5 user: lhmnai0 tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added MainForm.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
;<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
        stc
        return

onmessage WM_COMMAND
        movzx   esi,word [.wparam]
        cmp     esi, FirstID
        jl      .ondefault

        sub     esi,FirstID
        cmp     esi,[MainActionList.Number]
        jge     .ondefault

        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

        stdcall CreateCoolMenu, MainMenu, FALSE
        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_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
        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
        clc
        return

onmessage WM_DESTROY
        invoke  DeleteObject, [hEditorFont]
        clc
        return

endwp

Added ReadMe.txt.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
    This is small Notepad like program,
created using Fresh visual design and 
Fresh graphic libraries for menues
and toolbars.
    It edits .wiki files, providing 
easy to use tag inserting buttons.
	

Added 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


Added WikiPad.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
format PE GUI 4.0
entry start

include "%finc%/win32/win32a.inc"

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/application.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 '%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

  hIml            dd 0
  hImlGray        dd 0
endg

iglobal
  cMainTitle db 'Visual test',0
endg

resAppIcon = 1
resMainToolbar = 2

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

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

        invoke  SendMessage, [hApplication], AM_ONIDLE, 0, 0
        invoke  WaitMessage
        jmp     Run

.terminate:
        push    eax
        FinalizeAll
        invoke  ExitProcess


section '.data' data readable writeable
  data resource from 'resources/resources.res'
  end data

  IncludeAllGlobals


section '.idata' import data readable writeable
 include '%finc%/win32/allimports.asm'

Added WikiPad.exe.

cannot compute difference between binary files

Added WikiPad.fpr.

cannot compute difference between binary files

Added actions.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
184
185
186
187
188
189
190
191
192
ImageChecked = 8

uglobal
  hLoadedFilename dd ?
endg



iglobal

ActionList MainActionList, MainAccels,                                                                             \
  actNew,         0, '&New...',         <Ctrl, 'N'>,         'Creates new file.',          OnNew,               \
  actOpen,        1, '&Open',           <Ctrl, 'O'>,         'Open file',                  OnOpen,              \
  actSave,        2, '&Save',           <Ctrl, 'S'>,         'Save file',                  OnSave,              \
  actSaveAs,     -1, 'Save &As',        <NONE>,              'Save file with new name',    OnSaveAs,            \
  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,                  \
    mfNormal, actSave,                  \
    mfNormal, actSaveAs,                \
    mfSeparator, NONE,                  \
    mfNormal, actExit,                  \
  mfEnd, NONE,                          \
  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,                    \
  bfButton, actUndo,                    \
  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

.parseline:
        mov     ebx, esi        ; line start

.lineloop:
        dec     ecx
        js      .endparse

        lodsb
        cmp     al, $0d
        je      .line
        cmp     al, $0a
        jne     .lineloop

.line:
; skip the line end.
        mov     byte [esi-1], 0
        xor     al, $0d xor $0a
        cmp     byte [esi], al
        jne     @f
        inc     esi
        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 OnCut, .wparam, .lparam
begin
        invoke  SendDlgItemMessage, [hMainForm], idEdit, WM_CUT, 0, 0
        return
endp



proc OnCopy, .wparam, .lparam
begin
        invoke  SendDlgItemMessage, [hMainForm], idEdit, WM_COPY, 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

Added formatting.inc.























>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
Procedure|<span class="procedure">|</span>|Ctrl+P
Register|<span class="register"> |</span>|Ctrl+R
Variable|<span class="variable">|</span>|Ctrl+W
Flag|<span class="flag">|</span>|Ctrl+F
Constant|<span class="constant">|</span>|Ctrl+K
Note|<p class="note">|</p>|Ctrl+N
ToDo|<p class="todo">|</p>|Ctrl+T
Code|<pre class="fasm-code">|</pre>|Ctrl+D
Horiz line|<hr>||Ctrl+Shuft+H
Bold|<b>|</b>|Ctrl+B
Italic|<i>|</i>|Ctrl+I

Added opendialog.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
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
iglobal
  cOpenFileTitle text 'Open file:'
  cSaveFileTitle text 'Save file as:'
  cBackSlash text '\'
  WikiFilter:
        db 'Fossil Wiki page (*.wiki)', 0, '*.wiki',0
        db 'All files (*.*)', 0, '*.*',0
        db 0
  ShortcutFilter:
        db 'Tag shortcut file (*.cfg)', 0, '*.cfg',0
        db 'All files (*.*)', 0, '*.*',0
        db 0
  cOpenDialogError text 'Error show open dialog.'
endg


cFilenameBufferSize = 4096


proc OpenFilesDialog, .ptrTitle, .MultiSelect, .ptrFilter, .ptrCallBack, .hFileName, .lParam
.opn OPENFILENAME
.str rb 1024
.ptr dd ?
.errcnt dd ?
.oldwin dd ?
begin
        mov     [.errcnt], 0

        invoke  GetActiveWindow
        mov     [.oldwin], eax

; Allocate memory for filename buffer.
        stdcall GetMem, cFilenameBufferSize
        mov     edi, eax

        mov     [.opn.lpstrInitialDir], 0

        cmp     [.hFileName], 0
        je      .setstructure

        stdcall StrPtr, [.hFileName]
        lea     ecx, [.str]
        mov     [.opn.lpstrInitialDir], ecx
        lea     edx, [.ptr]
        invoke  GetFullPathName, eax, 1024, ecx, edx
        test    eax, eax
        jz      .setstructure

        mov     esi, [.ptr]
        test    esi, esi
        jz      .setstructure

        mov     byte [esi-1], 0

        push    edi

.copyname:
        lodsb
        stosb
        test    al,al
        jnz     .copyname

        pop     edi

.setstructure:
        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
        mov     [.opn.lpstrCustomFilter], edx
        mov     [.opn.nFilterIndex], 1
        mov     [.opn.lpstrFile], edi
        mov     [.opn.nMaxFile], cFilenameBufferSize
        mov     [.opn.lpstrFileTitle], edx
        mov     [.opn.nMaxFileTitle], edx
        mov     eax, [.ptrTitle]
        mov     [.opn.lpstrTitle], eax
        mov     [.opn.Flags], OFN_EXPLORER or           \
                              OFN_HIDEREADONLY or       \
                              OFN_NOCHANGEDIR or        \
                              OFN_FILEMUSTEXIST

        cmp     [.MultiSelect], FALSE
        je      @f
        or      [.opn.Flags], OFN_ALLOWMULTISELECT
@@:
        mov     [.opn.lpstrDefExt], edx
        mov     [.opn.lCustData], edx
        mov     [.opn.lpfnHook], edx

.retry:
        lea     eax, [.opn]
        invoke  GetOpenFileName, eax
        push    eax
        invoke  SetActiveWindow, [.oldwin]      ; restore the old active window.

        pop     eax
        test    eax, eax
        jnz     @f

; Error open dialog or simply cancel...
        invoke  CommDlgExtendedError
        test    eax, eax
        jz      .finish

        cmp     eax, $3002
        jne     .errbox

        cmp     [.errcnt], 0
        jne     .errbox

        mov     [.opn.lpstrInitialDir], 0
        inc     [.errcnt]
        jmp     .retry

.errbox:
        invoke  MessageBox, [hApplication], cOpenDialogError, NULL, MB_ICONERROR or MB_OK
        jmp     .finish

@@:
; Get file(s) path.

        movzx   esi, [.opn.nFileOffset]
        add     esi, edi
        cmp     byte [esi-1], 0                 ; if 0 then more than one file is selected.
        je      .multyfile                      ; The ebx string contains the filename.

; only one file to read:
        stdcall [.ptrCallBack], edi, [.lParam]
        jmp     .finish

.multyfile:
        stdcall StrNew
        mov     ebx, eax

.fileloop:
        cmp     byte [esi], 0
        je      .endfiles

        stdcall StrCopy, ebx, edi               ; path
        stdcall StrCat, ebx, cBackSlash         ; '\'
        stdcall StrCat, ebx, esi                ; path + name

        stdcall [.ptrCallBack], ebx, [.lParam]

.findend:
        lodsb
        test    al,al
        jnz     .findend
        jmp     .fileloop

.endfiles:
        stdcall StrDel, ebx

.finish:
;Free filename buffer
        stdcall FreeMem, edi
        return
endp



proc SaveFileDialog, .ptrTitle, .ptrFilter, .hFileName
.opn OPENFILENAME
begin
; Allocate memory for filename buffer.
        push      esi edi ebx
        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
        mov     [.opn.lpstrCustomFilter], edx
        mov     [.opn.nFilterIndex], 1
        mov     [.opn.lpstrFile], edi
        mov     [.opn.nMaxFile], 1024
        mov     [.opn.lpstrFileTitle], edx
        mov     [.opn.nMaxFileTitle], edx
        mov     [.opn.lpstrInitialDir], edx
        mov     eax, [.ptrTitle]
        mov     [.opn.lpstrTitle], eax
        mov     [.opn.Flags], OFN_EXPLORER or           \
                              OFN_HIDEREADONLY or       \
                              OFN_NOREADONLYRETURN or   \
                              OFN_NOCHANGEDIR
        mov     [.opn.lpstrDefExt], edx
        mov     [.opn.lCustData], edx
        mov     [.opn.lpfnHook], edx

        lea     eax, [.opn]
        invoke  GetSaveFileName, eax
        test    eax, eax
        jz      .finish

        stdcall StrFixLen, ebx
        mov     eax, ebx
.finish:
        pop     ebx edi esi
        return
endp



proc SelectPathDialog, .hOwner, .hTitle, .hPath
.bi BROWSEINFO
.str rb 256
.path rb 1024
.IMalloc dd ?
begin
        push    esi edi
        mov     eax, [.hOwner]
        lea     esi, [.str]
        mov     [.bi.hwndOwner], eax
        mov     [.bi.pidlRoot], 0

        mov     [.bi.pszDisplayName], esi
        stdcall StrPtr, [.hTitle]
        mov     [.bi.lpszTitle], eax
        mov     [.bi.ulFlags], BIF_RETURNONLYFSDIRS
        mov     [.bi.lpfn], _BrowseFolderProc
        lea     eax, [.hOwner]
        mov     [.bi.lParam], eax

        lea     eax, [.bi]
        invoke  SHBrowseForFolder, eax
        test    eax, eax
        jz      .finish

        push    eax

        lea     edi, [.path]
        xor     esi, esi
        invoke  SHGetPathFromIDList, eax, edi
        test    eax, eax
        jz      .memfree

        stdcall StrDup, edi
        mov     esi, eax

.memfree:
        invoke  CoTaskMemFree ; From the stack
        mov     eax, esi

.finish:
        pop     edi esi
        return
endp


proc _BrowseFolderProc, .hwnd, .wmsg, .lparam, .lpData
begin
        cmp     [.wmsg], BFFM_INITIALIZED
        jne     .finish

        mov     esi, [.lpData] ; This is pointer to arguments of SelectPathDialog
        stdcall StrPtr, [esi+4]
        invoke  SendMessage, [.hwnd], WM_SETTEXT, 0, eax
        stdcall StrPtr, [esi+8]
        invoke  SendMessage, [.hwnd], BFFM_SETSELECTION, TRUE, eax

.finish:
        xor     eax, eax
        return
endp

Added resources/minimalistic.gif.

cannot compute difference between binary files

Added resources/resources.res.

cannot compute difference between binary files

Added resources/turtlemini.ico.

cannot compute difference between binary files