From: Dirk B. <db...@us...> - 2005-08-31 17:03:29
|
Update of /cvsroot/win32forth/win32forth/apps/SciEdit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18856/apps/SciEdit Modified Files: CommandID.f EdCommand.f EdMenu.f EdVersion.f Main.f ScintillaHyperMDI.f ScintillaMDI.f Log Message: SciEdit - New options "Remove trailing white space" and "Ensure final line ending", and some bugfixes Index: EdVersion.f =================================================================== RCS file: /cvsroot/win32forth/win32forth/apps/SciEdit/EdVersion.f,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** EdVersion.f 21 Aug 2005 11:11:04 -0000 1.5 --- EdVersion.f 31 Aug 2005 17:03:19 -0000 1.6 *************** *** 1,5 **** \ $Id$ ! 10123 value sciedit_version# \ Version numbers: v.ww.rr --- 1,5 ---- \ $Id$ ! 10124 value sciedit_version# \ Version numbers: v.ww.rr *************** *** 179,183 **** the help menu. The Win32-SDK help file is needed for this command. If you don't have a copy you can download it from: ! http://www.borland.com/devsupport/borlandcpp/patches/BC52HLP1.ZIP --- 179,183 ---- the help menu. The Win32-SDK help file is needed for this command. If you don't have a copy you can download it from: ! http://www.borland.com/devsupport/borlandcpp/patches/BC52HLP1.ZIP *************** *** 202,204 **** - New menu entry "Handle debug messages?" in the Win32Forth menu to turn off the handling of the debug messages from the console ! window. \ No newline at end of file --- 202,208 ---- - New menu entry "Handle debug messages?" in the Win32Forth menu to turn off the handling of the debug messages from the console ! window. ! ! \ changes for Version 1.01.24 ! dbu Mittwoch, August 31 2005 ! - New options "Remove trailing white space" and "Ensure final line ending" Index: EdMenu.f =================================================================== RCS file: /cvsroot/win32forth/win32forth/apps/SciEdit/EdMenu.f,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** EdMenu.f 21 Aug 2005 11:11:04 -0000 1.3 --- EdMenu.f 31 Aug 2005 17:03:19 -0000 1.4 *************** *** 87,91 **** ENDSUBMENU MenuSeparator ! :MenuItem mp_backup "&Create Backup File (*.BAK)" IDM_CREATE_BAK DoCommand ; MenuSeparator :MenuItem mp_sabcompile "&Save all files before Compile" IDM_SAVE_ALL_BEFORE_COMPILE DoCommand ; --- 87,94 ---- ENDSUBMENU MenuSeparator ! :MenuItem mp_backup "&Create Backup File (*.BAK)" IDM_CREATE_BAK DoCommand ; ! MenuSeparator ! :MenuItem mp_rtwh "&Remove trailing white space" IDM_REMOVE_TRAILING_WHITE DoCommand ; ! :MenuItem mp_efle "&Ensure final line ending" IDM_ENSURE_FINAL_LINE_ENDING DoCommand ; MenuSeparator :MenuItem mp_sabcompile "&Save all files before Compile" IDM_SAVE_ALL_BEFORE_COMPILE DoCommand ; *************** *** 144,150 **** IsAnsWord? else false ! then ; ! : EnableEdit ( f -- ) \ File menu dup Enable: mf_save --- 147,153 ---- IsAnsWord? else false ! then ; ! : EnableEdit ( f -- ) \ File menu dup Enable: mf_save *************** *** 191,194 **** --- 194,199 ---- dup Enable: mp_sabcompile dup Enable: mp_tabs + dup Enable: mp_rtwh + dup Enable: mp_efle \ Win32Forth menu *************** *** 209,213 **** ?BrowseMode: ActiveChild not Enable: mf_saveas ?Selection: ActiveChild Enable: mf_openhl ! \ Edit menu CanUndo: ActiveChild Enable: me_undo --- 214,218 ---- ?BrowseMode: ActiveChild not Enable: mf_saveas ?Selection: ActiveChild Enable: mf_openhl ! \ Edit menu CanUndo: ActiveChild Enable: me_undo *************** *** 222,226 **** ?Find: ActiveChild Enable: me_findnext \ ?Find: ActiveChild Enable: me_findprev ! ?BrowseMode: ActiveChild not Enable: me_date ?BrowseMode: ActiveChild not Enable: me_date&time ?Selection: ActiveChild Enable: me_commentblock --- 227,231 ---- ?Find: ActiveChild Enable: me_findnext \ ?Find: ActiveChild Enable: me_findprev ! ?BrowseMode: ActiveChild not Enable: me_date ?BrowseMode: ActiveChild not Enable: me_date&time ?Selection: ActiveChild Enable: me_commentblock *************** *** 247,251 **** CreateBackup? Check: mp_backup SaveAllBeforeCompile? Check: mp_sabcompile ! \ Win32Forth menu GetTextLength: ActiveChild Enable: mp_compile --- 252,258 ---- CreateBackup? Check: mp_backup SaveAllBeforeCompile? Check: mp_sabcompile ! StripTrailingWhitespace? Check: mp_rtwh ! FinalNewLine? Check: mp_efle ! \ Win32Forth menu GetTextLength: ActiveChild Enable: mp_compile *************** *** 256,264 **** IsAnsWordSelected? Enable: mp_anshelp sdk-help? Enable: mp_apihelp ! then ! ShowToolbar? Check: mp_showtb ! ShowStatusbar? Check: mp_showsb ! ShowToolbar? Enable: mp_customizetb ActiveChild 0<> dup Enable: mf_saveall --- 263,271 ---- IsAnsWordSelected? Enable: mp_anshelp sdk-help? Enable: mp_apihelp ! then ! ShowToolbar? Check: mp_showtb ! ShowStatusbar? Check: mp_showsb ! ShowToolbar? Enable: mp_customizetb ActiveChild 0<> dup Enable: mf_saveall Index: EdCommand.f =================================================================== RCS file: /cvsroot/win32forth/win32forth/apps/SciEdit/EdCommand.f,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** EdCommand.f 21 Aug 2005 11:11:04 -0000 1.3 --- EdCommand.f 31 Aug 2005 17:03:19 -0000 1.4 *************** *** 13,17 **** needs CommandID.f needs EdAbout.f - needs EdAbout.f needs AnsLink.f needs src/tools/SdkHelp.f --- 13,16 ---- *************** *** 154,158 **** then then ! GetHandle: FindInFilesDlg \ if window already open, then set search text IF Find-buf count ID_SEARCHTEXT SetDlgItemText: FindInFilesDlg --- 153,157 ---- then then ! GetHandle: FindInFilesDlg \ if window already open, then set search text IF Find-buf count ID_SEARCHTEXT SetDlgItemText: FindInFilesDlg *************** *** 208,224 **** \ -------------------------------------------------------------------------- : ViewEOL ( -- ) ! ViewEOL? not to ViewEOL? Update ; IDM_VIEW_EOL SetCommand : ViewWhiteSpace ( -- ) ! ViewWhiteSpace? not to ViewWhiteSpace? Update ; IDM_VIEW_WHITESPACE SetCommand : ViewLineNumbers ( -- ) ! ViewLineNumbers? not to ViewLineNumbers? Update ; IDM_VIEW_LINE_NUMBERS SetCommand : Colorize ( -- ) ! Colorize? not to Colorize? Update ; IDM_COLORIZE SetCommand : mcBrowse ( -- ) ! ?BrowseMode: ActiveChild not SetBrowseMode: ActiveChild Update ; IDM_BROWSE SetCommand \ -------------------------------------------------------------------------- --- 207,223 ---- \ -------------------------------------------------------------------------- : ViewEOL ( -- ) ! ViewEOL? 0= to ViewEOL? Update ; IDM_VIEW_EOL SetCommand : ViewWhiteSpace ( -- ) ! ViewWhiteSpace? 0= to ViewWhiteSpace? Update ; IDM_VIEW_WHITESPACE SetCommand : ViewLineNumbers ( -- ) ! ViewLineNumbers? 0= to ViewLineNumbers? Update ; IDM_VIEW_LINE_NUMBERS SetCommand : Colorize ( -- ) ! Colorize? 0= to Colorize? Update ; IDM_COLORIZE SetCommand : mcBrowse ( -- ) ! ?BrowseMode: ActiveChild 0= SetBrowseMode: ActiveChild Update ; IDM_BROWSE SetCommand \ -------------------------------------------------------------------------- *************** *** 235,243 **** : CreateBAK ( -- ) ! CreateBackup? not to CreateBackup? Update ; IDM_CREATE_BAK SetCommand : SaveAllBeforeCompile ( -- ) ! SaveAllBeforeCompile? not to SaveAllBeforeCompile? Update ; IDM_SAVE_ALL_BEFORE_COMPILE SetCommand NewEditDialog SetTabSizeDlg "Tab options" "&Tab size (1 to 8):" "Ok" "" "&Use Tabs" --- 234,247 ---- : CreateBAK ( -- ) ! CreateBackup? 0= to CreateBackup? Update ; IDM_CREATE_BAK SetCommand : SaveAllBeforeCompile ( -- ) ! SaveAllBeforeCompile? 0= to SaveAllBeforeCompile? Update ; IDM_SAVE_ALL_BEFORE_COMPILE SetCommand + : StripTrailingSpaces ( -- ) + StripTrailingWhitespace? 0= to StripTrailingWhitespace? Update ; IDM_REMOVE_TRAILING_WHITE SetCommand + + : EnsureFinalNewLine ( -- ) + FinalNewLine? 0= to FinalNewLine? Update ; IDM_ENSURE_FINAL_LINE_ENDING SetCommand NewEditDialog SetTabSizeDlg "Tab options" "&Tab size (1 to 8):" "Ok" "" "&Use Tabs" *************** *** 298,306 **** : ShowToolbar ( -- ) ! ShowToolbar? not dup to ShowToolbar? Show: TheRebar ReSize: Frame Update ; IDM_SHOW_TOOLBAR SetCommand : ShowStatusbar ( -- ) ! ShowStatusbar? not dup to ShowStatusbar? Show: ScintillaStatusbar ReSize: Frame Update ; IDM_SHOW_STATUSBAR SetCommand --- 302,310 ---- : ShowToolbar ( -- ) ! ShowToolbar? 0= dup to ShowToolbar? Show: TheRebar ReSize: Frame Update ; IDM_SHOW_TOOLBAR SetCommand : ShowStatusbar ( -- ) ! ShowStatusbar? 0= dup to ShowStatusbar? Show: ScintillaStatusbar ReSize: Frame Update ; IDM_SHOW_STATUSBAR SetCommand Index: ScintillaHyperMDI.f =================================================================== RCS file: /cvsroot/win32forth/win32forth/apps/SciEdit/ScintillaHyperMDI.f,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ScintillaHyperMDI.f 21 Aug 2005 11:11:04 -0000 1.2 --- ScintillaHyperMDI.f 31 Aug 2005 17:03:19 -0000 1.3 *************** *** 160,163 **** --- 160,165 ---- TabSize SetTabWidth: super UseTabs? SetUseTabs: super + FinalNewLine? EnableEnsureFinalNewLine: super + StripTrailingWhitespace? EnableStripTrailingSpaces: super ;M Index: Main.f =================================================================== RCS file: /cvsroot/win32forth/win32forth/apps/SciEdit/Main.f,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Main.f 21 Aug 2005 11:11:04 -0000 1.9 --- Main.f 31 Aug 2005 17:03:19 -0000 1.10 *************** *** 18,22 **** only forth also editor definitions \ put all words into the EDITOR vocabulary ! true value sysgen s" apps\SciEdit" "fpath+ --- 18,22 ---- only forth also editor definitions \ put all words into the EDITOR vocabulary ! true value sysgen s" apps\SciEdit" "fpath+ *************** *** 53,56 **** --- 53,58 ---- true value ShowStatusbar? true value HandleW32FMsg? + true value StripTrailingWhitespace? + true value FinalNewLine? 0 constant FT_SOURCE *************** *** 61,65 **** needs EdMenu.f ! defer Compile-File ' beep is Compile-File defer CloseBrowser ' beep is CloseBrowser defer HandleW32FMsg ' noop is HandleW32FMsg --- 63,67 ---- needs EdMenu.f ! defer Compile-File ' beep is Compile-File defer CloseBrowser ' beep is CloseBrowser defer HandleW32FMsg ' noop is HandleW32FMsg *************** *** 128,132 **** tempRect.AddrOf GetClientRect: self ! Left: tempRect ShowToolbar? if Height: TheRebar 2 - else Top: tempRect then Right: tempRect --- 130,134 ---- tempRect.AddrOf GetClientRect: self ! Left: tempRect ShowToolbar? if Height: TheRebar 2 - else Top: tempRect then Right: tempRect *************** *** 137,146 **** ShowToolbar? if Width Height: TheRebar GetHandle: TheRebar AdjustWindowSize then ! ShowStatusbar? if Redraw: ScintillaStatusbar then ;M int WindowState :M On_Size: ( h m w -- ) ! to WindowState \ get WindowState, don't save size of maximised or minimised window ReSize: self ;M --- 139,148 ---- ShowToolbar? if Width Height: TheRebar GetHandle: TheRebar AdjustWindowSize then ! ShowStatusbar? if Redraw: ScintillaStatusbar then ;M int WindowState :M On_Size: ( h m w -- ) ! to WindowState \ get WindowState, don't save size of maximised or minimised window ReSize: self ;M *************** *** 174,182 **** s" Recent Files" s" File1" 9 0 DO 2dup + 1- 57 i - swap c! ! 4dup 2swap RegGetString 2dup FILE-STATUS nip 0= \ we only add the file's witch still exist IF pad place pad Insert: RecentFiles ELSE 2drop ! THEN LOOP 4drop ; --- 176,184 ---- s" Recent Files" s" File1" 9 0 DO 2dup + 1- 57 i - swap c! ! 4dup 2swap RegGetString 2dup FILE-STATUS nip 0= \ we only add the file's witch still exist IF pad place pad Insert: RecentFiles ELSE 2drop ! THEN LOOP 4drop ; *************** *** 194,198 **** Colorize? s>d (d.) s" Colorize" "SetDefault ViewLineNumbers? s>d (d.) s" ViewLineNumbers" "SetDefault - SaveAllBeforeCompile? s>d (d.) s" SaveAllBeforeCompile" "SetDefault TabSize s>d (d.) s" TabSize" "SetDefault UseTabs? s>d (d.) s" UseTabs" "SetDefault --- 196,199 ---- *************** *** 200,203 **** --- 201,207 ---- ShowStatusbar? s>d (d.) s" ShowStatusbar" "SetDefault HandleW32FMsg? s>d (d.) s" HandleW32FMsg" "SetDefault + FinalNewLine? s>d (d.) s" FinalNewLine" "SetDefault + SaveAllBeforeCompile? s>d (d.) s" SaveAllBeforeCompile" "SetDefault + StripTrailingWhitespace? s>d (d.) s" StripTrailingSpaces" "SetDefault WindowState SIZE_RESTORED = *************** *** 206,210 **** Width: self s>d (d.) s" WindowWidth" "SetDefault Height: self s>d (d.) s" WindowHeight" "SetDefault ! then mask-ptr count s" SearchMask" "SetDefault --- 210,214 ---- Width: self s>d (d.) s" WindowWidth" "SetDefault Height: self s>d (d.) s" WindowHeight" "SetDefault ! then mask-ptr count s" SearchMask" "SetDefault *************** *** 214,219 **** SaveRecentFiles ! SetRegistryKey: ControlToolBar ! true SaveRestore: ControlToolBar r> base ! ; --- 218,223 ---- SaveRecentFiles ! SetRegistryKey: ControlToolBar ! true SaveRestore: ControlToolBar r> base ! ; *************** *** 227,251 **** s" ViewEOL" "GetDefaultValue 0= IF drop false THEN to ViewEOL? s" WhiteSpace" "GetDefaultValue 0= IF drop SCWS_INVISIBLE THEN to ViewWhiteSpace? ! s" CaseSensitive" "GetDefaultValue 0= IF drop true THEN to CaseSensitive? ! s" SubDirectories" "GetDefaultValue 0= IF drop true THEN to sub-dirs? ! s" AllOccurances" "GetDefaultValue 0= IF drop true THEN to all-occur? ! s" Colorize" "GetDefaultValue 0= IF drop true THEN to Colorize? ! s" ViewLineNumbers" "GetDefaultValue 0= IF drop true THEN to ViewLineNumbers? ! s" SaveAllBeforeCompile" "GetDefaultValue 0= IF drop false THEN to SaveAllBeforeCompile? ! s" TabSize" "GetDefaultValue 0= IF drop 8 THEN to TabSize ! s" UseTabs" "GetDefaultValue 0= IF drop true THEN to UseTabs? s" HandleW32FMsg" "GetDefaultValue 0= IF drop true THEN to HandleW32FMsg? s" SearchText" "GetDefault -IF 2dup "CLIP" find-buf place THEN 2drop s" SearchPath" "GetDefault -IF 2dup "CLIP" path-ptr place THEN 2drop s" SearchMask" "GetDefault -IF 2dup "CLIP" mask-ptr place THEN 2drop ! s" ShowToolbar" "GetDefaultValue 0= IF drop true THEN dup to ShowToolbar? Show: TheRebar s" ShowStatusbar" "GetDefaultValue 0= IF drop true THEN dup to ShowStatusbar? Show: ScintillaStatusbar ! RestoreRecentFiles ! SetRegistryKey: ControlToolBar ! false SaveRestore: ControlToolBar r> base ! ; --- 231,257 ---- s" ViewEOL" "GetDefaultValue 0= IF drop false THEN to ViewEOL? s" WhiteSpace" "GetDefaultValue 0= IF drop SCWS_INVISIBLE THEN to ViewWhiteSpace? ! s" CaseSensitive" "GetDefaultValue 0= IF drop true THEN to CaseSensitive? ! s" SubDirectories" "GetDefaultValue 0= IF drop true THEN to sub-dirs? ! s" AllOccurances" "GetDefaultValue 0= IF drop true THEN to all-occur? ! s" Colorize" "GetDefaultValue 0= IF drop true THEN to Colorize? ! s" ViewLineNumbers" "GetDefaultValue 0= IF drop true THEN to ViewLineNumbers? ! s" TabSize" "GetDefaultValue 0= IF drop 8 THEN to TabSize ! s" UseTabs" "GetDefaultValue 0= IF drop true THEN to UseTabs? s" HandleW32FMsg" "GetDefaultValue 0= IF drop true THEN to HandleW32FMsg? + s" FinalNewLine" "GetDefaultValue 0= IF drop true THEN to FinalNewLine? + s" SaveAllBeforeCompile" "GetDefaultValue 0= IF drop true THEN to SaveAllBeforeCompile? + s" StripTrailingWhitespace" "GetDefaultValue 0= IF drop true THEN to StripTrailingWhitespace? s" SearchText" "GetDefault -IF 2dup "CLIP" find-buf place THEN 2drop s" SearchPath" "GetDefault -IF 2dup "CLIP" path-ptr place THEN 2drop s" SearchMask" "GetDefault -IF 2dup "CLIP" mask-ptr place THEN 2drop ! s" ShowToolbar" "GetDefaultValue 0= IF drop true THEN dup to ShowToolbar? Show: TheRebar s" ShowStatusbar" "GetDefaultValue 0= IF drop true THEN dup to ShowStatusbar? Show: ScintillaStatusbar ! RestoreRecentFiles ! SetRegistryKey: ControlToolBar ! false SaveRestore: ControlToolBar r> base ! ; *************** *** 254,259 **** base @ >r decimal \ MUST be in decimal when loading defaults InitRegistry: self ! s" WindowWidth" "GetDefaultValue 0= IF drop 400 THEN ! s" WindowHeight" "GetDefaultValue 0= IF drop 400 THEN r> base ! ;M --- 260,265 ---- base @ >r decimal \ MUST be in decimal when loading defaults InitRegistry: self ! s" WindowWidth" "GetDefaultValue 0= IF drop 400 THEN ! s" WindowHeight" "GetDefaultValue 0= IF drop 400 THEN r> base ! ;M *************** *** 261,266 **** base @ >r decimal \ MUST be in decimal when loading defaults InitRegistry: self ! s" WindowLeft" "GetDefaultValue 0= IF drop 0 THEN ! s" WindowTop" "GetDefaultValue 0= IF drop 0 THEN r> base ! ;M --- 267,272 ---- base @ >r decimal \ MUST be in decimal when loading defaults InitRegistry: self ! s" WindowLeft" "GetDefaultValue 0= IF drop 0 THEN ! s" WindowTop" "GetDefaultValue 0= IF drop 0 THEN r> base ! ;M *************** *** 282,286 **** :M OnWmCommand: ( hwnd msg wparam lparam -- hwnd msg wparam lparam ) ! over LOWORD ( command ID ) dup IsCommand? IF DoCommand \ intercept Toolbar and shortkey commands ELSE drop OnWmCommand: Super \ intercept Menu commands --- 288,292 ---- :M OnWmCommand: ( hwnd msg wparam lparam -- hwnd msg wparam lparam ) ! over LOWORD ( command ID ) dup IsCommand? IF DoCommand \ intercept Toolbar and shortkey commands ELSE drop OnWmCommand: Super \ intercept Menu commands *************** *** 600,604 **** \ FCONTROL 'R' IDM_RELOAD ACCELENTRY FSHIFT FCONTROL or 'O' IDM_OPEN_HIGHLIGHTED_FILE ACCELENTRY ! \ Edit menu FCONTROL 'F' IDM_FIND_TEXT ACCELENTRY --- 606,610 ---- \ FCONTROL 'R' IDM_RELOAD ACCELENTRY FSHIFT FCONTROL or 'O' IDM_OPEN_HIGHLIGHTED_FILE ACCELENTRY ! \ Edit menu FCONTROL 'F' IDM_FIND_TEXT ACCELENTRY *************** *** 702,705 **** --- 708,713 ---- [else] s" src\res\SciEditMDI.ico" s" SciEditMdi.exe" AddAppIcon + + debug breaker Main [then] Index: CommandID.f =================================================================== RCS file: /cvsroot/win32forth/win32forth/apps/SciEdit/CommandID.f,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CommandID.f 21 Aug 2005 11:11:04 -0000 1.3 --- CommandID.f 31 Aug 2005 17:03:19 -0000 1.4 *************** *** 72,75 **** --- 72,77 ---- NewID IDM_SHOW_TOOLBAR NewID IDM_SHOW_STATUSBAR + NewID IDM_REMOVE_TRAILING_WHITE + NewID IDM_ENSURE_FINAL_LINE_ENDING \ Win32Forth menu *************** *** 115,119 **** then ; ! : DoCommand ( ID -- ) >CommandTable @ ?dup IF execute THEN ; --- 117,121 ---- then ; ! : DoCommand ( ID -- ) >CommandTable @ ?dup IF execute THEN ; Index: ScintillaMDI.f =================================================================== RCS file: /cvsroot/win32forth/win32forth/apps/SciEdit/ScintillaMDI.f,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ScintillaMDI.f 19 Aug 2005 16:05:46 -0000 1.3 --- ScintillaMDI.f 31 Aug 2005 17:03:19 -0000 1.4 *************** *** 30,33 **** --- 30,35 ---- int CreateBackup? int Lexer + int StripTrailingSpaces? + int EnsureFinalNewLine? :M ?Modified: ( -- f ) *************** *** 78,81 **** --- 80,85 ---- 0 to FindMode true to CreateBackup? + true to StripTrailingSpaces? + true to EnsureFinalNewLine? FindText$ off InitLexer: self *************** *** 114,204 **** GetTextLength: ChildWindow ;M - : SaveText ( -- ) \ save the Text in the control to the file - \ get the complete text from the control - ReleaseBuffer: EditFile - GetTextLength: self 1+ AllocBuffer: EditFile - GetBuffer: EditFile GetText: ChildWindow - - \ adjust the Text length in the EditFile because - \ the Scintilla-Control returns on null byte at the - \ end of the Text. Thank's Ezra for telling me about this - \ bug (Freitag, August 19 2005 - dbu) - GetLength: EditFile 1- SetLength: EditFile - - \ save the text to the file - SaveFile: EditFile - ReleaseBuffer: EditFile - - \ and mark the text in the control as unchanged - SetSavepoint: ChildWindow - SetWindowTitle: self ; - - :M SaveFileAs: ( -- ) \ save the file under a new name - GetSaveFilename ?dup - if SetFileName: self - SaveText - else drop - then ;M - - : CreateBackup ( -- ) \ create a Backup of the active file (*.BAK) - CreateBackup? - if - GetFileName: self count pad place - pad count "minus-ext" pad place s" .bak" pad +place pad +null - - false pad count drop GetFileName: self count drop - Call CopyFile ?win-error - then ; - - :M SaveFile: ( -- ) \ save the file under it's current name - GetFileName: self c@ 0= - if SaveFileAs: self - else CreateBackup - SaveText - then ;M - - :M SaveBeforeCloseing: ( -- ) - GetModify: ChildWindow 0<> - if [ MB_YESNO MB_ICONQUESTION or ] literal - s" The current File has changed. Would you like to save your changes?" MessageBox - IDYES = if SaveFile: self then - then ;M - - :M NewFile: ( -- ) \ open a new empty file - ClearName: EditFile ;M - - : SetFile ( f -- ) - GetBuffer: EditFile ?dup - if over + 0 swap c! \ add 0-terminator - SetText: ChildWindow - then - EmptyUndoBuffer: ChildWindow - SetSavepoint: ChildWindow - 0 -1 Colourise: ChildWindow ; - - :M OpenNamedFile: ( addr len -- f ) \ open a file - SaveBeforeCloseing: self - LoadFile: EditFile - dup if SetFile then - SetWindowTitle: self ;M - - :M OpenFile: ( -- f ) \ open a file - GetOpenFilename ?dup - if OpenNamedFile: self - else drop false - then ;M - - :M ReloadFile: ( -- ) \ reload the current file - GetFileName: self c@ 0<> - if GetModify: ChildWindow 0<> - if [ MB_YESNO MB_ICONQUESTION or ] literal - s" The current File has changed. All changes will be lost. Would you like to continue?" MessageBox - IDYES = - if GetFileName: self count pad place - SetSavepoint: ChildWindow NewFile: self - pad count LoadFile SetFile - then - then - then ;M :M Delete: ( -- ) \ delete the selected text --- 118,121 ---- *************** *** 362,371 **** SelectAll: ChildWindow ;M - :M Compile: ( -- ) \ compile this File - GetModify: ChildWindow 0<> - if SaveFile: self - then GetFileName: self count Compile-File - ;M - :M GotoLine: ( n -- ) GotoLine: ChildWindow ;M --- 279,282 ---- *************** *** 380,383 **** --- 291,300 ---- to CreateBackup? ;M + :M EnableStripTrailingSpaces: ( f -- ) + cr dup space to StripTrailingSpaces? ;M + + :M EnableEnsureFinalNewLine: ( f -- ) + cr dup space to EnsureFinalNewLine? ;M + :M SetEOL: ( eolMode -- ) dup ConvertEOL: ChildWindow SetEOL: ChildWindow ;M *************** *** 412,415 **** --- 329,480 ---- ReleaseBuffer: EditFile ;m + \ remove trailing white space char's (spaces and tabs) form the end + \ of all lines in the file + :M StripTrailingSpaces: { \ lineStart lineEnd -- } + GetLineCount: ChildWindow 0 + ?DO i PositionFromLine: ChildWindow to lineStart + i GetLineEndPosition: ChildWindow dup to lineEnd 0> + if lineEnd + begin 1- + dup GetCharAt: ChildWindow + dup BL = swap 0x09 ( TAB ) = or + swap dup lineStart >= rot and 0= + until + dup i lineEnd 1- < + if 1+ SetTargetStart: ChildWindow + lineEnd SetTargetEnd: ChildWindow + 0 pad ! pad 0 ReplaceTarget: ChildWindow drop + else drop + then + then + LOOP ;M + + \ make shure that the last line of the file ends with a line end marker + :M EnsureFinalNewLine: { \ maxLines endDoc appendNewLine -- } + GetLineCount: ChildWindow to maxLines + maxLines 1 = to appendNewLine + maxLines PositionFromLine: ChildWindow to endDoc + + maxLines 1 > + if endDoc maxLines 1- PositionFromLine: ChildWindow > to appendNewLine + then + + appendNewLine + if GetEOL: ChildWindow + case SC_EOL_CRLF of 0x0D pad c! 0x0A pad 1+ c! 0 pad 2+ c! endof + SC_EOL_CR of 0x0D pad c! 0 pad 1+ c! endof + SC_EOL_LF of 0x0A pad c! 0 pad 1+ c! endof + endcase endDoc pad InsertText: ChildWindow + then ;M + + \ ---------------------------------------------------------------------------- + \ ---------------------------------------------------------------------------- + + : SaveText ( -- ) \ save the Text in the control to the file + cr + StripTrailingSpaces? dup . space + if StripTrailingSpaces: self + then + + EnsureFinalNewLine? dup . space + if EnsureFinalNewLine: self + then + + \ get the complete text from the control + ReleaseBuffer: EditFile + GetTextLength: self 1+ AllocBuffer: EditFile + GetBuffer: EditFile GetText: ChildWindow + + \ adjust the Text length in the EditFile because + \ the Scintilla-Control returns on null byte at the + \ end of the Text. Thank's Ezra for telling me about this + \ bug (Freitag, August 19 2005 - dbu) + GetLength: EditFile 1- SetLength: EditFile + + \ save the text to the file + SaveFile: EditFile + ReleaseBuffer: EditFile + + \ and mark the text in the control as unchanged + SetSavepoint: ChildWindow + SetWindowTitle: self ; + + :M SaveFileAs: ( -- ) \ save the file under a new name + GetSaveFilename ?dup + if SetFileName: self + SaveText + else drop + then ;M + + : CreateBackup ( -- ) \ create a Backup of the active file (*.BAK) + CreateBackup? + if + GetFileName: self count pad place + pad count "minus-ext" pad place s" .bak" pad +place pad +null + + false pad count drop GetFileName: self count drop + Call CopyFile ?win-error + then ; + + :M SaveFile: ( -- ) \ save the file under it's current name + GetFileName: self c@ 0= + if SaveFileAs: self + else CreateBackup + SaveText + then ;M + + :M SaveBeforeCloseing: ( -- ) + GetModify: ChildWindow 0<> + if [ MB_YESNO MB_ICONQUESTION or ] literal + s" The current File has changed. Would you like to save your changes?" MessageBox + IDYES = if SaveFile: self then + then ;M + + :M NewFile: ( -- ) \ open a new empty file + ClearName: EditFile ;M + + : SetFile ( f -- ) + GetBuffer: EditFile ?dup + if over + 0 swap c! \ add 0-terminator + SetText: ChildWindow + then + EmptyUndoBuffer: ChildWindow + SetSavepoint: ChildWindow + 0 -1 Colourise: ChildWindow ; + + :M OpenNamedFile: ( addr len -- f ) \ open a file + SaveBeforeCloseing: self + LoadFile: EditFile + dup if SetFile then + SetWindowTitle: self ;M + + :M OpenFile: ( -- f ) \ open a file + GetOpenFilename ?dup + if OpenNamedFile: self + else drop false + then ;M + + :M ReloadFile: ( -- ) \ reload the current file + GetFileName: self c@ 0<> + if GetModify: ChildWindow 0<> + if [ MB_YESNO MB_ICONQUESTION or ] literal + s" The current File has changed. All changes will be lost. Would you like to continue?" MessageBox + IDYES = + if GetFileName: self count pad place + SetSavepoint: ChildWindow NewFile: self + pad count LoadFile SetFile + then + then + then ;M + + \ ---------------------------------------------------------------------------- + + :M Compile: ( -- ) \ compile this File + GetModify: ChildWindow 0<> + if SaveFile: self + then GetFileName: self count Compile-File + ;M + + \ ---------------------------------------------------------------------------- : OpenFile ( adr -- f ) \ f=false = file is opend dup count FILE-STATUS nip 0= *************** *** 424,432 **** buf$ 1+ GetSelText: ChildWindow 1- 255 min buf$ c! ! \ try to open the file with the given path buf$ ?defext buf$ OpenFile if \ try to find the file in the folder of the current file buf$ count "to-pathend" pad place ! GetName: EditFile count "path-only" buf$ place buf$ ?+\ pad count buf$ +place buf$ OpenFile --- 489,497 ---- buf$ 1+ GetSelText: ChildWindow 1- 255 min buf$ c! ! \ try to open the file with the given path buf$ ?defext buf$ OpenFile if \ try to find the file in the folder of the current file buf$ count "to-pathend" pad place ! GetName: EditFile count "path-only" buf$ place buf$ ?+\ pad count buf$ +place buf$ OpenFile *************** *** 441,445 **** buf$ IDM_OPEN_RECENT_FILE DoCommand else 2drop beep ! then then then --- 506,510 ---- buf$ IDM_OPEN_RECENT_FILE DoCommand else 2drop beep ! then then then *************** *** 517,520 **** ;Class - - |