Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

251 lines
6.7 KiB

  1. /*===========================================================================*/
  2. /* Copyright (c) 1987 - 1988, Future Soft Engineering, Inc. */
  3. /* Houston, Texas */
  4. /*===========================================================================*/
  5. #define NOLSTRING TRUE /* jtf win3 mod */
  6. #include <windows.h>
  7. #include "port1632.h"
  8. #include "dcrc.h"
  9. #include "dynacomm.h"
  10. #include "fileopen.h"
  11. #include "task.h"
  12. #include <direct.h> /* adding this for getcwd prototype - sdj */
  13. /*---------------------------------------------------------------------------*/
  14. /* File Document Data Routines [mbb] */
  15. /*---------------------------------------------------------------------------*/
  16. VOID getFileDocData(FILEDOCTYPE fileDocType, BYTE *filePath, BYTE *fileName,
  17. BYTE *fileExt, BYTE *title)
  18. {
  19. if(filePath != NULL)
  20. strcpy(filePath, fileDocData[fileDocType].filePath);
  21. if(fileName != NULL)
  22. strcpy(fileName, fileDocData[fileDocType].fileName);
  23. if(fileExt != NULL)
  24. strcpy(fileExt, fileDocData[fileDocType].fileExt);
  25. if(title != NULL)
  26. strcpy(title, fileDocData[fileDocType].title);
  27. }
  28. VOID setFileDocData(FILEDOCTYPE fileDocType, BYTE *filePath, BYTE *fileName,
  29. BYTE *fileExt, BYTE *title)
  30. {
  31. if(filePath != NULL)
  32. strcpy(fileDocData[fileDocType].filePath, filePath);
  33. if(fileName != NULL)
  34. strcpy(fileDocData[fileDocType].fileName, fileName);
  35. if(fileExt != NULL)
  36. strcpy(fileDocData[fileDocType].fileExt, fileExt);
  37. if(title != NULL)
  38. {
  39. if(strlen(title) >= FO_MAXPATHLENGTH)
  40. title[FO_MAXPATHLENGTH-1] = 0;
  41. strcpy(fileDocData[fileDocType].title, title);
  42. }
  43. }
  44. VOID getDataPath(FILEDOCTYPE fileDocType, BYTE *filePath, BYTE *fileName)
  45. {
  46. BYTE savePath[FO_MAXPATHLENGTH];
  47. if(setPath(fileDocData[fileDocType].filePath, FALSE, savePath))
  48. {
  49. setFilePath(fileName);
  50. #ifdef ORGCODE
  51. _getcwd(filePath);
  52. #else
  53. _getcwd(filePath,PATHLEN);
  54. #endif
  55. setPath(savePath, FALSE, NULL);
  56. }
  57. }
  58. /*---------------------------------------------------------------------------*/
  59. /* dbFileType() - [mbb] */
  60. /*---------------------------------------------------------------------------*/
  61. BOOL APIENTRY dbFileType(HWND hDlg, UINT message, WPARAM wParam, LONG lParam)
  62. //HWND hDlg;
  63. //UINT message;
  64. //WPARAM wParam;
  65. //LONG lParam;
  66. {
  67. updateTimer();
  68. switch(message)
  69. {
  70. case WM_INITDIALOG:
  71. initDlgPos(hDlg);
  72. switch(saveFileType)
  73. {
  74. case FILE_NDX_SETTINGS:
  75. wParam = ITMSETTINGS;
  76. break;
  77. }
  78. return(TRUE);
  79. case WM_COMMAND:
  80. switch(GET_WM_COMMAND_ID(wParam, lParam))
  81. {
  82. case IDOK:
  83. switch(whichGrpButton(hDlg, ITMSETTINGS, ITMMEMO))
  84. {
  85. case ITMSETTINGS:
  86. wParam = FILE_NDX_SETTINGS;
  87. break;
  88. }
  89. break;
  90. case IDCANCEL:
  91. wParam = FALSE;
  92. break;
  93. default:
  94. return(TRUE);
  95. }
  96. break;
  97. default:
  98. return(FALSE);
  99. }
  100. EndDialog(hDlg, wParam);
  101. return(TRUE);
  102. }
  103. /*---------------------------------------------------------------------------*/
  104. /* doFileNew() - [mbb] */
  105. /*---------------------------------------------------------------------------*/
  106. VOID doFileNew()
  107. {
  108. INT fileType;
  109. BYTE szTitle[MINRESSTR];
  110. fileType = FILE_NDX_SETTINGS;
  111. if(childZoomStatus(0x0001, 0))
  112. childZoomStatus(0, 0x8000);
  113. LoadString(hInst, STR_TERMINAL, szTitle, MINRESSTR);
  114. termFile(fileDocData[fileType].filePath, NULL_STR, fileDocData[fileType].fileExt,
  115. (*fileDocData[fileType].title == 0) ? szTitle : fileDocData[fileType].title,
  116. (*fileDocData[fileType].title == 0) ? TF_DEFTITLE : 0);
  117. }
  118. /*---------------------------------------------------------------------------*/
  119. /* doFileOpen() - [mbb] */
  120. /*---------------------------------------------------------------------------*/
  121. INT_PTR APIENTRY FO_FileOpenType(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  122. {
  123. INT fileType;
  124. switch(message)
  125. {
  126. case WM_INITDIALOG:
  127. switch(pFOData->nType = saveFileType)
  128. {
  129. case FILE_NDX_SETTINGS:
  130. wParam = FO_IDSETTINGS;
  131. break;
  132. }
  133. break;
  134. case WM_COMMAND:
  135. switch(GET_WM_COMMAND_ID(wParam, lParam))
  136. {
  137. case FO_IDSETTINGS:
  138. fileType = FILE_NDX_SETTINGS;
  139. break;
  140. default:
  141. return(TRUE);
  142. }
  143. if(pFOData->nType == fileType)
  144. return(TRUE);
  145. pFOData->nType = fileType;
  146. break;
  147. case WM_NULL:
  148. if(wParam)
  149. saveFileType = pFOData->nType;
  150. return(FALSE);
  151. }
  152. return(FALSE);
  153. }
  154. VOID doFileOpen()
  155. {
  156. BYTE filePath[FO_MAXPATHLENGTH];
  157. BYTE fileName[FO_MAXFILELENGTH];
  158. BYTE fileExt[FO_MAXEXTLENGTH];
  159. BYTE szTitle[MINRESSTR];
  160. *filePath = 0;
  161. *fileName = 0;
  162. *fileExt = 0;
  163. strcpy(fileName, "*.TRM");
  164. strcpy(fileExt, "TRM");
  165. if(termData.filePath[strlen(termData.filePath) - 1] != '\\')
  166. strcat(termData.filePath, "\\");
  167. if(FileOpen(termData.filePath, fileName, NULL, fileExt, NULL, FO_DBFILETYPE,
  168. FO_FileOpenType, FO_FILEEXIST | FO_FORCEEXTENT))
  169. {
  170. strcpy(fileDocData[saveFileType].filePath, filePath);
  171. strcpy(fileDocData[saveFileType].fileName, fileName);
  172. if(childZoomStatus(0x0001, 0))
  173. childZoomStatus(0, 0x8000);
  174. LoadString(hInst, STR_TERMINAL, szTitle, MINRESSTR);
  175. termFile(termData.filePath, fileName, fileDocData[FILE_NDX_SETTINGS].fileExt,
  176. (*fileDocData[FILE_NDX_SETTINGS].title == 0) ? szTitle : fileDocData[FILE_NDX_SETTINGS].title,
  177. (*fileDocData[FILE_NDX_SETTINGS].title == 0) ? TF_DEFTITLE : 0);
  178. }
  179. }
  180. /*---------------------------------------------------------------------------*/
  181. /* doFileClose() - [mbb] */
  182. /*---------------------------------------------------------------------------*/
  183. VOID doFileClose()
  184. {
  185. termCloseFile();
  186. }
  187. /*---------------------------------------------------------------------------*/
  188. /* doFileSave() - [mbb] */
  189. /*---------------------------------------------------------------------------*/
  190. VOID doFileSave()
  191. {
  192. termSaveFile(FALSE);
  193. }
  194. /*---------------------------------------------------------------------------*/
  195. /* doFileSaveAs() - [mbb] */
  196. /*---------------------------------------------------------------------------*/
  197. VOID doFileSaveAs()
  198. {
  199. termSaveFile(TRUE);
  200. }