1 /****************************************************************************
2 PURPOSE: Filename Dialog
3 */
4
5 /* #include "windows.h" */
6 #include "psllw.h"
7
8
9 extern HANDLE hInst;
10 extern HWND hWnd;
11 extern char dir[];
12 extern LPSTR banner;
13 extern int storedir;
14 char title[120];
15 extern char *argv[];
16 extern char *iname;
17 extern int ScriptFile;
18 LPSTR comment=NULL;
19 extern char ahead_buf[];
20
21 /* Additional includes needed for the fstat() function */
22
23 #include <sys\types.h>
24 #include <sys\stat.h>
25
26 extern char FileName[];
27 char DefPath [128];
28 char ActPath [128];
29 char str[128];
30 char DefSpec[5] = "*.red";
31 char DefExt[5] = "";
32 char OpenName[128];
33
34
35
36 /****************************************************************************
37
38 FUNCTION: FileDlg(HWND, unsigned, WORD, LONG)
39
40 PURPOSE: Allows user to select a file name
41
42 COMMENTS:
43
44 This will initialize the window class if it is the first time this
45 application is run. It then creates the window, and processes the
46 message loop until a PostQuitMessage is received. It exits the
47 application by returning the value passed by the PostQuitMessage.
48
49 ****************************************************************************/
50
FileDlg(hDlg,message,wParam,lParam)51 int WINAPI FileDlg(hDlg, message, wParam, lParam)
52 HWND hDlg;
53 UINT message;
54 UINT wParam;
55 LONG lParam;
56 {
57 char TempName[128];
58 int name_found;
59
60 switch (message) {
61 case WM_INITDIALOG:
62
63 /* Process the path to fit within the IDC_PATH field */
64
65 if(comment)
66 SetDlgItemText(hDlg, IDC_PATH, comment);
67 else
68 DlgDirList(hDlg, DefPath, NULL, IDC_PATH, 0x4010);
69
70 /* Send the current filename to the edit control */
71
72 SetDlgItemText(hDlg, IDC_EDIT, FileName);
73
74 /* Accept all characters in the edit control */
75
76 SendDlgItemMessage(hDlg, IDC_EDIT, EM_SETSEL, 0,
77 MAKELONG(0, 0x7fff));
78
79
80 EnableWindow(GetDlgItem(hDlg, IDOK), TRUE);
81
82 /* Set the focus to the edit control within the dialog box */
83
84 SetFocus(GetDlgItem(hDlg, IDC_EDIT));
85 return (FALSE); /* FALSE since Focus was changed */
86
87 case WM_COMMAND:
88 switch (wParam) {
89 case IDC_EDIT:
90
91 return (TRUE);
92
93 case IDOK:
94
95 GetDlgItemText(hDlg, IDC_EDIT, FileName, 128);
96 EndDialog(hDlg, IDOK);
97 return (TRUE);
98
99 case IDCANCEL:
100
101 /* Tell the caller the user canceled the SaveAs function */
102
103 EndDialog(hDlg, IDCANCEL);
104 return (TRUE);
105 }
106 break;
107
108 }
109 return (FALSE);
110 }
111
read_parameter(char * s)112 read_parameter(char* s)
113 {
114 FARPROC lpFileDlg;
115 int r;
116
117 comment = s;
118 lpFileDlg = MakeProcInstance((FARPROC) FileDlg, hInst);
119 r = DialogBox(hInst, "ReadParameter", hWnd, lpFileDlg);
120 FreeProcInstance(lpFileDlg);
121 comment = NULL;
122 if(r=IDOK) return(1); else return(0);
123 }
124
125
126 /*------------------------------------------------------------------
127 Directory service
128 ------------------------------------------------------------------*/
129
130 char * expand_file_name(char * filename);
131
my_cd(char * filename,int mode)132 my_cd(char * filename,int mode)
133 {
134 int d; char c;
135
136 filename = expand_file_name(filename);
137 if(filename[1] == ':')
138 { c=filename[0];
139 if(c>= 'a') d=c-'a'; else d=c-'A';
140 _chdrive(d+1);
141 filename = filename + 2;
142 };
143 _chdir(filename);
144 set_dir();
145 if(mode) WriteProfileString("PSLLW","DIR",dir);
146 set_title();
147 }
148
set_dir()149 set_dir()
150 {
151 Wgwd(dir);
152 }
153
154 /*------------------------------------------------------------------
155 YESP
156 ------------------------------------------------------------------*/
157
yesp(LPSTR text1)158 yesp(LPSTR text1)
159 { return(yesp2(text1,(LPSTR) ""));}
160
161 LPSTR tx1,tx2;
162
yesp2(LPSTR text1,LPSTR text2)163 yesp2(LPSTR text1,LPSTR text2)
164 {
165 FARPROC lpYespDlg;
166 int r;
167
168 tx1 = text1;
169 tx2 = text2;
170 lpYespDlg = MakeProcInstance((FARPROC) YespDlg, hInst);
171 r = DialogBox(hInst, "Yesp", hWnd, lpYespDlg);
172 FreeProcInstance(lpYespDlg);
173 if(r==IDOK) return(1); else return(0); ;
174 }
175
YespDlg(hDlg,message,wParam,lParam)176 int WINAPI YespDlg(hDlg, message, wParam, lParam)
177 HWND hDlg;
178 UINT message;
179 UINT wParam;
180 LONG lParam;
181 {
182 switch (message) {
183 case WM_INITDIALOG:
184
185
186 /* Send the current filename to the edit control */
187 SetDlgItemText(hDlg, IDC_PATH, tx1);
188 SetDlgItemText(hDlg, IDC_EDIT, tx2);
189 EnableWindow(GetDlgItem(hDlg, IDOK), TRUE);
190 SetFocus(GetDlgItem(hDlg, IDC_EDIT));
191 return (FALSE); /* FALSE since Focus was changed */
192
193 case WM_COMMAND:
194 switch (wParam) {
195 case IDC_EDIT:
196 return (TRUE);
197
198 case IDOK:
199 case IDCANCEL:
200 EndDialog(hDlg, wParam);
201 return (TRUE);
202
203 }
204 break;
205
206 }
207 return (FALSE);
208 }
209
filep(LPSTR name)210 filep(LPSTR name)
211 { int f;
212 if((f=_lopen(name,OF_READ))==-1) return(0);
213 _lclose(f); return(1);
214 }
215
set_title()216 set_title()
217 { int i,j;
218 set_dir();
219 strcpy(title, "LISP: ");
220 i = strlen(title);
221 for(j=0; dir[j]; j++) title[i+j] = dir[j];
222 title[i+j++]='\\';
223 title[i+j++]='.'; title[i+j++]='.'; title[i+j++]='.';
224 title[i+j] = '\0';
225 SetWindowText(hWnd,title);
226 }
227
askUser(char * question)228 askUser(char * question)
229 {
230 FARPROC lpFileDlg;
231 int r;
232 comment = question;
233 // FileName[0] = '\0';
234 //WN lpFileDlg = MakeProcInstance((FARPROC) FileDlg, hInst);
235 r = DialogBox(hInst, "AskUser", hWnd,(DLGPROC) FileDlg);
236 FreeProcInstance(lpFileDlg);
237 return(r == IDOK);
238 }
239
240
askUser0(char * question)241 askUser0(char * question)
242 {
243 FileName[0] = '\0';
244 return askUser(question);
245 }
246