diff options
author | XhmikosR <xhmikosr@users.sourceforge.net> | 2010-10-31 17:15:54 +0000 |
---|---|---|
committer | XhmikosR <xhmikosr@users.sourceforge.net> | 2010-10-31 17:15:54 +0000 |
commit | e5eb2fe35699c79bef11a870fd4c111c040fc22c (patch) | |
tree | 3b9d3a7bb68282f644d3584d19990c392ef0570b | |
parent | eb9fac675e519f1507d9df5a038cac6efe1c3df7 (diff) | |
download | notepad2-mod-e5eb2fe35699c79bef11a870fd4c111c040fc22c.zip notepad2-mod-e5eb2fe35699c79bef11a870fd4c111c040fc22c.tar.gz notepad2-mod-e5eb2fe35699c79bef11a870fd4c111c040fc22c.tar.bz2 |
initial import of notepad2 4.1.24 in the svn
git-svn-id: https://notepad2-mod.googlecode.com/svn/trunk@2 28bd50df-7adb-d945-0439-6e466c6a13cc
-rw-r--r-- | License.txt | 29 | ||||
-rw-r--r-- | Notepad2.ini | bin | 0 -> 23068 bytes | |||
-rw-r--r-- | Notepad2.sln | 21 | ||||
-rw-r--r-- | Notepad2.txt | 835 | ||||
-rw-r--r-- | Notepad2.vcproj | 458 | ||||
-rw-r--r-- | Readme.txt | 78 | ||||
-rw-r--r-- | res/Copy.cur | bin | 0 -> 326 bytes | |||
-rw-r--r-- | res/Encoding.bmp | bin | 0 -> 2102 bytes | |||
-rw-r--r-- | res/Next.bmp | bin | 0 -> 154 bytes | |||
-rw-r--r-- | res/Notepad2.exe.manifest | 32 | ||||
-rw-r--r-- | res/Notepad2.ico | bin | 0 -> 25214 bytes | |||
-rw-r--r-- | res/Open.bmp | bin | 0 -> 154 bytes | |||
-rw-r--r-- | res/Pick.bmp | bin | 0 -> 198 bytes | |||
-rw-r--r-- | res/Prev.bmp | bin | 0 -> 154 bytes | |||
-rw-r--r-- | res/Run.ico | bin | 0 -> 766 bytes | |||
-rw-r--r-- | res/Styles.ico | bin | 0 -> 766 bytes | |||
-rw-r--r-- | res/Toolbar.bmp | bin | 0 -> 23606 bytes | |||
-rw-r--r-- | src/Dialogs.c | 2343 | ||||
-rw-r--r-- | src/Dialogs.h | 50 | ||||
-rw-r--r-- | src/Dlapi.c | 1769 | ||||
-rw-r--r-- | src/Dlapi.h | 201 | ||||
-rw-r--r-- | src/Edit.c | 6041 | ||||
-rw-r--r-- | src/Edit.h | 198 | ||||
-rw-r--r-- | src/Helpers.c | 2265 | ||||
-rw-r--r-- | src/Helpers.h | 219 | ||||
-rw-r--r-- | src/Notepad2.c | 6915 | ||||
-rw-r--r-- | src/Notepad2.h | 145 | ||||
-rw-r--r-- | src/Notepad2.rc | 1896 | ||||
-rw-r--r-- | src/Print.cpp | 604 | ||||
-rw-r--r-- | src/Styles.c | 3437 | ||||
-rw-r--r-- | src/Styles.h | 100 | ||||
-rw-r--r-- | src/resource.h | 392 | ||||
-rw-r--r-- | wdkbuild/build.cmd | 19 | ||||
-rw-r--r-- | wdkbuild/cl.txt | 49 | ||||
-rw-r--r-- | wdkbuild/link.txt | 51 |
35 files changed, 28147 insertions, 0 deletions
diff --git a/License.txt b/License.txt new file mode 100644 index 0000000..005a3d2 --- /dev/null +++ b/License.txt @@ -0,0 +1,29 @@ +Notepad2 Copyright © 2004-2010 Florian Balmer
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+1. Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+
+3. Neither the name of Florian Balmer nor the names of its contributors
+may be used to endorse or promote products derived from this software
+without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/Notepad2.ini b/Notepad2.ini Binary files differnew file mode 100644 index 0000000..e105607 --- /dev/null +++ b/Notepad2.ini diff --git a/Notepad2.sln b/Notepad2.sln new file mode 100644 index 0000000..63cdf00 --- /dev/null +++ b/Notepad2.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Notepad2", "Notepad2.vcproj", "{B69A8C7E-A22D-45DA-9997-2D1403C7AEE8}"
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ ConfigName.0 = Debug
+ ConfigName.1 = Release
+ EndGlobalSection
+ GlobalSection(ProjectDependencies) = postSolution
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {B69A8C7E-A22D-45DA-9997-2D1403C7AEE8}.Debug.ActiveCfg = Debug|Win32
+ {B69A8C7E-A22D-45DA-9997-2D1403C7AEE8}.Debug.Build.0 = Debug|Win32
+ {B69A8C7E-A22D-45DA-9997-2D1403C7AEE8}.Release.ActiveCfg = Release|Win32
+ {B69A8C7E-A22D-45DA-9997-2D1403C7AEE8}.Release.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/Notepad2.txt b/Notepad2.txt new file mode 100644 index 0000000..21243d1 --- /dev/null +++ b/Notepad2.txt @@ -0,0 +1,835 @@ +
+=======================================================================
+= =
+= =
+= Notepad2 - light-weight Scintilla-based text editor for Windows =
+= =
+= =
+= Notepad2 4.1.24 =
+= (c) Florian Balmer 2004-2010 =
+= http://www.flos-freeware.ch =
+= =
+= =
+=======================================================================
+
+
+Description
+
+ Notepad2 is a light-weight, free and open source Notepad-like text
+ editor with syntax highlighting for a few commonly used languages.
+ It's based on the Scintilla source code editing component and works
+ on NT-based versions of Windows.
+
+
+Features
+
+ - Syntax highlighting: HTML, XML, PHP, ASP (JS, VBS), CSS,
+ JavaScript, VBScript, C/C++, C#, Resource Script, Makefiles, Java,
+ Visual Basic, Pascal, Assembly, SQL, Perl, Python, Configuration
+ Files, Apache Config Files, PowerShell, Batch Files, Diff Files
+ - Drag & drop text editing inside and outside Notepad2
+ - Basic regular expression search and replace
+ - Useful word, line and block editing shortcuts
+ - Rectangular selection (Alt+Mouse)
+ - Brace matching, auto indent, long line marker, zoom functions
+ - Support for Unicode, UTF-8, Unix and Mac text files
+ - Open shell links
+ - Mostly adjustable
+
+
+New in Version 4.1.24 (released March 02, 2010)
+
+ - /z command line switch (support registry-based Notepad replacement)
+ - /u command line switch (launch Notepad2 with elevated privileges)
+ - Fixed some /p command line switch options not working properly
+ - Display more informative error messages for file operation failures
+ - Hotkey to copy pathname of current file to clipboard (Shift+F9)
+ - Window title indicator when running with elevated privileges
+ - Ini-options to control system MRU, taskbar and jump list behaviour
+ - Enhanced portability for directory settings inside My Documents
+ - Configure whether tab key should reformat indenting whitespace
+ - Revised word wrap settings dialog and added more detailed options
+ - New style setting to control font smoothing (see FAQ on my website)
+ - New style setting to control size of visible white space dots
+ - Improved cursor visibility on any background color
+ - Added new "HTML Element Text" and "XML Element Text" styles
+ - Improved default style utilization for HTML-embedded schemes
+ - Updated PowerShell keywords to version 2.0
+ - Added missing keywords to VBScript scheme
+ - Fixed deleted files reappearing in MRU lists
+ - Updated Scintilla library to 2.03
+
+
+New in Version 4.0.23 (released October 06, 2009)
+
+ - Added PowerShell Script syntax highlighting
+ - Added missing keywords to JavaScript schemes
+ - Further simplified syntax schemes by consolidating certain styles
+ - More accurate "mode" file variable matching with tightened rules
+ - Avoid repetitive zone checks when running Notepad2.exe internally
+ - Fixed choice of encoding conversion prompt being ignored
+ - Fixed recent file dialog hang with inaccessible UNC paths
+ - Internal changes to allow complete internationalization (future)
+
+
+New in Version 4.0.22 (released July 28, 2009)
+
+ - Support for numerous Windows, DOS, ISO, Mac and EBCDIC encodings
+ - Enhanced encoding selection dialog (F9)
+ - "Recode" (F8) to reload file with different source encoding
+ - "Recode file as system default ANSI" (Ctrl+Shift+A)
+ - "Recode file as system default OEM" (Ctrl+Shift+O)
+ - "Recode 7-bit ASCII file as UTF-8" (Shift+F8)
+ - Option to load 7-bit ASCII files as UTF-8 (File, Encoding, Default)
+ - Option to disable encoding tag parsing (File, Encoding, Default)
+ - Issue warning if data can't be converted to selected file encoding
+ - Fix loading of (invalid) Unicode files with embedded null bytes
+ - /e command line switch to specify file source encoding
+ - "Insert Encoding Identifier" (Ctrl+F8)
+ - "Tabify Indent" (Ctrl+Alt+T) and "Untabify Indent" (Ctrl+Alt+S)
+ - "Increase Number" (Ctrl+Alt++) and "Decrease Number" (Ctrl+Alt+-)
+ - Option to auto-reload unmodified files changed by external programs
+ - Hotkey (Alt+F5) and auto-reset option for file change notification
+ - Manual and automatic reloading of files keeps current encoding
+ - Scroll find matches and jump positions away from bottom border
+ - Enabled new Scintilla indent modes for wrapped lines
+ - Option to set any characters as boundaries for word wrap
+ - Allow bigger tab-/indent-widths (256) and long line limit (4096)
+ - Allow setting extra line spacing (through "Default Text" scheme)
+ - Dropping directories displays file open dialog
+ - Consolidated styles to simplify configuration (patch by Kai Liu)
+ - Ensure cursor visibility on any background color (patch by Kai Liu)
+ - Enabled improved Scintilla Pascal lexing module (patch by Kai Liu)
+ - Updated HTML keywords to version 5.0
+ - Remapped "Manage Favorites" hotkey to Alt+F9
+ - Remapped "Invert Case" hotkey to Ctrl+Alt+U
+ - Remapped "Title Case" hotkey to Ctrl+Alt+I
+ - Remapped "Sentence Case" hotkey to Ctrl+Alt+O
+ - Fixed various minor bugs
+ - Notepad2.exe program file no longer compressed with UPX
+ - Updated Scintilla library to 1.79
+
+
+New in Version 3.1.21 (released June 21, 2009)
+
+ - No ini-file is created by default (save settings with F7, once)
+ - "Move Up" and "Move Down" keep selection and work with blocks
+ - Set cursor to start (Ctrl+,) or end of text selection (Ctrl+.)
+ - "URL Encode" (Ctrl+Shift+E) and "URL Decode" (Ctrl+Shift+R)
+ - "Escape" (Ctrl+Alt+E) and "Unescape C Special Chars" (Ctrl+Alt+U)
+ - "Sort Lines" with several options (Alt+O)
+ - "Pad With Spaces" block command (Alt+B)
+ - "Replace Next" assigned to hotkey (F4)
+ - Auto strip trailing blanks option (File, Line Endings, Default)
+ - Remapped "Transparent Mode" hotkey to Ctrl+0
+ - Simple XML detection for files without extensions
+ - Simple language detection for cgi and fcgi files
+ - Reload file without file variable parsing (Alt+F8)
+ - Enabled better styling of C/C++ preprocessor elements
+ - Recent files and search strings merged with existing items on save
+ - Paste board mode ignores immediately repeated copy actions
+ - Command line switch + to accept multiple files (quoted spaces)
+ - Command line switch - to accept single file argument (no quotes)
+ - Option to set default command line mode (single or multiple files)
+ - Command line switches to set file encoding and line ending mode
+ - More /p command line switches (see "Command Line Switches" below)
+ - /r command line switch to reuse existing window
+ - /ns and /rs command line switches to enable single file instance
+ - Renamed /t command line switch to /d (select default text scheme)
+ - /t command line switch to set window title
+ - Set window title to excerpt of current text selection (Ctrl+9)
+ - Save relative pathnames for recent files (ini-option to disable)
+ - Save relative directories for "Open with..." and "Favorites"
+ - "Open with..." no longer sends short pathnames to external programs
+ - External commands use current file directory as working directory
+ - Remember "Save Copy" location until exit
+ - Require only single click to restore window from tray icon
+ - "Reuse Window" option timeout improves opening multiple files
+ - Replaced "Find Up" option with "Find Previous" button in dialogs
+ - "Find Wrap" notification dialogs provide "Cancel" button
+ - Option to suppress replace count notifications
+ - Find and replace dialogs provide new system menu commands
+ - Dialog boxes use correct theme fonts on Vista
+ - Patches to default styles, file types and auto-detection by Kai Liu
+ - Incorporated base x64 source code compatibility patch
+ - Fixed some problems with relative ini-file locations
+ - Fixed some minor file variable problems
+ - Fixed some encoding detection issues
+ - Fixed some find and replace problems
+ - Fixed several memory leaks when saving files
+ - Fixed several memory leaks for editing operations
+ - Reduced size of Notepad2.exe program file
+
+
+New in Version 3.0.20 (released October 31, 2008)
+
+ - Notepad2 converted to a native Win32 Unicode application
+ - "Copy Add" (Ctrl+E) to append selected text to clipboard
+ - "Unwrap Paragraphs" (Ctrl+Shift+J)
+ - "Strip Last Character" (Alt+U)
+ - "Select Line", can be used repeatedly (Ctrl+Shift+Space)
+ - Remapped "Delete Line" hotkey to Ctrl+Shift+D
+ - Remapped "Transparent Mode" hotkey to Alt+O
+ - Allow easy toggling of find and replace dialogs (Ctrl+F, Ctrl+H)
+ - Save and restore find and replace dialog positions (Ctrl+O, Ctrl+P)
+ - Files with UTF-8 Signature always loaded in UTF-8 mode
+ - Simple HTML detection for files without extensions
+ - Support basic Emacs file variables (see FAQ on my website)
+ - Update timestamps (Shift+F5) (see FAQ on my website)
+ - %APPDATA% searched for existing ini-file
+ - Modest enhancements to scheme customization dialog
+ - Improved performance for saving settings to ini-file
+ - Less restrictive handling of quoted filenames on command line
+ - Keep scrolling positions when reloading changed files
+ - Modified /s command line switch to work with extensions, not ids
+ - /m command line switch to match specified text
+ - /q command line switch to force creation of new files
+ - Pass command line switches to existing windows: /s /t /h /x /g /q
+ - Proceed to next match after choosing "replace" in replace dialog
+ - Fixed some more find and replace problems
+ - Improved visual appearance on Windows Vista
+ - Updated Scintilla library to 1.77
+
+
+New in Version 2.1.19 (released April 10, 2008)
+
+ - "Line Comment" (Ctrl+Q) and "Stream Comment" (Ctrl+Shift+Q)
+ - "Title Case" (Ctrl+Alt+T) and "Sentence Case" (Ctrl+Alt+S)
+ - "Compress Whitespace" (Alt+P) command reduces spaces and tabs
+ - Original Notepad .LOG feature
+ - /f command line switch to set ini-file (/f0 to omit ini-file)
+ - /p command line switch trumps sticky window position
+ - /p0 uses system default settings for new window position
+ - Move new off-screen windows prior to resizing
+ - Option to skip Unicode text detection (File, Encoding, Default)
+ - Reload file with different default encoding (Ctrl+F8, Shift+F8)
+ - Unsaved documents with just whitespace considered empty
+ - Improved handling of relative path names
+ - File dialog filters can be specified in the Notepad2 ini-file
+ - Type of indent guides can be specified in the Notepad2 ini-file
+ - Track width of displayed text to adjust horizontal scroll range
+ - Selected find results are better scrolled into view
+ - Restore scrolling positions on revert
+ - Ctrl+Back and Ctrl+Del stop at newlines, as usual on Windows
+ - Ctrl+Space doesn't select initial line indentation whitespace
+ - Ctrl+Tab hotkey modified to always insert a tabulator
+ - Increase (Alt++) and decrease (Alt+-) long lines limit
+ - Display long lines limit in statusbar if visual marker enabled
+ - Import and export settings from customization dialog (Alt+I, Alt+X)
+ - Added "Regular Expression" style to JavaScript and Java schemes
+ - Updated filename extension lists with more default types
+ - Updated Python keywords to version 3.0
+ - Simplified SQL keywords (merged from MySQL and SQLite)
+ - Improved compatibility with Windows Vista
+ - Improved visual appearance of toolbar button images
+ - Print margins can be set to "0"
+ - Fixed several bugs with regular expression find and replace
+ - Fixed bug with hanging of recent files dialog
+ - Fixed bug with charset not being saved properly
+ - Fixed bug with display of text selection at the beginning of lines
+ - Fixed bug with cursor movement at start and end of wrapped lines
+ - Updated Scintilla library to 1.76
+
+
+New in Version 2.0.18 (released July 26, 2007)
+
+ - "Select To" command in find dialog allows expanding the selection
+ - "Select To Next" (F2) and "Select To Previous" (Shift+F2)
+ - "Save Find Text" (Alt+F3) for later use with F2, F3, etc.
+ - "Swap" (Ctrl+K) to exchange selected text with clipboard contents
+ - Notepad2.exe program file is compressed with UPX by default
+
+
+New in Version 2.0.17 (released July 24, 2007)
+
+ - Option to allow only one Notepad2 window for each file
+ - Option to display filename in window title in various forms
+ - Hotkey Shift+Esc to save file and exit Notepad2
+ - Indent size can be specified separately from tab width
+ - Indent guides are highlighted along with matching braces
+ - Caret can be displayed as a block (specify "block" for caret width)
+ - Find and replace dialogs can be toggled from the toolbar
+ - Tray icon is restored when Explorer is restarted
+ - Fixed bug with brace matching
+ - Fixed bug with replacement of ^c cutting the last character
+ - Fixed bug with regular expression search causing infinite loop
+ - Updated Scintilla library to 1.74
+
+
+New in Version 2.0.16 (released May 14, 2007)
+
+ - The msvcr70.dll runtime library is no longer required
+ - "Enclose Selection" helper tool (Alt+Q)
+ - Single line files are opened with default line ending mode
+ - Remapped hotkey Ctrl+Shift+Z from "Undo" to "Redo"
+ - Remapped hotkey Ctrl+Shift+Y from "Redo" to "Undo"
+ - Fixed bug: problem with MRU lists causing random crashes
+ - Fixed bug: moving lines up/down not working properly
+ - Fixed bug: window settings overwritten on new screen resolution
+
+
+New in Version 2.0.15 (released April 07, 2007)
+
+ - BSD License for Notepad2 and source code (see License.txt)
+ - "Insert HTML/XML Tag" helper tool (Alt+X)
+ - Regex support for \d, \D, \s, \S, \w, \W, \xHH
+ - Text selection can have "eolfilled" style (on by default)
+ - Caret blink rate is set to system default on startup
+ - Support for opening makefiles without filename extension
+ - Dropped Windows 9x support
+ - Requires msvcr70.dll runtime library
+ - Updated Scintilla library to 1.73
+
+
+New in Version 2.0.14 (not released to the public)
+
+ - Find and replace dialogs: Don't wrap around on find option
+ - Use the clipboard contents as the replacement text (enter ^c)
+ - Date and time formats can be changed using template strings
+ - "FileCheckInterval" ini-setting (see FAQ on my website)
+
+
+New in Version 2.0.13 (not released to the public)
+
+ - Settings are stored in ini-file
+ - File change notification (optional)
+ - Find and replace dialogs are now modeless
+ - Multiline find and replace through transform backslashes function
+ - Find next / previous word / selected text (Ctrl+F3, Ctrl+Shift+F3)
+ - Find and replace dialogs: exclusive options deactivate each other
+ - Find wrap notification message can be deactivated
+ - Preview function in scheme customization dialog
+ - Quickly change the default font (F2)
+ - Script information is saved along with font settings
+ - Selection and current line background support transparency
+ - Open ASCII files as UTF-8 if the default setting is UTF-8
+ - Open empty files with default encoding and line ending settings
+ - Don't prompt to save modified empty untitled documents
+ - Line endings are always converted to current setting on paste
+ - Ensure consistent line endings option (File, Line Endings, Default)
+ - NTFS streams are preserved when saving files
+ - Switching encoding performs proper text conversion to new encoding
+ - Encoding conversion notification message can be deactivated
+ - Encoding selection dialog displays info about system ANSI code page
+ - Downgraded ANSI code page support to system default only
+ - Big file warning message can be deactivated
+ - "Wrap Text To Column" command (Ctrl+Shift+W)
+ - "Modify Lines" command to prefix and append text to lines (Alt+M)
+ - "Duplicate Selection" command (Alt+D)
+ - "Invert Case" command (Ctrl+Shift+E)
+ - "Clear clipboard" command (in the "Edit" menu)
+ - Force indent and unindent (Ctrl+Tab, Ctrl+Shift+Tab)
+ - Highlight current line (Ctrl+Shift+I)
+ - Additional hotkey for "New File": Ctrl+F4
+ - Mapped Ctrl+Shift+Y/Z to Ctrl+Y/Z
+ - New hotkey for "Tab Settings" (Ctrl+T)
+ - Changed hotkey for "Join Lines" (Ctrl+J)
+ - Rearranged some items in the "View" and "Settings" menus
+ - "Copy" tool button works as "Copy All" when no text selected
+ - "Clear" tool button works as "Clear All" when no text selected
+ - Ctrl+Space: select line if word is already selected
+ - <br>, <hr> and other tags are no longer closed automatically
+ - File, revert now asks if you really want to revert the file
+ - "Open with..." and "Favorites" directories can be relative
+ - Directories can be used as favorites (triggers open dialog)
+ - Filter for open and save dialogs is always set to *.*
+ - Location of metapath.exe can be specified in ini-file
+ - "DefaultDirectory" ini-setting (see FAQ on my website)
+ - "DefaultExtension" ini-setting (see FAQ on my website)
+ - Select print color mode (defaults to color on white)
+ - Don't print separator line if header or footer omitted
+ - Added proper support for multiple monitor systems
+ - Allow multiple window position settings for different screen sizes
+ - Option to use a sticky window position
+ - New command line switches to select syntax schemes: /s, /t, /h, /x
+ - Added Apache Config Files syntax highlighting
+ - Added Perl POD verbatim style
+ - Updated PHP keywords to PHP5
+ - Updated SQL keywords
+ - Updated CSS syntax highlighting to CSS2
+ - Removed NSIS syntax highlighting
+ - Removed ActionScript syntax highlighting
+ - Removed "Bookmarks" feature
+ - Removed "Delete Line Left/Right" and "Transpose Line" commands
+ - Removed code page trace message
+ - Fixed several bugs that caused Notepad2 to crash when saving files
+ - Fixed crash when printing to offline printer
+ - Fixed bug with transparency level setting
+
+
+New in Version 1.0.12 (released June 25, 2004)
+
+ - Notepad2 source code now released under the GNU GPL
+ - "Read Only" option handles file attributes
+ - Enhanced find and replace dialogs with new options
+ - Optionally auto close HTML/XML tags (Ctrl+Shift+H)
+ - Improved tabify/untabify selection functions
+ - New hotkey to select XML scheme (Shift+F11)
+
+
+New in Version 1.0.11 (released May 30, 2004)
+
+ - Simple favorites management based on file shortcuts (Alt+I)
+ - Optional toolbar buttons for favorites management
+ - Improved undo / redo handling of auto indent text
+ - Better cursor behaviour for line editing commands
+ - Clipboard text is converted according to font character set
+ - Auto-select ANSI code page option (File, Encoding, Default...)
+ - Windows system text and background colors used by default
+ - Enabled some new comment styles for C/C++ related languages
+
+
+New in Version 1.0.10 (released May 21, 2004)
+
+ - Option to select a default syntax scheme (F12)
+ - Find, replace, upper- and lowercase handle umlauts and accents
+ - Paste board feature (cmd switch /b) to collect clipboard entries
+ - Text is copied to clipboard in Unicode format (Windows NT/2k/XP)
+ - Reload current file without encoding detection (F8)
+ - Updated CSS properties to version 2.1
+ - "Reuse Window" disabled by default to allow multiple windows
+
+
+New in Version 1.0.09 (released May 13, 2004)
+
+ - Convert tabs to spaces and vice versa (Ctrl+Shift+S/T)
+ - Insert time/date (short form/long form) (Ctrl+F5, Ctrl+Shift+F5)
+ - Insert filename/path and filename (Ctrl+F9, Ctrl+Shift+F9)
+ - Added missing copy line command (Ctrl+Shift+C)
+ - Enabled script selection in font dialogs
+
+
+New in Version 1.0.08 (released May 08, 2004)
+
+ - Find and replace dialogs accept Unicode input (Windows NT/2k/XP)
+ - Warning message for large files (customizable using Notepad2.reg)
+ - Default file extension is "txt" (customizable using Notepad2.reg)
+ - New command line parameters: /c, /g, /?
+ - Fixed writing of hidden and system files (Windows XP/2k)
+ - Fixed some handling problems with relative pathnames
+ - Notepad2.txt outlines how to import and export Notepad2 settings
+
+
+New in Version 1.0.07 (released May 03, 2004)
+
+ - Select default encoding for new files
+ - Select default line endings for new files
+ - Right clicking moves cursor if no selection
+ - Zooming with Ctrl+Mousewheel recalculates line number width
+
+
+New in Version 1.0.06 (released April 30, 2004)
+
+ - Word wrap settings, show word wrap symbols (Ctrl+Shift+0)
+ - Move line up/down (Ctrl+Shift+Up/Down)
+ - Remove blank lines (Alt+R)
+ - Bookmarks for file navigation (Ctrl+F2)
+ - Minimal print header and footer customization
+ - Remapped some keyboard shortcuts (see Notepad2.txt)
+ - Added a few comments to Notepad2.txt
+
+
+New in Version 1.0.05 (released April 26, 2004)
+
+ - Support for XML, ActionScript 2.0, Python, NSIS Script
+ - Fully customizable second default style (Shift+F12)
+ - Find matching brace (Ctrl+B)
+ - Select to matching brace (Ctrl+Shift+B)
+ - Goto column (Ctrl+J)
+ - Optionally change background color of long lines
+ - Transparent mode on Windows 2k and above (Alt+U)
+ - Fixed line endings detection for Unicode files
+
+
+New in Version 1.0.04 (released April 20, 2004)
+
+ - Fixed loading of UTF-8 files with signature
+
+
+New in Version 1.0.03 (released April 19,2004)
+
+ - Toggle word wrap toolbar button
+ - New block command: strip first character (Alt+Z)
+ - Strip trailing blanks uses selection, if any
+
+
+New in Version 1.0.02 (released April 17, 2004)
+
+ - Reload current file (F5)
+ - Revised printing functionality
+ - Zooming recalculates line number width
+
+
+New in Version 1.0.01 (released April 15, 2004)
+
+ - Initial public release
+
+
+Installation and Uninstallation
+
+ Just put a copy of Notepad2.exe and Notepad2.ini to any directory on
+ your computer. To uninstall Notepad2, simply delete these two files.
+ Notepad2 does not create any registry entries on your computer.
+
+
+Keyboard Shortcuts for Notepad2
+
+ File
+
+ Ctrl+N New file.
+ Ctrl+F4 Close file, identical with Ctrl+N.
+ Ctrl+O Open file.
+ F5 Reload file.
+ F8 Recode file.
+ Ctrl+Shift+A Recode file as system default ANSI.
+ Ctrl+Shift+O Recode file as system default OEM.
+ Shift+F8 Recode 7-bit ASCII file as UTF-8.
+ Alt+F8 Reload file without file variable parsing.
+ Ctrl+S Save file.
+ F6 Save file as.
+ Ctrl+F6 Save file copy.
+ Ctrl+P Print file.
+ Alt+H Open recent file.
+
+ Tools
+
+ Alt+N Open document in new window.
+ Alt+0 Open new empty window.
+ Ctrl+M Run metapath file browser plugin.
+ Ctrl+L Launch document.
+ Alt+L Open with.
+ Ctrl+R Run command.
+
+ Favorites
+
+ Alt+I Open favorites.
+ Alt+K Add to favorites.
+ Alt+F9 Manage favorites.
+
+ Edit
+
+ Ctrl+Z Undo.
+ Ctrl+Shift+Z Redo.
+ Alt+Backspace Undo.
+ Ctrl+Y Redo.
+ Ctrl+Shift+Y Undo.
+ Ctrl+X Cut.
+ Shift+Del Cut.
+ Ctrl+C Copy.
+ Alt+C Copy all.
+ Ctrl+E Copy add.
+ Ctrl+V Paste.
+ Shift+Ins Paste.
+ Ctrl+K Swap.
+ Del Clear.
+ Ctrl+A Select all.
+ Alt+Shift+Arrows Rectangular selection.
+ Ctrl+Enter New line with toggled auto indent option.
+ Ctrl+PgUp/PgDn Goto previous/next block.
+ Ctrl+Shift+PgUp/PgDn Select to previous/next block.
+
+ Char, Word
+
+ Ctrl+Space Select word (or line).
+ Ctrl+Backspace Delete word before/left.
+ Ctrl+Del Delete word after/right.
+ Ctrl+Tab Insert tabulator.
+
+ Lines
+
+ Ctrl+Shift+Space Select line.
+ Ctrl+Shift+Up Move line (block) up.
+ Ctrl+Shift+Down Move line (block) down.
+ Ctrl+D Duplicate line.
+ Ctrl+Shift+X Cut line.
+ Ctrl+Shift+C Copy line.
+ Ctrl+Shift+D Delete line.
+ Ctrl+Shift+Backspace Delete line left.
+ Ctrl+Shift+Del Delete line right.
+ Ctrl+Shift+W Column wrap.
+ Ctrl+I Split lines.
+ Ctrl+J Join lines.
+ Ctrl+Shift+J Join paragraphs.
+
+ Block
+
+ Tab Indent selected block.
+ Shift+Tab Unindent selected block.
+ Alt+Q Enclose selection.
+ Alt+D Duplicate selection.
+ Alt+B Pad with spaces.
+ Alt+Z Strip first character.
+ Alt+U Strip last character.
+ Alt+W Strip trailing blanks.
+ Alt+P Compress whitespace.
+ Alt+R Remove blank lines.
+ Alt+M Modify lines.
+ Alt+O Sort lines.
+
+ Convert
+
+ Ctrl+Shift+U Make uppercase.
+ Ctrl+U Make lowercase.
+ Ctrl+Alt+U Invert case.
+ Ctrl+Alt+I Title case.
+ Ctrl+Alt+O Sentence case.
+ Ctrl+Shift+S Convert tabs to spaces.
+ Ctrl+Shift+T Convert spaces to tabs.
+ Ctrl+Alt+S Convert indenting tabs to spaces.
+ Ctrl+Alt+T Convert indenting spaces to tabs.
+
+ Insert
+
+ Alt+X HTML/XML tag.
+ Ctrl+F8 Encoding identifier.
+ Ctrl+F5 Time/date (short form).
+ Ctrl+Shift+F5 Time/date (long form).
+ Ctrl+F9 Filename.
+ Ctrl+Shift+F9 Path and filename.
+
+ Special
+
+ Ctrl+Q Block comment (toggle).
+ Ctrl+Shift+Q Stream comment.
+ Ctrl+Shift+E URL Encode.
+ Ctrl+Shift+R URL Decode.
+ Ctrl+Alt+E Escape C Special Chars.
+ Ctrl+Alt+U Unescape C Special Chars.
+ Ctrl+B Find matching brace.
+ Ctrl+Shift+B Select to matching brace.
+ Ctrl+1 Enclose within ''.
+ Ctrl+2 Enclose within "".
+ Ctrl+3 Enclose within ().
+ Ctrl+4 Enclose within [].
+ Ctrl+5 Enclose within {}.
+ Ctrl+6 Enclose within ``.
+ Shift+F5 Update timestamps.
+ Ctrl+Alt++ Increase number.
+ Ctrl+Alt+- Decrease number.
+ Ctrl+, Jump to selection start.
+ Ctrl+. Jump to selection end.
+
+ Find, Replace
+
+ Ctrl+F Find.
+ Alt+F3 Save find text.
+ F3 Find next.
+ Shift+F3 Find previous.
+ Ctrl+F3 Find next word or selection.
+ Ctrl+Shift+F3 Find previous word or selection.
+ F2 Expand selection to next match.
+ Shift+F2 Expand selection to previous match.
+ Ctrl+H Replace.
+ F4 Replace next.
+ Ctrl+G Jump to line.
+
+ Syntax scheme, Font
+
+ F12 Select syntax scheme.
+ Shift+F12 Select 2nd default syntax scheme.
+ Ctrl+F12 Customize syntax schemes.
+ Alt+F12 Select default font.
+ F11 Select default text syntax scheme.
+ Ctrl+F11 Select web source code syntax scheme.
+ Shift+F11 Select XML document syntax scheme.
+
+ View
+
+ Ctrl+W Toggle word wrap.
+ Ctrl+Shift+L Show long line marker.
+ Ctrl+Shift+G Show indentation guides.
+ Ctrl+Shift+N Show line numbers.
+ Ctrl+Shift+M Show selection margin.
+ Ctrl+Shift+8 Show whitespace.
+ Ctrl+Shift+9 Show line endings.
+ Ctrl+Shift+0 Show wrap symbols.
+ Ctrl+Shift+V Toggle visual brace matching.
+ Ctrl+Shift+I Highlight current line.
+
+ Zoom
+
+ Ctrl++ Zoom in.
+ Ctrl+- Zoom out.
+ Ctrl+/ Reset zoom.
+
+ Settings
+
+ Ctrl+T Tab settings.
+ Alt++ Increase limit for long lines.
+ Alt+- Decrease limit for long lines.
+ Ctrl+Shift+H Toggle auto close HTML/XML.
+ Alt+T Always on top.
+ Ctrl+0 Transparent mode.
+ Alt+F5 File change notification settings.
+ Ctrl+9 Display text excerpt in title.
+ F7 Save settings now.
+ Ctrl+F7 Jump to ini-file.
+
+ Misc.
+
+ Shift+F9 Copy pathname to clipboard.
+ Esc Optionally minimize or exit Notepad2.
+ Shift+Esc Save file and exit Notepad2.
+ F1 Display version info.
+
+
+Regular Expression Syntax
+
+ Note: the Scintilla source code editing component supports only a
+ basic subset of regular expression syntax, and searches are limited
+ to single lines.
+
+ . Matches any character
+
+ \( This marks the start of a region for tagging a match.
+
+ \) This marks the end of a tagged region.
+
+ \n Where n is 1 through 9 refers to the first through ninth
+ tagged region when replacing. For example, if the search
+ string was Fred\([1-9]\)XXX and the replace string was
+ Sam\1YYY, when applied to Fred2XXX this would generate
+ Sam2YYY.
+
+ \< This matches the start of a word.
+
+ \> This matches the end of a word.
+
+ \x This allows you to use a character x that would otherwise
+ have a special meaning. For example, \[ would be interpreted
+ as [ and not as the start of a character set.
+
+ [...] This indicates a set of characters, for example, [abc] means
+ any of the characters a, b or c. You can also use ranges, for
+ example [a-z] for any lower case character.
+
+ [^...] The complement of the characters in the set. For example,
+ [^A-Za-z] means any character except an alphabetic character.
+
+ ^ This matches the start of a line (unless used inside a set,
+ see above).
+
+ $ This matches the end of a line.
+
+ * This matches 0 or more times. For example, Sa*m matches Sm,
+ Sam, Saam, Saaam and so on.
+
+ + This matches 1 or more times. For example, Sa+m matches Sam,
+ Saam, Saaam and so on.
+
+ \d Any decimal digit.
+ \D Any character that is not a decimal digit.
+
+ \s Any whitespace character.
+ \S Any character that is not a whitespace character.
+
+ \w Any "word" character.
+ \W Any "non-word" character.
+
+ \xHH Character with hex code HH.
+
+ -----> Examples (don't use quotes)
+ - Quote lines: find "^" replace with "> "
+ - Unquote lines: find "^> " replace with ""
+ - Remove line numbers: find "^[0-9]+" replace with ""
+ - Convert tabs to double spaces: find "\t" replace with " "
+ - Remove NULL bytes: find "\x00" replace with ""
+
+
+Command Line Switches
+
+ Notepad2.exe [(encoding)] [(line ending mode)] [/e id] [/g ln[,col]]
+ [/m[-][r|b] text] [/q] [/s ext] [/d] [/h] [/x] [/c]
+ [/b] [/n|/ns] [/r|/rs]
+ [/p x,y,cx,cy[,max]|/p0|/ps|/pf,l,t,r,b,m]
+ [/t title] [/i] [/f ini|/f0] [/u] [/z ...] [/?]
+ [+|-] [file] ...
+
+ file File to open, can be a relative pathname, or a shell link.
+ Must be the last argument, no quoted spaces by default.
+ + Accept multiple file arguments (with quoted spaces).
+ - Accept single file argument (without quoted spaces).
+ ... Desired file encoding (can be one of /ansi, /unicode,
+ /unicodebe, /utf8 or /utf8sig).
+ ... Desired line ending mode (either /crlf, /lf, or /cr).
+ /e Specify file source encoding.
+ /g Jump to specified position, /g -1 means end of file.
+ /m Match specified text (/m- last, /mr regex, /mb backslash).
+ /q Force creation of new files without prompt.
+ /s Select syntax scheme associated with specified extension.
+ /d Select default text scheme.
+ /h Select Web Source Code scheme.
+ /x Select XML Document scheme.
+ /c Open a new Notepad2 window and paste the clipboard contents.
+ /b Open a new Notepad2 paste board to collect clipboard entries.
+ /n Always open a new Notepad2 window (/ns single file instance).
+ /r Reuse Notepad2 window (/rs single file instance).
+ /p Set window position to x,y with size cx,cy, optional max set
+ to nonzero to zoom; /p0 system, /ps internal defaults;
+ /p(f)ull,(l)eft,(t)op,(r)ight,(b)ottom,(m)argin.
+ /t Set window title.
+ /i Start as tray icon.
+ /f Specify ini-file; /f0 use no ini-file (don't save settings).
+ /u Launch with elevated privileges.
+ /z Skip next (usable for registry-based Notepad replacement).
+ /? Display a brief summary about command line parameters.
+
+
+Source Code
+
+ Notepad2 is based on the Scintilla source code editing component:
+ http://www.scintilla.org
+
+ The full Notepad2 source code can be found at:
+ http://www.flos-freeware.ch
+
+
+More Information and Resources
+
+ For more information on Notepad2 features, how to replace Windows
+ Notepad, and answers to the most frequently asked questions (FAQ),
+ please visit the Notepad2 website:
+ http://www.flos-freeware.ch
+
+
+Feature Requests
+
+ Thank you very much for the overwhelming feedback about Notepad2!
+ Feature requests are always welcome, but please keep in mind that
+ Notepad2 has been designed as a compact Notepad replacement.
+
+
+Credits and Special Thanks
+
+ Here I would like to say "THANK YOU" to the developers of the great
+ Scintilla source code editing component [1], which is the core of
+ Notepad2. Without Scintilla, the rich features found in Notepad2
+ wouldn't have been possible!
+
+ [1] http://www.scintilla.org
+
+ Many thanks to everybody for sending me bug reports and useful hints.
+ A special thank goes to Roland Weigelt [2] for his helpful thoughts
+ and comments about Notepad2 features and usability in early develop-
+ ment stages. I'd also like to express my thanks to Timo Kunze [3],
+ to Kai Liu [4] and to Moritz Kroll for sending detailed bug reports
+ and ready-to-use patches.
+
+ [2] http://www.roland-weigelt.de
+ [3] http://www.TimoSoft-Software.de
+ [4] http://code.kliu.org/misc/notepad2/
+
+
+Copyright
+
+ Notepad2 is FREE SOFTWARE and may be used and distributed freely.
+ Please do not charge any distribution or download fees for this
+ program, except for the cost of the distribution medium. The use of
+ this software is AT YOUR OWN RISK. See License.txt for full details.
+
+ If you have comments or questions, please drop me a note:
+ florian.balmer@gmail.com
+
+ (c) Florian Balmer 2004-2010
+
+###
diff --git a/Notepad2.vcproj b/Notepad2.vcproj new file mode 100644 index 0000000..09f79dd --- /dev/null +++ b/Notepad2.vcproj @@ -0,0 +1,458 @@ +<?xml version="1.0" encoding = "Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.00"
+ Name="Notepad2"
+ ProjectGUID="{B69A8C7E-A22D-45DA-9997-2D1403C7AEE8}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="1"
+ CharacterSet="1">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="scintilla\include;scintilla\src;scintilla\win32"
+ PreprocessorDefinitions="STATIC_BUILD;SCI_LEXER;UNICODE;_UNICODE"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="FALSE"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="comctl32.lib shlwapi.lib imm32.lib"
+ OutputFile="$(OutDir)/Notepad2.exe"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/Notepad2.pdb"
+ SubSystem="2"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="1"
+ CharacterSet="1">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ InlineFunctionExpansion="1"
+ OmitFramePointers="TRUE"
+ AdditionalIncludeDirectories="scintilla\include;scintilla\src;scintilla\win32"
+ PreprocessorDefinitions="STATIC_BUILD;SCI_LEXER;NDEBUG;UNICODE;_UNICODE"
+ StringPooling="TRUE"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="TRUE"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="FALSE"
+ DebugInformationFormat="0"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="comctl32.lib shlwapi.lib imm32.lib"
+ OutputFile="$(OutDir)/Notepad2.exe"
+ LinkIncremental="1"
+ GenerateDebugInformation="FALSE"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ </Configuration>
+ </Configurations>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm">
+ <File
+ RelativePath="src\Dialogs.c">
+ </File>
+ <File
+ RelativePath="src\Dlapi.c">
+ </File>
+ <File
+ RelativePath="src\Edit.c">
+ </File>
+ <File
+ RelativePath="src\Helpers.c">
+ </File>
+ <File
+ RelativePath="src\Notepad2.c">
+ </File>
+ <File
+ RelativePath="src\Print.cpp">
+ </File>
+ <File
+ RelativePath="src\Styles.c">
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc">
+ <File
+ RelativePath="src\Dialogs.h">
+ </File>
+ <File
+ RelativePath="src\Dlapi.h">
+ </File>
+ <File
+ RelativePath="src\Edit.h">
+ </File>
+ <File
+ RelativePath="src\Helpers.h">
+ </File>
+ <File
+ RelativePath="src\Notepad2.h">
+ </File>
+ <File
+ RelativePath="src\Styles.h">
+ </File>
+ <File
+ RelativePath="src\resource.h">
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;manifest;xpm">
+ <File
+ RelativePath="res\Copy.cur">
+ </File>
+ <File
+ RelativePath="res\Encoding.bmp">
+ </File>
+ <File
+ RelativePath="res\Hover.cur">
+ </File>
+ <File
+ RelativePath="scintilla\win32\Margin.cur">
+ </File>
+ <File
+ RelativePath="res\Next.bmp">
+ </File>
+ <File
+ RelativePath="res\Notepad2.exe.manifest">
+ </File>
+ <File
+ RelativePath="res\Notepad2.ico">
+ </File>
+ <File
+ RelativePath="src\Notepad2.rc">
+ </File>
+ <File
+ RelativePath="res\Open.bmp">
+ </File>
+ <File
+ RelativePath="res\Pick.bmp">
+ </File>
+ <File
+ RelativePath="res\Prev.bmp">
+ </File>
+ <File
+ RelativePath="res\Run.ico">
+ </File>
+ <File
+ RelativePath="res\Styles.ico">
+ </File>
+ <File
+ RelativePath="res\Toolbar.bmp">
+ </File>
+ </Filter>
+ <Filter
+ Name="Scintilla"
+ Filter="">
+ <Filter
+ Name="include"
+ Filter="">
+ <File
+ RelativePath="scintilla\include\Accessor.h">
+ </File>
+ <File
+ RelativePath="scintilla\include\KeyWords.h">
+ </File>
+ <File
+ RelativePath="scintilla\include\Platform.h">
+ </File>
+ <File
+ RelativePath="scintilla\include\PropSet.h">
+ </File>
+ <File
+ RelativePath="scintilla\include\SString.h">
+ </File>
+ <File
+ RelativePath="scintilla\include\SciLexer.h">
+ </File>
+ <File
+ RelativePath="scintilla\include\Scintilla.h">
+ </File>
+ <File
+ RelativePath="scintilla\include\ScintillaWidget.h">
+ </File>
+ <File
+ RelativePath="scintilla\include\WindowAccessor.h">
+ </File>
+ </Filter>
+ <Filter
+ Name="src"
+ Filter="">
+ <File
+ RelativePath="scintilla\src\AutoComplete.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\AutoComplete.h">
+ </File>
+ <File
+ RelativePath="scintilla\src\CallTip.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\CallTip.h">
+ </File>
+ <File
+ RelativePath="scintilla\src\CellBuffer.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\CellBuffer.h">
+ </File>
+ <File
+ RelativePath="scintilla\src\CharClassify.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\CharClassify.h">
+ </File>
+ <File
+ RelativePath="scintilla\src\CharacterSet.h">
+ </File>
+ <File
+ RelativePath="scintilla\src\ContractionState.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\ContractionState.h">
+ </File>
+ <File
+ RelativePath="scintilla\src\Decoration.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\Decoration.h">
+ </File>
+ <File
+ RelativePath="scintilla\src\Document.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\Document.h">
+ </File>
+ <File
+ RelativePath="scintilla\src\DocumentAccessor.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\DocumentAccessor.h">
+ </File>
+ <File
+ RelativePath="scintilla\src\Editor.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\Editor.h">
+ </File>
+ <File
+ RelativePath="scintilla\src\ExternalLexer.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\ExternalLexer.h">
+ </File>
+ <File
+ RelativePath="scintilla\src\Indicator.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\Indicator.h">
+ </File>
+ <File
+ RelativePath="scintilla\src\KeyMap.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\KeyMap.h">
+ </File>
+ <File
+ RelativePath="scintilla\src\KeyWords.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\LexAsm.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\LexCPP.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\LexCSS.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\LexConf.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\LexHTML.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\LexOthers.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\LexPascal.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\LexPerl.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\LexPowerShell.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\LexPython.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\LexSQL.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\LexVB.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\LineMarker.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\LineMarker.h">
+ </File>
+ <File
+ RelativePath="scintilla\src\Partitioning.h">
+ </File>
+ <File
+ RelativePath="scintilla\src\PerLine.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\PerLine.h">
+ </File>
+ <File
+ RelativePath="scintilla\src\PositionCache.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\PositionCache.h">
+ </File>
+ <File
+ RelativePath="scintilla\src\PropSet.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\RESearch.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\RESearch.h">
+ </File>
+ <File
+ RelativePath="scintilla\src\RunStyles.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\RunStyles.h">
+ </File>
+ <File
+ RelativePath="scintilla\src\SVector.h">
+ </File>
+ <File
+ RelativePath="scintilla\src\ScintillaBase.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\ScintillaBase.h">
+ </File>
+ <File
+ RelativePath="scintilla\src\Selection.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\Selection.h">
+ </File>
+ <File
+ RelativePath="scintilla\src\SplitVector.h">
+ </File>
+ <File
+ RelativePath="scintilla\src\Style.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\Style.h">
+ </File>
+ <File
+ RelativePath="scintilla\src\StyleContext.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\StyleContext.h">
+ </File>
+ <File
+ RelativePath="scintilla\src\UniConversion.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\UniConversion.h">
+ </File>
+ <File
+ RelativePath="scintilla\src\ViewStyle.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\ViewStyle.h">
+ </File>
+ <File
+ RelativePath="scintilla\src\WindowAccessor.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\XPM.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\src\XPM.h">
+ </File>
+ </Filter>
+ <Filter
+ Name="win32"
+ Filter="">
+ <File
+ RelativePath="scintilla\win32\PlatWin.cxx">
+ </File>
+ <File
+ RelativePath="scintilla\win32\PlatformRes.h">
+ </File>
+ <File
+ RelativePath="scintilla\win32\ScintillaWin.cxx">
+ </File>
+ </Filter>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/Readme.txt b/Readme.txt new file mode 100644 index 0000000..4cf7c8c --- /dev/null +++ b/Readme.txt @@ -0,0 +1,78 @@ +
+=======================================================================
+= =
+= =
+= Notepad2 - light-weight Scintilla-based text editor for Windows =
+= =
+= =
+= Notepad2 4.1.24 =
+= (c) Florian Balmer 2004-2010 =
+= http://www.flos-freeware.ch =
+= =
+= =
+=======================================================================
+
+
+The Notepad2 Source Code
+
+ This package contains the full source code of Notepad2 4.1.24 for
+ Windows. Project files for Visual C++ 7.0 are included. Chances are
+ that Notepad2 can be rebuilt with other development tools, including
+ the free Visual C++ Express Edition, but I haven't tested this.
+
+
+Rebuilding from the Source Code
+
+ To be able to rebuild Notepad2, the source code of the Scintilla
+ editing component [1] has to be unzipped to the "Scintilla"
+ subdirectory of the Notepad2 source code directory.
+
+ [1] http://www.scintilla.org
+
+ Notepad2 4.1.24 has been created with Scintilla 2.03. The following
+ modification to the Scintilla source code is necessary:
+
+ Scintilla/src/KeyWords.cxx:
+
+ #define LINK_LEXER(lexer) extern LexerModule lexer; ...
+
+ must be replaced with:
+
+ #define LINK_LEXER(lexer) void(0)
+
+
+Creating a Compact Executable Program File
+
+ Linking to the system CRT slightly improves disk footprint, memory
+ usage and startup because the pages for the system CRT are already
+ loaded and shared in memory. To achieve this, the release version of
+ Notepad2.exe is built using the Windows Driver Kit (WDK) 7.1.0 tools,
+ available as a free download from Microsoft. The appropriate build
+ scripts can be found in the "wdkbuild" subdirectory. Set %WDKBASEDIR%
+ to the directory where the WDK tools are located on your system.
+
+
+How to add or modify Syntax Schemes
+
+ The Scintilla documentation has an overview of syntax highlighting,
+ and how to write your own lexing module, in case the language you
+ would like to add is not currently supported by Scintilla.
+
+ Add your own lexer data structs to the global pLexArray (Styles.c),
+ then adjust NUMLEXERS (Styles.h) to the new total number of syntax
+ schemes. The style definitions can be found in SciLexer.h of the
+ Scintilla source code. Include the Lex*.cxx file from Scintilla
+ required for your language into your project.
+
+
+Copyright
+
+ See License.txt for details about distribution and modification.
+
+ If you have any comments or questions, please drop me a note:
+ florian.balmer@gmail.com
+
+ (c) Florian Balmer 2004-2010
+ http://www.flos-freeware.ch
+
+###
diff --git a/res/Copy.cur b/res/Copy.cur Binary files differnew file mode 100644 index 0000000..c86d3ef --- /dev/null +++ b/res/Copy.cur diff --git a/res/Encoding.bmp b/res/Encoding.bmp Binary files differnew file mode 100644 index 0000000..9757b06 --- /dev/null +++ b/res/Encoding.bmp diff --git a/res/Next.bmp b/res/Next.bmp Binary files differnew file mode 100644 index 0000000..1174334 --- /dev/null +++ b/res/Next.bmp diff --git a/res/Notepad2.exe.manifest b/res/Notepad2.exe.manifest new file mode 100644 index 0000000..1d492c1 --- /dev/null +++ b/res/Notepad2.exe.manifest @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
+ <assemblyIdentity
+ name="Notepad2"
+ processorArchitecture="x86"
+ version="5.1.0.0"
+ type="win32"
+ />
+ <description>Notepad2</description>
+ <dependency>
+ <dependentAssembly>
+ <assemblyIdentity
+ type="win32"
+ name="Microsoft.Windows.Common-Controls"
+ version="6.0.0.0"
+ processorArchitecture="x86"
+ publicKeyToken="6595b64144ccf1df"
+ language="*"
+ />
+ </dependentAssembly>
+ </dependency>
+ <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
+ <security>
+ <requestedPrivileges>
+ <requestedExecutionLevel
+ level="asInvoker"
+ uiAccess="false"
+ />
+ </requestedPrivileges>
+ </security>
+ </trustInfo>
+</assembly>
\ No newline at end of file diff --git a/res/Notepad2.ico b/res/Notepad2.ico Binary files differnew file mode 100644 index 0000000..0a34ea4 --- /dev/null +++ b/res/Notepad2.ico diff --git a/res/Open.bmp b/res/Open.bmp Binary files differnew file mode 100644 index 0000000..5c57efa --- /dev/null +++ b/res/Open.bmp diff --git a/res/Pick.bmp b/res/Pick.bmp Binary files differnew file mode 100644 index 0000000..cc9717f --- /dev/null +++ b/res/Pick.bmp diff --git a/res/Prev.bmp b/res/Prev.bmp Binary files differnew file mode 100644 index 0000000..91c9e59 --- /dev/null +++ b/res/Prev.bmp diff --git a/res/Run.ico b/res/Run.ico Binary files differnew file mode 100644 index 0000000..4c0377c --- /dev/null +++ b/res/Run.ico diff --git a/res/Styles.ico b/res/Styles.ico Binary files differnew file mode 100644 index 0000000..6461783 --- /dev/null +++ b/res/Styles.ico diff --git a/res/Toolbar.bmp b/res/Toolbar.bmp Binary files differnew file mode 100644 index 0000000..85206e4 --- /dev/null +++ b/res/Toolbar.bmp diff --git a/src/Dialogs.c b/src/Dialogs.c new file mode 100644 index 0000000..e369891 --- /dev/null +++ b/src/Dialogs.c @@ -0,0 +1,2343 @@ +/******************************************************************************
+*
+*
+* Notepad2
+*
+* Dialogs.c
+* Notepad2 dialog boxes implementation
+*
+* See Readme.txt for more information about this source code.
+* Please send me your comments to this work.
+*
+* See License.txt for details about distribution and modification.
+*
+* (c) Florian Balmer 1996-2010
+* florian.balmer@gmail.com
+* http://www.flos-freeware.ch
+*
+*
+******************************************************************************/
+#define _WIN32_WINNT 0x501
+#include <windows.h>
+#include <commctrl.h>
+#include <shlobj.h>
+#include <shellapi.h>
+#include <shlwapi.h>
+#include <commdlg.h>
+#include <string.h>
+#include "notepad2.h"
+#include "scintilla.h"
+#include "edit.h"
+#include "helpers.h"
+#include "dlapi.h"
+#include "dialogs.h"
+#include "resource.h"
+
+
+extern HWND hwndMain;
+extern HWND hwndEdit;
+extern HINSTANCE g_hInstance;
+extern LPMALLOC g_lpMalloc;
+extern DWORD dwLastIOError;
+extern BOOL bSkipUnicodeDetection;
+extern BOOL bLoadASCIIasUTF8;
+extern int fNoFileVariables;
+extern BOOL bNoEncodingTags;
+extern BOOL bFixLineEndings;
+extern BOOL bAutoStripBlanks;
+extern WCHAR szCurFile[MAX_PATH+40];
+
+
+//=============================================================================
+//
+// MsgBox()
+//
+int MsgBox(int iType,UINT uIdMsg,...)
+{
+
+ WCHAR szText [1024];
+ WCHAR szBuf [1024];
+ WCHAR szTitle[64];
+ int iIcon = 0;
+ HWND hwnd;
+
+ if (!GetString(uIdMsg,szBuf,COUNTOF(szBuf)))
+ return(0);
+
+ wvsprintf(szText,szBuf,(LPVOID)((PUINT_PTR)&uIdMsg + 1));
+
+ if (uIdMsg == IDS_ERR_LOADFILE || uIdMsg == IDS_ERR_SAVEFILE ||
+ uIdMsg == IDS_CREATEINI_FAIL || uIdMsg == IDS_WRITEINI_FAIL) {
+ LPVOID lpMsgBuf;
+ WCHAR wcht;
+ FormatMessage(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ dwLastIOError,
+ MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),
+ (LPTSTR)&lpMsgBuf,
+ 0,
+ NULL);
+ StrTrim(lpMsgBuf,L" \a\b\f\n\r\t\v");
+ StrCatBuff(szText,L"\n",COUNTOF(szText));
+ StrCatBuff(szText,lpMsgBuf,COUNTOF(szText));
+ LocalFree(lpMsgBuf);
+ wcht = *CharPrev(szText,StrEnd(szText));
+ if (IsCharAlphaNumeric(wcht) || wcht == '"' || wcht == '\'')
+ StrCatBuff(szText,L".",COUNTOF(szText));
+ }
+
+ GetString(IDS_APPTITLE,szTitle,COUNTOF(szTitle));
+
+ switch (iType) {
+ case MBINFO: iIcon = MB_ICONEXCLAMATION; break;
+ case MBWARN: iIcon = MB_ICONEXCLAMATION; break;
+ case MBYESNO: iIcon = MB_ICONEXCLAMATION | MB_YESNO; break;
+ case MBYESNOCANCEL: iIcon = MB_ICONEXCLAMATION | MB_YESNOCANCEL; break;
+ case MBYESNOWARN: iIcon = MB_ICONEXCLAMATION | MB_YESNO; break;
+ case MBOKCANCEL: iIcon = MB_ICONEXCLAMATION | MB_OKCANCEL; break;
+ }
+
+ if (!(hwnd = GetFocus()))
+ hwnd = hwndMain;
+
+ return MessageBoxEx(hwnd,
+ szText,szTitle,
+ MB_SETFOREGROUND | iIcon,
+ MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT));
+
+}
+
+
+//=============================================================================
+//
+// DisplayCmdLineHelp()
+//
+void DisplayCmdLineHelp()
+{
+ MSGBOXPARAMS mbp;
+
+ WCHAR szTitle[32];
+ WCHAR szText[2048];
+
+ GetString(IDS_APPTITLE,szTitle,COUNTOF(szTitle));
+ GetString(IDS_CMDLINEHELP,szText,COUNTOF(szText));
+
+ mbp.cbSize = sizeof(MSGBOXPARAMS);
+ mbp.hwndOwner = NULL;
+ mbp.hInstance = g_hInstance;
+ mbp.lpszText = szText;
+ mbp.lpszCaption = szTitle;
+ mbp.dwStyle = MB_OK | MB_USERICON | MB_SETFOREGROUND;
+ mbp.lpszIcon = MAKEINTRESOURCE(IDR_MAINWND);
+ mbp.dwContextHelpId = 0;
+ mbp.lpfnMsgBoxCallback = NULL;
+ mbp.dwLanguageId = MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL);
+
+ MessageBoxIndirect(&mbp);
+}
+
+
+//=============================================================================
+//
+// BFFCallBack()
+//
+int CALLBACK BFFCallBack(HWND hwnd,UINT umsg,LPARAM lParam,LPARAM lpData)
+{
+ if (umsg == BFFM_INITIALIZED)
+ SendMessage(hwnd,BFFM_SETSELECTION,TRUE,lpData);
+
+ return(0);
+
+ lParam;
+}
+
+
+//=============================================================================
+//
+// GetDirectory()
+//
+BOOL GetDirectory(HWND hwndParent,int iTitle,LPWSTR pszFolder,LPCWSTR pszBase,BOOL bNewDialogStyle)
+{
+
+ BROWSEINFO bi;
+ LPITEMIDLIST pidl;
+ //LPMALLOC lpMalloc;
+ WCHAR szTitle[256];
+ WCHAR szBase[MAX_PATH];
+ BOOL fOk = FALSE;
+
+ lstrcpy(szTitle,L"");
+ GetString(iTitle,szTitle,COUNTOF(szTitle));
+
+ if (!pszBase || !*pszBase)
+ GetCurrentDirectory(MAX_PATH,szBase);
+ else
+ lstrcpy(szBase,pszBase);
+
+ bi.hwndOwner = hwndParent;
+ bi.pidlRoot = NULL;
+ bi.pszDisplayName = pszFolder;
+ bi.lpszTitle = szTitle;
+ bi.ulFlags = BIF_RETURNONLYFSDIRS;
+ if (bNewDialogStyle)
+ bi.ulFlags |= BIF_NEWDIALOGSTYLE;
+ bi.lpfn = &BFFCallBack;
+ bi.lParam = (LPARAM)szBase;
+ bi.iImage = 0;
+
+ //if (SHGetMalloc(&lpMalloc) != NOERROR)
+ // return FALSE;
+
+ pidl = SHBrowseForFolder(&bi);
+ if (pidl)
+ {
+ SHGetPathFromIDList(pidl,pszFolder);
+
+ g_lpMalloc->lpVtbl->Free(g_lpMalloc,pidl);
+
+ fOk = TRUE;
+ }
+ //lpMalloc->lpVtbl->Release(lpMalloc);
+
+ return fOk;
+
+}
+
+
+//=============================================================================
+//
+// AboutDlgProc()
+//
+static const DWORD dwVerMajor = 4;
+static const DWORD dwVerMinor = 1;
+static const DWORD dwBuildNumber = 24;
+static const WCHAR* szRevision = L"";
+static const WCHAR* szExtra = L"";
+static const BOOL bReleaseBuild = TRUE;
+
+BOOL CALLBACK AboutDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
+{
+
+ static HFONT hFontTitle;
+
+ switch(umsg)
+ {
+ case WM_INITDIALOG:
+ {
+ WCHAR szVersion[64];
+ WCHAR szDate[64];
+ WCHAR szLink[256];
+ WCHAR szLinkCode[256];
+ LOGFONT lf;
+
+ if (bReleaseBuild) {
+ wsprintf(szVersion,L"Notepad2 %u.%u.%0.2u%s",
+ dwVerMajor,dwVerMinor,dwBuildNumber,szRevision);
+ SetDlgItemText(hwnd,IDC_VERSION,szVersion);
+ }
+ else {
+ MultiByteToWideChar(CP_ACP,0,__DATE__,-1,szDate,COUNTOF(szDate));
+ wsprintf(szVersion,L"Notepad2 %u.%u.%0.2u%s%s %s",
+ dwVerMajor,dwVerMinor,dwBuildNumber,szRevision,szExtra,szDate);
+ SetDlgItemText(hwnd,IDC_VERSION,szVersion);
+ }
+
+ if (hFontTitle)
+ DeleteObject(hFontTitle);
+
+ if (NULL == (hFontTitle = (HFONT)SendDlgItemMessage(hwnd,IDC_VERSION,WM_GETFONT,0,0)))
+ hFontTitle = GetStockObject(DEFAULT_GUI_FONT);
+ GetObject(hFontTitle,sizeof(LOGFONT),&lf);
+ lf.lfWeight = FW_BOLD;
+ hFontTitle = CreateFontIndirect(&lf);
+ SendDlgItemMessage(hwnd,IDC_VERSION,WM_SETFONT,(WPARAM)hFontTitle,TRUE);
+
+ if (GetDlgItem(hwnd,IDC_WEBPAGE) == NULL)
+ ShowWindow(GetDlgItem(hwnd,IDC_WEBPAGE2),SW_SHOWNORMAL);
+ else {
+ GetDlgItemText(hwnd,IDC_WEBPAGE2,szLink,COUNTOF(szLink));
+ wsprintf(szLinkCode,L"<A>%s</A>",szLink);
+ SetDlgItemText(hwnd,IDC_WEBPAGE,szLinkCode);
+ }
+
+ if (GetDlgItem(hwnd,IDC_EMAIL) == NULL)
+ ShowWindow(GetDlgItem(hwnd,IDC_EMAIL2),SW_SHOWNORMAL);
+ else {
+ GetDlgItemText(hwnd,IDC_EMAIL2,szLink,COUNTOF(szLink));
+ wsprintf(szLinkCode,L"<A>%s</A>",szLink);
+ SetDlgItemText(hwnd,IDC_EMAIL,szLinkCode);
+ }
+
+ CenterDlgInParent(hwnd);
+ }
+ return TRUE;
+
+ case WM_NOTIFY:
+ {
+ LPNMHDR pnmhdr = (LPNMHDR)lParam;
+ switch (pnmhdr->code) {
+
+ case NM_CLICK:
+ case NM_RETURN:
+ {
+ if (pnmhdr->idFrom == IDC_WEBPAGE) {
+ ShellExecute(hwnd,L"open",L"http://www.flos-freeware.ch",NULL,NULL,SW_SHOWNORMAL);
+ }
+ else if (pnmhdr->idFrom == IDC_EMAIL) {
+ ShellExecute(hwnd,L"open",L"mailto:florian.balmer@gmail.com",NULL,NULL,SW_SHOWNORMAL);
+ }
+ }
+ break;
+ }
+ }
+ break;
+
+ case WM_COMMAND:
+
+ switch(LOWORD(wParam))
+ {
+ case IDOK:
+ case IDCANCEL:
+ EndDialog(hwnd,IDOK);
+ break;
+ }
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+
+//=============================================================================
+//
+// RunDlgProc()
+//
+BOOL CALLBACK RunDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
+{
+
+ switch(umsg)
+ {
+
+ case WM_INITDIALOG:
+ {
+ MakeBitmapButton(hwnd,IDC_SEARCHEXE,g_hInstance,IDB_OPEN);
+
+ SendDlgItemMessage(hwnd,IDC_COMMANDLINE,EM_LIMITTEXT,MAX_PATH - 1,0);
+ SetDlgItemText(hwnd,IDC_COMMANDLINE,(LPCWSTR)lParam);
+ SHAutoComplete(GetDlgItem(hwnd,IDC_COMMANDLINE),SHACF_FILESYSTEM);
+
+ CenterDlgInParent(hwnd);
+ }
+ return TRUE;
+
+
+ case WM_DESTROY:
+ DeleteBitmapButton(hwnd,IDC_SEARCHEXE);
+ return FALSE;
+
+
+ case WM_COMMAND:
+
+ switch(LOWORD(wParam))
+ {
+
+ case IDC_SEARCHEXE:
+ {
+ WCHAR szArgs[MAX_PATH];
+ WCHAR szArg2[MAX_PATH];
+ WCHAR szFile[MAX_PATH * 2];
+ WCHAR szFilter[256];
+ OPENFILENAME ofn;
+ ZeroMemory(&ofn,sizeof(OPENFILENAME));
+
+ GetDlgItemText(hwnd,IDC_COMMANDLINE,szArgs,COUNTOF(szArgs));
+ ExpandEnvironmentStringsEx(szArgs,COUNTOF(szArgs));
+ ExtractFirstArgument(szArgs,szFile,szArg2);
+
+ GetString(IDS_FILTER_EXE,szFilter,COUNTOF(szFilter));
+ PrepareFilterStr(szFilter);
+
+ ofn.lStructSize = sizeof(OPENFILENAME);
+ ofn.hwndOwner = hwnd;
+ ofn.lpstrFilter = szFilter;
+ ofn.lpstrFile = szFile;
+ ofn.nMaxFile = COUNTOF(szFile);
+ ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_DONTADDTORECENT
+ | OFN_PATHMUSTEXIST | OFN_SHAREAWARE | OFN_NODEREFERENCELINKS;
+
+ if (GetOpenFileName(&ofn)) {
+ PathQuoteSpaces(szFile);
+ if (lstrlen(szArg2))
+ {
+ lstrcat(szFile,L" ");
+ lstrcat(szFile,szArg2);
+ }
+ SetDlgItemText(hwnd,IDC_COMMANDLINE,szFile);
+ }
+
+ PostMessage(hwnd,WM_NEXTDLGCTL,1,0);
+ }
+ break;
+
+
+ case IDC_COMMANDLINE:
+ {
+ BOOL bEnableOK = FALSE;
+ WCHAR args[MAX_PATH];
+
+ if (GetDlgItemText(hwnd,IDC_COMMANDLINE,args,MAX_PATH))
+ if (ExtractFirstArgument(args,args,NULL))
+ if (lstrlen(args))
+ bEnableOK = TRUE;
+
+ EnableWindow(GetDlgItem(hwnd,IDOK),bEnableOK);
+ }
+ break;
+
+
+ case IDOK:
+ {
+ WCHAR arg1[MAX_PATH];
+ WCHAR arg2[MAX_PATH];
+ SHELLEXECUTEINFO sei;
+ WCHAR wchDirectory[MAX_PATH] = L"";
+
+ if (GetDlgItemText(hwnd,IDC_COMMANDLINE,arg1,MAX_PATH))
+ {
+ BOOL bQuickExit = FALSE;
+
+ ExpandEnvironmentStringsEx(arg1,COUNTOF(arg1));
+ ExtractFirstArgument(arg1,arg1,arg2);
+
+ if (lstrcmpi(arg1,L"notepad2") == 0 ||
+ lstrcmpi(arg1,L"notepad2.exe") == 0) {
+ GetModuleFileName(NULL,arg1,COUNTOF(arg1));
+ bQuickExit = TRUE;
+ }
+
+ if (lstrlen(szCurFile)) {
+ lstrcpy(wchDirectory,szCurFile);
+ PathRemoveFileSpec(wchDirectory);
+ }
+
+ ZeroMemory(&sei,sizeof(SHELLEXECUTEINFO));
+
+ sei.cbSize = sizeof(SHELLEXECUTEINFO);
+ sei.fMask = 0;
+ sei.hwnd = hwnd;
+ sei.lpVerb = NULL;
+ sei.lpFile = arg1;
+ sei.lpParameters = arg2;
+ sei.lpDirectory = wchDirectory;
+ sei.nShow = SW_SHOWNORMAL;
+
+ if (bQuickExit) {
+ sei.fMask |= /*SEE_MASK_NOZONECHECKS*/0x00800000;
+ EndDialog(hwnd,IDOK);
+ ShellExecuteEx(&sei);
+ }
+
+ else {
+
+ if (ShellExecuteEx(&sei))
+ EndDialog(hwnd,IDOK);
+
+ else
+ PostMessage(hwnd,WM_NEXTDLGCTL,
+ (WPARAM)(GetDlgItem(hwnd,IDC_COMMANDLINE)),1);
+ }
+ }
+ }
+ break;
+
+
+ case IDCANCEL:
+ EndDialog(hwnd,IDCANCEL);
+ break;
+
+ }
+
+ return TRUE;
+
+ }
+
+ return FALSE;
+
+}
+
+
+//=============================================================================
+//
+// RunDlg()
+//
+void RunDlg(HWND hwnd,LPCWSTR lpstrDefault)
+{
+
+ ThemedDialogBoxParam(g_hInstance,MAKEINTRESOURCE(IDD_RUN),
+ hwnd,RunDlgProc,(LPARAM)lpstrDefault);
+
+}
+
+
+//=============================================================================
+//
+// OpenWithDlgProc()
+//
+extern WCHAR tchOpenWithDir[MAX_PATH];
+extern int flagNoFadeHidden;
+
+extern int cxOpenWithDlg;
+extern int cyOpenWithDlg;
+
+BOOL CALLBACK OpenWithDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
+{
+
+ switch(umsg)
+ {
+
+ case WM_INITDIALOG:
+ {
+ LVCOLUMN lvc = { LVCF_FMT|LVCF_TEXT, LVCFMT_LEFT, 0, L"", -1, 0, 0, 0 };
+
+ ResizeDlg_Init(hwnd,cxOpenWithDlg,cyOpenWithDlg,IDC_RESIZEGRIP3);
+
+ SetWindowLongPtr(hwnd,DWLP_USER,lParam);
+
+ //SetExplorerTheme(GetDlgItem(hwnd,IDC_OPENWITHDIR));
+ ListView_SetExtendedListViewStyle(GetDlgItem(hwnd,IDC_OPENWITHDIR),/*LVS_EX_FULLROWSELECT|*/LVS_EX_DOUBLEBUFFER|LVS_EX_LABELTIP);
+ ListView_InsertColumn(GetDlgItem(hwnd,IDC_OPENWITHDIR),0,&lvc);
+ DirList_Init(GetDlgItem(hwnd,IDC_OPENWITHDIR),NULL);
+ DirList_Fill(GetDlgItem(hwnd,IDC_OPENWITHDIR),tchOpenWithDir,DL_ALLOBJECTS,NULL,FALSE,flagNoFadeHidden,DS_NAME,FALSE);
+ DirList_StartIconThread(GetDlgItem(hwnd,IDC_OPENWITHDIR));
+ ListView_SetItemState(GetDlgItem(hwnd,IDC_OPENWITHDIR),0,LVIS_FOCUSED,LVIS_FOCUSED);
+
+ MakeBitmapButton(hwnd,IDC_GETOPENWITHDIR,g_hInstance,IDB_OPEN);
+
+ CenterDlgInParent(hwnd);
+ }
+ return TRUE;
+
+
+ case WM_DESTROY:
+ DirList_Destroy(GetDlgItem(hwnd,IDC_OPENWITHDIR));
+ DeleteBitmapButton(hwnd,IDC_GETOPENWITHDIR);
+
+ ResizeDlg_Destroy(hwnd,&cxOpenWithDlg,&cyOpenWithDlg);
+ return FALSE;
+
+
+ case WM_SIZE:
+ {
+ int dx;
+ int dy;
+ HDWP hdwp;
+
+ ResizeDlg_Size(hwnd,lParam,&dx,&dy);
+
+ hdwp = BeginDeferWindowPos(6);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDC_RESIZEGRIP3,dx,dy,SWP_NOSIZE);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDOK,dx,dy,SWP_NOSIZE);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDCANCEL,dx,dy,SWP_NOSIZE);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDC_OPENWITHDIR,dx,dy,SWP_NOMOVE);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDC_GETOPENWITHDIR,0,dy,SWP_NOSIZE);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDC_OPENWITHDESCR,0,dy,SWP_NOSIZE);
+ EndDeferWindowPos(hdwp);
+
+ ListView_SetColumnWidth(GetDlgItem(hwnd,IDC_OPENWITHDIR),0,LVSCW_AUTOSIZE_USEHEADER);
+ }
+ return TRUE;
+
+
+ case WM_GETMINMAXINFO:
+ ResizeDlg_GetMinMaxInfo(hwnd,lParam);
+ return TRUE;
+
+
+ case WM_NOTIFY:
+ {
+ LPNMHDR pnmh = (LPNMHDR)lParam;
+
+ if (pnmh->idFrom == IDC_OPENWITHDIR)
+ {
+ switch(pnmh->code)
+ {
+ case LVN_GETDISPINFO:
+ DirList_GetDispInfo(GetDlgItem(hwnd,IDC_OPENWITHDIR),lParam,flagNoFadeHidden);
+ break;
+
+ case LVN_DELETEITEM:
+ DirList_DeleteItem(GetDlgItem(hwnd,IDC_OPENWITHDIR),lParam);
+ break;
+
+ case LVN_ITEMCHANGED: {
+ NM_LISTVIEW *pnmlv = (NM_LISTVIEW*)lParam;
+ EnableWindow(GetDlgItem(hwnd,IDOK),(pnmlv->uNewState & LVIS_SELECTED));
+ }
+ break;
+
+ case NM_DBLCLK:
+ if (ListView_GetSelectedCount(GetDlgItem(hwnd,IDC_OPENWITHDIR)))
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(IDOK,1),0);
+ break;
+ }
+ }
+ }
+ return TRUE;
+
+
+ case WM_COMMAND:
+
+ switch(LOWORD(wParam))
+ {
+
+ case IDC_GETOPENWITHDIR:
+ {
+ if (GetDirectory(hwnd,IDS_OPENWITH,tchOpenWithDir,tchOpenWithDir,TRUE))
+ {
+ DirList_Fill(GetDlgItem(hwnd,IDC_OPENWITHDIR),tchOpenWithDir,DL_ALLOBJECTS,NULL,FALSE,flagNoFadeHidden,DS_NAME,FALSE);
+ DirList_StartIconThread(GetDlgItem(hwnd,IDC_OPENWITHDIR));
+ ListView_EnsureVisible(GetDlgItem(hwnd,IDC_OPENWITHDIR),0,FALSE);
+ ListView_SetItemState(GetDlgItem(hwnd,IDC_OPENWITHDIR),0,LVIS_FOCUSED,LVIS_FOCUSED);
+ }
+ PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_OPENWITHDIR)),1);
+ }
+ break;
+
+
+ case IDOK: {
+ LPDLITEM lpdli = (LPDLITEM)GetWindowLongPtr(hwnd,DWLP_USER);
+ lpdli->mask = DLI_FILENAME | DLI_TYPE;
+ lpdli->ntype = DLE_NONE;
+ DirList_GetItem(GetDlgItem(hwnd,IDC_OPENWITHDIR),(-1),lpdli);
+
+ if (lpdli->ntype != DLE_NONE)
+ EndDialog(hwnd,IDOK);
+ else
+ MessageBeep(0);
+ }
+ break;
+
+
+ case IDCANCEL:
+ EndDialog(hwnd,IDCANCEL);
+ break;
+
+ }
+
+ return TRUE;
+
+ }
+
+ return FALSE;
+
+}
+
+
+//=============================================================================
+//
+// OpenWithDlg()
+//
+BOOL OpenWithDlg(HWND hwnd,LPCWSTR lpstrFile)
+{
+
+ DLITEM dliOpenWith;
+ dliOpenWith.mask = DLI_FILENAME;
+
+ if (IDOK == ThemedDialogBoxParam(g_hInstance,MAKEINTRESOURCE(IDD_OPENWITH),
+ hwnd,OpenWithDlgProc,(LPARAM)&dliOpenWith))
+ {
+ SHELLEXECUTEINFO sei;
+ WCHAR szParam[MAX_PATH];
+ WCHAR wchDirectory[MAX_PATH] = L"";
+
+ if (lstrlen(szCurFile)) {
+ lstrcpy(wchDirectory,szCurFile);
+ PathRemoveFileSpec(wchDirectory);
+ }
+
+ ZeroMemory(&sei,sizeof(SHELLEXECUTEINFO));
+ sei.cbSize = sizeof(SHELLEXECUTEINFO);
+ sei.fMask = 0;
+ sei.hwnd = hwnd;
+ sei.lpVerb = NULL;
+ sei.lpFile = dliOpenWith.szFileName;
+ sei.lpParameters = szParam;
+ sei.lpDirectory = wchDirectory;
+ sei.nShow = SW_SHOWNORMAL;
+
+ // resolve links and get short path name
+ if (!(PathIsLnkFile(lpstrFile) && PathGetLnkPath(lpstrFile,szParam,COUNTOF(szParam))))
+ lstrcpy(szParam,lpstrFile);
+ //GetShortPathName(szParam,szParam,sizeof(WCHAR)*COUNTOF(szParam));
+ PathQuoteSpaces(szParam);
+
+ ShellExecuteEx(&sei);
+
+ return(TRUE);
+ }
+
+ return(FALSE);
+
+}
+
+
+//=============================================================================
+//
+// FavoritesDlgProc()
+//
+extern WCHAR tchFavoritesDir[MAX_PATH];
+//extern int flagNoFadeHidden;
+
+extern int cxFavoritesDlg;
+extern int cyFavoritesDlg;
+
+BOOL CALLBACK FavoritesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
+{
+
+ static HWND hwndLV;
+
+ switch(umsg)
+ {
+
+ case WM_INITDIALOG:
+ {
+ LVCOLUMN lvc = { LVCF_FMT|LVCF_TEXT, LVCFMT_LEFT, 0, L"", -1, 0, 0, 0 };
+
+ ResizeDlg_Init(hwnd,cxFavoritesDlg,cyFavoritesDlg,IDC_RESIZEGRIP3);
+
+ SetWindowLongPtr(hwnd,DWLP_USER,lParam);
+
+ //SetExplorerTheme(GetDlgItem(hwnd,IDC_FAVORITESDIR));
+ ListView_SetExtendedListViewStyle(GetDlgItem(hwnd,IDC_FAVORITESDIR),/*LVS_EX_FULLROWSELECT|*/LVS_EX_DOUBLEBUFFER|LVS_EX_LABELTIP);
+ ListView_InsertColumn(GetDlgItem(hwnd,IDC_FAVORITESDIR),0,&lvc);
+ DirList_Init(GetDlgItem(hwnd,IDC_FAVORITESDIR),NULL);
+ DirList_Fill(GetDlgItem(hwnd,IDC_FAVORITESDIR),tchFavoritesDir,DL_ALLOBJECTS,NULL,FALSE,flagNoFadeHidden,DS_NAME,FALSE);
+ DirList_StartIconThread(GetDlgItem(hwnd,IDC_FAVORITESDIR));
+ ListView_SetItemState(GetDlgItem(hwnd,IDC_FAVORITESDIR),0,LVIS_FOCUSED,LVIS_FOCUSED);
+
+ MakeBitmapButton(hwnd,IDC_GETFAVORITESDIR,g_hInstance,IDB_OPEN);
+
+ CenterDlgInParent(hwnd);
+ }
+ return TRUE;
+
+
+ case WM_DESTROY:
+ DirList_Destroy(GetDlgItem(hwnd,IDC_FAVORITESDIR));
+ DeleteBitmapButton(hwnd,IDC_GETFAVORITESDIR);
+
+ ResizeDlg_Destroy(hwnd,&cxFavoritesDlg,&cyFavoritesDlg);
+ return FALSE;
+
+
+ case WM_SIZE:
+ {
+ int dx;
+ int dy;
+ HDWP hdwp;
+
+ ResizeDlg_Size(hwnd,lParam,&dx,&dy);
+
+ hdwp = BeginDeferWindowPos(6);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDC_RESIZEGRIP3,dx,dy,SWP_NOSIZE);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDOK,dx,dy,SWP_NOSIZE);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDCANCEL,dx,dy,SWP_NOSIZE);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDC_FAVORITESDIR,dx,dy,SWP_NOMOVE);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDC_GETFAVORITESDIR,0,dy,SWP_NOSIZE);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDC_FAVORITESDESCR,0,dy,SWP_NOSIZE);
+ EndDeferWindowPos(hdwp);
+ ListView_SetColumnWidth(GetDlgItem(hwnd,IDC_FAVORITESDIR),0,LVSCW_AUTOSIZE_USEHEADER);
+ }
+ return TRUE;
+
+
+ case WM_GETMINMAXINFO:
+ ResizeDlg_GetMinMaxInfo(hwnd,lParam);
+ return TRUE;
+
+
+ case WM_NOTIFY:
+ {
+ LPNMHDR pnmh = (LPNMHDR)lParam;
+
+ if (pnmh->idFrom == IDC_FAVORITESDIR)
+ {
+ switch(pnmh->code)
+ {
+ case LVN_GETDISPINFO:
+ DirList_GetDispInfo(GetDlgItem(hwnd,IDC_OPENWITHDIR),lParam,flagNoFadeHidden);
+ break;
+
+ case LVN_DELETEITEM:
+ DirList_DeleteItem(GetDlgItem(hwnd,IDC_FAVORITESDIR),lParam);
+ break;
+
+ case LVN_ITEMCHANGED: {
+ NM_LISTVIEW *pnmlv = (NM_LISTVIEW*)lParam;
+ EnableWindow(GetDlgItem(hwnd,IDOK),(pnmlv->uNewState & LVIS_SELECTED));
+ }
+ break;
+
+ case NM_DBLCLK:
+ if (ListView_GetSelectedCount(GetDlgItem(hwnd,IDC_FAVORITESDIR)))
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(IDOK,1),0);
+ break;
+ }
+ }
+ }
+ return TRUE;
+
+
+ case WM_COMMAND:
+
+ switch(LOWORD(wParam))
+ {
+
+ case IDC_GETFAVORITESDIR:
+ {
+ if (GetDirectory(hwnd,IDS_FAVORITES,tchFavoritesDir,tchFavoritesDir,TRUE))
+ {
+ DirList_Fill(GetDlgItem(hwnd,IDC_FAVORITESDIR),tchFavoritesDir,DL_ALLOBJECTS,NULL,FALSE,flagNoFadeHidden,DS_NAME,FALSE);
+ DirList_StartIconThread(GetDlgItem(hwnd,IDC_FAVORITESDIR));
+ ListView_EnsureVisible(GetDlgItem(hwnd,IDC_FAVORITESDIR),0,FALSE);
+ ListView_SetItemState(GetDlgItem(hwnd,IDC_FAVORITESDIR),0,LVIS_FOCUSED,LVIS_FOCUSED);
+ }
+ PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_FAVORITESDIR)),1);
+ }
+ break;
+
+
+ case IDOK: {
+ LPDLITEM lpdli = (LPDLITEM)GetWindowLongPtr(hwnd,DWLP_USER);
+ lpdli->mask = DLI_FILENAME | DLI_TYPE;
+ lpdli->ntype = DLE_NONE;
+ DirList_GetItem(GetDlgItem(hwnd,IDC_FAVORITESDIR),(-1),lpdli);
+
+ if (lpdli->ntype != DLE_NONE)
+ EndDialog(hwnd,IDOK);
+ else
+ MessageBeep(0);
+ }
+ break;
+
+
+ case IDCANCEL:
+ EndDialog(hwnd,IDCANCEL);
+ break;
+
+ }
+
+ return TRUE;
+
+ }
+
+ return FALSE;
+
+}
+
+
+//=============================================================================
+//
+// FavoritesDlg()
+//
+BOOL FavoritesDlg(HWND hwnd,LPWSTR lpstrFile)
+{
+
+ DLITEM dliFavorite;
+ dliFavorite.mask = DLI_FILENAME;
+
+ if (IDOK == ThemedDialogBoxParam(g_hInstance,MAKEINTRESOURCE(IDD_FAVORITES),
+ hwnd,FavoritesDlgProc,(LPARAM)&dliFavorite))
+ {
+ lstrcpyn(lpstrFile,dliFavorite.szFileName,MAX_PATH);
+ return(TRUE);
+ }
+
+ return(FALSE);
+
+}
+
+
+//=============================================================================
+//
+// AddToFavDlgProc()
+//
+// Controls: 100 Edit
+//
+BOOL CALLBACK AddToFavDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
+{
+
+ switch(umsg)
+ {
+
+ WCHAR *pszName;
+
+ case WM_INITDIALOG:
+ pszName = (LPWSTR)lParam;
+ SetWindowLongPtr(hwnd,DWLP_USER,(LONG_PTR)pszName);
+
+ SendDlgItemMessage(hwnd,100,EM_LIMITTEXT,MAX_PATH-1,0);
+ SetDlgItemText(hwnd,100,pszName);
+
+ CenterDlgInParent(hwnd);
+ return TRUE;
+
+
+ case WM_COMMAND:
+
+ switch(LOWORD(wParam))
+ {
+
+ case 100:
+ EnableWindow(GetDlgItem(hwnd,IDOK),
+ GetWindowTextLength(GetDlgItem(hwnd,100)));
+ break;
+
+
+ case IDOK:
+ pszName = (LPWSTR)GetWindowLongPtr(hwnd,DWLP_USER);
+ GetDlgItemText(hwnd,100,pszName,
+ MAX_PATH-1);
+ EndDialog(hwnd,IDOK);
+ break;
+
+
+ case IDCANCEL:
+ EndDialog(hwnd,IDCANCEL);
+ break;
+
+ }
+
+ return TRUE;
+
+ }
+
+ return FALSE;
+
+}
+
+
+//=============================================================================
+//
+// AddToFavDlg()
+//
+BOOL AddToFavDlg(HWND hwnd,LPCWSTR lpszName,LPCWSTR lpszTarget)
+{
+
+ int iResult;
+
+ WCHAR pszName[MAX_PATH];
+ lstrcpy(pszName,lpszName);
+
+ iResult = ThemedDialogBoxParam(
+ g_hInstance,
+ MAKEINTRESOURCE(IDD_ADDTOFAV),
+ hwnd,
+ AddToFavDlgProc,(LPARAM)pszName);
+
+ if (iResult == IDOK)
+ {
+ if (!PathCreateFavLnk(pszName,lpszTarget,tchFavoritesDir)) {
+ MsgBox(MBWARN,IDS_FAV_FAILURE);
+ return FALSE;
+ }
+
+ else {
+ MsgBox(MBINFO,IDS_FAV_SUCCESS);
+ return TRUE;
+ }
+ }
+
+ else
+ return FALSE;
+
+}
+
+
+//=============================================================================
+//
+// FileMRUDlgProc()
+//
+//
+extern LPMRULIST pFileMRU;
+extern BOOL bSaveRecentFiles;
+extern int cxFileMRUDlg;
+extern int cyFileMRUDlg;
+extern int flagNoFadeHidden;
+
+typedef struct tagIconThreadInfo
+{
+ HWND hwnd; // HWND of ListView Control
+ HANDLE hExitThread; // Flag is set when Icon Thread should terminate
+ HANDLE hTerminatedThread; // Flag is set when Icon Thread has terminated
+
+} ICONTHREADINFO, *LPICONTHREADINFO;
+
+DWORD WINAPI FileMRUIconThread(LPVOID lpParam) {
+
+ HWND hwnd;
+ LPICONTHREADINFO lpit;
+ LV_ITEM lvi;
+ WCHAR tch[MAX_PATH];
+ SHFILEINFO shfi;
+ DWORD dwFlags = SHGFI_SMALLICON | SHGFI_SYSICONINDEX | SHGFI_ATTRIBUTES | SHGFI_ATTR_SPECIFIED;
+ DWORD dwAttr = 0;
+ int iItem = 0;
+ int iMaxItem;
+
+ lpit = (LPICONTHREADINFO)lpParam;
+ ResetEvent(lpit->hTerminatedThread);
+
+ hwnd = lpit->hwnd;
+ iMaxItem = ListView_GetItemCount(hwnd);
+
+ CoInitialize(NULL);
+
+ ZeroMemory(&lvi,sizeof(LV_ITEM));
+
+ while (iItem < iMaxItem && WaitForSingleObject(lpit->hExitThread,0) != WAIT_OBJECT_0) {
+
+ lvi.mask = LVIF_TEXT;
+ lvi.pszText = tch;
+ lvi.cchTextMax = COUNTOF(tch);
+ lvi.iItem = iItem;
+ if (ListView_GetItem(hwnd,&lvi)) {
+
+ if (PathIsUNC(tch) || !PathFileExists(tch)) {
+ dwFlags |= SHGFI_USEFILEATTRIBUTES;
+ dwAttr = FILE_ATTRIBUTE_NORMAL;
+ shfi.dwAttributes = 0;
+ SHGetFileInfo(PathFindFileName(tch),dwAttr,&shfi,sizeof(SHFILEINFO),dwFlags);
+ }
+
+ else {
+ shfi.dwAttributes = SFGAO_LINK | SFGAO_SHARE;
+ SHGetFileInfo(tch,dwAttr,&shfi,sizeof(SHFILEINFO),dwFlags);
+ }
+
+ lvi.mask = LVIF_IMAGE;
+ lvi.iImage = shfi.iIcon;
+ lvi.stateMask = 0;
+ lvi.state = 0;
+
+ if (shfi.dwAttributes & SFGAO_LINK) {
+ lvi.mask |= LVIF_STATE;
+ lvi.stateMask |= LVIS_OVERLAYMASK;
+ lvi.state |= INDEXTOOVERLAYMASK(2);
+ }
+
+ if (shfi.dwAttributes & SFGAO_SHARE) {
+ lvi.mask |= LVIF_STATE;
+ lvi.stateMask |= LVIS_OVERLAYMASK;
+ lvi.state |= INDEXTOOVERLAYMASK(1);
+ }
+
+ if (PathIsUNC(tch))
+ dwAttr = FILE_ATTRIBUTE_NORMAL;
+ else
+ dwAttr = GetFileAttributes(tch);
+
+ if (!flagNoFadeHidden &&
+ dwAttr != INVALID_FILE_ATTRIBUTES &&
+ dwAttr & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM)) {
+ lvi.mask |= LVIF_STATE;
+ lvi.stateMask |= LVIS_CUT;
+ lvi.state |= LVIS_CUT;
+ }
+
+ lvi.iSubItem = 0;
+ ListView_SetItem(hwnd,&lvi);
+ }
+ iItem++;
+ }
+
+ CoUninitialize();
+
+ SetEvent(lpit->hTerminatedThread);
+ ExitThread(0);
+ return(0);
+}
+
+BOOL CALLBACK FileMRUDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
+{
+
+ switch(umsg)
+ {
+
+ case WM_INITDIALOG:
+ {
+ SHFILEINFO shfi;
+ LVCOLUMN lvc = { LVCF_FMT|LVCF_TEXT, LVCFMT_LEFT, 0, L"", -1, 0, 0, 0 };
+
+ LPICONTHREADINFO lpit = (LPVOID)GlobalAlloc(GPTR,sizeof(ICONTHREADINFO));
+ SetProp(hwnd,L"it",(HANDLE)lpit);
+ lpit->hwnd = GetDlgItem(hwnd,IDC_FILEMRU);
+ lpit->hExitThread = CreateEvent(NULL,TRUE,FALSE,NULL);
+ lpit->hTerminatedThread = CreateEvent(NULL,TRUE,TRUE,NULL);
+
+ SetWindowLongPtr(hwnd,DWLP_USER,lParam);
+
+ ResizeDlg_Init(hwnd,cxFileMRUDlg,cyFileMRUDlg,IDC_RESIZEGRIP);
+
+ ListView_SetImageList(GetDlgItem(hwnd,IDC_FILEMRU),
+ (HIMAGELIST)SHGetFileInfo(L"C:\\",0,&shfi,sizeof(SHFILEINFO),SHGFI_SMALLICON | SHGFI_SYSICONINDEX),
+ LVSIL_SMALL);
+
+ ListView_SetImageList(GetDlgItem(hwnd,IDC_FILEMRU),
+ (HIMAGELIST)SHGetFileInfo(L"C:\\",0,&shfi,sizeof(SHFILEINFO),SHGFI_LARGEICON | SHGFI_SYSICONINDEX),
+ LVSIL_NORMAL);
+
+ //SetExplorerTheme(GetDlgItem(hwnd,IDC_FILEMRU));
+ ListView_SetExtendedListViewStyle(GetDlgItem(hwnd,IDC_FILEMRU),/*LVS_EX_FULLROWSELECT|*/LVS_EX_DOUBLEBUFFER|LVS_EX_LABELTIP);
+ ListView_InsertColumn(GetDlgItem(hwnd,IDC_FILEMRU),0,&lvc);
+
+ // Update view
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(0x00A0,1),0);
+
+ if (bSaveRecentFiles)
+ CheckDlgButton(hwnd,IDC_SAVEMRU,BST_CHECKED);
+
+ CenterDlgInParent(hwnd);
+ }
+ return TRUE;
+
+
+ case WM_DESTROY:
+ {
+ LPICONTHREADINFO lpit = (LPVOID)GetProp(hwnd,L"it");
+ SetEvent(lpit->hExitThread);
+ while (WaitForSingleObject(lpit->hTerminatedThread,0) != WAIT_OBJECT_0) {
+ MSG msg;
+ if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ }
+ CloseHandle(lpit->hExitThread);
+ CloseHandle(lpit->hTerminatedThread);
+ RemoveProp(hwnd,L"it");
+ GlobalFree(lpit);
+
+ bSaveRecentFiles = (IsDlgButtonChecked(hwnd,IDC_SAVEMRU)) ? 1 : 0;
+
+ ResizeDlg_Destroy(hwnd,&cxFileMRUDlg,&cyFileMRUDlg);
+ }
+ return FALSE;
+
+
+ case WM_SIZE:
+ {
+ int dx;
+ int dy;
+ HDWP hdwp;
+
+ ResizeDlg_Size(hwnd,lParam,&dx,&dy);
+
+ hdwp = BeginDeferWindowPos(5);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDC_RESIZEGRIP,dx,dy,SWP_NOSIZE);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDOK,dx,dy,SWP_NOSIZE);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDCANCEL,dx,dy,SWP_NOSIZE);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDC_FILEMRU,dx,dy,SWP_NOMOVE);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDC_SAVEMRU,0,dy,SWP_NOSIZE);
+ EndDeferWindowPos(hdwp);
+ ListView_SetColumnWidth(GetDlgItem(hwnd,IDC_FILEMRU),0,LVSCW_AUTOSIZE_USEHEADER);
+ }
+ return TRUE;
+
+
+ case WM_GETMINMAXINFO:
+ ResizeDlg_GetMinMaxInfo(hwnd,lParam);
+ return TRUE;
+
+
+ case WM_NOTIFY: {
+ if (((LPNMHDR)(lParam))->idFrom == IDC_FILEMRU) {
+
+ switch (((LPNMHDR)(lParam))->code) {
+
+ case NM_DBLCLK:
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(IDOK,1),0);
+ break;
+
+
+ case LVN_GETDISPINFO: {
+ /*
+ LV_DISPINFO *lpdi = (LPVOID)lParam;
+
+ if (lpdi->item.mask & LVIF_IMAGE) {
+
+ WCHAR tch[MAX_PATH];
+ LV_ITEM lvi;
+ SHFILEINFO shfi;
+ DWORD dwFlags = SHGFI_SMALLICON | SHGFI_SYSICONINDEX | SHGFI_ATTRIBUTES | SHGFI_ATTR_SPECIFIED;
+ DWORD dwAttr = 0;
+
+ ZeroMemory(&lvi,sizeof(LV_ITEM));
+
+ lvi.mask = LVIF_TEXT;
+ lvi.pszText = tch;
+ lvi.cchTextMax = COUNTOF(tch);
+ lvi.iItem = lpdi->item.iItem;
+
+ ListView_GetItem(GetDlgItem(hwnd,IDC_FILEMRU),&lvi);
+
+ if (!PathFileExists(tch)) {
+ dwFlags |= SHGFI_USEFILEATTRIBUTES;
+ dwAttr = FILE_ATTRIBUTE_NORMAL;
+ shfi.dwAttributes = 0;
+ SHGetFileInfo(PathFindFileName(tch),dwAttr,&shfi,sizeof(SHFILEINFO),dwFlags);
+ }
+
+ else {
+ shfi.dwAttributes = SFGAO_LINK | SFGAO_SHARE;
+ SHGetFileInfo(tch,dwAttr,&shfi,sizeof(SHFILEINFO),dwFlags);
+ }
+
+ lpdi->item.iImage = shfi.iIcon;
+ lpdi->item.mask |= LVIF_DI_SETITEM;
+
+ lpdi->item.stateMask = 0;
+ lpdi->item.state = 0;
+
+ if (shfi.dwAttributes & SFGAO_LINK) {
+ lpdi->item.mask |= LVIF_STATE;
+ lpdi->item.stateMask |= LVIS_OVERLAYMASK;
+ lpdi->item.state |= INDEXTOOVERLAYMASK(2);
+ }
+
+ if (shfi.dwAttributes & SFGAO_SHARE) {
+ lpdi->item.mask |= LVIF_STATE;
+ lpdi->item.stateMask |= LVIS_OVERLAYMASK;
+ lpdi->item.state |= INDEXTOOVERLAYMASK(1);
+ }
+
+ dwAttr = GetFileAttributes(tch);
+
+ if (!flagNoFadeHidden &&
+ dwAttr != INVALID_FILE_ATTRIBUTES &&
+ dwAttr & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM)) {
+ lpdi->item.mask |= LVIF_STATE;
+ lpdi->item.stateMask |= LVIS_CUT;
+ lpdi->item.state |= LVIS_CUT;
+ }
+ }
+ */
+ }
+ break;
+
+
+ case LVN_ITEMCHANGED:
+ case LVN_DELETEITEM:
+ EnableWindow(GetDlgItem(hwnd,IDOK),ListView_GetSelectedCount(GetDlgItem(hwnd,IDC_FILEMRU)));
+ break;
+ }
+ }
+ }
+
+ return TRUE;
+
+
+ case WM_COMMAND:
+
+ switch(LOWORD(wParam))
+ {
+
+ case 0x00A0:
+ {
+ int i;
+ WCHAR tch[MAX_PATH];
+ LV_ITEM lvi;
+ SHFILEINFO shfi;
+
+ DWORD dwtid;
+ LPICONTHREADINFO lpit = (LPVOID)GetProp(hwnd,L"it");
+
+ SetEvent(lpit->hExitThread);
+ while (WaitForSingleObject(lpit->hTerminatedThread,0) != WAIT_OBJECT_0) {
+ MSG msg;
+ if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ }
+ ResetEvent(lpit->hExitThread);
+ SetEvent(lpit->hTerminatedThread);
+
+ ListView_DeleteAllItems(GetDlgItem(hwnd,IDC_FILEMRU));
+
+ ZeroMemory(&lvi,sizeof(LV_ITEM));
+ lvi.mask = LVIF_TEXT | LVIF_IMAGE;
+
+ SHGetFileInfo(L"Icon",FILE_ATTRIBUTE_NORMAL,&shfi,sizeof(SHFILEINFO),
+ SHGFI_USEFILEATTRIBUTES | SHGFI_SMALLICON | SHGFI_SYSICONINDEX);
+ lvi.iImage = shfi.iIcon;
+
+ for (i = 0; i < MRU_Enum(pFileMRU,0,NULL,0); i++) {
+ MRU_Enum(pFileMRU,i,tch,COUNTOF(tch));
+ PathAbsoluteFromApp(tch,NULL,0,TRUE);
+ // SendDlgItemMessage(hwnd,IDC_FILEMRU,LB_ADDSTRING,0,(LPARAM)tch); }
+ // SendDlgItemMessage(hwnd,IDC_FILEMRU,LB_SETCARETINDEX,0,FALSE);
+ lvi.iItem = i;
+ lvi.pszText = tch;
+ ListView_InsertItem(GetDlgItem(hwnd,IDC_FILEMRU),&lvi);
+ }
+
+ ListView_SetItemState(GetDlgItem(hwnd,IDC_FILEMRU),0,LVIS_FOCUSED,LVIS_FOCUSED);
+ ListView_SetColumnWidth(GetDlgItem(hwnd,IDC_FILEMRU),0,LVSCW_AUTOSIZE_USEHEADER);
+
+ CreateThread(NULL,0,FileMRUIconThread,(LPVOID)lpit,0,&dwtid);
+ }
+ break;
+
+ case IDC_FILEMRU:
+ break;
+
+
+ case IDOK:
+ {
+ WCHAR tch[MAX_PATH];
+ //int iItem;
+
+ //if ((iItem = SendDlgItemMessage(hwnd,IDC_FILEMRU,LB_GETCURSEL,0,0)) != LB_ERR)
+ if (ListView_GetSelectedCount(GetDlgItem(hwnd,IDC_FILEMRU)))
+ {
+ //SendDlgItemMessage(hwnd,IDC_FILEMRU,LB_GETTEXT,(WPARAM)iItem,(LPARAM)tch);
+ LV_ITEM lvi;
+ ZeroMemory(&lvi,sizeof(LV_ITEM));
+
+ lvi.mask = LVIF_TEXT;
+ lvi.pszText = tch;
+ lvi.cchTextMax = COUNTOF(tch);
+ lvi.iItem = ListView_GetNextItem(GetDlgItem(hwnd,IDC_FILEMRU),-1,LVNI_ALL | LVNI_SELECTED);
+
+ ListView_GetItem(GetDlgItem(hwnd,IDC_FILEMRU),&lvi);
+
+ PathUnquoteSpaces(tch);
+
+ if (!PathFileExists(tch)) {
+
+ // Ask...
+ if (IDYES == MsgBox(MBYESNO,IDS_ERR_MRUDLG)) {
+
+ MRU_Delete(pFileMRU,lvi.iItem);
+ MRU_DeleteFileFromStore(pFileMRU,tch);
+
+ //SendDlgItemMessage(hwnd,IDC_FILEMRU,LB_DELETESTRING,(WPARAM)iItem,0);
+ //ListView_DeleteItem(GetDlgItem(hwnd,IDC_FILEMRU),lvi.iItem);
+ // must use IDM_VIEW_REFRESH, index might change...
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(0x00A0,1),0);
+
+ //EnableWindow(GetDlgItem(hwnd,IDOK),
+ // (LB_ERR != SendDlgItemMessage(hwnd,IDC_GOTO,LB_GETCURSEL,0,0)));
+
+ EnableWindow(GetDlgItem(hwnd,IDOK),
+ ListView_GetSelectedCount(GetDlgItem(hwnd,IDC_FILEMRU)));
+ }
+ }
+
+ else {
+ lstrcpy((LPWSTR)GetWindowLongPtr(hwnd,DWLP_USER),tch);
+ EndDialog(hwnd,IDOK);
+ }
+ }
+ }
+ break;
+
+
+ case IDCANCEL:
+ EndDialog(hwnd,IDCANCEL);
+ break;
+
+ }
+
+ return TRUE;
+
+ }
+
+ return FALSE;
+
+}
+
+
+//=============================================================================
+//
+// FileMRUDlg()
+//
+//
+BOOL FileMRUDlg(HWND hwnd,LPWSTR lpstrFile)
+{
+
+ if (IDOK == ThemedDialogBoxParam(g_hInstance,MAKEINTRESOURCE(IDD_FILEMRU),
+ hwnd,FileMRUDlgProc,(LPARAM)lpstrFile))
+ return TRUE;
+ else
+ return FALSE;
+
+}
+
+
+//=============================================================================
+//
+// ChangeNotifyDlgProc()
+//
+// Controls: 100 Radio Button
+// 101 Radio Button
+// 102 Radio Button
+// 103 Check Box
+//
+extern int iFileWatchingMode;
+extern BOOL bResetFileWatching;
+
+BOOL CALLBACK ChangeNotifyDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
+{
+ switch(umsg)
+ {
+ case WM_INITDIALOG:
+ CheckRadioButton(hwnd,100,102,100+iFileWatchingMode);
+ if (bResetFileWatching)
+ CheckDlgButton(hwnd,103,BST_CHECKED);
+ CenterDlgInParent(hwnd);
+ return TRUE;
+
+ case WM_COMMAND:
+ switch(LOWORD(wParam))
+ {
+ case IDOK:
+ if (IsDlgButtonChecked(hwnd,100) == BST_CHECKED)
+ iFileWatchingMode = 0;
+ else if (IsDlgButtonChecked(hwnd,101) == BST_CHECKED)
+ iFileWatchingMode = 1;
+ else
+ iFileWatchingMode = 2;
+ bResetFileWatching = (IsDlgButtonChecked(hwnd,103) == BST_CHECKED) ? TRUE : FALSE;
+ EndDialog(hwnd,IDOK);
+ break;
+
+ case IDCANCEL:
+ EndDialog(hwnd,IDCANCEL);
+ break;
+ }
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+//=============================================================================
+//
+// ChangeNotifyDlg()
+//
+BOOL ChangeNotifyDlg(HWND hwnd)
+{
+
+ int iResult;
+
+ iResult = ThemedDialogBoxParam(
+ g_hInstance,
+ MAKEINTRESOURCEW(IDD_CHANGENOTIFY),
+ hwnd,
+ ChangeNotifyDlgProc,
+ 0);
+
+ return (iResult == IDOK) ? TRUE : FALSE;
+
+}
+
+
+//=============================================================================
+//
+// ColumnWrapDlgProc()
+//
+// Controls: 100 Edit
+//
+BOOL CALLBACK ColumnWrapDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
+{
+
+ static int *piNumber;
+
+ switch(umsg)
+ {
+
+ case WM_INITDIALOG:
+ {
+
+ piNumber = (int*)lParam;
+
+ SetDlgItemInt(hwnd,100,*piNumber,FALSE);
+ SendDlgItemMessage(hwnd,100,EM_LIMITTEXT,15,0);
+
+ CenterDlgInParent(hwnd);
+
+ }
+ return TRUE;
+
+
+ case WM_COMMAND:
+
+ switch(LOWORD(wParam))
+ {
+
+ case IDOK: {
+
+ BOOL fTranslated;
+
+ int iNewNumber = GetDlgItemInt(hwnd,100,&fTranslated,FALSE);
+
+ if (fTranslated)
+ {
+ *piNumber = iNewNumber;
+
+ EndDialog(hwnd,IDOK);
+ }
+
+ else
+ PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,100)),1);
+
+ }
+ break;
+
+
+ case IDCANCEL:
+ EndDialog(hwnd,IDCANCEL);
+ break;
+
+ }
+
+ return TRUE;
+
+ }
+
+ return FALSE;
+
+}
+
+
+//=============================================================================
+//
+// ColumnWrapDlg()
+//
+BOOL ColumnWrapDlg(HWND hwnd,UINT uidDlg,int *iNumber)
+{
+
+ int iResult;
+
+ iResult = ThemedDialogBoxParam(
+ g_hInstance,
+ MAKEINTRESOURCE(uidDlg),
+ hwnd,
+ ColumnWrapDlgProc,(LPARAM)iNumber);
+
+ return (iResult == IDOK) ? TRUE : FALSE;
+
+}
+
+
+//=============================================================================
+//
+// WordWrapSettingsDlgProc()
+//
+// Controls: 100 Combo
+// 101 Combo
+// 102 Combo
+// 103 Combo
+// 200 Text
+// 201 Text
+// 202 Text
+// 203 Text
+//
+extern int iWordWrapMode;
+extern int iWordWrapIndent;
+extern int iWordWrapSymbols;
+extern BOOL bShowWordWrapSymbols;
+
+BOOL CALLBACK WordWrapSettingsDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
+{
+
+ switch(umsg)
+ {
+
+ case WM_INITDIALOG:
+ {
+
+ WCHAR tch[512];
+ WCHAR *p1, *p2;
+ int i;
+
+ for (i = 0; i < 4; i++) {
+ GetDlgItemText(hwnd,200+i,tch,COUNTOF(tch));
+ lstrcat(tch,L"|");
+ p1 = tch;
+ while (p2 = StrChr(p1,L'|')) {
+ *p2++ = L'\0';
+ if (*p1)
+ SendDlgItemMessage(hwnd,100+i,CB_ADDSTRING,0,(LPARAM)p1);
+ p1 = p2;
+ }
+
+ SendDlgItemMessage(hwnd,100+i,CB_SETEXTENDEDUI,TRUE,0);
+ }
+
+ SendDlgItemMessage(hwnd,100,CB_SETCURSEL,(WPARAM)iWordWrapIndent,0);
+ SendDlgItemMessage(hwnd,101,CB_SETCURSEL,(WPARAM)(bShowWordWrapSymbols) ? iWordWrapSymbols%10 : 0,0);
+ SendDlgItemMessage(hwnd,102,CB_SETCURSEL,(WPARAM)(bShowWordWrapSymbols) ? ((iWordWrapSymbols%100)-(iWordWrapSymbols%10))/10 : 0,0);
+ SendDlgItemMessage(hwnd,103,CB_SETCURSEL,(WPARAM)iWordWrapMode,0);
+
+ CenterDlgInParent(hwnd);
+
+ }
+ return TRUE;
+
+
+ case WM_COMMAND:
+
+ switch(LOWORD(wParam))
+ {
+
+ case IDOK: {
+
+ int iSel, iSel2;
+
+ iSel = SendDlgItemMessage(hwnd,100,CB_GETCURSEL,0,0);
+ iWordWrapIndent = iSel;
+
+ bShowWordWrapSymbols = FALSE;
+ iSel = SendDlgItemMessage(hwnd,101,CB_GETCURSEL,0,0);
+ iSel2 = SendDlgItemMessage(hwnd,102,CB_GETCURSEL,0,0);
+ if (iSel > 0 || iSel2 > 0) {
+ bShowWordWrapSymbols = TRUE;
+ iWordWrapSymbols = iSel + iSel2*10;
+ }
+
+ iSel = SendDlgItemMessage(hwnd,103,CB_GETCURSEL,0,0);
+ iWordWrapMode = iSel;
+
+ EndDialog(hwnd,IDOK);
+ }
+ break;
+
+
+ case IDCANCEL:
+ EndDialog(hwnd,IDCANCEL);
+ break;
+
+ }
+
+ return TRUE;
+
+ }
+
+ return FALSE;
+
+}
+
+
+//=============================================================================
+//
+// WordWrapSettingsDlg()
+//
+BOOL WordWrapSettingsDlg(HWND hwnd,UINT uidDlg,int *iNumber)
+{
+
+ int iResult;
+
+ iResult = ThemedDialogBoxParam(
+ g_hInstance,
+ MAKEINTRESOURCE(uidDlg),
+ hwnd,
+ WordWrapSettingsDlgProc,(LPARAM)iNumber);
+
+ return (iResult == IDOK) ? TRUE : FALSE;
+
+}
+
+
+//=============================================================================
+//
+// LongLineSettingsDlgProc()
+//
+// Controls: 100 Edit
+// 101 Radio1
+// 102 Radio2
+//
+extern int iLongLineMode;
+
+BOOL CALLBACK LongLineSettingsDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
+{
+
+ static int *piNumber;
+
+ switch(umsg)
+ {
+
+ case WM_INITDIALOG:
+ {
+
+ piNumber = (int*)lParam;
+
+ SetDlgItemInt(hwnd,100,*piNumber,FALSE);
+ SendDlgItemMessage(hwnd,100,EM_LIMITTEXT,15,0);
+
+ if (iLongLineMode == EDGE_LINE)
+ CheckRadioButton(hwnd,101,102,101);
+ else
+ CheckRadioButton(hwnd,101,102,102);
+
+ CenterDlgInParent(hwnd);
+
+ }
+ return TRUE;
+
+
+ case WM_COMMAND:
+
+ switch(LOWORD(wParam))
+ {
+
+ case IDOK: {
+
+ BOOL fTranslated;
+
+ int iNewNumber = GetDlgItemInt(hwnd,100,&fTranslated,FALSE);
+
+ if (fTranslated)
+ {
+ *piNumber = iNewNumber;
+
+ iLongLineMode = (IsDlgButtonChecked(hwnd,101)) ? EDGE_LINE : EDGE_BACKGROUND;
+
+ EndDialog(hwnd,IDOK);
+ }
+
+ else
+ PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,100)),1);
+
+ }
+ break;
+
+
+ case IDCANCEL:
+ EndDialog(hwnd,IDCANCEL);
+ break;
+
+ }
+
+ return TRUE;
+
+ }
+
+ return FALSE;
+
+}
+
+
+//=============================================================================
+//
+// LongLineSettingsDlg()
+//
+BOOL LongLineSettingsDlg(HWND hwnd,UINT uidDlg,int *iNumber)
+{
+
+ int iResult;
+
+ iResult = ThemedDialogBoxParam(
+ g_hInstance,
+ MAKEINTRESOURCE(uidDlg),
+ hwnd,
+ LongLineSettingsDlgProc,(LPARAM)iNumber);
+
+ return (iResult == IDOK) ? TRUE : FALSE;
+
+}
+
+
+//=============================================================================
+//
+// TabSettingsDlgProc()
+//
+// Controls: 100 Edit
+// 101 Edit
+// 102 Check
+// 103 Check
+//
+extern int iTabWidth;
+extern int iIndentWidth;
+extern BOOL bTabsAsSpaces;
+extern BOOL bTabIndents;
+
+BOOL CALLBACK TabSettingsDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
+{
+
+ switch(umsg)
+ {
+
+ case WM_INITDIALOG:
+ {
+
+ SetDlgItemInt(hwnd,100,iTabWidth,FALSE);
+ SendDlgItemMessage(hwnd,100,EM_LIMITTEXT,15,0);
+
+ SetDlgItemInt(hwnd,101,iIndentWidth,FALSE);
+ SendDlgItemMessage(hwnd,101,EM_LIMITTEXT,15,0);
+
+ if (bTabsAsSpaces)
+ CheckDlgButton(hwnd,102,BST_CHECKED);
+
+ if (bTabIndents)
+ CheckDlgButton(hwnd,103,BST_CHECKED);
+
+ CenterDlgInParent(hwnd);
+
+ }
+ return TRUE;
+
+
+ case WM_COMMAND:
+
+ switch(LOWORD(wParam))
+ {
+
+ case IDOK: {
+
+ BOOL fTranslated1,fTranslated2;
+
+ int iNewTabWidth = GetDlgItemInt(hwnd,100,&fTranslated1,FALSE);
+ int iNewIndentWidth = GetDlgItemInt(hwnd,101,&fTranslated2,FALSE);
+
+ if (fTranslated1 && fTranslated2)
+ {
+ iTabWidth = iNewTabWidth;
+ iIndentWidth = iNewIndentWidth;
+
+ bTabsAsSpaces = (IsDlgButtonChecked(hwnd,102)) ? TRUE : FALSE;
+
+ bTabIndents = (IsDlgButtonChecked(hwnd,103)) ? TRUE : FALSE;
+
+ EndDialog(hwnd,IDOK);
+ }
+
+ else
+ PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,(fTranslated1) ? 101 : 100)),1);
+
+ }
+ break;
+
+
+ case IDCANCEL:
+ EndDialog(hwnd,IDCANCEL);
+ break;
+
+ }
+
+ return TRUE;
+
+ }
+
+ return FALSE;
+
+}
+
+
+//=============================================================================
+//
+// TabSettingsDlg()
+//
+BOOL TabSettingsDlg(HWND hwnd,UINT uidDlg,int *iNumber)
+{
+
+ int iResult;
+
+ iResult = ThemedDialogBoxParam(
+ g_hInstance,
+ MAKEINTRESOURCE(uidDlg),
+ hwnd,
+ TabSettingsDlgProc,(LPARAM)iNumber);
+
+ return (iResult == IDOK) ? TRUE : FALSE;
+
+}
+
+
+//=============================================================================
+//
+// SelectDefEncodingDlgProc()
+//
+//
+typedef struct encodedlg {
+ BOOL bRecodeOnly;
+ int idEncoding;
+ int cxDlg;
+ int cyDlg;
+} ENCODEDLG, *PENCODEDLG;
+
+BOOL CALLBACK SelectDefEncodingDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
+{
+ static PENCODEDLG pdd;
+
+ switch(umsg)
+ {
+ case WM_INITDIALOG:
+ {
+ HBITMAP hbmp;
+ HIMAGELIST himl;
+
+ pdd = (PENCODEDLG)lParam;
+
+ hbmp = LoadImage(g_hInstance,MAKEINTRESOURCE(IDB_ENCODING),IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION);
+ himl = ImageList_Create(16,16,ILC_COLOR32|ILC_MASK,0,0);
+ ImageList_AddMasked(himl,hbmp,CLR_DEFAULT);
+ DeleteObject(hbmp);
+ SendDlgItemMessage(hwnd,IDC_ENCODINGLIST,CBEM_SETIMAGELIST,0,(LPARAM)himl);
+ SendDlgItemMessage(hwnd,IDC_ENCODINGLIST,CB_SETEXTENDEDUI,TRUE,0);
+
+ Encoding_AddToComboboxEx(GetDlgItem(hwnd,IDC_ENCODINGLIST),pdd->idEncoding,0);
+
+ if (bSkipUnicodeDetection)
+ CheckDlgButton(hwnd,IDC_NOUNICODEDETECTION,BST_CHECKED);
+
+ if (bLoadASCIIasUTF8)
+ CheckDlgButton(hwnd,IDC_ASCIIASUTF8,BST_CHECKED);
+
+ if (bNoEncodingTags)
+ CheckDlgButton(hwnd,IDC_ENCODINGFROMFILEVARS,BST_CHECKED);
+
+ CenterDlgInParent(hwnd);
+ }
+ return TRUE;
+
+
+ case WM_COMMAND:
+ switch(LOWORD(wParam))
+ {
+ case IDOK: {
+ if (Encoding_GetFromComboboxEx(GetDlgItem(hwnd,IDC_ENCODINGLIST),&pdd->idEncoding)) {
+ bSkipUnicodeDetection = (IsDlgButtonChecked(hwnd,IDC_NOUNICODEDETECTION) == BST_CHECKED) ? 1 : 0;
+ bLoadASCIIasUTF8 = (IsDlgButtonChecked(hwnd,IDC_ASCIIASUTF8) == BST_CHECKED) ? 1 : 0;
+ bNoEncodingTags = (IsDlgButtonChecked(hwnd,IDC_ENCODINGFROMFILEVARS) == BST_CHECKED) ? 1 : 0;
+ EndDialog(hwnd,IDOK);
+ }
+ else
+ PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_ENCODINGLIST)),1);
+ }
+ break;
+
+ case IDCANCEL:
+ EndDialog(hwnd,IDCANCEL);
+ break;
+ }
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+//=============================================================================
+//
+// SelectDefEncodingDlg()
+//
+BOOL SelectDefEncodingDlg(HWND hwnd,int *pidREncoding)
+{
+
+ int iResult;
+ ENCODEDLG dd;
+
+ dd.bRecodeOnly = FALSE;
+ dd.idEncoding = *pidREncoding;
+
+ iResult = ThemedDialogBoxParam(
+ g_hInstance,
+ MAKEINTRESOURCE(IDD_DEFENCODING),
+ hwnd,
+ SelectDefEncodingDlgProc,
+ (LPARAM)&dd);
+
+ if (iResult == IDOK) {
+ *pidREncoding = dd.idEncoding;
+ return(TRUE);
+ }
+ else
+ return(FALSE);
+
+}
+
+
+//=============================================================================
+//
+// SelectEncodingDlgProc()
+//
+//
+BOOL CALLBACK SelectEncodingDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
+{
+
+ static PENCODEDLG pdd;
+ static HWND hwndLV;
+
+ switch(umsg)
+ {
+
+ case WM_INITDIALOG:
+ {
+ LVCOLUMN lvc = { LVCF_FMT|LVCF_TEXT, LVCFMT_LEFT, 0, L"", -1, 0, 0, 0 };
+ HBITMAP hbmp;
+ HIMAGELIST himl;
+
+ pdd = (PENCODEDLG)lParam;
+
+ ResizeDlg_Init(hwnd,pdd->cxDlg,pdd->cyDlg,IDC_RESIZEGRIP4);
+
+ hwndLV = GetDlgItem(hwnd,IDC_ENCODINGLIST);
+
+ hbmp = LoadImage(g_hInstance,MAKEINTRESOURCE(IDB_ENCODING),IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION);
+ himl = ImageList_Create(16,16,ILC_COLOR32|ILC_MASK,0,0);
+ ImageList_AddMasked(himl,hbmp,CLR_DEFAULT);
+ DeleteObject(hbmp);
+ ListView_SetImageList(GetDlgItem(hwnd,IDC_ENCODINGLIST),himl,LVSIL_SMALL);
+
+ //SetExplorerTheme(hwndLV);
+ ListView_SetExtendedListViewStyle(hwndLV,/*LVS_EX_FULLROWSELECT|*/LVS_EX_DOUBLEBUFFER|LVS_EX_LABELTIP);
+ ListView_InsertColumn(hwndLV,0,&lvc);
+
+ Encoding_AddToListView(hwndLV,pdd->idEncoding,pdd->bRecodeOnly);
+
+ ListView_SetColumnWidth(hwndLV,0,LVSCW_AUTOSIZE_USEHEADER);
+
+ CenterDlgInParent(hwnd);
+ }
+ return TRUE;
+
+
+ case WM_DESTROY:
+ ResizeDlg_Destroy(hwnd,&pdd->cxDlg,&pdd->cyDlg);
+ return FALSE;
+
+
+ case WM_SIZE:
+ {
+ int dx;
+ int dy;
+ HDWP hdwp;
+
+ ResizeDlg_Size(hwnd,lParam,&dx,&dy);
+
+ hdwp = BeginDeferWindowPos(4);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDC_RESIZEGRIP4,dx,dy,SWP_NOSIZE);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDOK,dx,dy,SWP_NOSIZE);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDCANCEL,dx,dy,SWP_NOSIZE);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDC_ENCODINGLIST,dx,dy,SWP_NOMOVE);
+ EndDeferWindowPos(hdwp);
+ ListView_SetColumnWidth(GetDlgItem(hwnd,IDC_ENCODINGLIST),0,LVSCW_AUTOSIZE_USEHEADER);
+ }
+ return TRUE;
+
+
+ case WM_GETMINMAXINFO:
+ ResizeDlg_GetMinMaxInfo(hwnd,lParam);
+ return TRUE;
+
+
+ case WM_NOTIFY: {
+ if (((LPNMHDR)(lParam))->idFrom == IDC_ENCODINGLIST) {
+
+ switch (((LPNMHDR)(lParam))->code) {
+
+ case NM_DBLCLK:
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(IDOK,1),0);
+ break;
+
+ case LVN_ITEMCHANGED:
+ case LVN_DELETEITEM: {
+ int i = ListView_GetNextItem(hwndLV,-1,LVNI_ALL | LVNI_SELECTED);
+ EnableWindow(GetDlgItem(hwnd,IDOK),i != -1);
+ }
+ break;
+ }
+ }
+ }
+ return TRUE;
+
+
+ case WM_COMMAND:
+
+ switch(LOWORD(wParam))
+ {
+
+ case IDOK:
+ if (Encoding_GetFromListView(hwndLV,&pdd->idEncoding))
+ EndDialog(hwnd,IDOK);
+ else
+ PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_ENCODINGLIST)),1);
+ break;
+
+
+ case IDCANCEL:
+ EndDialog(hwnd,IDCANCEL);
+ break;
+
+ }
+
+ return TRUE;
+
+ }
+
+ return FALSE;
+
+}
+
+
+//=============================================================================
+//
+// SelectEncodingDlg()
+//
+extern int cxEncodingDlg;
+extern int cyEncodingDlg;
+
+BOOL SelectEncodingDlg(HWND hwnd,int *pidREncoding)
+{
+
+ int iResult;
+ ENCODEDLG dd;
+
+ dd.bRecodeOnly = FALSE;
+ dd.idEncoding = *pidREncoding;
+ dd.cxDlg = cxEncodingDlg;
+ dd.cyDlg = cyEncodingDlg;
+
+ iResult = ThemedDialogBoxParam(
+ g_hInstance,
+ MAKEINTRESOURCE(IDD_ENCODING),
+ hwnd,
+ SelectEncodingDlgProc,
+ (LPARAM)&dd);
+
+ cxEncodingDlg = dd.cxDlg;
+ cyEncodingDlg = dd.cyDlg;
+
+ if (iResult == IDOK) {
+ *pidREncoding = dd.idEncoding;
+ return(TRUE);
+ }
+ else
+ return(FALSE);
+
+}
+
+
+//=============================================================================
+//
+// RecodeDlg()
+//
+extern int cxRecodeDlg;
+extern int cyRecodeDlg;
+
+BOOL RecodeDlg(HWND hwnd,int *pidREncoding)
+{
+
+ int iResult;
+ ENCODEDLG dd;
+
+ dd.bRecodeOnly = TRUE;
+ dd.idEncoding = *pidREncoding;
+ dd.cxDlg = cxRecodeDlg;
+ dd.cyDlg = cyRecodeDlg;
+
+ iResult = ThemedDialogBoxParam(
+ g_hInstance,
+ MAKEINTRESOURCE(IDD_RECODE),
+ hwnd,
+ SelectEncodingDlgProc,
+ (LPARAM)&dd);
+
+ cxRecodeDlg = dd.cxDlg;
+ cyRecodeDlg = dd.cyDlg;
+
+ if (iResult == IDOK) {
+ *pidREncoding = dd.idEncoding;
+ return(TRUE);
+ }
+ else
+ return(FALSE);
+
+}
+
+
+//=============================================================================
+//
+// SelectDefLineEndingDlgProc()
+//
+// Controls: 100 Combo
+// IDC_CONSISTENTEOLS
+// IDC_AUTOSTRIPBLANKS
+//
+BOOL CALLBACK SelectDefLineEndingDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
+{
+ static int *piOption;
+
+ switch(umsg)
+ {
+ case WM_INITDIALOG:
+ {
+ int i;
+ WCHAR wch[128];
+
+ piOption = (int*)lParam;
+
+ // Load options
+ for (i = 0; i < 3; i++) {
+ GetString(IDS_EOLMODENAME0+i,wch,COUNTOF(wch));
+ SendDlgItemMessage(hwnd,100,CB_ADDSTRING,0,(LPARAM)wch);
+ }
+
+ SendDlgItemMessage(hwnd,100,CB_SETCURSEL,(WPARAM)*piOption,0);
+ SendDlgItemMessage(hwnd,100,CB_SETEXTENDEDUI,TRUE,0);
+
+ if (bFixLineEndings)
+ CheckDlgButton(hwnd,IDC_CONSISTENTEOLS,BST_CHECKED);
+
+ if (bAutoStripBlanks)
+ CheckDlgButton(hwnd,IDC_AUTOSTRIPBLANKS, BST_CHECKED);
+
+ CenterDlgInParent(hwnd);
+ }
+ return TRUE;
+
+
+ case WM_COMMAND:
+ switch(LOWORD(wParam))
+ {
+ case IDOK: {
+ *piOption = SendDlgItemMessage(hwnd,100,CB_GETCURSEL,0,0);
+ bFixLineEndings = (IsDlgButtonChecked(hwnd,IDC_CONSISTENTEOLS) == BST_CHECKED) ? 1 : 0;
+ bAutoStripBlanks = (IsDlgButtonChecked(hwnd,IDC_AUTOSTRIPBLANKS) == BST_CHECKED) ? 1 : 0;
+ EndDialog(hwnd,IDOK);
+ }
+ break;
+
+ case IDCANCEL:
+ EndDialog(hwnd,IDCANCEL);
+ break;
+ }
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+//=============================================================================
+//
+// SelectDefLineEndingDlg()
+//
+BOOL SelectDefLineEndingDlg(HWND hwnd,int *iOption)
+{
+
+ int iResult;
+
+ iResult = ThemedDialogBoxParam(
+ g_hInstance,
+ MAKEINTRESOURCE(IDD_DEFEOLMODE),
+ hwnd,
+ SelectDefLineEndingDlgProc,
+ (LPARAM)iOption);
+
+ return (iResult == IDOK) ? TRUE : FALSE;
+
+}
+
+
+//=============================================================================
+//
+// InfoBoxDlgProc()
+//
+//
+typedef struct _infobox {
+ LPWSTR lpstrMessage;
+ LPWSTR lpstrSetting;
+ BOOL bDisableCheckBox;
+} INFOBOX, *LPINFOBOX;
+
+BOOL CALLBACK InfoBoxDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
+{
+ LPINFOBOX lpib;
+
+ switch(umsg)
+ {
+ case WM_INITDIALOG:
+ lpib = (LPINFOBOX)lParam;
+ SetWindowLongPtr(hwnd,DWLP_USER,lParam);
+ SendDlgItemMessage(hwnd,IDC_INFOBOXICON,STM_SETICON,
+ (WPARAM)LoadIcon(NULL,IDI_EXCLAMATION),0);
+ SetDlgItemText(hwnd,IDC_INFOBOXTEXT,lpib->lpstrMessage);
+ if (lpib->bDisableCheckBox)
+ EnableWindow(GetDlgItem(hwnd,IDC_INFOBOXCHECK),FALSE);
+ LocalFree(lpib->lpstrMessage);
+ CenterDlgInParent(hwnd);
+ return TRUE;
+
+ case WM_COMMAND:
+ switch(LOWORD(wParam))
+ {
+ case IDOK:
+ case IDCANCEL:
+ case IDYES:
+ case IDNO:
+ lpib = (LPINFOBOX)GetWindowLongPtr(hwnd,DWLP_USER);
+ if (IsDlgButtonChecked(hwnd,IDC_INFOBOXCHECK))
+ IniSetInt(L"Suppressed Messages",lpib->lpstrSetting,1);
+ EndDialog(hwnd,LOWORD(wParam));
+ break;
+ }
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+//=============================================================================
+//
+// InfoBox()
+//
+//
+extern WCHAR szIniFile[MAX_PATH];
+
+int InfoBox(int iType,LPCWSTR lpstrSetting,int uidMessage,...)
+{
+
+ HWND hwnd;
+ int idDlg = IDD_INFOBOX;
+ INFOBOX ib;
+ WCHAR wchFormat[512];
+
+ if (IniGetInt(L"Suppressed Messages",lpstrSetting,0))
+ return (iType == MBYESNO) ? IDYES : IDOK;
+
+ if (!GetString(uidMessage,wchFormat,COUNTOF(wchFormat)))
+ return(-1);
+
+ ib.lpstrMessage = LocalAlloc(LPTR,1024 * sizeof(WCHAR));
+ wvsprintf(ib.lpstrMessage,wchFormat,(LPVOID)((PUINT_PTR)&uidMessage + 1));
+
+ ib.lpstrSetting = (LPWSTR)lpstrSetting;
+
+ ib.bDisableCheckBox = (lstrlen(szIniFile) == 0) ? TRUE : FALSE;
+
+ if (iType == MBYESNO)
+ idDlg = IDD_INFOBOX2;
+ else if (iType == MBOKCANCEL)
+ idDlg = IDD_INFOBOX3;
+
+ if (!(hwnd = GetFocus()))
+ hwnd = hwndMain;
+
+ MessageBeep(MB_ICONEXCLAMATION);
+
+ return ThemedDialogBoxParam(
+ g_hInstance,
+ MAKEINTRESOURCE(idDlg),
+ hwnd,
+ InfoBoxDlgProc,
+ (LPARAM)&ib);
+
+}
+
+
+
+// End of Dialogs.c
diff --git a/src/Dialogs.h b/src/Dialogs.h new file mode 100644 index 0000000..b03859c --- /dev/null +++ b/src/Dialogs.h @@ -0,0 +1,50 @@ +/******************************************************************************
+*
+*
+* Notepad2
+*
+* Dialogs.h
+* Definitions for Notepad2 dialog boxes
+*
+* See Readme.txt for more information about this source code.
+* Please send me your comments to this work.
+*
+* See License.txt for details about distribution and modification.
+*
+* (c) Florian Balmer 1996-2010
+* florian.balmer@gmail.com
+* http://www.flos-freeware.ch
+*
+*
+******************************************************************************/
+
+
+#define MBINFO 0
+#define MBWARN 1
+#define MBYESNO 2
+#define MBYESNOWARN 3
+#define MBYESNOCANCEL 4
+#define MBOKCANCEL 8
+
+int MsgBox(int,UINT,...);
+void DisplayCmdLineHelp();
+BOOL GetDirectory(HWND,int,LPWSTR,LPCWSTR,BOOL);
+BOOL CALLBACK AboutDlgProc(HWND,UINT,WPARAM,LPARAM);
+void RunDlg(HWND,LPCWSTR);
+BOOL OpenWithDlg(HWND,LPCWSTR);
+BOOL FavoritesDlg(HWND,LPWSTR);
+BOOL AddToFavDlg(HWND,LPCWSTR,LPCWSTR);
+BOOL FileMRUDlg(HWND,LPWSTR);
+BOOL ChangeNotifyDlg(HWND);
+BOOL ColumnWrapDlg(HWND,UINT,int *);
+BOOL WordWrapSettingsDlg(HWND,UINT,int *);
+BOOL LongLineSettingsDlg(HWND,UINT,int *);
+BOOL TabSettingsDlg(HWND,UINT,int *);
+BOOL SelectDefEncodingDlg(HWND,int *);
+BOOL SelectEncodingDlg(HWND,int *);
+BOOL RecodeDlg(HWND,int *);
+BOOL SelectDefLineEndingDlg(HWND,int *);
+int InfoBox(int,LPCWSTR,int,...);
+
+
+// End of Dialogs.h
diff --git a/src/Dlapi.c b/src/Dlapi.c new file mode 100644 index 0000000..139c731 --- /dev/null +++ b/src/Dlapi.c @@ -0,0 +1,1769 @@ +/******************************************************************************
+*
+*
+* Notepad2
+*
+* Dlapi.c
+* Directory Listing APIs used in Notepad2
+*
+* See Readme.txt for more information about this source code.
+* Please send me your comments to this work.
+*
+* See License.txt for details about distribution and modification.
+*
+* (c) Florian Balmer 1996-2010
+* florian.balmer@gmail.com
+* http://www.flos-freeware.ch
+*
+*
+******************************************************************************/
+#define _WIN32_WINNT 0x501
+#include <windows.h>
+#include <commctrl.h>
+#include <shlobj.h>
+#include <shlwapi.h>
+#include <string.h>
+#include "dlapi.h"
+
+
+
+//==== Global LPMALLOC instance ===============================================
+extern LPMALLOC g_lpMalloc;
+
+
+
+//==== DirList ================================================================
+
+//==== DLDATA Structure =======================================================
+
+typedef struct tagDLDATA // dl
+{
+
+ HWND hwnd; // HWND of ListView Control
+ UINT cbidl; // Size of pidl
+ LPITEMIDLIST pidl; // Directory Id
+ LPSHELLFOLDER lpsf; // IShellFolder Interface to pidl
+ WCHAR szPath[MAX_PATH]; // Pathname to Directory Id
+ int iDefIconFolder; // Default Folder Icon
+ int iDefIconFile; // Default File Icon
+ BOOL bNoFadeHidden; // Flag passed from GetDispInfo()
+ HANDLE hExitThread; // Flag is set when Icon Thread should terminate
+ HANDLE hTerminatedThread; // Flag is set when Icon Thread has terminated
+
+} DLDATA, *LPDLDATA;
+
+
+//==== Property Name ==========================================================
+static const WCHAR *pDirListProp = L"DirListData";
+
+
+
+//=============================================================================
+//
+// DirList_Init()
+//
+// Initializes the DLDATA structure and sets up the listview control
+//
+BOOL DirList_Init(HWND hwnd,LPCWSTR pszHeader)
+{
+
+ HIMAGELIST hil;
+ SHFILEINFO shfi;
+ LV_COLUMN lvc;
+
+ // Allocate DirListData Property
+ LPDLDATA lpdl = (LPVOID)GlobalAlloc(GPTR,sizeof(DLDATA));
+ SetProp(hwnd,pDirListProp,(HANDLE)lpdl);
+
+ // Setup dl
+ lpdl->hwnd = hwnd;
+ lpdl->cbidl = 0;
+ lpdl->pidl = NULL;
+ lpdl->lpsf = NULL;
+ lstrcpy(lpdl->szPath,L"");
+
+ // Add Imagelists
+ hil = (HIMAGELIST)SHGetFileInfo(L"C:\\",0,&shfi,sizeof(SHFILEINFO),
+ SHGFI_SMALLICON | SHGFI_SYSICONINDEX);
+
+ ListView_SetImageList(hwnd,hil,LVSIL_SMALL);
+
+ hil = (HIMAGELIST)SHGetFileInfo(L"C:\\",0,&shfi,sizeof(SHFILEINFO),
+ SHGFI_LARGEICON | SHGFI_SYSICONINDEX);
+
+ ListView_SetImageList(hwnd,hil,LVSIL_NORMAL);
+
+ // Initialize default icons - done in DirList_Fill()
+ //SHGetFileInfo(L"Icon",FILE_ATTRIBUTE_DIRECTORY,&shfi,sizeof(SHFILEINFO),
+ // SHGFI_USEFILEATTRIBUTES | SHGFI_SMALLICON | SHGFI_SYSICONINDEX);
+ //lpdl->iDefIconFolder = shfi.iIcon;
+
+ //SHGetFileInfo(L"Icon",FILE_ATTRIBUTE_NORMAL,&shfi,sizeof(SHFILEINFO),
+ // SHGFI_USEFILEATTRIBUTES | SHGFI_SMALLICON | SHGFI_SYSICONINDEX);
+ //lpdl->iDefIconFile = shfi.iIcon;
+
+ lpdl->iDefIconFolder = 0;
+ lpdl->iDefIconFile = 0;
+
+ // Icon thread control
+ lpdl->hExitThread = CreateEvent(NULL,TRUE,FALSE,NULL);
+ lpdl->hTerminatedThread = CreateEvent(NULL,TRUE,TRUE,NULL);
+
+ lvc;
+ pszHeader;
+
+ return TRUE;
+
+}
+
+
+//=============================================================================
+//
+// DirList_Destroy()
+//
+// Free memory used by dl structure
+//
+BOOL DirList_Destroy(HWND hwnd)
+{
+
+ //LPMALLOC lpMalloc;
+
+ LPDLDATA lpdl = (LPVOID)GetProp(hwnd,pDirListProp);
+
+ // Release multithreading objects
+ DirList_TerminateIconThread(hwnd);
+ CloseHandle(lpdl->hExitThread);
+ CloseHandle(lpdl->hTerminatedThread);
+
+ //if (NOERROR == SHGetMalloc(&lpMalloc))
+ //{
+
+ if (lpdl->pidl)
+ g_lpMalloc->lpVtbl->Free(g_lpMalloc,lpdl->pidl);
+
+ //lpMalloc->lpVtbl->Release(lpMalloc);
+
+ if (lpdl->lpsf)
+ lpdl->lpsf->lpVtbl->Release(lpdl->lpsf);
+
+ //}
+
+ // Free DirListData Property
+ RemoveProp(hwnd,pDirListProp);
+ GlobalFree(lpdl);
+
+ return FALSE;
+
+}
+
+
+//=============================================================================
+//
+// DirList_StartIconThread()
+//
+// Start thread to extract file icons in the background
+//
+BOOL DirList_StartIconThread(HWND hwnd)
+{
+
+ DWORD dwtid;
+ LPDLDATA lpdl = (LPVOID)GetProp(hwnd,pDirListProp);
+
+ DirList_TerminateIconThread(hwnd);
+
+ ResetEvent(lpdl->hExitThread);
+ //ResetEvent(lpdl->hTerminatedThread);
+
+ CreateThread(NULL,0,DirList_IconThread,(LPVOID)lpdl,0,&dwtid);
+
+ return TRUE;
+
+}
+
+
+//=============================================================================
+//
+// DirList_TerminateIconThread()
+//
+// Terminate Icon Thread and reset multithreading control structures
+//
+BOOL DirList_TerminateIconThread(HWND hwnd)
+{
+
+ LPDLDATA lpdl = (LPVOID)GetProp(hwnd,pDirListProp);
+
+ SetEvent(lpdl->hExitThread);
+
+ //WaitForSingleObject(lpdl->hTerminatedThread,INFINITE);
+ while (WaitForSingleObject(lpdl->hTerminatedThread,0) != WAIT_OBJECT_0)
+ {
+ MSG msg;
+ if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ }
+
+ ResetEvent(lpdl->hExitThread);
+ SetEvent(lpdl->hTerminatedThread);
+
+ return TRUE;
+
+}
+
+
+//=============================================================================
+//
+// DirList_Fill()
+//
+// Snapshots a directory and displays the items in the listview control
+//
+int DirList_Fill(HWND hwnd,LPCWSTR lpszDir,DWORD grfFlags,LPCWSTR lpszFileSpec,
+ BOOL bExcludeFilter,BOOL bNoFadeHidden,
+ int iSortFlags,BOOL fSortRev)
+{
+
+ WCHAR wszDir[MAX_PATH];
+
+ //LPMALLOC lpMalloc = NULL;
+
+ LPSHELLFOLDER lpsfDesktop = NULL;
+ LPSHELLFOLDER lpsf = NULL;
+
+ LPITEMIDLIST pidl = NULL;
+ LPITEMIDLIST pidlEntry = NULL;
+
+ LPENUMIDLIST lpe = NULL;
+
+ LV_ITEM lvi;
+ LPLV_ITEMDATA lplvid;
+
+ ULONG chParsed = 0;
+ ULONG dwAttributes = 0;
+
+ DL_FILTER dlf;
+ SHFILEINFO shfi;
+
+ LPDLDATA lpdl = (LPVOID)GetProp(hwnd,pDirListProp);
+
+ // Initialize default icons
+ SHGetFileInfo(L"Icon",FILE_ATTRIBUTE_DIRECTORY,&shfi,sizeof(SHFILEINFO),
+ SHGFI_USEFILEATTRIBUTES | SHGFI_SMALLICON | SHGFI_SYSICONINDEX);
+ lpdl->iDefIconFolder = shfi.iIcon;
+
+ SHGetFileInfo(L"Icon",FILE_ATTRIBUTE_NORMAL,&shfi,sizeof(SHFILEINFO),
+ SHGFI_USEFILEATTRIBUTES | SHGFI_SMALLICON | SHGFI_SYSICONINDEX);
+ lpdl->iDefIconFile = shfi.iIcon;
+
+ // First of all terminate running icon thread
+ DirList_TerminateIconThread(hwnd);
+
+ // A Directory is strongly required
+ if (!lpszDir || !*lpszDir)
+ return(-1);
+
+ lstrcpy(lpdl->szPath,lpszDir);
+
+ // Init ListView
+ SendMessage(hwnd,WM_SETREDRAW,0,0);
+ ListView_DeleteAllItems(hwnd);
+
+ // Init Filter
+ DirList_CreateFilter(&dlf,lpszFileSpec,bExcludeFilter);
+
+ // Init lvi
+ lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
+ lvi.iItem = 0;
+ lvi.iSubItem = 0;
+ lvi.pszText = LPSTR_TEXTCALLBACK;
+ lvi.cchTextMax = MAX_PATH;
+ lvi.iImage = I_IMAGECALLBACK;
+
+ // Convert Directory to a UNICODE string
+ /*MultiByteToWideChar(CP_ACP,
+ MB_PRECOMPOSED,
+ lpszDir,
+ -1,
+ wszDir,
+ MAX_PATH);*/
+ lstrcpy(wszDir,lpszDir);
+
+
+ // Get Shell's IMalloc Interface
+ //if (NOERROR == SHGetMalloc(&lpMalloc))
+ //{
+
+ // Get Desktop Folder
+ if (NOERROR == SHGetDesktopFolder(&lpsfDesktop))
+ {
+
+ // Convert wszDir into a pidl
+ if (NOERROR == lpsfDesktop->lpVtbl->ParseDisplayName(
+ lpsfDesktop,
+ hwnd,
+ NULL,
+ wszDir,
+ &chParsed,
+ &pidl,
+ &dwAttributes))
+
+ {
+
+ // Bind pidl to IShellFolder
+ if (NOERROR == lpsfDesktop->lpVtbl->BindToObject(
+ lpsfDesktop,
+ pidl,
+ NULL,
+ &IID_IShellFolder,
+ &lpsf))
+
+ {
+
+ // Create an Enumeration object for lpsf
+ if (NOERROR == lpsf->lpVtbl->EnumObjects(
+ lpsf,
+ hwnd,
+ grfFlags,
+ &lpe))
+
+ {
+
+ // Enumerate the contents of lpsf
+ while (NOERROR == lpe->lpVtbl->Next(
+ lpe,
+ 1,
+ &pidlEntry,
+ NULL))
+
+ {
+
+ // Add found item to the List
+ // Check if it's part of the Filesystem
+ dwAttributes = SFGAO_FILESYSTEM | SFGAO_FOLDER;
+
+ lpsf->lpVtbl->GetAttributesOf(
+ lpsf,
+ 1,
+ &pidlEntry,
+ &dwAttributes);
+
+ if (dwAttributes & SFGAO_FILESYSTEM)
+ {
+
+ // Check if item matches specified filter
+ if (DirList_MatchFilter(lpsf,pidlEntry,&dlf))
+ {
+
+ lplvid = g_lpMalloc->lpVtbl->Alloc(
+ g_lpMalloc,
+ sizeof(LV_ITEMDATA));
+
+ lplvid->pidl = pidlEntry;
+ lplvid->lpsf = lpsf;
+
+ lpsf->lpVtbl->AddRef(lpsf);
+
+ lvi.lParam = (LPARAM)lplvid;
+
+ // Setup default Icon - Folder or File
+ lvi.iImage = (dwAttributes & SFGAO_FOLDER) ?
+ lpdl->iDefIconFolder : lpdl->iDefIconFile;
+
+ ListView_InsertItem(hwnd,&lvi);
+
+ lvi.iItem++;
+
+ }
+
+ }
+
+ //lpMalloc->lpVtbl->Free(lpMalloc,pidlEntry);
+
+ } // IEnumIDList::Next()
+
+ lpe->lpVtbl->Release(lpe);
+
+ } // IShellFolder::EnumObjects()
+
+ } // IShellFolder::BindToObject()
+
+ } // IShellFolder::ParseDisplayName()
+
+ lpsfDesktop->lpVtbl->Release(lpsfDesktop);
+
+ } // SHGetDesktopFolder()
+
+ if (lpdl->pidl)
+ g_lpMalloc->lpVtbl->Free(g_lpMalloc,lpdl->pidl);
+
+ if (lpdl->lpsf && lpdl->lpsf->lpVtbl)
+ lpdl->lpsf->lpVtbl->Release(lpdl->lpsf);
+
+ //lpMalloc->lpVtbl->Release(lpMalloc);
+
+ //} // SHGetMalloc()
+
+ // Set lpdl
+ lpdl->cbidl = IL_GetSize(pidl);
+ lpdl->pidl = pidl;
+ lpdl->lpsf = lpsf;
+ lpdl->bNoFadeHidden = bNoFadeHidden;
+
+ // Set column width to fit window
+ ListView_SetColumnWidth(hwnd,0,LVSCW_AUTOSIZE_USEHEADER);
+
+ // Sort before display is updated
+ DirList_Sort(hwnd,iSortFlags,fSortRev);
+
+ // Redraw Listview
+ SendMessage(hwnd,WM_SETREDRAW,1,0);
+
+ // Return number of items in the control
+ return (ListView_GetItemCount(hwnd));
+
+}
+
+
+//=============================================================================
+//
+// DirList_IconThread()
+//
+// Thread to extract file icons in the background
+//
+DWORD WINAPI DirList_IconThread(LPVOID lpParam)
+{
+
+ HWND hwnd;
+
+ LPDLDATA lpdl;
+ LV_ITEM lvi;
+ LPLV_ITEMDATA lplvid;
+
+ LPMALLOC lpMalloc;
+ IShellIcon* lpshi;
+
+ int iItem = 0;
+ int iMaxItem;
+
+ lpdl = (LPDLDATA)lpParam;
+ ResetEvent(lpdl->hTerminatedThread);
+
+ // Exit immediately if DirList_Fill() hasn't been called
+ if (!lpdl->lpsf) {
+ SetEvent(lpdl->hTerminatedThread);
+ ExitThread(0);
+ return(0);
+ }
+
+ hwnd = lpdl->hwnd;
+ iMaxItem = ListView_GetItemCount(hwnd);
+
+ CoInitialize(NULL);
+ SHGetMalloc(&lpMalloc);
+
+ // Get IShellIcon
+ lpdl->lpsf->lpVtbl->QueryInterface(lpdl->lpsf,&IID_IShellIcon,&lpshi);
+
+ while (iItem < iMaxItem && WaitForSingleObject(lpdl->hExitThread,0) != WAIT_OBJECT_0) {
+
+ lvi.iItem = iItem;
+ lvi.mask = LVIF_PARAM;
+ if (ListView_GetItem(hwnd,&lvi)) {
+
+ SHFILEINFO shfi;
+ LPITEMIDLIST pidl;
+ DWORD dwAttributes = SFGAO_LINK | SFGAO_SHARE;
+
+ lplvid = (LPLV_ITEMDATA)lvi.lParam;
+
+ lvi.mask = LVIF_IMAGE;
+
+ if (!lpshi || NOERROR != lpshi->lpVtbl->GetIconOf(lpshi,lplvid->pidl,GIL_FORSHELL,&lvi.iImage))
+ {
+ pidl = IL_Create(lpMalloc,lpdl->pidl,lpdl->cbidl,lplvid->pidl,0);
+ SHGetFileInfo((LPCWSTR)pidl,0,&shfi,sizeof(SHFILEINFO),SHGFI_PIDL | SHGFI_SYSICONINDEX | SHGFI_SMALLICON);
+ lpMalloc->lpVtbl->Free(lpMalloc,pidl);
+ lvi.iImage = shfi.iIcon;
+ }
+
+ // It proved necessary to reset the state bits...
+ lvi.stateMask = 0;
+ lvi.state = 0;
+
+ // Link and Share Overlay
+ lplvid->lpsf->lpVtbl->GetAttributesOf(
+ lplvid->lpsf,
+ 1,&lplvid->pidl,
+ &dwAttributes);
+
+ if (dwAttributes & SFGAO_LINK)
+ {
+ lvi.mask |= LVIF_STATE;
+ lvi.stateMask |= LVIS_OVERLAYMASK;
+ lvi.state |= INDEXTOOVERLAYMASK(2);
+ }
+
+ if (dwAttributes & SFGAO_SHARE)
+ {
+ lvi.mask |= LVIF_STATE;
+ lvi.stateMask |= LVIS_OVERLAYMASK;
+ lvi.state |= INDEXTOOVERLAYMASK(1);
+ }
+
+ // Fade hidden/system files
+ if (!lpdl->bNoFadeHidden)
+ {
+ WIN32_FIND_DATA fd;
+ if (NOERROR == SHGetDataFromIDList(lplvid->lpsf,lplvid->pidl,
+ SHGDFIL_FINDDATA,&fd,sizeof(WIN32_FIND_DATA)))
+ {
+ if ((fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) ||
+ (fd.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM))
+ {
+ lvi.mask |= LVIF_STATE;
+ lvi.stateMask |= LVIS_CUT;
+ lvi.state |= LVIS_CUT;
+ }
+ }
+ }
+ lvi.iSubItem = 0;
+ ListView_SetItem(hwnd,&lvi);
+ }
+ iItem++;
+ }
+
+ if (lpshi)
+ lpshi->lpVtbl->Release(lpshi);
+
+ lpMalloc->lpVtbl->Release(lpMalloc);
+ CoUninitialize();
+
+ SetEvent(lpdl->hTerminatedThread);
+ ExitThread(0);
+ return(0);
+
+}
+
+
+//=============================================================================
+//
+// DirList_GetDispInfo()
+//
+// Must be called in response to a WM_NOTIFY/LVN_GETDISPINFO message from
+// the listview control
+//
+BOOL DirList_GetDispInfo(HWND hwnd,LPARAM lParam,BOOL bNoFadeHidden)
+{
+
+ LPDLDATA lpdl = (LPVOID)GetProp(hwnd,pDirListProp);
+
+ LV_DISPINFO *lpdi = (LPVOID)lParam;
+
+ LPLV_ITEMDATA lplvid = (LPLV_ITEMDATA)lpdi->item.lParam;
+
+ // SubItem 0 is handled only
+ if (lpdi->item.iSubItem != 0)
+ return FALSE;
+
+ // Text
+ if (lpdi->item.mask & LVIF_TEXT)
+ IL_GetDisplayName(lplvid->lpsf,lplvid->pidl,SHGDN_INFOLDER,
+ lpdi->item.pszText,lpdi->item.cchTextMax);
+
+ // Image
+ //if (lpdi->item.mask & LVIF_IMAGE)
+ //{
+
+ // //LPMALLOC lpMalloc;
+ // SHFILEINFO shfi;
+ // LPITEMIDLIST pidl;
+ // DWORD dwAttributes = SFGAO_LINK | SFGAO_SHARE;
+
+ // //if (NOERROR == SHGetMalloc(&lpMalloc))
+ // //{
+
+ // // Generate Full Qualified pidl
+ // pidl = IL_Create(g_lpMalloc,lpdl->pidl,lpdl->cbidl,lplvid->pidl,0);
+
+ // SHGetFileInfo((LPCWSTR)pidl,0,&shfi,sizeof(SHFILEINFO),SHGFI_PIDL | SHGFI_SYSICONINDEX);
+
+ // lpdi->item.iImage = shfi.iIcon;
+
+ // g_lpMalloc->lpVtbl->Free(g_lpMalloc,pidl);
+ // //lpMalloc->lpVtbl->Release(lpMalloc);
+
+ // //}
+
+ // // It proved necessary to reset the state bits...
+ // lpdi->item.stateMask = 0;
+ // lpdi->item.state = 0;
+
+ // // Link and Share Overlay
+ // lplvid->lpsf->lpVtbl->GetAttributesOf(
+ // lplvid->lpsf,
+ // 1,&lplvid->pidl,
+ // &dwAttributes);
+
+ // if (dwAttributes & SFGAO_LINK)
+ // {
+ // lpdi->item.mask |= LVIF_STATE;
+ // lpdi->item.stateMask |= LVIS_OVERLAYMASK;
+ // lpdi->item.state |= INDEXTOOVERLAYMASK(2);
+ // }
+
+ // if (dwAttributes & SFGAO_SHARE)
+ // {
+ // lpdi->item.mask |= LVIF_STATE;
+ // lpdi->item.stateMask |= LVIS_OVERLAYMASK;
+ // lpdi->item.state |= INDEXTOOVERLAYMASK(1);
+ // }
+
+ // // Fade hidden/system files
+ // if (!bNoFadeHidden)
+ // {
+ // WIN32_FIND_DATA fd;
+ // if (NOERROR == SHGetDataFromIDList(lplvid->lpsf,lplvid->pidl,
+ // SHGDFIL_FINDDATA,&fd,sizeof(WIN32_FIND_DATA)))
+ // {
+ // if ((fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) ||
+ // (fd.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM))
+ // {
+ // lpdi->item.mask |= LVIF_STATE;
+ // lpdi->item.stateMask |= LVIS_CUT;
+ // lpdi->item.state |= LVIS_CUT;
+ // }
+ // }
+
+ // }
+
+ //}
+
+ // Set values
+ lpdi->item.mask |= LVIF_DI_SETITEM;
+
+ return TRUE;
+
+}
+
+
+//=============================================================================
+//
+// DirList_DeleteItem()
+//
+// Must be called in response to a WM_NOTIFY/LVN_DELETEITEM message
+// from the control
+//
+BOOL DirList_DeleteItem(HWND hwnd,LPARAM lParam)
+{
+
+ LPDLDATA lpdl = (LPVOID)GetProp(hwnd,pDirListProp);
+
+ LV_ITEM lvi;
+ //LPMALLOC lpMalloc;
+
+ NM_LISTVIEW *lpnmlv = (LPVOID)lParam;
+
+ lvi.iItem = lpnmlv->iItem;
+ lvi.iSubItem = 0;
+ lvi.mask = LVIF_PARAM;
+
+ if (ListView_GetItem(hwnd,&lvi))
+ {
+
+ //if (NOERROR == SHGetMalloc(&lpMalloc))
+ //{
+
+ // Free mem
+ LPLV_ITEMDATA lplvid = (LPLV_ITEMDATA)lvi.lParam;
+ g_lpMalloc->lpVtbl->Free(g_lpMalloc,lplvid->pidl);
+ lplvid->lpsf->lpVtbl->Release(lplvid->lpsf);
+
+ g_lpMalloc->lpVtbl->Free(g_lpMalloc,lplvid);
+
+ //lpMalloc->lpVtbl->Release(lpMalloc);
+
+ return TRUE;
+
+ //}
+
+ }
+
+ else
+ return FALSE;
+
+}
+
+
+//=============================================================================
+//
+// DirList_CompareProc()
+//
+// Compares two list items
+//
+int CALLBACK DirList_CompareProcFw(LPARAM lp1,LPARAM lp2,LPARAM lFlags)
+{
+
+ HRESULT hr;
+ int result;
+
+ LPLV_ITEMDATA lplvid1 = (LPLV_ITEMDATA)lp1;
+ LPLV_ITEMDATA lplvid2 = (LPLV_ITEMDATA)lp2;
+
+ hr = (lplvid1->lpsf->lpVtbl->CompareIDs(
+ lplvid1->lpsf,
+ lFlags,
+ lplvid1->pidl,
+ lplvid2->pidl));
+
+ result = (short)(SCODE_CODE(GetScode(hr)));
+
+ if (result != 0 || lFlags == 0)
+ return(result);
+
+ hr = (lplvid1->lpsf->lpVtbl->CompareIDs(
+ lplvid1->lpsf,
+ 0,
+ lplvid1->pidl,
+ lplvid2->pidl));
+
+ result = (short)(SCODE_CODE(GetScode(hr)));
+
+ return(result);
+
+}
+
+int CALLBACK DirList_CompareProcRw(LPARAM lp1,LPARAM lp2,LPARAM lFlags)
+{
+
+ HRESULT hr;
+ int result;
+
+ LPLV_ITEMDATA lplvid1 = (LPLV_ITEMDATA)lp1;
+ LPLV_ITEMDATA lplvid2 = (LPLV_ITEMDATA)lp2;
+
+ hr = (lplvid1->lpsf->lpVtbl->CompareIDs(
+ lplvid1->lpsf,
+ lFlags,
+ lplvid1->pidl,
+ lplvid2->pidl));
+
+ result = -(short)(SCODE_CODE(GetScode(hr)));
+
+ if (result != 0)
+ return(result);
+
+ hr = (lplvid1->lpsf->lpVtbl->CompareIDs(
+ lplvid1->lpsf,
+ 0,
+ lplvid1->pidl,
+ lplvid2->pidl));
+
+ result = -(short)(SCODE_CODE(GetScode(hr)));
+
+ return(result);
+
+}
+
+
+//=============================================================================
+//
+// DirList_Sort()
+//
+// Sorts the listview control by the specified order
+//
+BOOL DirList_Sort(HWND hwnd,int lFlags,BOOL fRev)
+{
+
+ LPDLDATA lpdl = (LPVOID)GetProp(hwnd,pDirListProp);
+
+ if (fRev)
+
+ return ListView_SortItems(hwnd,DirList_CompareProcRw,lFlags);
+
+ else
+
+ return ListView_SortItems(hwnd,DirList_CompareProcFw,lFlags);
+
+}
+
+
+//=============================================================================
+//
+// DirList_GetItem()
+//
+// Copies the data of the specified item in the listview control to a buffer
+//
+int DirList_GetItem(HWND hwnd,int iItem,LPDLITEM lpdli)
+{
+
+ LV_ITEM lvi;
+ LPLV_ITEMDATA lplvid;
+
+ ULONG dwAttributes = SFGAO_FILESYSTEM;
+
+
+ if (iItem == -1)
+ {
+
+ if (ListView_GetSelectedCount(hwnd))
+
+ iItem = ListView_GetNextItem(hwnd,-1,LVNI_ALL | LVNI_SELECTED);
+
+ else
+
+ return(-1);
+
+ }
+
+ lvi.mask = LVIF_PARAM;
+ lvi.iItem = iItem;
+ lvi.iSubItem = 0;
+
+ if (!ListView_GetItem(hwnd,&lvi))
+ {
+
+ if (lpdli->mask & DLI_TYPE)
+
+ lpdli->ntype = DLE_NONE;
+
+ return(-1);
+
+ }
+
+ lplvid = (LPLV_ITEMDATA)lvi.lParam;
+
+ // Filename
+ if (lpdli->mask & DLI_FILENAME)
+
+ IL_GetDisplayName(lplvid->lpsf,lplvid->pidl,SHGDN_FORPARSING,
+ lpdli->szFileName,MAX_PATH);
+
+ // Displayname
+ if (lpdli->mask & DLI_DISPNAME)
+
+ IL_GetDisplayName(lplvid->lpsf,lplvid->pidl,SHGDN_INFOLDER,
+ lpdli->szDisplayName,MAX_PATH);
+
+ // Type (File / Directory)
+ if (lpdli->mask & DLI_TYPE)
+ {
+
+ WIN32_FIND_DATA fd;
+
+ if (NOERROR == SHGetDataFromIDList(lplvid->lpsf,
+ lplvid->pidl,
+ SHGDFIL_FINDDATA,
+ &fd,
+ sizeof(WIN32_FIND_DATA)))
+
+ lpdli->ntype = (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ?
+ DLE_DIR : DLE_FILE;
+
+ /*lplvid->lpsf->lpVtbl->GetAttributesOf(
+ lplvid->lpsf,
+ 1,
+ &lplvid->pidl,
+ &dwAttributes);
+
+ lpdli->ntype = (dwAttributes & SFGAO_FOLDER) ? DLE_DIR : DLE_FILE;*/
+
+ }
+
+ return iItem;
+
+}
+
+
+//=============================================================================
+//
+// DirList_GetItemEx()
+//
+// Retrieves extended infomration on a dirlist item
+//
+int DirList_GetItemEx(HWND hwnd,int iItem,LPWIN32_FIND_DATA pfd)
+{
+
+ LV_ITEM lvi;
+ LPLV_ITEMDATA lplvid;
+
+
+ if (iItem == -1)
+ {
+
+ if (ListView_GetSelectedCount(hwnd))
+
+ iItem = ListView_GetNextItem(hwnd,-1,LVNI_ALL | LVNI_SELECTED);
+
+ else
+
+ return(-1);
+
+ }
+
+ lvi.mask = LVIF_PARAM;
+ lvi.iItem = iItem;
+ lvi.iSubItem = 0;
+
+ if (!ListView_GetItem(hwnd,&lvi))
+ return(-1);
+
+ lplvid = (LPLV_ITEMDATA)lvi.lParam;
+
+ if (NOERROR == SHGetDataFromIDList(lplvid->lpsf,
+ lplvid->pidl,
+ SHGDFIL_FINDDATA,
+ pfd,
+ sizeof(WIN32_FIND_DATA)))
+ return iItem;
+
+ else
+ return(-1);
+
+}
+
+
+//=============================================================================
+//
+// DirList_PropertyDlg()
+//
+// Shows standard Win95 Property Dlg for selected Item
+//
+BOOL DirList_PropertyDlg(HWND hwnd,int iItem)
+{
+
+ LV_ITEM lvi;
+ LPLV_ITEMDATA lplvid;
+ LPCONTEXTMENU lpcm;
+ CMINVOKECOMMANDINFO cmi;
+ BOOL bSuccess = TRUE;
+
+ static const char *lpVerb = "properties";
+
+ if (iItem == -1)
+ {
+ if (ListView_GetSelectedCount(hwnd))
+ iItem = ListView_GetNextItem(hwnd,-1,LVNI_ALL | LVNI_SELECTED);
+
+ else
+ return FALSE;
+ }
+
+ lvi.mask = LVIF_PARAM;
+ lvi.iItem = iItem;
+ lvi.iSubItem = 0;
+
+ if (!ListView_GetItem(hwnd,&lvi))
+ return FALSE;
+
+ lplvid = (LPLV_ITEMDATA)lvi.lParam;
+
+ if (NOERROR == lplvid->lpsf->lpVtbl->GetUIObjectOf(
+ lplvid->lpsf,
+ GetParent(hwnd), // Owner
+ 1, // Number of objects
+ &lplvid->pidl, // pidl
+ &IID_IContextMenu,
+ NULL,
+ &lpcm))
+ {
+
+ cmi.cbSize = sizeof(CMINVOKECOMMANDINFO);
+ cmi.fMask = 0;
+ cmi.hwnd = GetParent(hwnd);
+ cmi.lpVerb = lpVerb;
+ cmi.lpParameters = NULL;
+ cmi.lpDirectory = NULL;
+ cmi.nShow = SW_SHOWNORMAL;
+ cmi.dwHotKey = 0;
+ cmi.hIcon = NULL;
+
+ if (NOERROR != lpcm->lpVtbl->InvokeCommand(lpcm,&cmi))
+ bSuccess = FALSE;
+
+ lpcm->lpVtbl->Release(lpcm);
+
+ }
+
+ else
+ bSuccess = FALSE;
+
+ return(bSuccess);
+
+}
+
+
+
+//=============================================================================
+//
+// DirList_DoDragDrop()
+//
+// Execute an OLE Drag & Drop Operation in response to LVN_BEGIN(R)DRAG
+//
+//extern LPDROPSOURCE CreateDropSource();
+
+void DirList_DoDragDrop(HWND hwnd,LPARAM lParam)
+{
+
+ //LV_ITEM lvi;
+ //LPLV_ITEMDATA lplvid;
+ //LPDATAOBJECT lpdo;
+ //LPDROPSOURCE lpds;
+ //DWORD dwEffect;
+ //NM_LISTVIEW *pnmlv = (LPVOID)lParam;
+
+ //lvi.iItem = pnmlv->iItem;
+ //lvi.iSubItem = 0;
+ //lvi.mask = LVIF_PARAM;
+
+ //if (ListView_GetItem(hwnd,&lvi))
+ //{
+
+ // lplvid = (LPLV_ITEMDATA)lvi.lParam;
+
+ // if (SUCCEEDED(lplvid->lpsf->lpVtbl->GetUIObjectOf(
+ // lplvid->lpsf,
+ // GetParent(hwnd),
+ // 1,
+ // &lplvid->pidl,
+ // &IID_IDataObject,
+ // NULL,
+ // &lpdo)))
+ // {
+
+ // lpds = CreateDropSource();
+
+ // DoDragDrop(lpdo,lpds,DROPEFFECT_COPY|DROPEFFECT_MOVE|DROPEFFECT_LINK,&dwEffect);
+
+ // lpdo->lpVtbl->Release(lpdo);
+ // lpds->lpVtbl->Release(lpds);
+
+ // }
+ //}
+}
+
+
+
+//=============================================================================
+//
+// DirList_GetLongPathName()
+//
+// Get long pathname for currently displayed directory
+//
+BOOL DirList_GetLongPathName(HWND hwnd,LPWSTR lpszLongPath)
+{
+ WCHAR tch[MAX_PATH];
+ LPDLDATA lpdl = (LPVOID)GetProp(hwnd,pDirListProp);
+ if (SHGetPathFromIDList(lpdl->pidl,tch))
+ {
+ lstrcpy(lpszLongPath,tch);
+ return(TRUE);
+ }
+ else
+ return(FALSE);
+}
+
+
+
+//=============================================================================
+//
+// DirList_SelectItem()
+//
+// Select specified item in the list
+//
+BOOL DirList_SelectItem(HWND hwnd,LPCWSTR lpszDisplayName,LPCWSTR lpszFullPath)
+{
+
+ #define LVIS_FLAGS LVIS_SELECTED|LVIS_FOCUSED
+
+ WCHAR szShortPath[MAX_PATH];
+ SHFILEINFO shfi;
+
+ LV_FINDINFO lvfi;
+ DLITEM dli;
+
+ int i = -1;
+
+ if (!lpszFullPath || !lstrlen(lpszFullPath))
+ return(FALSE);
+ else
+ GetShortPathName(lpszFullPath,szShortPath,MAX_PATH);
+
+ if (!lpszDisplayName || !lstrlen(lpszDisplayName))
+ SHGetFileInfo(lpszFullPath,0,&shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME);
+ else
+ lstrcpyn(shfi.szDisplayName,lpszDisplayName,MAX_PATH);
+
+ lvfi.flags = LVFI_STRING;
+ lvfi.psz = shfi.szDisplayName;
+
+ dli.mask = DLI_ALL;
+
+ while ((i = ListView_FindItem(hwnd,i,&lvfi)) != -1)
+ {
+
+ DirList_GetItem(hwnd,i,&dli);
+ GetShortPathName(dli.szFileName,dli.szFileName,MAX_PATH);
+
+ if (!lstrcmpi(dli.szFileName,szShortPath))
+ {
+ ListView_SetItemState(hwnd,i,LVIS_FLAGS,LVIS_FLAGS);
+ ListView_EnsureVisible(hwnd,i,FALSE);
+
+ return(TRUE);
+ }
+
+ }
+
+ return(FALSE);
+
+}
+
+
+
+//=============================================================================
+//
+// DirList_CreateFilter()
+//
+// Create a valid DL_FILTER structure
+//
+void DirList_CreateFilter(PDL_FILTER pdlf,LPCWSTR lpszFileSpec,
+ BOOL bExcludeFilter)
+{
+
+ WCHAR *p;
+
+ ZeroMemory(pdlf,sizeof(DL_FILTER));
+ lstrcpyn(pdlf->tFilterBuf,lpszFileSpec,(DL_FILTER_BUFSIZE-1));
+ pdlf->bExcludeFilter = bExcludeFilter;
+
+ if (!lstrcmp(lpszFileSpec,L"*.*") || !lstrlen(lpszFileSpec))
+ return;
+
+ pdlf->nCount = 1;
+ pdlf->pFilter[0] = &pdlf->tFilterBuf[0]; // Zeile zum Ausprobieren
+
+ while (p = StrChr(pdlf->pFilter[pdlf->nCount-1],L';'))
+ {
+ *p = L'\0'; // Replace L';' by L'\0'
+ pdlf->pFilter[pdlf->nCount] = (p + 1); // Next position after L';'
+ pdlf->nCount++; // Increase number of filters
+ }
+
+}
+
+
+
+//=============================================================================
+//
+// DirList_MatchFilter()
+//
+// Check if a specified item matches a given filter
+//
+BOOL DirList_MatchFilter(LPSHELLFOLDER lpsf,LPCITEMIDLIST pidl,PDL_FILTER pdlf)
+{
+
+ int i;
+ WIN32_FIND_DATA fd;
+ BOOL bMatchSpec;
+
+ // Immediately return true if lpszFileSpec is *.* or NULL
+ if (pdlf->nCount == 0 && !pdlf->bExcludeFilter)
+ return TRUE;
+
+ SHGetDataFromIDList(lpsf,pidl,SHGDFIL_FINDDATA,&fd,sizeof(WIN32_FIND_DATA));
+
+ // All the directories are added
+ if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ return(TRUE);
+
+ // Check if exclude *.* after directories have been added
+ if (pdlf->nCount == 0 && pdlf->bExcludeFilter)
+ return FALSE;
+
+ for (i = 0; i < pdlf->nCount; i++)
+ {
+ if (*pdlf->pFilter[i]) // Filters like L"\0" are ignored
+ {
+ bMatchSpec = PathMatchSpec(fd.cFileName,pdlf->pFilter[i]);
+ if (bMatchSpec)
+ {
+ if (!pdlf->bExcludeFilter)
+ return(TRUE);
+ else
+ return(FALSE);
+ }
+ }
+ }
+
+ // No matching
+ return(pdlf->bExcludeFilter)?TRUE:FALSE;
+
+}
+
+
+
+//==== DriveBox ===============================================================
+
+//=============================================================================
+//
+// Internal Itemdata Structure
+//
+typedef struct tagDC_ITEMDATA
+{
+
+ LPITEMIDLIST pidl;
+ LPSHELLFOLDER lpsf;
+
+} DC_ITEMDATA, *LPDC_ITEMDATA;
+
+
+//=============================================================================
+//
+// DriveBox_Init()
+//
+// Initializes the drive box
+//
+BOOL DriveBox_Init(HWND hwnd)
+{
+
+ HIMAGELIST hil;
+ SHFILEINFO shfi;
+
+ hil = (HIMAGELIST)SHGetFileInfo(L"C:\\",0,&shfi,sizeof(SHFILEINFO),
+ SHGFI_SMALLICON | SHGFI_SYSICONINDEX);
+ SendMessage(hwnd,CBEM_SETIMAGELIST,0,(LPARAM)hil);
+ SendMessage(hwnd,CBEM_SETEXTENDEDSTYLE,CBES_EX_NOSIZELIMIT,CBES_EX_NOSIZELIMIT);
+
+ return TRUE;
+
+}
+
+
+//=============================================================================
+//
+// DriveBox_Fill
+//
+
+int DriveBox_Fill(HWND hwnd)
+{
+
+ //LPMALLOC lpMalloc;
+
+ LPSHELLFOLDER lpsfDesktop;
+ LPSHELLFOLDER lpsf; // Workspace == CSIDL_DRIVES
+
+ LPITEMIDLIST pidl;
+ LPITEMIDLIST pidlEntry;
+
+ LPENUMIDLIST lpe;
+
+ COMBOBOXEXITEM cbei;
+ LPDC_ITEMDATA lpdcid;
+
+ ULONG dwAttributes = 0;
+
+ DWORD grfFlags = SHCONTF_FOLDERS;
+
+
+ // Init ComboBox
+ SendMessage(hwnd,WM_SETREDRAW,0,0);
+ SendMessage(hwnd,CB_RESETCONTENT,0,0);
+
+ ZeroMemory(&cbei,sizeof(COMBOBOXEXITEM));
+ cbei.mask = CBEIF_TEXT | CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBEIF_LPARAM;
+ cbei.pszText = LPSTR_TEXTCALLBACK;
+ cbei.cchTextMax = MAX_PATH;
+ cbei.iImage = I_IMAGECALLBACK;
+ cbei.iSelectedImage = I_IMAGECALLBACK;
+
+ // Get Shell's IMalloc Interface
+ //if (NOERROR == SHGetMalloc(&lpMalloc))
+ //{
+
+ // Get pidl to [My Computer]
+ if (NOERROR == SHGetSpecialFolderLocation(hwnd,
+ CSIDL_DRIVES,
+ &pidl))
+ {
+
+ // Get Desktop Folder
+ if (NOERROR == SHGetDesktopFolder(&lpsfDesktop))
+ {
+
+ // Bind pidl to IShellFolder
+ if (NOERROR == lpsfDesktop->lpVtbl->BindToObject(
+ lpsfDesktop,
+ pidl,
+ NULL,
+ &IID_IShellFolder,
+ &lpsf))
+
+ {
+
+ // Create an Enumeration object for lpsf
+ if (NOERROR == lpsf->lpVtbl->EnumObjects(
+ lpsf,
+ hwnd,
+ grfFlags,
+ &lpe))
+
+ {
+
+ // Enumerate the contents of [My Computer]
+ while (NOERROR == lpe->lpVtbl->Next(
+ lpe,
+ 1,
+ &pidlEntry,
+ NULL))
+
+ {
+
+ // Add item to the List if it is part of the
+ // Filesystem
+ dwAttributes = SFGAO_FILESYSTEM;
+
+ lpsf->lpVtbl->GetAttributesOf(
+ lpsf,
+ 1,
+ &pidlEntry,
+ &dwAttributes);
+
+ if (dwAttributes & SFGAO_FILESYSTEM)
+ {
+
+ // Windows XP: check if pidlEntry is a drive
+ SHDESCRIPTIONID di;
+ HRESULT hr;
+ hr = SHGetDataFromIDList(lpsf,pidlEntry,SHGDFIL_DESCRIPTIONID,
+ &di,sizeof(SHDESCRIPTIONID));
+ if (hr != NOERROR || (di.dwDescriptionId >= SHDID_COMPUTER_DRIVE35 &&
+ di.dwDescriptionId <= SHDID_COMPUTER_OTHER))
+ {
+
+ lpdcid = g_lpMalloc->lpVtbl->Alloc(
+ g_lpMalloc,
+ sizeof(DC_ITEMDATA));
+
+ //lpdcid->pidl = IL_Copy(lpMalloc,pidlEntry);
+ lpdcid->pidl = pidlEntry;
+ lpdcid->lpsf = lpsf;
+
+ lpsf->lpVtbl->AddRef(lpsf);
+
+ // Insert sorted ...
+ {
+ COMBOBOXEXITEM cbei2;
+ LPDC_ITEMDATA lpdcid2;
+ HRESULT hr;
+ cbei2.mask = CBEIF_LPARAM;
+ cbei2.iItem = 0;
+
+ while ((SendMessage(hwnd,CBEM_GETITEM,0,(LPARAM)&cbei2)))
+ {
+ lpdcid2 = (LPDC_ITEMDATA)cbei2.lParam;
+ hr = (lpdcid->lpsf->lpVtbl->CompareIDs(
+ lpdcid->lpsf,
+ 0,
+ lpdcid->pidl,
+ lpdcid2->pidl));
+
+ if ((short)(SCODE_CODE(GetScode(hr))) < 0)
+ break;
+ else
+ cbei2.iItem++;
+ }
+
+ cbei.iItem = cbei2.iItem;
+ cbei.lParam = (LPARAM)lpdcid;
+ SendMessage(hwnd,CBEM_INSERTITEM,0,(LPARAM)&cbei);
+
+ }
+
+ }
+
+ }
+
+ //lpMalloc->lpVtbl->Free(lpMalloc,pidlEntry);
+
+ } // IEnumIDList::Next()
+
+ lpe->lpVtbl->Release(lpe);
+
+ } // IShellFolder::EnumObjects()
+
+ lpsf->lpVtbl->Release(lpsf);
+
+ } // IShellFolder::BindToObject()
+
+ g_lpMalloc->lpVtbl->Free(g_lpMalloc,pidl);
+
+ } // SHGetSpecialFolderLocation()
+
+ lpsfDesktop->lpVtbl->Release(lpsfDesktop);
+
+ } // SHGetDesktopFolder()
+
+ //lpMalloc->lpVtbl->Release(lpMalloc);
+
+ //} // SHGetMalloc()
+
+
+ SendMessage(hwnd,WM_SETREDRAW,1,0);
+ // Return number of items added to combo box
+ return (SendMessage(hwnd,CB_GETCOUNT,0,0));
+
+}
+
+
+//=============================================================================
+//
+// DriveBox_GetSelDrive
+//
+BOOL DriveBox_GetSelDrive(HWND hwnd,LPWSTR lpszDrive,int nDrive,BOOL fNoSlash)
+{
+
+ COMBOBOXEXITEM cbei;
+ LPDC_ITEMDATA lpdcid;
+ int i = SendMessage(hwnd,CB_GETCURSEL,0,0);
+
+ // CB_ERR means no Selection
+ if (i == CB_ERR)
+ return FALSE;
+
+ // Get DC_ITEMDATA* of selected Item
+ cbei.mask = CBEIF_LPARAM;
+ cbei.iItem = i;
+ SendMessage(hwnd,CBEM_GETITEM,0,(LPARAM)&cbei);
+ lpdcid = (LPDC_ITEMDATA)cbei.lParam;
+
+ // Get File System Path for Drive
+ IL_GetDisplayName(lpdcid->lpsf,lpdcid->pidl,SHGDN_FORPARSING,lpszDrive,nDrive);
+
+ // Remove Backslash if required (makes Drive relative!!!)
+ if (fNoSlash)
+ PathRemoveBackslash(lpszDrive);
+
+ return TRUE;
+
+}
+
+
+//=============================================================================
+//
+// DriveBox_SelectDrive
+//
+BOOL DriveBox_SelectDrive(HWND hwnd,LPCWSTR lpszPath)
+{
+
+ COMBOBOXEXITEM cbei;
+ LPDC_ITEMDATA lpdcid;
+ WCHAR szRoot[64];
+
+ int i;
+ int cbItems = SendMessage(hwnd,CB_GETCOUNT,0,0);
+
+ // No Drives in Combo Box
+ if (!cbItems)
+ return FALSE;
+
+ cbei.mask = CBEIF_LPARAM;
+
+ for (i = 0; i < cbItems; i++)
+ {
+ // Get DC_ITEMDATA* of Item i
+ cbei.iItem = i;
+ SendMessage(hwnd,CBEM_GETITEM,0,(LPARAM)&cbei);
+ lpdcid = (LPDC_ITEMDATA)cbei.lParam;
+
+ // Get File System Path for Drive
+ IL_GetDisplayName(lpdcid->lpsf,lpdcid->pidl,SHGDN_FORPARSING,szRoot,64);
+
+ // Compare Root Directory with Path
+ if (PathIsSameRoot(lpszPath,szRoot))
+ {
+ // Select matching Drive
+ SendMessage(hwnd,CB_SETCURSEL,i,0);
+ return TRUE;
+ }
+ }
+
+ // Don't select anything
+ SendMessage(hwnd,CB_SETCURSEL,(WPARAM)-1,0);
+ return FALSE;
+
+}
+
+
+//=============================================================================
+//
+// DriveBox_PropertyDlg()
+//
+// Shows standard Win95 Property Dlg for selected Drive
+//
+BOOL DriveBox_PropertyDlg(HWND hwnd)
+{
+
+ COMBOBOXEXITEM cbei;
+ LPDC_ITEMDATA lpdcid;
+ int iItem;
+ LPCONTEXTMENU lpcm;
+ CMINVOKECOMMANDINFO cmi;
+ BOOL bSuccess = TRUE;
+
+ static const char *lpVerb = "properties";
+
+ iItem = SendMessage(hwnd,CB_GETCURSEL,0,0);
+
+ if (iItem == CB_ERR)
+ return FALSE;
+
+ cbei.mask = CBEIF_LPARAM;
+ cbei.iItem = iItem;
+ SendMessage(hwnd,CBEM_GETITEM,0,(LPARAM)&cbei);
+ lpdcid = (LPDC_ITEMDATA)cbei.lParam;
+
+ if (NOERROR == lpdcid->lpsf->lpVtbl->GetUIObjectOf(
+ lpdcid->lpsf,
+ GetParent(hwnd), // Owner
+ 1, // Number of objects
+ &lpdcid->pidl, // pidl
+ &IID_IContextMenu,
+ NULL,
+ &lpcm))
+ {
+
+ cmi.cbSize = sizeof(CMINVOKECOMMANDINFO);
+ cmi.fMask = 0;
+ cmi.hwnd = GetParent(hwnd);
+ cmi.lpVerb = lpVerb;
+ cmi.lpParameters = NULL;
+ cmi.lpDirectory = NULL;
+ cmi.nShow = SW_SHOWNORMAL;
+ cmi.dwHotKey = 0;
+ cmi.hIcon = NULL;
+
+ if (NOERROR != lpcm->lpVtbl->InvokeCommand(lpcm,&cmi))
+ bSuccess = FALSE;
+
+ lpcm->lpVtbl->Release(lpcm);
+
+ }
+
+ else
+ bSuccess = FALSE;
+
+ return(bSuccess);
+
+}
+
+
+//=============================================================================
+//
+// DriveBox_DeleteItem
+//
+LRESULT DriveBox_DeleteItem(HWND hwnd,LPARAM lParam)
+{
+
+ //LPMALLOC lpMalloc;
+ NMCOMBOBOXEX *lpnmcbe;
+ COMBOBOXEXITEM cbei;
+ LPDC_ITEMDATA lpdcid;
+
+ lpnmcbe = (LPVOID)lParam;
+ cbei.iItem = lpnmcbe->ceItem.iItem;
+
+ cbei.mask = CBEIF_LPARAM;
+ SendMessage(hwnd,CBEM_GETITEM,0,(LPARAM)&cbei);
+ lpdcid = (LPDC_ITEMDATA)cbei.lParam;
+
+ //SHGetMalloc(&lpMalloc);
+
+ // Free pidl
+ g_lpMalloc->lpVtbl->Free(g_lpMalloc,lpdcid->pidl);
+ // Release lpsf
+ lpdcid->lpsf->lpVtbl->Release(lpdcid->lpsf);
+
+ // Free lpdcid itself
+ g_lpMalloc->lpVtbl->Free(g_lpMalloc,lpdcid);
+
+ // Release lpMalloc
+ //lpMalloc->lpVtbl->Release(lpMalloc);
+
+ return TRUE;
+
+}
+
+
+//=============================================================================
+//
+// DriveBox_GetDispInfo
+//
+LRESULT DriveBox_GetDispInfo(HWND hwnd,LPARAM lParam)
+{
+
+ NMCOMBOBOXEX *lpnmcbe;
+ LPDC_ITEMDATA lpdcid;
+ SHFILEINFO shfi;
+ WCHAR szTemp[256];
+
+ lpnmcbe = (LPVOID)lParam;
+ lpdcid = (LPDC_ITEMDATA)lpnmcbe->ceItem.lParam;
+
+ if (!lpdcid)
+ return FALSE;
+
+ // Get Display Name
+ if (lpnmcbe->ceItem.mask & CBEIF_TEXT)
+ IL_GetDisplayName(lpdcid->lpsf,lpdcid->pidl,SHGDN_NORMAL,lpnmcbe->ceItem.pszText,lpnmcbe->ceItem.cchTextMax);
+
+ // Get Icon Index
+ if (lpnmcbe->ceItem.mask & (CBEIF_IMAGE | CBEIF_SELECTEDIMAGE))
+ {
+ IL_GetDisplayName(lpdcid->lpsf,lpdcid->pidl,SHGDN_FORPARSING,szTemp,256);
+ SHGetFileInfo(szTemp,0,&shfi,sizeof(SHFILEINFO),SHGFI_SYSICONINDEX | SHGFI_SMALLICON);
+ lpnmcbe->ceItem.iImage = shfi.iIcon;
+ lpnmcbe->ceItem.iSelectedImage = shfi.iIcon;
+ }
+
+ // Set values
+ lpnmcbe->ceItem.mask |= CBEIF_DI_SETITEM;
+
+ return TRUE;
+
+}
+
+
+
+//==== ItemID =================================================================
+
+//=============================================================================
+//
+// IL_Create()
+//
+// Creates an ITEMIDLIST by concatenating pidl1 and pidl2
+// cb1 and cb2 indicate the sizes of the pidls, where cb1
+// can be zero and pidl1 can be NULL
+//
+// If cb2 is zero, the size of pidl2 is retrieved using
+// IL_GetSize(pidl2)
+//
+LPITEMIDLIST IL_Create(LPMALLOC lpMalloc,
+ LPCITEMIDLIST pidl1,UINT cb1,
+ LPCITEMIDLIST pidl2,UINT cb2)
+{
+
+ LPITEMIDLIST pidl;
+
+ if (!pidl2)
+ return NULL;
+
+ if (!cb2)
+ cb2 = IL_GetSize(pidl2) + 2; // Space for terminating Bytes
+
+ if (!cb1)
+ cb1 = IL_GetSize(pidl1);
+
+ // Allocate Memory
+ pidl = lpMalloc->lpVtbl->Alloc(lpMalloc,cb1 + cb2);
+
+ // Init new ITEMIDLIST
+ if (pidl1)
+ CopyMemory(pidl,pidl1,cb1);
+
+ // pidl2 can't be NULL here
+ CopyMemory((LPBYTE)pidl + cb1,pidl2,cb2);
+
+ return pidl;
+
+}
+
+
+//=============================================================================
+//
+// IL_GetSize()
+//
+// Retrieves the number of bytes in a pidl
+// Does not add space for zero terminators !!
+//
+UINT IL_GetSize(LPCITEMIDLIST pidl)
+{
+
+ LPITEMIDLIST pidlTmp;
+ UINT cb = 0;
+
+ if (!pidl)
+ return 0;
+
+ for (pidlTmp = (LPITEMIDLIST)pidl;
+ pidlTmp->mkid.cb;
+ pidlTmp = _IL_Next(pidlTmp))
+
+ cb += pidlTmp->mkid.cb;
+
+
+ return cb;
+
+}
+
+
+//=============================================================================
+//
+// IL_GetDisplayName()
+//
+// Gets the Display Name of a pidl. lpsf is the parent IShellFolder Interface
+// dwFlags specify a SHGDN_xx value
+//
+BOOL IL_GetDisplayName(LPSHELLFOLDER lpsf,
+ LPCITEMIDLIST pidl,
+ DWORD dwFlags,
+ LPWSTR lpszDisplayName,
+ int nDisplayName)
+{
+
+ STRRET str;
+
+ if (NOERROR == lpsf->lpVtbl->GetDisplayNameOf(lpsf,
+ pidl,
+ dwFlags,
+ &str))
+ {
+
+ // Shlwapi.dll provides new function:
+ return StrRetToBuf(&str,pidl,lpszDisplayName,nDisplayName);
+ // ...but I suppose my version is faster ;-)
+ /*switch (str.uType)
+ {
+
+ case STRRET_WSTR:
+ WideCharToMultiByte(CP_ACP,
+ 0,
+ str.pOleStr,
+ -1,
+ lpszDisplayName,
+ nDisplayName,
+ NULL,
+ NULL);
+ g_lpMalloc->lpVtbl->Free(g_lpMalloc,str.pOleStr);
+ break;
+
+ case STRRET_OFFSET:
+ lstrcpyn(lpszDisplayName,
+ ((WCHAR *)(pidl)) + str.uOffset,
+ nDisplayName);
+ break;
+
+ case STRRET_CSTR:
+ lstrcpyn(lpszDisplayName,str.cStr,nDisplayName);
+ break;
+
+ }
+
+ return TRUE;*/
+ }
+
+ return FALSE;
+}
+
+
+
+/// End of Dlapi.c \\\
diff --git a/src/Dlapi.h b/src/Dlapi.h new file mode 100644 index 0000000..84b2b09 --- /dev/null +++ b/src/Dlapi.h @@ -0,0 +1,201 @@ +/******************************************************************************
+*
+*
+* Notepad2
+*
+* Dlapi.h
+* Definitions for Directory Listing APIs
+*
+* See Readme.txt for more information about this source code.
+* Please send me your comments to this work.
+*
+* See License.txt for details about distribution and modification.
+*
+* (c) Florian Balmer 1996-2010
+* florian.balmer@gmail.com
+* http://www.flos-freeware.ch
+*
+*
+******************************************************************************/
+
+#ifndef _DLAPI_H_
+#define _DLAPI_H_
+
+#ifdef __cplusplus
+extern L"C" { // C-Declarations
+#endif //__cplusplus
+
+
+
+//==== DirList ================================================================
+
+//==== LV_ITEMDATA Structure ==================================================
+typedef struct tagLV_ITEMDATA // lvid
+{
+ LPITEMIDLIST pidl; // Item Id
+ LPSHELLFOLDER lpsf; // Parent IShellFolder Interface
+
+} LV_ITEMDATA, *LPLV_ITEMDATA;
+
+
+//==== DlInit() ===============================================================
+
+BOOL DirList_Init(HWND,LPCWSTR);
+
+
+//==== DlDestroy() ============================================================
+
+BOOL DirList_Destroy(HWND);
+
+
+//==== DlStartIconThread() ====================================================
+
+BOOL DirList_StartIconThread(HWND);
+
+
+//==== DlTerminateIconThread() ================================================
+
+BOOL DirList_TerminateIconThread(HWND);
+
+
+//==== DlFill() ===============================================================
+
+#define DL_FOLDERS 32
+#define DL_NONFOLDERS 64
+#define DL_INCLHIDDEN 128
+#define DL_ALLOBJECTS (32|64|128)
+
+int DirList_Fill(HWND,LPCWSTR,DWORD,LPCWSTR,BOOL,BOOL,int,BOOL);
+
+
+//==== DlIconThread() =========================================================
+
+DWORD WINAPI DirList_IconThread(LPVOID);
+
+
+//==== DlGetDispInfo() ========================================================
+
+BOOL DirList_GetDispInfo(HWND,LPARAM,BOOL);
+
+
+//==== DlDeleteItem() =========================================================
+
+BOOL DirList_DeleteItem(HWND,LPARAM);
+
+
+//==== DlSort() ===============================================================
+
+#define DS_NAME 0
+#define DS_SIZE 1
+#define DS_TYPE 2
+#define DS_LASTMOD 3
+
+BOOL DirList_Sort(HWND,int,BOOL);
+
+
+//==== DlGetItem() ============================================================
+
+#define DLE_NONE 0
+#define DLE_DIR 1
+#define DLE_FILE 2
+
+#define DLI_FILENAME 1
+#define DLI_DISPNAME 2
+#define DLI_TYPE 4
+#define DLI_ALL (1|2|4)
+
+typedef struct tagDLITEM // dli
+{
+
+ UINT mask;
+ WCHAR szFileName[MAX_PATH];
+ WCHAR szDisplayName[MAX_PATH];
+ int ntype;
+
+} DLITEM, *LPDLITEM;
+
+DirList_GetItem(HWND,int,LPDLITEM);
+
+
+//==== DlGetItemEx() ==========================================================
+
+int DirList_GetItemEx(HWND,int,LPWIN32_FIND_DATA);
+
+
+//==== DlPropertyDlg() ========================================================
+
+BOOL DirList_PropertyDlg(HWND,int);
+
+
+//==== DlDoDragDrop() =========================================================
+
+void DirList_DoDragDrop(HWND,LPARAM);
+
+//==== DlGetLongPathName() ====================================================
+
+BOOL DirList_GetLongPathName(HWND,LPWSTR);
+
+//==== DlSelectItem() =========================================================
+
+BOOL DirList_SelectItem(HWND,LPCWSTR,LPCWSTR);
+
+//==== DlCreateFilter() and DlMatchFilter() ===================================
+
+#define DL_FILTER_BUFSIZE 128
+
+typedef struct tagDL_FILTER { //dlf
+ int nCount;
+ WCHAR tFilterBuf[DL_FILTER_BUFSIZE];
+ WCHAR *pFilter [DL_FILTER_BUFSIZE];
+ BOOL bExcludeFilter;
+} DL_FILTER, *PDL_FILTER;
+
+void DirList_CreateFilter(PDL_FILTER,LPCWSTR,BOOL);
+
+BOOL DirList_MatchFilter(LPSHELLFOLDER,LPCITEMIDLIST,PDL_FILTER);
+
+
+
+//==== DriveBox ===============================================================
+
+BOOL DriveBox_Init(HWND);
+int DriveBox_Fill(HWND);
+BOOL DriveBox_GetSelDrive(HWND,LPWSTR,int,BOOL);
+BOOL DriveBox_SelectDrive(HWND,LPCWSTR);
+BOOL DriveBox_PropertyDlg(HWND);
+
+LRESULT DriveBox_DeleteItem(HWND,LPARAM);
+LRESULT DriveBox_GetDispInfo(HWND,LPARAM);
+
+
+
+//==== ItemID =================================================================
+
+//==== IL_Next() ==============================================================
+#define _IL_Next(pidl) ((LPITEMIDLIST)(((LPBYTE)(pidl)) + pidl->mkid.cb))
+
+//==== IL_Create() ============================================================
+LPITEMIDLIST IL_Create(LPMALLOC,
+ LPCITEMIDLIST,UINT,
+ LPCITEMIDLIST,UINT);
+
+//==== IL_GetSize() ===========================================================
+UINT IL_GetSize(LPCITEMIDLIST);
+
+//==== IL_GetDisplayName() ====================================================
+BOOL IL_GetDisplayName(LPSHELLFOLDER,
+ LPCITEMIDLIST,
+ DWORD,LPWSTR,int);
+
+
+
+
+#ifdef __cplusplus
+}
+#endif //__cplusplus
+
+
+#endif // _DLAPI_H_
+
+
+/// End of Dlapi.h \\\
diff --git a/src/Edit.c b/src/Edit.c new file mode 100644 index 0000000..97c3967 --- /dev/null +++ b/src/Edit.c @@ -0,0 +1,6041 @@ +/******************************************************************************
+*
+*
+* Notepad2
+*
+* Edit.c
+* Text File Editing Helper Stuff
+*
+* See Readme.txt for more information about this source code.
+* Please send me your comments to this work.
+*
+* See License.txt for details about distribution and modification.
+*
+* (c) Florian Balmer 1996-2010
+* florian.balmer@gmail.com
+* http://www.flos-freeware.ch
+*
+*
+******************************************************************************/
+#define _WIN32_WINNT 0x501
+#include <windows.h>
+#include <shlwapi.h>
+#include <commctrl.h>
+#include <commdlg.h>
+#include <stdio.h>
+#include <string.h>
+#include <limits.h>
+#include "notepad2.h"
+#include "helpers.h"
+#include "dialogs.h"
+#include "scintilla.h"
+#include "scilexer.h"
+#include "styles.h"
+#include "edit.h"
+#include "resource.h"
+
+
+extern HWND hwndMain;
+extern HWND hwndEdit;
+extern HINSTANCE g_hInstance;
+extern LPMALLOC g_lpMalloc;
+extern DWORD dwLastIOError;
+extern HWND hDlgFindReplace;
+extern UINT cpLastFind;
+extern BOOL bReplaceInitialized;
+
+static EDITFINDREPLACE efrSave;
+static BOOL bSwitchedFindReplace = FALSE;
+static int xFindReplaceDlgSave;
+static int yFindReplaceDlgSave;
+extern int xFindReplaceDlg;
+extern int yFindReplaceDlg;
+
+extern int iDefaultEncoding;
+extern int iDefaultEOLMode;
+extern int iLineEndings[3];
+extern BOOL bFixLineEndings;
+extern BOOL bAutoStripBlanks;
+
+
+// Default Codepage and Character Set
+extern int iDefaultCodePage;
+extern int iDefaultCharSet;
+extern BOOL bSkipUnicodeDetection;
+extern BOOL bLoadASCIIasUTF8;
+extern int iSrcEncoding;
+extern int iWeakSrcEncoding;
+
+
+// Supported Encodings
+WCHAR wchANSI[8] = L"";
+WCHAR wchOEM [8] = L"";
+
+NP2ENCODING mEncoding[] = {
+ { NCP_DEFAULT|NCP_RECODE, 0, "ansi,ansi,ascii,", 61000, L"" },
+ { NCP_8BIT|NCP_RECODE, 0, "oem,oem,", 61001, L"" },
+ { NCP_UNICODE|NCP_UNICODE_BOM, 0, "", 61002, L"" },
+ { NCP_UNICODE|NCP_UNICODE_REVERSE|NCP_UNICODE_BOM, 0, "", 61003, L"" },
+ { NCP_UNICODE, 0, "", 61004, L"" },
+ { NCP_UNICODE|NCP_UNICODE_REVERSE, 0, "", 61005, L"" },
+ { NCP_UTF8|NCP_RECODE, 0, "utf-8,utf8,", 61006, L"" },
+ { NCP_UTF8|NCP_UTF8_SIGN, 0, "utf-8,utf8,", 61007, L"" },
+ { NCP_8BIT|NCP_RECODE, CP_UTF7, "utf-7,utf7,", 61008, L"" },
+ { NCP_8BIT|NCP_RECODE, 720, "DOS-720,dos720,", 61009, L"" },
+ { NCP_8BIT|NCP_RECODE, 28596, "iso-8859-6,iso88596,arabic,csisolatinarabic,ecma114,isoir127,", 61010, L"" },
+ { NCP_8BIT|NCP_RECODE, 10004, "x-mac-arabic,xmacarabic,", 61011, L"" },
+ { NCP_8BIT|NCP_RECODE, 1256, "windows-1256,windows1256,cp1256", 61012, L"" },
+ { NCP_8BIT|NCP_RECODE, 775, "ibm775,ibm775,cp500,", 61013, L"" },
+ { NCP_8BIT|NCP_RECODE, 28594, "iso-8859-4,iso88594,csisolatin4,isoir110,l4,latin4,", 61014, L"" },
+ { NCP_8BIT|NCP_RECODE, 1257, "windows-1257,windows1257,", 61015, L"" },
+ { NCP_8BIT|NCP_RECODE, 852, "ibm852,ibm852,cp852,", 61016, L"" },
+ { NCP_8BIT|NCP_RECODE, 28592, "iso-8859-2,iso88592,csisolatin2,isoir101,latin2,l2,", 61017, L"" },
+ { NCP_8BIT|NCP_RECODE, 10029, "x-mac-ce,xmacce,", 61018, L"" },
+ { NCP_8BIT|NCP_RECODE, 1250, "windows-1250,windows1250,xcp1250,", 61019, L"" },
+ { NCP_8BIT|NCP_RECODE, 936, "gb2312,gb2312,chinese,cngb,csgb2312,csgb231280,gb231280,gbk,", 61020, L"" },
+ { NCP_8BIT|NCP_RECODE, 10008, "x-mac-chinesesimp,xmacchinesesimp,", 61021, L"" },
+ { NCP_8BIT|NCP_RECODE, 950, "big5,big5,cnbig5,csbig5,xxbig5,", 61022, L"" },
+ { NCP_8BIT|NCP_RECODE, 10002, "x-mac-chinesetrad,xmacchinesetrad,", 61023, L"" },
+ { NCP_8BIT|NCP_RECODE, 10082, "x-mac-croatian,xmaccroatian,", 61024, L"" },
+ { NCP_8BIT|NCP_RECODE, 866, "cp866,cp866,ibm866,", 61025, L"" },
+ { NCP_8BIT|NCP_RECODE, 28595, "iso-8859-5,iso88595,csisolatin5,csisolatincyrillic,cyrillic,isoir144,", 61026, L"" },
+ { NCP_8BIT|NCP_RECODE, 20866, "koi8-r,koi8r,cskoi8r,koi,koi8,", 61027, L"" },
+ { NCP_8BIT|NCP_RECODE, 21866, "koi8-u,koi8u,koi8ru,", 61028, L"" },
+ { NCP_8BIT|NCP_RECODE, 10007, "x-mac-cyrillic,xmaccyrillic,", 61029, L"" },
+ { NCP_8BIT|NCP_RECODE, 1251, "windows-1251,windows1251,xcp1251,", 61030, L"" },
+ { NCP_8BIT|NCP_RECODE, 28603, "iso-8859-13,iso885913,", 61031, L"" },
+ { NCP_8BIT|NCP_RECODE, 863, "ibm863,ibm863,", 61032, L"" },
+ { NCP_8BIT|NCP_RECODE, 737, "ibm737,ibm737,", 61033, L"" },
+ { NCP_8BIT|NCP_RECODE, 28597, "iso-8859-7,iso88597,csisolatingreek,ecma118,elot928,greek,greek8,isoir126,", 61034, L"" },
+ { NCP_8BIT|NCP_RECODE, 10006, "x-mac-greek,xmacgreek,", 61035, L"" },
+ { NCP_8BIT|NCP_RECODE, 1253, "windows-1253,windows1253,", 61036, L"" },
+ { NCP_8BIT|NCP_RECODE, 869, "ibm869,ibm869,", 61037, L"" },
+ { NCP_8BIT|NCP_RECODE, 862, "DOS-862,dos862,", 61038, L"" },
+ { NCP_8BIT|NCP_RECODE, 38598, "iso-8859-8-i,iso88598i,logical,", 61039, L"" },
+ { NCP_8BIT|NCP_RECODE, 28598, "iso-8859-8,iso88598,csisolatinhebrew,hebrew,isoir138,visual,", 61040, L"" },
+ { NCP_8BIT|NCP_RECODE, 10005, "x-mac-hebrew,xmachebrew,", 61041, L"" },
+ { NCP_8BIT|NCP_RECODE, 1255, "windows-1255,windows1255,", 61042, L"" },
+ { NCP_8BIT|NCP_RECODE, 861, "ibm861,ibm861,", 61043, L"" },
+ { NCP_8BIT|NCP_RECODE, 10079, "x-mac-icelandic,xmacicelandic,", 61044, L"" },
+ { NCP_8BIT|NCP_RECODE, 10001, "x-mac-japanese,xmacjapanese,", 61045, L"" },
+ { NCP_8BIT|NCP_RECODE, 932, "shift_jis,shiftjis,shiftjs,csshiftjis,cswindows31j,mskanji,xmscp932,xsjis,", 61046, L"" },
+ { NCP_8BIT|NCP_RECODE, 10003, "x-mac-korean,xmackorean,", 61047, L"" },
+ { NCP_8BIT|NCP_RECODE, 949, "windows-949,windows949,ksc56011987,csksc5601,euckr,isoir149,korean,ksc56011989", 61048, L"" },
+ { NCP_8BIT|NCP_RECODE, 28593, "iso-8859-3,iso88593,latin3,isoir109,l3,", 61049, L"" },
+ { NCP_8BIT|NCP_RECODE, 28605, "iso-8859-15,iso885915,latin9,l9,", 61050, L"" },
+ { NCP_8BIT|NCP_RECODE, 865, "ibm865,ibm865,", 61051, L"" },
+ { NCP_8BIT|NCP_RECODE, 437, "ibm437,ibm437,437,cp437,cspc8,codepage437,", 61052, L"" },
+ { NCP_8BIT|NCP_RECODE, 858, "ibm858,ibm858,ibm00858,", 61053, L"" },
+ { NCP_8BIT|NCP_RECODE, 860, "ibm860,ibm860,", 61054, L"" },
+ { NCP_8BIT|NCP_RECODE, 10010, "x-mac-romanian,xmacromanian,", 61055, L"" },
+ { NCP_8BIT|NCP_RECODE, 10021, "x-mac-thai,xmacthai,", 61056, L"" },
+ { NCP_8BIT|NCP_RECODE, 874, "windows-874,windows874,dos874,iso885911,tis620,", 61057, L"" },
+ { NCP_8BIT|NCP_RECODE, 857, "ibm857,ibm857,", 61058, L"" },
+ { NCP_8BIT|NCP_RECODE, 28599, "iso-8859-9,iso88599,latin5,isoir148,l5,", 61059, L"" },
+ { NCP_8BIT|NCP_RECODE, 10081, "x-mac-turkish,xmacturkish,", 61060, L"" },
+ { NCP_8BIT|NCP_RECODE, 1254, "windows-1254,windows1254,", 61061, L"" },
+ { NCP_8BIT|NCP_RECODE, 10017, "x-mac-ukrainian,xmacukrainian,", 61062, L"" },
+ { NCP_8BIT|NCP_RECODE, 1258, "windows-1258,windows-258,", 61063, L"" },
+ { NCP_8BIT|NCP_RECODE, 850, "ibm850,ibm850,", 61064, L"" },
+ { NCP_8BIT|NCP_RECODE, 28591, "iso-8859-1,iso88591,cp819,latin1,ibm819,isoir100,latin1,l1,", 61065, L"" },
+ { NCP_8BIT|NCP_RECODE, 10000, "macintosh,macintosh,", 61066, L"" },
+ { NCP_8BIT|NCP_RECODE, 1252, "windows-1252,windows1252,cp367,cp819,ibm367,us,xansi,", 61067, L"" },
+ { NCP_8BIT|NCP_RECODE, 37, "ebcdic-cp-us,ebcdiccpus,ebcdiccpca,ebcdiccpwt,ebcdiccpnl,ibm037,cp037,", 61068, L"" },
+ { NCP_8BIT|NCP_RECODE, 500, "x-ebcdic-international,xebcdicinternational,", 61069, L"" },
+/*{ NCP_8BIT|NCP_RECODE, 870, "CP870,cp870,ebcdiccproece,ebcdiccpyu,csibm870,ibm870,", 00000, L"" }, // IBM EBCDIC (Multilingual Latin-2) */
+ { NCP_8BIT|NCP_RECODE, 875, "x-EBCDIC-GreekModern,xebcdicgreekmodern,", 61070, L"" },
+ { NCP_8BIT|NCP_RECODE, 1026, "CP1026,cp1026,csibm1026,ibm1026,", 61071, L"" },
+/*{ NCP_8BIT|NCP_RECODE, 1047, "IBM01047,ibm01047,", 00000, L"" }, // IBM EBCDIC (Open System Latin-1)
+ { NCP_8BIT|NCP_RECODE, 1140, "x-ebcdic-cp-us-euro,xebcdiccpuseuro,", 00000, L"" }, // IBM EBCDIC (US-Canada-Euro)
+ { NCP_8BIT|NCP_RECODE, 1141, "x-ebcdic-germany-euro,xebcdicgermanyeuro,", 00000, L"" }, // IBM EBCDIC (Germany-Euro)
+ { NCP_8BIT|NCP_RECODE, 1142, "x-ebcdic-denmarknorway-euro,xebcdicdenmarknorwayeuro,", 00000, L"" }, // IBM EBCDIC (Denmark-Norway-Euro)
+ { NCP_8BIT|NCP_RECODE, 1143, "x-ebcdic-finlandsweden-euro,xebcdicfinlandswedeneuro,", 00000, L"" }, // IBM EBCDIC (Finland-Sweden-Euro)
+ { NCP_8BIT|NCP_RECODE, 1144, "x-ebcdic-italy-euro,xebcdicitalyeuro,", 00000, L"" }, // IBM EBCDIC (Italy-Euro)
+ { NCP_8BIT|NCP_RECODE, 1145, "x-ebcdic-spain-euro,xebcdicspaineuro,", 00000, L"" }, // IBM EBCDIC (Spain-Latin America-Euro)
+ { NCP_8BIT|NCP_RECODE, 1146, "x-ebcdic-uk-euro,xebcdicukeuro,", 00000, L"" }, // IBM EBCDIC (UK-Euro)
+ { NCP_8BIT|NCP_RECODE, 1147, "x-ebcdic-france-euro,xebcdicfranceeuro,", 00000, L"" }, // IBM EBCDIC (France-Euro)
+ { NCP_8BIT|NCP_RECODE, 1148, "x-ebcdic-international-euro,xebcdicinternationaleuro,", 00000, L"" }, // IBM EBCDIC (International-Euro)
+ { NCP_8BIT|NCP_RECODE, 1149, "x-ebcdic-icelandic-euro,xebcdicicelandiceuro,", 00000, L"" }, // IBM EBCDIC (Icelandic-Euro)
+ { NCP_8BIT|NCP_RECODE, 20273, "x-EBCDIC-Germany,xebcdicgermany,", 00000, L"" }, // IBM EBCDIC (Germany)
+ { NCP_8BIT|NCP_RECODE, 20277, "x-EBCDIC-DenmarkNorway,xebcdicdenmarknorway,ebcdiccpdk,ebcdiccpno,", 00000, L"" }, // IBM EBCDIC (Denmark-Norway)
+ { NCP_8BIT|NCP_RECODE, 20278, "x-EBCDIC-FinlandSweden,xebcdicfinlandsweden,ebcdicpfi,ebcdiccpse,", 00000, L"" }, // IBM EBCDIC (Finland-Sweden)
+ { NCP_8BIT|NCP_RECODE, 20280, "x-EBCDIC-Italy,xebcdicitaly,", 00000, L"" }, // IBM EBCDIC (Italy)
+ { NCP_8BIT|NCP_RECODE, 20284, "x-EBCDIC-Spain,xebcdicspain,ebcdiccpes,", 00000, L"" }, // IBM EBCDIC (Spain-Latin America)
+ { NCP_8BIT|NCP_RECODE, 20285, "x-EBCDIC-UK,xebcdicuk,ebcdiccpgb,", 00000, L"" }, // IBM EBCDIC (UK)
+ { NCP_8BIT|NCP_RECODE, 20290, "x-EBCDIC-JapaneseKatakana,xebcdicjapanesekatakana,", 00000, L"" }, // IBM EBCDIC (Japanese Katakana)
+ { NCP_8BIT|NCP_RECODE, 20297, "x-EBCDIC-France,xebcdicfrance,ebcdiccpfr,", 00000, L"" }, // IBM EBCDIC (France)
+ { NCP_8BIT|NCP_RECODE, 20420, "x-EBCDIC-Arabic,xebcdicarabic,ebcdiccpar1,", 00000, L"" }, // IBM EBCDIC (Arabic)
+ { NCP_8BIT|NCP_RECODE, 20423, "x-EBCDIC-Greek,xebcdicgreek,ebcdiccpgr,", 00000, L"" }, // IBM EBCDIC (Greek)
+ { NCP_8BIT|NCP_RECODE, 20424, "x-EBCDIC-Hebrew,xebcdichebrew,ebcdiccphe,", 00000, L"" }, // IBM EBCDIC (Hebrew)
+ { NCP_8BIT|NCP_RECODE, 20833, "x-EBCDIC-KoreanExtended,xebcdickoreanextended,", 00000, L"" }, // IBM EBCDIC (Korean Extended)
+ { NCP_8BIT|NCP_RECODE, 20838, "x-EBCDIC-Thai,xebcdicthai,ibmthai,csibmthai,", 00000, L"" }, // IBM EBCDIC (Thai)
+ { NCP_8BIT|NCP_RECODE, 20871, "x-EBCDIC-Icelandic,xebcdicicelandic,ebcdiccpis,", 00000, L"" }, // IBM EBCDIC (Icelandic)
+ { NCP_8BIT|NCP_RECODE, 20880, "x-EBCDIC-CyrillicRussian,xebcdiccyrillicrussian,ebcdiccyrillic,", 00000, L"" }, // IBM EBCDIC (Cyrillic Russian)
+ { NCP_8BIT|NCP_RECODE, 20905, "x-EBCDIC-Turkish,xebcdicturkish,ebcdiccptr,", 00000, L"" }, // IBM EBCDIC (Turkish)
+ { NCP_8BIT|NCP_RECODE, 20924, "IBM00924,ibm00924,ebcdiclatin9euro,", 00000, L"" }, // IBM EBCDIC (Open System-Euro Latin-1)
+ { NCP_8BIT|NCP_RECODE, 21025, "x-EBCDIC-CyrillicSerbianBulgarian,xebcdiccyrillicserbianbulgarian,", 00000, L"" }, // IBM EBCDIC (Cyrillic Serbian-Bulgarian)
+ { NCP_8BIT|NCP_RECODE, 50930, "x-EBCDIC-JapaneseAndKana,xebcdicjapaneseandkana,", 00000, L"" }, // IBM EBCDIC (Japanese and Japanese Katakana)
+ { NCP_8BIT|NCP_RECODE, 50931, "x-EBCDIC-JapaneseAndUSCanada,xebcdicjapaneseanduscanada,", 00000, L"" }, // IBM EBCDIC (Japanese and US-Canada)
+ { NCP_8BIT|NCP_RECODE, 50933, "x-EBCDIC-KoreanAndKoreanExtended,xebcdickoreanandkoreanextended,", 00000, L"" }, // IBM EBCDIC (Korean and Korean Extended)
+ { NCP_8BIT|NCP_RECODE, 50935, "x-EBCDIC-SimplifiedChinese,xebcdicsimplifiedchinese,", 00000, L"" }, // IBM EBCDIC (Chinese Simplified)
+ { NCP_8BIT|NCP_RECODE, 50937, "x-EBCDIC-TraditionalChinese,xebcdictraditionalchinese,", 00000, L"" }, // IBM EBCDIC (Chinese Traditional)
+ { NCP_8BIT|NCP_RECODE, 50939, "x-EBCDIC-JapaneseAndJapaneseLatin,xebcdicjapaneseandjapaneselatin,", 00000, L"" }, // IBM EBCDIC (Japanese and Japanese-Latin)
+ { NCP_8BIT|NCP_RECODE, 20105, "x-IA5,xia5,", 00000, L"" }, // Western European (IA5)
+ { NCP_8BIT|NCP_RECODE, 20106, "x-IA5-German,xia5german,", 00000, L"" }, // German (IA5)
+ { NCP_8BIT|NCP_RECODE, 20107, "x-IA5-Swedish,xia5swedish,", 00000, L"" }, // Swedish (IA5)
+ { NCP_8BIT|NCP_RECODE, 20108, "x-IA5-Norwegian,xia5norwegian,", 00000, L"" }, // Norwegian (IA5)
+ { NCP_8BIT|NCP_RECODE, 20936, "x-cp20936,xcp20936,", 00000, L"" }, // Chinese Simplified (GB2312)
+ { NCP_8BIT|NCP_RECODE, 52936, "hz-gb-2312,hzgb2312,hz,", 00000, L"" }, // Chinese Simplified (HZ-GB2312) */
+ { NCP_8BIT|NCP_RECODE, 54936, "gb18030,gb18030,", 61072, L"" },
+/*{ NCP_8BIT|NCP_RECODE, 1361, "johab,johab,", 00000, L"" }, // Korean (Johab)
+ { NCP_8BIT|NCP_RECODE, 20932, "euc-jp,,", 00000, L"" }, // Japanese (JIS X 0208-1990 & 0212-1990)
+ { NCP_8BIT|NCP_RECODE, 50220, "iso-2022-jp,iso2022jp,", 00000, L"" }, // Japanese (JIS)
+ { NCP_8BIT|NCP_RECODE, 50221, "csISO2022JP,csiso2022jp,", 00000, L"" }, // Japanese (JIS-Allow 1 byte Kana)
+ { NCP_8BIT|NCP_RECODE, 50222, "_iso-2022-jp$SIO,iso2022jpSIO,", 00000, L"" }, // Japanese (JIS-Allow 1 byte Kana - SO/SI)
+ { NCP_8BIT|NCP_RECODE, 50225, "iso-2022-kr,iso2022kr,csiso2022kr,", 00000, L"" }, // Korean (ISO-2022-KR)
+ { NCP_8BIT|NCP_RECODE, 50227, "x-cp50227,xcp50227,", 00000, L"" }, // Chinese Simplified (ISO-2022)
+ { NCP_8BIT|NCP_RECODE, 50229, "iso-2022-cn,iso2022cn,", 00000, L"" }, // Chinese Traditional (ISO-2022)
+ { NCP_8BIT|NCP_RECODE, 20000, "x-Chinese-CNS,xchinesecns,", 00000, L"" }, // Chinese Traditional (CNS)
+ { NCP_8BIT|NCP_RECODE, 20002, "x-Chinese-Eten,xchineseeten,", 00000, L"" }, // Chinese Traditional (Eten)
+ { NCP_8BIT|NCP_RECODE, 51932, "euc-jp,eucjp,xeuc,xeucjp,", 00000, L"" }, // Japanese (EUC)
+ { NCP_8BIT|NCP_RECODE, 51936, "euc-cn,euccn,xeuccn,", 00000, L"" }, // Chinese Simplified (EUC)
+ { NCP_8BIT|NCP_RECODE, 51949, "euc-kr,euckr,cseuckr,", 00000, L"" }, // Korean (EUC)
+ { NCP_8BIT|NCP_RECODE, 57002, "x-iscii-de,xisciide,", 00000, L"" }, // ISCII Devanagari
+ { NCP_8BIT|NCP_RECODE, 57003, "x-iscii-be,xisciibe,", 00000, L"" }, // ISCII Bengali
+ { NCP_8BIT|NCP_RECODE, 57004, "x-iscii-ta,xisciita,", 00000, L"" }, // ISCII Tamil
+ { NCP_8BIT|NCP_RECODE, 57005, "x-iscii-te,xisciite,", 00000, L"" }, // ISCII Telugu
+ { NCP_8BIT|NCP_RECODE, 57006, "x-iscii-as,xisciias,", 00000, L"" }, // ISCII Assamese
+ { NCP_8BIT|NCP_RECODE, 57007, "x-iscii-or,xisciior,", 00000, L"" }, // ISCII Oriya
+ { NCP_8BIT|NCP_RECODE, 57008, "x-iscii-ka,xisciika,", 00000, L"" }, // ISCII Kannada
+ { NCP_8BIT|NCP_RECODE, 57009, "x-iscii-ma,xisciima,", 00000, L"" }, // ISCII Malayalam
+ { NCP_8BIT|NCP_RECODE, 57010, "x-iscii-gu,xisciigu,", 00000, L"" }, // ISCII Gujarathi
+ { NCP_8BIT|NCP_RECODE, 57011, "x-iscii-pa,xisciipa,", 00000, L"" }, // ISCII Panjabi */
+};
+
+
+extern LPMRULIST mruFind;
+extern LPMRULIST mruReplace;
+
+
+//=============================================================================
+//
+// EditCreate()
+//
+HWND EditCreate(HWND hwndParent)
+{
+
+ HWND hwnd;
+
+ hwnd = CreateWindowEx(
+ WS_EX_CLIENTEDGE,
+ L"Scintilla",
+ NULL,
+ WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS,
+ 0,0,0,0,
+ hwndParent,
+ (HMENU)IDC_EDIT,
+ g_hInstance,
+ NULL);
+
+ SendMessage(hwnd,SCI_SETCODEPAGE,iDefaultCodePage,0);
+ SendMessage(hwnd,SCI_SETEOLMODE,SC_EOL_CRLF,0);
+ SendMessage(hwnd,SCI_SETPASTECONVERTENDINGS,1,0);
+ SendMessage(hwnd,SCI_SETMODEVENTMASK,/*SC_MODEVENTMASKALL*/SC_MOD_INSERTTEXT|SC_MOD_DELETETEXT,0);
+ SendMessage(hwnd,SCI_USEPOPUP,FALSE,0);
+ SendMessage(hwnd,SCI_SETCARETPERIOD,GetCaretBlinkTime(),0);
+ SendMessage(hwnd,SCI_SETSCROLLWIDTH,2048,0);
+ SendMessage(hwnd,SCI_SETSCROLLWIDTHTRACKING,TRUE,0);
+ SendMessage(hwnd,SCI_SETENDATLASTLINE,TRUE,0);
+ SendMessage(hwnd,SCI_SETCARETSTICKY,FALSE,0);
+ SendMessage(hwnd,SCI_SETXCARETPOLICY,CARET_SLOP|CARET_EVEN,50);
+ SendMessage(hwnd,SCI_SETYCARETPOLICY,CARET_EVEN,0);
+ SendMessage(hwnd,SCI_SETBACKSPACEUNINDENTS,FALSE,0);
+ SendMessage(hwnd,SCI_SETMULTIPLESELECTION,FALSE,0);
+ SendMessage(hwnd,SCI_SETADDITIONALSELECTIONTYPING,FALSE,0);
+ SendMessage(hwnd,SCI_SETVIRTUALSPACEOPTIONS,SCVS_NONE,0);
+ SendMessage(hwnd,SCI_SETADDITIONALCARETSBLINK,FALSE,0);
+ SendMessage(hwnd,SCI_SETADDITIONALCARETSVISIBLE,FALSE,0);
+
+ SendMessage(hwnd,SCI_ASSIGNCMDKEY,(SCK_NEXT + (SCMOD_CTRL << 16)),SCI_PARADOWN);
+ SendMessage(hwnd,SCI_ASSIGNCMDKEY,(SCK_PRIOR + (SCMOD_CTRL << 16)),SCI_PARAUP);
+ SendMessage(hwnd,SCI_ASSIGNCMDKEY,(SCK_NEXT + ((SCMOD_CTRL | SCMOD_SHIFT) << 16)),SCI_PARADOWNEXTEND);
+ SendMessage(hwnd,SCI_ASSIGNCMDKEY,(SCK_PRIOR + ((SCMOD_CTRL | SCMOD_SHIFT) << 16)),SCI_PARAUPEXTEND);
+ SendMessage(hwnd,SCI_ASSIGNCMDKEY,(SCK_HOME + (0 << 16)),SCI_VCHOMEWRAP);
+ SendMessage(hwnd,SCI_ASSIGNCMDKEY,(SCK_END + (0 << 16)),SCI_LINEENDWRAP);
+ SendMessage(hwnd,SCI_ASSIGNCMDKEY,(SCK_HOME + (SCMOD_SHIFT << 16)),SCI_VCHOMEWRAPEXTEND);
+ SendMessage(hwnd,SCI_ASSIGNCMDKEY,(SCK_END + (SCMOD_SHIFT << 16)),SCI_LINEENDWRAPEXTEND);
+
+ // Init default values for printing
+ EditPrintInit();
+
+ //SciInitThemes(hwnd);
+
+ return(hwnd);
+
+}
+
+
+//=============================================================================
+//
+// EditSetNewText()
+//
+extern BOOL bFreezeAppTitle;
+extern FILEVARS fvCurFile;
+
+void EditSetNewText(HWND hwnd,char* lpstrText,DWORD cbText)
+{
+ bFreezeAppTitle = TRUE;
+
+ if (SendMessage(hwnd,SCI_GETREADONLY,0,0))
+ SendMessage(hwnd,SCI_SETREADONLY,FALSE,0);
+
+ SendMessage(hwnd,SCI_CANCEL,0,0);
+ SendMessage(hwnd,SCI_SETUNDOCOLLECTION,0,0);
+ SendMessage(hwnd,SCI_EMPTYUNDOBUFFER,0,0);
+ SendMessage(hwnd,SCI_CLEARALL,0,0);
+ SendMessage(hwnd,SCI_MARKERDELETEALL,(WPARAM)-1,0);
+ SendMessage(hwnd,SCI_SETSCROLLWIDTH,2048,0);
+ SendMessage(hwnd,SCI_SETXOFFSET,0,0);
+
+ FileVars_Apply(hwnd,&fvCurFile);
+
+ if (cbText > 0)
+ SendMessage(hwnd,SCI_ADDTEXT,cbText,(LPARAM)lpstrText);
+
+ SendMessage(hwnd,SCI_SETUNDOCOLLECTION,1,0);
+ SendMessage(hwnd,EM_EMPTYUNDOBUFFER,0,0);
+ SendMessage(hwnd,SCI_SETSAVEPOINT,0,0);
+ SendMessage(hwnd,SCI_GOTOPOS,0,0);
+ SendMessage(hwnd,SCI_CHOOSECARETX,0,0);
+
+ bFreezeAppTitle = FALSE;
+}
+
+
+//=============================================================================
+//
+// EditConvertText()
+//
+BOOL EditConvertText(HWND hwnd,UINT cpSource,UINT cpDest,BOOL bSetSavePoint)
+{
+ struct TextRange tr = { { 0, -1 }, NULL };
+ int length, cbText, cbwText;
+ char *pchText;
+ WCHAR *pwchText;
+
+ if (cpSource == cpDest)
+ return(TRUE);
+
+ length = SendMessage(hwnd,SCI_GETLENGTH,0,0);
+
+ if (length == 0) {
+ SendMessage(hwnd,SCI_CANCEL,0,0);
+ SendMessage(hwnd,SCI_SETUNDOCOLLECTION,0,0);
+ SendMessage(hwnd,SCI_EMPTYUNDOBUFFER,0,0);
+ SendMessage(hwnd,SCI_CLEARALL,0,0);
+ SendMessage(hwnd,SCI_MARKERDELETEALL,(WPARAM)-1,0);
+ SendMessage(hwnd,SCI_SETCODEPAGE,cpDest,0);
+ SendMessage(hwnd,SCI_SETUNDOCOLLECTION,1,0);
+ SendMessage(hwnd,EM_EMPTYUNDOBUFFER,0,0);
+ SendMessage(hwnd,SCI_GOTOPOS,0,0);
+ SendMessage(hwnd,SCI_CHOOSECARETX,0,0);
+
+ if (bSetSavePoint)
+ SendMessage(hwnd,SCI_SETSAVEPOINT,0,0);
+ }
+
+ else {
+ pchText = GlobalAlloc(GPTR,length*5+2);
+
+ tr.lpstrText = pchText;
+ SendMessage(hwnd,SCI_GETTEXTRANGE,0,(LPARAM)&tr);
+
+ pwchText = GlobalAlloc(GPTR,length*3+2);
+ cbwText = MultiByteToWideChar(cpSource,0,pchText,length,pwchText,length*3+2);
+ cbText = WideCharToMultiByte(cpDest,0,pwchText,cbwText,pchText,length*5+2,NULL,NULL);
+
+ SendMessage(hwnd,SCI_CANCEL,0,0);
+ SendMessage(hwnd,SCI_SETUNDOCOLLECTION,0,0);
+ SendMessage(hwnd,SCI_EMPTYUNDOBUFFER,0,0);
+ SendMessage(hwnd,SCI_CLEARALL,0,0);
+ SendMessage(hwnd,SCI_MARKERDELETEALL,(WPARAM)-1,0);
+ SendMessage(hwnd,SCI_SETCODEPAGE,cpDest,0);
+ SendMessage(hwnd,SCI_ADDTEXT,cbText,(LPARAM)pchText);
+ SendMessage(hwnd,SCI_EMPTYUNDOBUFFER,0,0);
+ SendMessage(hwnd,SCI_SETUNDOCOLLECTION,1,0);
+ SendMessage(hwnd,SCI_GOTOPOS,0,0);
+ SendMessage(hwnd,SCI_CHOOSECARETX,0,0);
+
+ GlobalFree(pchText);
+ GlobalFree(pwchText);
+ }
+ return(TRUE);
+}
+
+
+//=============================================================================
+//
+// EditSetNewEncoding()
+//
+BOOL EditSetNewEncoding(HWND hwnd,int iCurrentEncoding,int iNewEncoding,BOOL bNoUI,BOOL bSetSavePoint) {
+
+ if (iCurrentEncoding != iNewEncoding) {
+
+ if ((iCurrentEncoding == CPI_DEFAULT && iNewEncoding == CPI_DEFAULT) ||
+ (iCurrentEncoding != CPI_DEFAULT && iNewEncoding != CPI_DEFAULT))
+ return(TRUE);
+
+ if (SendMessage(hwnd,SCI_GETLENGTH,0,0) == 0) {
+
+ BOOL bIsEmptyUndoHistory =
+ (SendMessage(hwnd,SCI_CANUNDO,0,0) == 0 && SendMessage(hwnd,SCI_CANREDO,0,0) == 0);
+
+ if ((iCurrentEncoding == CPI_DEFAULT || iNewEncoding == CPI_DEFAULT) &&
+ (bNoUI || bIsEmptyUndoHistory || InfoBox(MBYESNO,L"MsgConv2",IDS_ASK_ENCODING2) == IDYES)) {
+
+ EditConvertText(hwnd,
+ (mEncoding[iCurrentEncoding].uFlags & NCP_DEFAULT) ? iDefaultCodePage : SC_CP_UTF8,
+ (mEncoding[iNewEncoding].uFlags & NCP_DEFAULT) ? iDefaultCodePage : SC_CP_UTF8,
+ bSetSavePoint);
+
+ return(TRUE);
+ }
+
+ else
+ return(FALSE);
+ }
+
+ else if ((iCurrentEncoding == CPI_DEFAULT || iNewEncoding == CPI_DEFAULT) &&
+ (bNoUI || InfoBox(MBYESNO,L"MsgConv1",IDS_ASK_ENCODING) == IDYES)) {
+
+ BeginWaitCursor();
+
+ EditConvertText(hwnd,
+ (mEncoding[iCurrentEncoding].uFlags & NCP_DEFAULT) ? iDefaultCodePage : SC_CP_UTF8,
+ (mEncoding[iNewEncoding].uFlags & NCP_DEFAULT) ? iDefaultCodePage : SC_CP_UTF8,
+ FALSE);
+
+ EndWaitCursor();
+
+ return(TRUE);
+ }
+
+ else
+ return(FALSE);
+ }
+
+ else
+ return(FALSE);
+}
+
+
+//=============================================================================
+//
+// EditGetClipboardText()
+//
+char* EditGetClipboardText(HWND hwnd)
+{
+ HANDLE hmem;
+ WCHAR *pwch;
+ char *pmch;
+ char *ptmp;
+ int wlen, mlen, mlen2;
+ int codepage;
+ int eolmode;
+
+ if (!IsClipboardFormatAvailable(CF_UNICODETEXT) || !OpenClipboard(GetParent(hwnd)))
+ return(NULL);
+
+ hmem = GetClipboardData(CF_UNICODETEXT);
+ pwch = GlobalLock(hmem);
+
+ wlen = lstrlenW(pwch);
+
+ codepage = SendMessage(hwnd,SCI_GETCODEPAGE,0,0);
+ eolmode = SendMessage(hwnd,SCI_GETEOLMODE,0,0);
+
+ mlen = WideCharToMultiByte(codepage,0,pwch,wlen + 1,NULL,0,0,0) - 1;
+ pmch = LocalAlloc(LPTR,mlen + 1);
+ if (pmch)
+ WideCharToMultiByte(codepage,0,pwch,wlen + 1,pmch,mlen + 1,NULL,NULL);
+
+ ptmp = LocalAlloc(LPTR,mlen * 2 + 1);
+ if (ptmp) {
+ char *s = pmch;
+ char *d = ptmp;
+ int i;
+
+ for (i = 0; (i < mlen) && (*s != 0); i++) {
+ if (*s == '\n' || *s == '\r') {
+ if (eolmode == SC_EOL_CR) {
+ *d++ = '\r';
+ } else if (eolmode == SC_EOL_LF) {
+ *d++ = '\n';
+ } else { // eolmode == SC_EOL_CRLF
+ *d++ = '\r';
+ *d++ = '\n';
+ }
+ if ((*s == '\r') && (i+1 < mlen) && (*(s+1) == '\n')) {
+ i++;
+ s++;
+ }
+ s++;
+ } else {
+ *d++ = *s++;
+ }
+ }
+ *d++ = 0;
+ mlen2 = (d - ptmp) - 1;
+
+ LocalFree(pmch);
+ pmch = LocalAlloc(LPTR,mlen2 + 1);
+ lstrcpyA(pmch,ptmp);
+ LocalFree(ptmp);
+ }
+
+ GlobalUnlock(hmem);
+ CloseClipboard();
+
+ return(pmch);
+}
+
+
+//=============================================================================
+//
+// EditCopyAppend()
+//
+BOOL EditCopyAppend(HWND hwnd)
+{
+ HANDLE hOld;
+ WCHAR *pszOld;
+
+ HANDLE hNew;
+ WCHAR *pszNew;
+
+ char *pszText;
+ int cchTextW;
+ WCHAR *pszTextW;
+
+ WCHAR *pszSep = L"\r\n\r\n";
+
+ UINT uCodePage;
+
+ int iCurPos;
+ int iAnchorPos;
+
+ if (!IsClipboardFormatAvailable(CF_UNICODETEXT)) {
+ SendMessage(hwnd,SCI_COPY,0,0);
+ return(TRUE);
+ }
+
+ iCurPos = SendMessage(hwnd,SCI_GETCURRENTPOS,0,0);
+ iAnchorPos = SendMessage(hwnd,SCI_GETANCHOR,0,0);
+
+ if (iCurPos != iAnchorPos) {
+
+ if (SC_SEL_RECTANGLE == SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) {
+ MsgBox(MBINFO,IDS_SELRECT);
+ return(FALSE);
+ }
+
+ else {
+ int iSelCount =
+ SendMessage(hwnd,SCI_GETSELECTIONEND,0,0) -
+ SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0);
+
+ pszText = LocalAlloc(LPTR,iSelCount + 1);
+ SendMessage(hwnd,SCI_GETSELTEXT,0,(LPARAM)pszText);
+ }
+ }
+
+ else {
+ int cchText = SendMessage(hwnd,SCI_GETLENGTH,0,0);
+ pszText = LocalAlloc(LPTR,cchText + 1);
+ SendMessage(hwnd,SCI_GETTEXT,LocalSize(pszText),(LPARAM)pszText);
+ }
+
+ uCodePage = (SendMessage(hwnd,SCI_GETCODEPAGE,0,0) == SC_CP_UTF8) ? CP_UTF8 : CP_ACP;
+
+ cchTextW = MultiByteToWideChar(uCodePage,0,pszText,-1,NULL,0);
+ if (cchTextW > 0) {
+ pszTextW = LocalAlloc(LPTR,sizeof(WCHAR)*(lstrlen(pszSep) + cchTextW + 1));
+ lstrcpy(pszTextW,pszSep);
+ MultiByteToWideChar(uCodePage,0,pszText,-1,StrEnd(pszTextW),LocalSize(pszTextW)/sizeof(WCHAR));
+ }
+ else {
+ pszTextW = L"";
+ }
+
+ LocalFree(pszText);
+
+ if (!OpenClipboard(GetParent(hwnd))) {
+ LocalFree(pszTextW);
+ return(FALSE);
+ }
+
+ hOld = GetClipboardData(CF_UNICODETEXT);
+ pszOld = GlobalLock(hOld);
+
+ hNew = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,
+ sizeof(WCHAR) * (lstrlen(pszOld) + lstrlen(pszTextW) + 1));
+ pszNew = GlobalLock(hNew);
+
+ lstrcpy(pszNew,pszOld);
+ lstrcat(pszNew,pszTextW);
+
+ GlobalUnlock(hNew);
+ GlobalUnlock(hOld);
+
+ EmptyClipboard();
+ SetClipboardData(CF_UNICODETEXT,hNew);
+ CloseClipboard();
+
+ return(TRUE);
+}
+
+
+//=============================================================================
+//
+// EditDetectEOLMode() - moved here to handle Unicode files correctly
+//
+int EditDetectEOLMode(HWND hwnd,char* lpData,DWORD cbData)
+{
+ int iEOLMode = iLineEndings[iDefaultEOLMode];
+ char *cp = (char*)lpData;
+
+ if (!cp)
+ return (iEOLMode);
+
+ while (*cp && (*cp != '\x0D' && *cp != '\x0A')) cp++;
+
+ if (*cp == '\x0D' && *(cp+1) == '\x0A')
+ iEOLMode = SC_EOL_CRLF;
+ else if (*cp == '\x0D' && *(cp+1) != '\x0A')
+ iEOLMode = SC_EOL_CR;
+ else if (*cp == '\x0A')
+ iEOLMode = SC_EOL_LF;
+
+ return (iEOLMode);
+}
+
+
+
+//=============================================================================
+//
+// Encoding Helper Functions
+//
+void Encoding_InitDefaults() {
+ wsprintf(wchANSI,L" (%i)",GetACP());
+ mEncoding[CPI_OEM].uCodePage = GetOEMCP();
+ wsprintf(wchOEM,L" (%i)",mEncoding[CPI_OEM].uCodePage);
+}
+
+
+int Encoding_MapIniSetting(BOOL bLoad,int iSetting) {
+ if (bLoad) {
+ switch (iSetting) {
+ case 0: return CPI_DEFAULT;
+ case 1: return CPI_UNICODEBOM;
+ case 2: return CPI_UNICODEBEBOM;
+ case 3: return CPI_UTF8;
+ case 4: return CPI_UTF8SIGN;
+ case 5: return CPI_OEM;
+ case 6: return CPI_UNICODE;
+ case 7: return CPI_UNICODEBE;
+ case 8: return CPI_UTF7;
+ default: {
+ int i;
+ for (i = CPI_UTF7 + 1; i < COUNTOF(mEncoding); i++) {
+ if (mEncoding[i].uCodePage == iSetting && Encoding_IsValid(i))
+ return(i);
+ }
+ return CPI_DEFAULT;
+ }
+ }
+ }
+ else {
+ switch (iSetting) {
+ case CPI_DEFAULT: return 0;
+ case CPI_UNICODEBOM: return 1;
+ case CPI_UNICODEBEBOM: return 2;
+ case CPI_UTF8: return 3;
+ case CPI_UTF8SIGN: return 4;
+ case CPI_OEM: return 5;
+ case CPI_UNICODE: return 6;
+ case CPI_UNICODEBE: return 7;
+ case CPI_UTF7: return 8;
+ default: return(mEncoding[iSetting].uCodePage);
+ }
+ }
+}
+
+
+void Encoding_GetLabel(int iEncoding) {
+ if (mEncoding[iEncoding].wchLabel[0] == 0) {
+ WCHAR *pwsz;
+ WCHAR wch[256] = L"";
+ GetString(mEncoding[iEncoding].idsName,wch,COUNTOF(wch));
+ if (pwsz = StrChr(wch,L';')) {
+ if (pwsz = StrChr(CharNext(pwsz),L';')) {
+ pwsz = CharNext(pwsz);
+ }
+ }
+ if (!pwsz)
+ pwsz = wch;
+ StrCpyN(mEncoding[iEncoding].wchLabel,pwsz,COUNTOF(mEncoding[iEncoding].wchLabel));
+ }
+}
+
+
+int Encoding_MatchW(LPCWSTR pwszTest) {
+ char tchTest[256];
+ WideCharToMultiByte(CP_ACP,0,pwszTest,-1,tchTest,COUNTOF(tchTest),NULL,NULL);
+ return(Encoding_MatchA(tchTest));
+}
+
+
+int Encoding_MatchA(char *pchTest) {
+ int i;
+ char chTest[256];
+ char *pchSrc = pchTest;
+ char *pchDst = chTest;
+ *pchDst++ = ',';
+ while (*pchSrc) {
+ if (IsCharAlphaNumericA(*pchSrc))
+ *pchDst++ = *CharLowerA(pchSrc);
+ pchSrc++;
+ }
+ *pchDst++ = ',';
+ *pchDst = 0;
+ for (i = 0; i < COUNTOF(mEncoding); i++) {
+ if (StrStrIA(mEncoding[i].pszParseNames,chTest)) {
+ CPINFO cpi;
+ if ((mEncoding[i].uFlags & NCP_INTERNAL) ||
+ IsValidCodePage(mEncoding[i].uCodePage) &&
+ GetCPInfo(mEncoding[i].uCodePage,&cpi))
+ return(i);
+ else
+ return(-1);
+ }
+ }
+ return(-1);
+}
+
+
+BOOL Encoding_IsValid(int iTestEncoding) {
+ CPINFO cpi;
+ if (iTestEncoding >= 0 &&
+ iTestEncoding < COUNTOF(mEncoding)) {
+ if ((mEncoding[iTestEncoding].uFlags & NCP_INTERNAL) ||
+ IsValidCodePage(mEncoding[iTestEncoding].uCodePage) &&
+ GetCPInfo(mEncoding[iTestEncoding].uCodePage,&cpi)) {
+ return(TRUE);
+ }
+ }
+ return(FALSE);
+}
+
+
+typedef struct _ee {
+ int id;
+ WCHAR wch[256];
+} ENCODINGENTRY, *PENCODINGENTRY;
+
+int CmpEncoding(const void *s1, const void *s2) {
+ return StrCmp(((PENCODINGENTRY)s1)->wch,((PENCODINGENTRY)s2)->wch);
+}
+
+void Encoding_AddToListView(HWND hwnd,int idSel,BOOL bRecodeOnly)
+{
+ int i;
+ int iSelItem = -1;
+ LVITEM lvi;
+ WCHAR wchBuf[256];
+
+ PENCODINGENTRY pEE = LocalAlloc(LPTR,COUNTOF(mEncoding) * sizeof(ENCODINGENTRY));
+ for (i = 0; i < COUNTOF(mEncoding); i++) {
+ pEE[i].id = i;
+ GetString(mEncoding[i].idsName,pEE[i].wch,COUNTOF(pEE[i].wch));
+ }
+ qsort(pEE,COUNTOF(mEncoding),sizeof(ENCODINGENTRY),CmpEncoding);
+
+ ZeroMemory(&lvi,sizeof(LVITEM));
+ lvi.mask = LVIF_PARAM | LVIF_TEXT | LVIF_IMAGE;
+ lvi.pszText = wchBuf;
+
+ for (i = 0; i < COUNTOF(mEncoding); i++) {
+
+ int id = pEE[i].id;
+ if (!bRecodeOnly || (mEncoding[id].uFlags & NCP_RECODE)) {
+
+ CPINFO cpi;
+ WCHAR *pwsz;
+
+ lvi.iItem = ListView_GetItemCount(hwnd);
+
+ if (pwsz = StrChr(pEE[i].wch,L';')) {
+ StrCpyN(wchBuf,CharNext(pwsz),COUNTOF(wchBuf));
+ if (pwsz = StrChr(wchBuf,L';'))
+ *pwsz = 0;
+ }
+ else
+ StrCpyN(wchBuf,pEE[i].wch,COUNTOF(wchBuf));
+
+ if (id == CPI_DEFAULT)
+ StrCatN(wchBuf,wchANSI,COUNTOF(wchBuf));
+ else if (id == CPI_OEM)
+ StrCatN(wchBuf,wchOEM,COUNTOF(wchBuf));
+
+ if ((mEncoding[id].uFlags & NCP_INTERNAL) ||
+ (IsValidCodePage(mEncoding[id].uCodePage) &&
+ GetCPInfo(mEncoding[id].uCodePage,&cpi)))
+ lvi.iImage = 0;
+ else
+ lvi.iImage = 1;
+
+ lvi.lParam = (LPARAM)id;
+ ListView_InsertItem(hwnd,&lvi);
+
+ if (idSel == id)
+ iSelItem = lvi.iItem;
+ }
+ }
+
+ LocalFree(pEE);
+
+ if (iSelItem != -1) {
+ ListView_SetItemState(hwnd,iSelItem,LVIS_SELECTED|LVIS_FOCUSED,LVIS_SELECTED|LVIS_FOCUSED);
+ ListView_EnsureVisible(hwnd,iSelItem,FALSE);
+ }
+ else {
+ ListView_SetItemState(hwnd,0,LVIS_FOCUSED,LVIS_FOCUSED);
+ ListView_EnsureVisible(hwnd,0,FALSE);
+ }
+}
+
+
+BOOL Encoding_GetFromListView(HWND hwnd,int *pidEncoding)
+{
+ LVITEM lvi;
+
+ lvi.iItem = ListView_GetNextItem(hwnd,-1,LVNI_ALL | LVNI_SELECTED);
+ lvi.iSubItem = 0;
+ lvi.mask = LVIF_PARAM;
+
+ if (ListView_GetItem(hwnd,&lvi)) {
+ if (Encoding_IsValid(lvi.lParam)) {
+ *pidEncoding = lvi.lParam;
+ return (TRUE);
+ }
+ else
+ MsgBox(MBINFO,IDS_ERR_ENCODINGNA);
+ }
+ return(FALSE);
+}
+
+
+void Encoding_AddToComboboxEx(HWND hwnd,int idSel,BOOL bRecodeOnly)
+{
+ int i;
+ int iSelItem = -1;
+ COMBOBOXEXITEM cbei;
+ WCHAR wchBuf[256];
+
+ PENCODINGENTRY pEE = LocalAlloc(LPTR,COUNTOF(mEncoding) * sizeof(ENCODINGENTRY));
+ for (i = 0; i < COUNTOF(mEncoding); i++) {
+ pEE[i].id = i;
+ GetString(mEncoding[i].idsName,pEE[i].wch,COUNTOF(pEE[i].wch));
+ }
+ qsort(pEE,COUNTOF(mEncoding),sizeof(ENCODINGENTRY),CmpEncoding);
+
+ ZeroMemory(&cbei,sizeof(COMBOBOXEXITEM));
+ cbei.mask = CBEIF_TEXT | CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBEIF_LPARAM;
+ cbei.pszText = wchBuf;
+ cbei.cchTextMax = COUNTOF(wchBuf);
+ cbei.iImage = 0;
+ cbei.iSelectedImage = 0;
+
+ for (i = 0; i < COUNTOF(mEncoding); i++) {
+
+ int id = pEE[i].id;
+ if (!bRecodeOnly || (mEncoding[id].uFlags & NCP_RECODE)) {
+
+ CPINFO cpi;
+ WCHAR *pwsz;
+
+ cbei.iItem = SendMessage(hwnd,CB_GETCOUNT,0,0);
+
+ if (pwsz = StrChr(pEE[i].wch,L';')) {
+ StrCpyN(wchBuf,CharNext(pwsz),COUNTOF(wchBuf));
+ if (pwsz = StrChr(wchBuf,L';'))
+ *pwsz = 0;
+ }
+ else
+ StrCpyN(wchBuf,pEE[i].wch,COUNTOF(wchBuf));
+
+ if (id == CPI_DEFAULT)
+ StrCatN(wchBuf,wchANSI,COUNTOF(wchBuf));
+ else if (id == CPI_OEM)
+ StrCatN(wchBuf,wchOEM,COUNTOF(wchBuf));
+
+ if ((mEncoding[id].uFlags & NCP_INTERNAL) ||
+ (IsValidCodePage(mEncoding[id].uCodePage) &&
+ GetCPInfo(mEncoding[id].uCodePage,&cpi)))
+ cbei.iImage = 0;
+ else
+ cbei.iImage = 1;
+
+ cbei.lParam = (LPARAM)id;
+ SendMessage(hwnd,CBEM_INSERTITEM,0,(LPARAM)&cbei);
+
+ if (idSel == id)
+ iSelItem = cbei.iItem;
+ }
+ }
+
+ LocalFree(pEE);
+
+ if (iSelItem != -1)
+ SendMessage(hwnd,CB_SETCURSEL,(WPARAM)iSelItem,0);
+}
+
+
+BOOL Encoding_GetFromComboboxEx(HWND hwnd,int *pidEncoding)
+{
+ COMBOBOXEXITEM cbei;
+
+ cbei.iItem = SendMessage(hwnd,CB_GETCURSEL,0,0);
+ cbei.mask = CBEIF_LPARAM;
+
+ if (SendMessage(hwnd,CBEM_GETITEM,0,(LPARAM)&cbei)) {
+ if (Encoding_IsValid(cbei.lParam)) {
+ *pidEncoding = cbei.lParam;
+ return (TRUE);
+ }
+ else
+ MsgBox(MBINFO,IDS_ERR_ENCODINGNA);
+ }
+ return(FALSE);
+}
+
+
+BOOL IsUnicode(const char* pBuffer,int cb,LPBOOL lpbBOM,LPBOOL lpbReverse)
+{
+ int i = 0xFFFF;
+
+ BOOL bIsTextUnicode;
+
+ BOOL bHasBOM;
+ BOOL bHasRBOM;
+
+ if (!pBuffer || cb < 2)
+ return FALSE;
+
+ if (!bSkipUnicodeDetection)
+ bIsTextUnicode = IsTextUnicode(pBuffer,cb,&i);
+ else
+ bIsTextUnicode = FALSE;
+
+ bHasBOM = (*pBuffer == '\xFF' && *(pBuffer+1) == '\xFE');
+ bHasRBOM = (*pBuffer == '\xFE' && *(pBuffer+1) == '\xFF');
+
+ /*{
+ char szBuf[512];
+ wsprintfA(szBuf,
+ "IS_TEXT_UNICODE_ASCII16\t\t\t%s\n"\
+ "IS_TEXT_UNICODE_REVERSE_ASCII16\t\t%s\n"\
+ "IS_TEXT_UNICODE_STATISTICS\t\t%s\n"\
+ "IS_TEXT_UNICODE_REVERSE_STATISTICS\t%s\n"\
+ "IS_TEXT_UNICODE_CONTROLS\t\t%s\n"\
+ "IS_TEXT_UNICODE_REVERSE_CONTROLS\t%s\n"\
+ "IS_TEXT_UNICODE_SIGNATURE\t\t%s\n"\
+ "IS_TEXT_UNICODE_REVERSE_SIGNATURE\t%s\n"\
+ "IS_TEXT_UNICODE_ILLEGAL_CHARS\t\t%s\n"\
+ "IS_TEXT_UNICODE_ODD_LENGTH\t\t%s\n"\
+ "IS_TEXT_UNICODE_DBCS_LEADBYTE\t\t%s\n"\
+ "IS_TEXT_UNICODE_NULL_BYTES\t\t%s\n\n"\
+ "IsTextUnicode()\t\t\t\t%i\n\n"\
+ "HasBOM\t\t\t\t\t%i\n"\
+ "HasRBOM\t\t\t\t\t%i",
+ i & IS_TEXT_UNICODE_ASCII16 ? "1" :"-",
+ i & IS_TEXT_UNICODE_REVERSE_ASCII16 ? "1" :"-",
+ i & IS_TEXT_UNICODE_STATISTICS ? "1" :"-",
+ i & IS_TEXT_UNICODE_REVERSE_STATISTICS ? "1" :"-",
+ i & IS_TEXT_UNICODE_CONTROLS ? "1" :"-",
+ i & IS_TEXT_UNICODE_REVERSE_CONTROLS ? "1" :"-",
+ i & IS_TEXT_UNICODE_SIGNATURE ? "1" :"-",
+ i & IS_TEXT_UNICODE_REVERSE_SIGNATURE ? "1" :"-",
+ i & IS_TEXT_UNICODE_ILLEGAL_CHARS ? "1" :"-",
+ i & IS_TEXT_UNICODE_ODD_LENGTH ? "1" :"-",
+ i & IS_TEXT_UNICODE_DBCS_LEADBYTE ? "1" :"-",
+ i & IS_TEXT_UNICODE_NULL_BYTES ? "1" :"-",
+ bIsTextUnicode,bHasBOM,bHasRBOM);
+ MessageBoxA(NULL,szBuf,"IsTextUnicode()",0);
+ }*/
+
+ if (i == 0xFFFF) // i doesn't seem to have been modified ...
+ i = 0;
+
+ if (bIsTextUnicode || bHasBOM || bHasRBOM ||
+ ((i & (IS_TEXT_UNICODE_UNICODE_MASK | IS_TEXT_UNICODE_REVERSE_MASK)) &&
+ !((i & IS_TEXT_UNICODE_UNICODE_MASK) && (i & IS_TEXT_UNICODE_REVERSE_MASK)) &&
+ !(i & IS_TEXT_UNICODE_ODD_LENGTH) &&
+ !(i & IS_TEXT_UNICODE_ILLEGAL_CHARS && !(i & IS_TEXT_UNICODE_REVERSE_SIGNATURE)) &&
+ !((i & IS_TEXT_UNICODE_REVERSE_MASK) == IS_TEXT_UNICODE_REVERSE_STATISTICS))) {
+
+ if (lpbBOM)
+ *lpbBOM = (bHasBOM || bHasRBOM ||
+ (i & (IS_TEXT_UNICODE_SIGNATURE | IS_TEXT_UNICODE_REVERSE_SIGNATURE)))
+ ? TRUE : FALSE;
+
+ if (lpbReverse)
+ *lpbReverse = (bHasRBOM || (i & IS_TEXT_UNICODE_REVERSE_MASK)) ? TRUE : FALSE;
+
+ return TRUE;
+ }
+
+ else
+
+ return FALSE;
+}
+
+
+BOOL IsUTF8(const char* pTest,int nLength)
+{
+ static int byte_class_table[256] = {
+ /* 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F */
+ /* 00 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ /* 10 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ /* 20 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ /* 30 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ /* 40 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ /* 50 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ /* 60 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ /* 70 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ /* 80 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ /* 90 */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ /* A0 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ /* B0 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ /* C0 */ 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+ /* D0 */ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+ /* E0 */ 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 7, 7,
+ /* F0 */ 9,10,10,10,11, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
+ /* 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F */ };
+
+ /* state table */
+ typedef enum {
+ kSTART = 0,kA,kB,kC,kD,kE,kF,kG,kERROR,kNumOfStates } utf8_state;
+
+ static utf8_state state_table[] = {
+ /* kSTART, kA, kB, kC, kD, kE, kF, kG, kERROR */
+ /* 0x00-0x7F: 0 */ kSTART, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR,
+ /* 0x80-0x8F: 1 */ kERROR, kSTART, kA, kERROR, kA, kB, kERROR, kB, kERROR,
+ /* 0x90-0x9f: 2 */ kERROR, kSTART, kA, kERROR, kA, kB, kB, kERROR, kERROR,
+ /* 0xa0-0xbf: 3 */ kERROR, kSTART, kA, kA, kERROR, kB, kB, kERROR, kERROR,
+ /* 0xc0-0xc1, 0xf5-0xff: 4 */ kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR,
+ /* 0xc2-0xdf: 5 */ kA, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR,
+ /* 0xe0: 6 */ kC, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR,
+ /* 0xe1-0xec, 0xee-0xef: 7 */ kB, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR,
+ /* 0xed: 8 */ kD, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR,
+ /* 0xf0: 9 */ kF, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR,
+ /* 0xf1-0xf3: 10 */ kE, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR,
+ /* 0xf4: 11 */ kG, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR };
+
+ #define BYTE_CLASS(b) (byte_class_table[(unsigned char)b])
+ #define NEXT_STATE(b,cur) (state_table[(BYTE_CLASS(b) * kNumOfStates) + (cur)])
+
+ utf8_state current = kSTART;
+ int i;
+
+ const char* pt = pTest;
+ int len = nLength;
+
+ for(i = 0; i < len ; i++, pt++) {
+
+ current = NEXT_STATE(*pt,current);
+ if (kERROR == current)
+ break;
+ }
+
+ return (current == kSTART) ? TRUE : FALSE;
+ }
+
+
+BOOL IsUTF7(const char* pTest,int nLength)
+{
+ int i;
+ const char *pt = pTest;
+
+ for (i = 0; i < nLength; i++) {
+ if (*pt & 0x80 || !*pt)
+ return FALSE;
+ pt++;
+ }
+
+ return TRUE;
+}
+
+
+#define IsUTF8Signature(p) \
+ ((*(p+0) == '\xEF' && *(p+1) == '\xBB' && *(p+2) == '\xBF'))
+
+
+#define UTF8StringStart(p) \
+ (IsUTF8Signature(p)) ? (p+3) : (p)
+
+
+/* byte length of UTF-8 sequence based on value of first byte.
+ for UTF-16 (21-bit space), max. code length is 4, so we only need to look
+ at 4 upper bits.
+ */
+static const INT utf8_lengths[16]=
+{
+ 1,1,1,1,1,1,1,1, /* 0000 to 0111 : 1 byte (plain ASCII) */
+ 0,0,0,0, /* 1000 to 1011 : not valid */
+ 2,2, /* 1100, 1101 : 2 bytes */
+ 3, /* 1110 : 3 bytes */
+ 4 /* 1111 :4 bytes */
+};
+
+/*++
+Function :
+ UTF8_mbslen_bytes [INTERNAL]
+
+ Calculates the byte size of a NULL-terminated UTF-8 string.
+
+Parameters :
+ char *utf8_string : string to examine
+
+Return value :
+ size (in bytes) of a NULL-terminated UTF-8 string.
+ -1 if invalid NULL-terminated UTF-8 string
+--*/
+static INT UTF8_mbslen_bytes(LPCSTR utf8_string)
+{
+ INT length=0;
+ INT code_size;
+ BYTE byte;
+
+ while(*utf8_string)
+ {
+ byte=(BYTE)*utf8_string;
+
+ if( (byte <= 0xF7) && (0 != (code_size = utf8_lengths[ byte >> 4 ])))
+ {
+ length+=code_size;
+ utf8_string+=code_size;
+ }
+ else
+ {
+ /* we got an invalid byte value but need to count it,
+ it will be later ignored during the string conversion */
+ //WARN("invalid first byte value 0x%02X in UTF-8 sequence!\n",byte);
+ length++;
+ utf8_string++;
+ }
+ }
+ length++; /* include NULL terminator */
+ return length;
+}
+
+/*++
+Function :
+ UTF8_mbslen [INTERNAL]
+
+ Calculates the character size of a NULL-terminated UTF-8 string.
+
+Parameters :
+ char *utf8_string : string to examine
+ int byte_length : byte size of string
+
+Return value :
+ size (in characters) of a UTF-8 string.
+ -1 if invalid UTF-8 string
+--*/
+static INT UTF8_mbslen(LPCSTR source, INT byte_length)
+{
+ INT wchar_length=0;
+ INT code_size;
+ BYTE byte;
+
+ while(byte_length > 0)
+ {
+ byte=(BYTE)*source;
+
+ /* UTF-16 can't encode 5-byte and 6-byte sequences, so maximum value
+ for first byte is 11110111. Use lookup table to determine sequence
+ length based on upper 4 bits of first byte */
+ if ((byte <= 0xF7) && (0 != (code_size=utf8_lengths[ byte >> 4])))
+ {
+ /* 1 sequence == 1 character */
+ wchar_length++;
+
+ if(code_size==4)
+ wchar_length++;
+
+ source+=code_size; /* increment pointer */
+ byte_length-=code_size; /* decrement counter*/
+ }
+ else
+ {
+ /*
+ unlike UTF8_mbslen_bytes, we ignore the invalid characters.
+ we only report the number of valid characters we have encountered
+ to match the Windows behavior.
+ */
+ //WARN("invalid byte 0x%02X in UTF-8 sequence, skipping it!\n",
+ // byte);
+ source++;
+ byte_length--;
+ }
+ }
+ return wchar_length;
+}
+
+
+//=============================================================================
+//
+// EditLoadFile()
+//
+BOOL EditLoadFile(
+ HWND hwnd,
+ LPCWSTR pszFile,
+ BOOL bSkipEncodingDetection,
+ int* iEncoding,
+ int* iEOLMode,
+ BOOL *pbUnicodeErr,
+ BOOL *pbFileTooBig)
+{
+
+ HANDLE hFile;
+
+ DWORD dwFileSize;
+ DWORD dwFileSizeLimit;
+ DWORD dwBufSize;
+ BOOL bReadSuccess;
+
+ char* lpData;
+ DWORD cbData;
+ //char *cp;
+ int _iDefaultEncoding;
+
+ BOOL bBOM;
+ BOOL bReverse;
+
+ *pbUnicodeErr = FALSE;
+ *pbFileTooBig = FALSE;
+
+ hFile = CreateFile(pszFile,
+ GENERIC_READ,
+ FILE_SHARE_READ|FILE_SHARE_WRITE,
+ NULL,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+ dwLastIOError = GetLastError();
+
+ if (hFile == INVALID_HANDLE_VALUE) {
+ iSrcEncoding = -1;
+ iWeakSrcEncoding = -1;
+ return FALSE;
+ }
+
+ // calculate buffer limit
+ dwFileSize = GetFileSize(hFile,NULL);
+ dwBufSize = dwFileSize + 10;
+
+ // Check if a warning message should be displayed for large files
+ dwFileSizeLimit = IniGetInt(L"Settings2",L"FileLoadWarningMB",1);
+ if (dwFileSizeLimit != 0 && dwFileSizeLimit * 1024 * 1024 < dwFileSize) {
+ if (InfoBox(MBYESNO,L"MsgFileSizeWarning",IDS_WARNLOADBIGFILE) != IDYES) {
+ CloseHandle(hFile);
+ *pbFileTooBig = TRUE;
+ iSrcEncoding = -1;
+ iWeakSrcEncoding = -1;
+ return FALSE;
+ }
+ }
+
+ lpData = GlobalAlloc(GPTR,dwBufSize);
+ bReadSuccess = ReadFile(hFile,lpData,GlobalSize(lpData)-2,&cbData,NULL);
+ dwLastIOError = GetLastError();
+ CloseHandle(hFile);
+
+ if (!bReadSuccess) {
+ GlobalFree(lpData);
+ iSrcEncoding = -1;
+ iWeakSrcEncoding = -1;
+ return FALSE;
+ }
+
+ if (!Encoding_IsValid(iDefaultEncoding))
+ iDefaultEncoding = CPI_DEFAULT;
+
+ _iDefaultEncoding = iDefaultEncoding;
+ if (iWeakSrcEncoding != -1 && Encoding_IsValid(iWeakSrcEncoding))
+ _iDefaultEncoding = iWeakSrcEncoding;
+
+ *iEncoding = CPI_DEFAULT;
+
+ if (cbData == 0) {
+ FileVars_Init(NULL,0,&fvCurFile);
+ *iEOLMode = iLineEndings[iDefaultEOLMode];
+ if (iSrcEncoding == -1) {
+ if (bLoadASCIIasUTF8)
+ *iEncoding = CPI_UTF8;
+ else
+ *iEncoding = _iDefaultEncoding;
+ }
+ else
+ *iEncoding = iSrcEncoding;
+ SendMessage(hwnd,SCI_SETCODEPAGE,(mEncoding[*iEncoding].uFlags & NCP_DEFAULT) ? iDefaultCodePage : SC_CP_UTF8,0);
+ EditSetNewText(hwnd,"",0);
+ SendMessage(hwnd,SCI_SETEOLMODE,iLineEndings[iDefaultEOLMode],0);
+ GlobalFree(lpData);
+ }
+
+ else if (!bSkipEncodingDetection && iSrcEncoding == -1 &&
+ IsUnicode(lpData,cbData,&bBOM,&bReverse) && !IsUTF8Signature(lpData)) // check for UTF-8 signature
+ {
+ char* lpDataUTF8;
+
+ if (bReverse) {
+ _swab(lpData,lpData,cbData);
+ if (bBOM)
+ *iEncoding = CPI_UNICODEBEBOM;
+ else
+ *iEncoding = CPI_UNICODEBE;
+ }
+ else {
+ if (bBOM)
+ *iEncoding = CPI_UNICODEBOM;
+ else
+ *iEncoding = CPI_UNICODE;
+ }
+
+ lpDataUTF8 = GlobalAlloc(GPTR,(cbData * 3) + 2);
+ cbData = WideCharToMultiByte(CP_UTF8,0,(bBOM) ? (LPWSTR)lpData + 1 : (LPWSTR)lpData,
+ (bBOM) ? (cbData)/sizeof(WCHAR) : cbData/sizeof(WCHAR) + 1,lpDataUTF8,GlobalSize(lpDataUTF8),NULL,NULL);
+
+ if (cbData == 0) {
+ cbData = WideCharToMultiByte(CP_ACP,0,(bBOM) ? (LPWSTR)lpData + 1 : (LPWSTR)lpData,
+ (-1),lpDataUTF8,GlobalSize(lpDataUTF8),NULL,NULL);
+ *pbUnicodeErr = TRUE;
+ }
+
+ GlobalFree(lpData);
+ SendMessage(hwnd,SCI_SETCODEPAGE,SC_CP_UTF8,0);
+ EditSetNewText(hwnd,"",0);
+ FileVars_Init(lpDataUTF8,cbData-1,&fvCurFile);
+ EditSetNewText(hwnd,lpDataUTF8,cbData-1);
+ *iEOLMode = EditDetectEOLMode(hwnd,lpDataUTF8,cbData-1);
+ GlobalFree(lpDataUTF8);
+ }
+
+ else {
+ FileVars_Init(lpData,cbData,&fvCurFile);
+ if (!bSkipEncodingDetection && (iSrcEncoding == -1 || iSrcEncoding == CPI_UTF8 || iSrcEncoding == CPI_UTF8SIGN) &&
+ ((IsUTF8Signature(lpData) ||
+ FileVars_IsUTF8(&fvCurFile) ||
+ (iSrcEncoding == CPI_UTF8 || iSrcEncoding == CPI_UTF8SIGN) ||
+ (IsUTF8(lpData,cbData) &&
+ (((UTF8_mbslen_bytes(UTF8StringStart(lpData)) - 1 !=
+ UTF8_mbslen(UTF8StringStart(lpData),IsUTF8Signature(lpData) ? cbData-3 : cbData)) ||
+ mEncoding[_iDefaultEncoding].uFlags & NCP_UTF8 ||
+ bLoadASCIIasUTF8))))) && !(FileVars_IsNonUTF8(&fvCurFile) &&
+ (iSrcEncoding != CPI_UTF8 && iSrcEncoding != CPI_UTF8SIGN)))
+ {
+ SendMessage(hwnd,SCI_SETCODEPAGE,SC_CP_UTF8,0);
+ EditSetNewText(hwnd,"",0);
+ if (IsUTF8Signature(lpData)) {
+ EditSetNewText(hwnd,UTF8StringStart(lpData),cbData-3);
+ *iEncoding = CPI_UTF8SIGN;
+ *iEOLMode = EditDetectEOLMode(hwnd,UTF8StringStart(lpData),cbData-3);
+ }
+ else {
+ EditSetNewText(hwnd,lpData,cbData);
+ *iEncoding = CPI_UTF8;
+ *iEOLMode = EditDetectEOLMode(hwnd,lpData,cbData);
+ }
+ GlobalFree(lpData);
+ }
+
+ else {
+
+ UINT uCodePage = CP_UTF8;
+ LPWSTR lpDataWide;
+ int cbDataWide;
+
+ if (iSrcEncoding != -1)
+ *iEncoding = iSrcEncoding;
+ else {
+ *iEncoding = FileVars_GetEncoding(&fvCurFile);
+ if (*iEncoding == -1) {
+ if (fvCurFile.mask & FV_ENCODING)
+ *iEncoding = CPI_DEFAULT;
+ else {
+ if (iWeakSrcEncoding == -1)
+ *iEncoding = _iDefaultEncoding;
+ else if (mEncoding[iWeakSrcEncoding].uFlags & NCP_INTERNAL)
+ *iEncoding = iDefaultEncoding;
+ else
+ *iEncoding = _iDefaultEncoding;
+ }
+ }
+ }
+
+ if ((mEncoding[*iEncoding].uFlags & NCP_8BIT && mEncoding[*iEncoding].uCodePage != CP_UTF7) ||
+ (mEncoding[*iEncoding].uCodePage == CP_UTF7 && IsUTF7(lpData,cbData))) {
+
+ uCodePage = mEncoding[*iEncoding].uCodePage;
+
+ lpDataWide = GlobalAlloc(GPTR,cbData * 2 + 16);
+ cbDataWide = MultiByteToWideChar(uCodePage,0,lpData,cbData,lpDataWide,GlobalSize(lpDataWide)/sizeof(WCHAR));
+
+ GlobalFree(lpData);
+ lpData = GlobalAlloc(GPTR,cbDataWide * 3 + 16);
+
+ cbData = WideCharToMultiByte(CP_UTF8,0,lpDataWide,cbDataWide,lpData,GlobalSize(lpData),NULL,NULL);
+ GlobalFree(lpDataWide);
+
+ SendMessage(hwnd,SCI_SETCODEPAGE,SC_CP_UTF8,0);
+ EditSetNewText(hwnd,"",0);
+ EditSetNewText(hwnd,lpData,cbData);
+ *iEOLMode = EditDetectEOLMode(hwnd,lpData,cbData);
+
+ GlobalFree(lpData);
+ }
+
+ else {
+
+ SendMessage(hwnd,SCI_SETCODEPAGE,iDefaultCodePage,0);
+ EditSetNewText(hwnd,"",0);
+ EditSetNewText(hwnd,lpData,cbData);
+ *iEncoding = CPI_DEFAULT;
+ *iEOLMode = EditDetectEOLMode(hwnd,lpData,cbData);
+ GlobalFree(lpData);
+ }
+ }
+ }
+
+ iSrcEncoding = -1;
+ iWeakSrcEncoding = -1;
+ return TRUE;
+
+}
+
+
+//=============================================================================
+//
+// EditSaveFile()
+//
+BOOL EditSaveFile(
+ HWND hwnd,
+ LPCWSTR pszFile,
+ int iEncoding,
+ BOOL *pbCancelDataLoss,
+ BOOL bSaveCopy)
+{
+
+ HANDLE hFile;
+ BOOL bWriteSuccess;
+
+ char* lpData;
+ DWORD cbData;
+ DWORD dwBytesWritten;
+
+ *pbCancelDataLoss = FALSE;
+
+ hFile = CreateFile(pszFile,
+ GENERIC_WRITE,
+ FILE_SHARE_READ|FILE_SHARE_WRITE,
+ NULL,
+ OPEN_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+ dwLastIOError = GetLastError();
+
+ // failure could be due to missing attributes (2k/XP)
+ if (hFile == INVALID_HANDLE_VALUE)
+ {
+ DWORD dwAttributes = GetFileAttributes(pszFile);
+ if (dwAttributes != INVALID_FILE_ATTRIBUTES)
+ {
+ dwAttributes = dwAttributes & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM);
+ hFile = CreateFile(pszFile,
+ GENERIC_WRITE,
+ FILE_SHARE_READ|FILE_SHARE_WRITE,
+ NULL,
+ OPEN_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL | dwAttributes,
+ NULL);
+ dwLastIOError = GetLastError();
+ }
+ }
+
+ if (hFile == INVALID_HANDLE_VALUE)
+ return FALSE;
+
+ // ensure consistent line endings
+ if (bFixLineEndings)
+ SendMessage(hwnd,SCI_CONVERTEOLS,SendMessage(hwnd,SCI_GETEOLMODE,0,0),0);
+
+ // strip trailing blanks
+ if (bAutoStripBlanks)
+ EditStripTrailingBlanks(hwnd,TRUE);
+
+ // get text
+ cbData = SendMessage(hwnd,SCI_GETLENGTH,0,0);
+ lpData = GlobalAlloc(GPTR,cbData + 1);
+ SendMessage(hwnd,SCI_GETTEXT,GlobalSize(lpData),(LPARAM)lpData);
+
+ if (cbData == 0) {
+ bWriteSuccess = SetEndOfFile(hFile);
+ dwLastIOError = GetLastError();
+ }
+
+ else {
+
+ // FIXME: move checks in front of disk file access
+ /*if ((mEncoding[iEncoding].uFlags & NCP_UNICODE) == 0 && (mEncoding[iEncoding].uFlags & NCP_UTF8_SIGN) == 0) {
+ BOOL bEncodingMismatch = TRUE;
+ FILEVARS fv;
+ FileVars_Init(lpData,cbData,&fv);
+ if (fv.mask & FV_ENCODING) {
+ int iAltEncoding;
+ if (FileVars_IsValidEncoding(&fv)) {
+ iAltEncoding = FileVars_GetEncoding(&fv);
+ if (iAltEncoding == iEncoding)
+ bEncodingMismatch = FALSE;
+ else if ((mEncoding[iAltEncoding].uFlags & NCP_UTF8) && (mEncoding[iEncoding].uFlags & NCP_UTF8))
+ bEncodingMismatch = FALSE;
+ }
+ if (bEncodingMismatch) {
+ Encoding_GetLabel(iAltEncoding);
+ Encoding_GetLabel(iEncoding);
+ InfoBox(0,L"MsgEncodingMismatch",IDS_ENCODINGMISMATCH,
+ mEncoding[iAltEncoding].wchLabel,
+ mEncoding[iEncoding].wchLabel);
+ }
+ }
+ }*/
+
+ if (mEncoding[iEncoding].uFlags & NCP_UNICODE)
+ {
+ LPWSTR lpDataWide;
+ int cbDataWide;
+
+ SetEndOfFile(hFile);
+
+ lpDataWide = GlobalAlloc(GPTR,cbData * 2 + 16);
+ cbDataWide = MultiByteToWideChar(CP_UTF8,0,lpData,cbData,lpDataWide,GlobalSize(lpDataWide)/sizeof(WCHAR));
+
+ if (mEncoding[iEncoding].uFlags & NCP_UNICODE_BOM) {
+ if (mEncoding[iEncoding].uFlags & NCP_UNICODE_REVERSE)
+ WriteFile(hFile,(LPCVOID)"\xFE\xFF",2,&dwBytesWritten,NULL);
+ else
+ WriteFile(hFile,(LPCVOID)"\xFF\xFE",2,&dwBytesWritten,NULL);
+ }
+
+ if (mEncoding[iEncoding].uFlags & NCP_UNICODE_REVERSE)
+ _swab((char*)lpDataWide,(char*)lpDataWide,cbDataWide * sizeof(WCHAR));
+
+ bWriteSuccess = WriteFile(hFile,lpDataWide,cbDataWide * sizeof(WCHAR),&dwBytesWritten,NULL);
+ dwLastIOError = GetLastError();
+
+ GlobalFree(lpDataWide);
+ GlobalFree(lpData);
+ }
+
+ else if (mEncoding[iEncoding].uFlags & NCP_UTF8)
+ {
+ SetEndOfFile(hFile);
+
+ if (mEncoding[iEncoding].uFlags & NCP_UTF8_SIGN)
+ WriteFile(hFile,(LPCVOID)"\xEF\xBB\xBF",3,&dwBytesWritten,NULL);
+
+ bWriteSuccess = WriteFile(hFile,lpData,cbData,&dwBytesWritten,NULL);
+ dwLastIOError = GetLastError();
+
+ GlobalFree(lpData);
+ }
+
+ else if (mEncoding[iEncoding].uFlags & NCP_8BIT) {
+
+ BOOL bCancelDataLoss = FALSE;
+ UINT uCodePage = mEncoding[iEncoding].uCodePage;
+
+ LPWSTR lpDataWide = GlobalAlloc(GPTR,cbData * 2 + 16);
+ int cbDataWide = MultiByteToWideChar(CP_UTF8,0,lpData,cbData,lpDataWide,GlobalSize(lpDataWide)/sizeof(WCHAR));
+
+ // Special cases: 42, 50220, 50221, 50222, 50225, 50227, 50229, 54936, 57002-11, 65000, 65001
+ if (uCodePage == CP_UTF7 || uCodePage == 54936) {
+ GlobalFree(lpData);
+ lpData = GlobalAlloc(GPTR,GlobalSize(lpDataWide)*2);
+ }
+ else
+ ZeroMemory(lpData,GlobalSize(lpData));
+
+ if (uCodePage == CP_UTF7 || uCodePage == 54936)
+ cbData = WideCharToMultiByte(uCodePage,0,lpDataWide,cbDataWide,lpData,GlobalSize(lpData),NULL,NULL);
+ else {
+ cbData = WideCharToMultiByte(uCodePage,WC_NO_BEST_FIT_CHARS,lpDataWide,cbDataWide,lpData,GlobalSize(lpData),NULL,&bCancelDataLoss);
+ if (!bCancelDataLoss) {
+ cbData = WideCharToMultiByte(uCodePage,0,lpDataWide,cbDataWide,lpData,GlobalSize(lpData),NULL,NULL);
+ bCancelDataLoss = FALSE;
+ }
+ }
+ GlobalFree(lpDataWide);
+
+ if (!bCancelDataLoss || InfoBox(MBOKCANCEL,L"MsgConv3",IDS_ERR_UNICODE2) == IDOK) {
+ SetEndOfFile(hFile);
+ bWriteSuccess = WriteFile(hFile,lpData,cbData,&dwBytesWritten,NULL);
+ dwLastIOError = GetLastError();
+ }
+ else {
+ bWriteSuccess = FALSE;
+ *pbCancelDataLoss = TRUE;
+ }
+
+ GlobalFree(lpData);
+ }
+
+ else {
+ SetEndOfFile(hFile);
+ bWriteSuccess = WriteFile(hFile,lpData,cbData,&dwBytesWritten,NULL);
+ dwLastIOError = GetLastError();
+ GlobalFree(lpData);
+ }
+ }
+
+ CloseHandle(hFile);
+
+ if (bWriteSuccess)
+ {
+ if (!bSaveCopy)
+ SendMessage(hwnd,SCI_SETSAVEPOINT,0,0);
+
+ return TRUE;
+ }
+
+ else
+ return FALSE;
+
+}
+
+
+//=============================================================================
+//
+// EditMakeUppercase()
+//
+void EditMakeUppercase(HWND hwnd)
+{
+ int cchTextW;
+ int iCurPos;
+ int iAnchorPos;
+ UINT cpEdit;
+ int i;
+ BOOL bChanged = FALSE;
+
+ iCurPos = SendMessage(hwnd,SCI_GETCURRENTPOS,0,0);
+ iAnchorPos = SendMessage(hwnd,SCI_GETANCHOR,0,0);
+
+ if (iCurPos != iAnchorPos)
+ {
+ if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0))
+ {
+ int iSelCount = SendMessage(hwnd,SCI_GETSELECTIONEND,0,0) -
+ SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0);
+
+ char* pszText = GlobalAlloc(GPTR,(iSelCount)+2);
+ LPWSTR pszTextW = GlobalAlloc(GPTR,(iSelCount*2)+2);
+
+ if (pszText == NULL || pszTextW == NULL) {
+ GlobalFree(pszText);
+ GlobalFree(pszTextW);
+ return;
+ }
+
+ SendMessage(hwnd,SCI_GETSELTEXT,0,(LPARAM)pszText);
+
+ cpEdit = SendMessage(hwnd,SCI_GETCODEPAGE,0,0);
+
+ cchTextW = MultiByteToWideChar(cpEdit,0,pszText,iSelCount,pszTextW,GlobalSize(pszTextW)/sizeof(WCHAR));
+
+ for (i = 0; i < cchTextW; i++) {
+ if (IsCharLowerW(pszTextW[i])) {
+ pszTextW[i] = LOWORD(CharUpperW((LPWSTR)MAKELONG(pszTextW[i],0)));
+ bChanged = TRUE;
+ }
+ }
+
+ if (bChanged) {
+
+ WideCharToMultiByte(cpEdit,0,pszTextW,cchTextW,pszText,GlobalSize(pszText),NULL,NULL);
+
+ SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0);
+ SendMessage(hwnd,SCI_CLEAR,0,0);
+ SendMessage(hwnd,SCI_ADDTEXT,(WPARAM)iSelCount,(LPARAM)pszText);
+ SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos);
+ SendMessage(hwnd,SCI_ENDUNDOACTION,0,0);
+ }
+
+ GlobalFree(pszText);
+ GlobalFree(pszTextW);
+ }
+ else
+ MsgBox(MBINFO,IDS_SELRECT);
+ }
+}
+
+
+//=============================================================================
+//
+// EditMakeLowercase()
+//
+void EditMakeLowercase(HWND hwnd)
+{
+ int cchTextW;
+ int iCurPos;
+ int iAnchorPos;
+ UINT cpEdit;
+ int i;
+ BOOL bChanged = FALSE;
+
+ iCurPos = SendMessage(hwnd,SCI_GETCURRENTPOS,0,0);
+ iAnchorPos = SendMessage(hwnd,SCI_GETANCHOR,0,0);
+
+ if (iCurPos != iAnchorPos)
+ {
+ if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0))
+ {
+ int iSelCount = SendMessage(hwnd,SCI_GETSELECTIONEND,0,0) -
+ SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0);
+
+ char* pszText = GlobalAlloc(GPTR,(iSelCount)+2);
+ LPWSTR pszTextW = GlobalAlloc(GPTR,(iSelCount*2)+2);
+
+ if (pszText == NULL || pszTextW == NULL) {
+ GlobalFree(pszText);
+ GlobalFree(pszTextW);
+ return;
+ }
+
+ SendMessage(hwnd,SCI_GETSELTEXT,0,(LPARAM)pszText);
+
+ cpEdit = SendMessage(hwnd,SCI_GETCODEPAGE,0,0);
+
+ cchTextW = MultiByteToWideChar(cpEdit,0,pszText,iSelCount,pszTextW,GlobalSize(pszTextW)/sizeof(WCHAR));
+
+ for (i = 0; i < cchTextW; i++) {
+ if (IsCharUpperW(pszTextW[i])) {
+ pszTextW[i] = LOWORD(CharLowerW((LPWSTR)MAKELONG(pszTextW[i],0)));
+ bChanged = TRUE;
+ }
+ }
+
+ if (bChanged) {
+
+ WideCharToMultiByte(cpEdit,0,pszTextW,cchTextW,pszText,GlobalSize(pszText),NULL,NULL);
+
+ SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0);
+ SendMessage(hwnd,SCI_CLEAR,0,0);
+ SendMessage(hwnd,SCI_ADDTEXT,(WPARAM)iSelCount,(LPARAM)pszText);
+ SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos);
+ SendMessage(hwnd,SCI_ENDUNDOACTION,0,0);
+ }
+
+ GlobalFree(pszText);
+ GlobalFree(pszTextW);
+ }
+ else
+ MsgBox(MBINFO,IDS_SELRECT);
+ }
+}
+
+
+//=============================================================================
+//
+// EditInvertCase()
+//
+void EditInvertCase(HWND hwnd)
+{
+ int cchTextW;
+ int iCurPos;
+ int iAnchorPos;
+ UINT cpEdit;
+ int i;
+ BOOL bChanged = FALSE;
+
+ iCurPos = SendMessage(hwnd,SCI_GETCURRENTPOS,0,0);
+ iAnchorPos = SendMessage(hwnd,SCI_GETANCHOR,0,0);
+
+ if (iCurPos != iAnchorPos)
+ {
+ if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0))
+ {
+ int iSelCount = SendMessage(hwnd,SCI_GETSELECTIONEND,0,0) -
+ SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0);
+
+ char* pszText = GlobalAlloc(GPTR,(iSelCount)+2);
+ LPWSTR pszTextW = GlobalAlloc(GPTR,(iSelCount*2)+2);
+
+ if (pszText == NULL || pszTextW == NULL) {
+ GlobalFree(pszText);
+ GlobalFree(pszTextW);
+ return;
+ }
+
+ SendMessage(hwnd,SCI_GETSELTEXT,0,(LPARAM)pszText);
+
+ cpEdit = SendMessage(hwnd,SCI_GETCODEPAGE,0,0);
+
+ cchTextW = MultiByteToWideChar(cpEdit,0,pszText,iSelCount,pszTextW,GlobalSize(pszTextW)/sizeof(WCHAR));
+
+ for (i = 0; i < cchTextW; i++) {
+ if (IsCharUpperW(pszTextW[i])) {
+ pszTextW[i] = LOWORD(CharLowerW((LPWSTR)MAKELONG(pszTextW[i],0)));
+ bChanged = TRUE;
+ }
+ else if (IsCharLowerW(pszTextW[i])) {
+ pszTextW[i] = LOWORD(CharUpperW((LPWSTR)MAKELONG(pszTextW[i],0)));
+ bChanged = TRUE;
+ }
+ }
+
+ if (bChanged) {
+
+ WideCharToMultiByte(cpEdit,0,pszTextW,cchTextW,pszText,GlobalSize(pszText),NULL,NULL);
+
+ SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0);
+ SendMessage(hwnd,SCI_CLEAR,0,0);
+ SendMessage(hwnd,SCI_ADDTEXT,(WPARAM)iSelCount,(LPARAM)pszText);
+ SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos);
+ SendMessage(hwnd,SCI_ENDUNDOACTION,0,0);
+
+ }
+
+ GlobalFree(pszText);
+ GlobalFree(pszTextW);
+ }
+ else
+ MsgBox(MBINFO,IDS_SELRECT);
+ }
+}
+
+
+//=============================================================================
+//
+// EditTitleCase()
+//
+void EditTitleCase(HWND hwnd)
+{
+ int cchTextW;
+ int iCurPos;
+ int iAnchorPos;
+ UINT cpEdit;
+ int i;
+ BOOL bNewWord = TRUE;
+ BOOL bChanged = FALSE;
+
+ iCurPos = SendMessage(hwnd,SCI_GETCURRENTPOS,0,0);
+ iAnchorPos = SendMessage(hwnd,SCI_GETANCHOR,0,0);
+
+ if (iCurPos != iAnchorPos)
+ {
+ if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0))
+ {
+ int iSelCount = SendMessage(hwnd,SCI_GETSELECTIONEND,0,0) -
+ SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0);
+
+ char* pszText = GlobalAlloc(GPTR,(iSelCount)+2);
+ LPWSTR pszTextW = GlobalAlloc(GPTR,(iSelCount*2)+2);
+
+ if (pszText == NULL || pszTextW == NULL) {
+ GlobalFree(pszText);
+ GlobalFree(pszTextW);
+ return;
+ }
+
+ SendMessage(hwnd,SCI_GETSELTEXT,0,(LPARAM)pszText);
+
+ cpEdit = SendMessage(hwnd,SCI_GETCODEPAGE,0,0);
+
+ cchTextW = MultiByteToWideChar(cpEdit,0,pszText,iSelCount,pszTextW,GlobalSize(pszTextW)/sizeof(WCHAR));
+
+ for (i = 0; i < cchTextW; i++) {
+ if (!IsCharAlphaNumericW(pszTextW[i]) && !StrChr(L"'’",pszTextW[i])) {
+ bNewWord = TRUE;
+ }
+ else {
+ if (bNewWord) {
+ if (IsCharLowerW(pszTextW[i])) {
+ pszTextW[i] = LOWORD(CharUpperW((LPWSTR)MAKELONG(pszTextW[i],0)));
+ bChanged = TRUE;
+ }
+ }
+ else {
+ if (IsCharUpperW(pszTextW[i])) {
+ pszTextW[i] = LOWORD(CharLowerW((LPWSTR)MAKELONG(pszTextW[i],0)));
+ bChanged = TRUE;
+ }
+ }
+ bNewWord = FALSE;
+ }
+ }
+
+ if (bChanged) {
+
+ WideCharToMultiByte(cpEdit,0,pszTextW,cchTextW,pszText,GlobalSize(pszText),NULL,NULL);
+
+ SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0);
+ SendMessage(hwnd,SCI_CLEAR,0,0);
+ SendMessage(hwnd,SCI_ADDTEXT,(WPARAM)iSelCount,(LPARAM)pszText);
+ SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos);
+ SendMessage(hwnd,SCI_ENDUNDOACTION,0,0);
+
+ }
+
+ GlobalFree(pszText);
+ GlobalFree(pszTextW);
+ }
+ else
+ MsgBox(MBINFO,IDS_SELRECT);
+ }
+}
+
+
+//=============================================================================
+//
+// EditSentenceCase()
+//
+void EditSentenceCase(HWND hwnd)
+{
+ int cchTextW;
+ int iCurPos;
+ int iAnchorPos;
+ UINT cpEdit;
+ int i;
+ BOOL bNewSentence = TRUE;
+ BOOL bChanged = FALSE;
+
+ iCurPos = SendMessage(hwnd,SCI_GETCURRENTPOS,0,0);
+ iAnchorPos = SendMessage(hwnd,SCI_GETANCHOR,0,0);
+
+ if (iCurPos != iAnchorPos)
+ {
+ if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0))
+ {
+ int iSelCount = SendMessage(hwnd,SCI_GETSELECTIONEND,0,0) -
+ SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0);
+
+ char* pszText = GlobalAlloc(GPTR,(iSelCount)+2);
+ LPWSTR pszTextW = GlobalAlloc(GPTR,(iSelCount*2)+2);
+
+ if (pszText == NULL || pszTextW == NULL) {
+ GlobalFree(pszText);
+ GlobalFree(pszTextW);
+ return;
+ }
+
+ SendMessage(hwnd,SCI_GETSELTEXT,0,(LPARAM)pszText);
+
+ cpEdit = SendMessage(hwnd,SCI_GETCODEPAGE,0,0);
+
+ cchTextW = MultiByteToWideChar(cpEdit,0,pszText,iSelCount,pszTextW,GlobalSize(pszTextW)/sizeof(WCHAR));
+
+ for (i = 0; i < cchTextW; i++) {
+ if (StrChr(L".;!?\r\n",pszTextW[i])) {
+ bNewSentence = TRUE;
+ }
+ else {
+ if (IsCharAlphaNumericW(pszTextW[i])) {
+ if (bNewSentence) {
+ if (IsCharLowerW(pszTextW[i])) {
+ pszTextW[i] = LOWORD(CharUpperW((LPWSTR)MAKELONG(pszTextW[i],0)));
+ bChanged = TRUE;
+ }
+ bNewSentence = FALSE;
+ }
+ else {
+ if (IsCharUpperW(pszTextW[i])) {
+ pszTextW[i] = LOWORD(CharLowerW((LPWSTR)MAKELONG(pszTextW[i],0)));
+ bChanged = TRUE;
+ }
+ }
+ }
+ }
+ }
+
+ if (bChanged) {
+
+ WideCharToMultiByte(cpEdit,0,pszTextW,cchTextW,pszText,GlobalSize(pszText),NULL,NULL);
+
+ SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0);
+ SendMessage(hwnd,SCI_CLEAR,0,0);
+ SendMessage(hwnd,SCI_ADDTEXT,(WPARAM)iSelCount,(LPARAM)pszText);
+ SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos);
+ SendMessage(hwnd,SCI_ENDUNDOACTION,0,0);
+ }
+
+ GlobalFree(pszText);
+ GlobalFree(pszTextW);
+ }
+ else
+ MsgBox(MBINFO,IDS_SELRECT);
+ }
+}
+
+
+//=============================================================================
+//
+// EditURLEncode()
+//
+void EditURLEncode(HWND hwnd)
+{
+ int cchTextW;
+ int iCurPos;
+ int iAnchorPos;
+ UINT cpEdit;
+
+ iCurPos = SendMessage(hwnd,SCI_GETCURRENTPOS,0,0);
+ iAnchorPos = SendMessage(hwnd,SCI_GETANCHOR,0,0);
+
+ if (iCurPos != iAnchorPos)
+ {
+ if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0))
+ {
+ int iSelCount = SendMessage(hwnd,SCI_GETSELECTIONEND,0,0) -
+ SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0);
+
+ char* pszText;
+ LPWSTR pszTextW;
+
+ DWORD cchEscaped;
+ char* pszEscaped;
+ DWORD cchEscapedW;
+ LPWSTR pszEscapedW;
+
+ pszText = LocalAlloc(LPTR,(iSelCount)+2);
+ if (pszText == NULL) {
+ return;
+ }
+
+ pszTextW = LocalAlloc(LPTR,(iSelCount*2)+2);
+ if (pszTextW == NULL) {
+ LocalFree(pszText);
+ return;
+ }
+
+ SendMessage(hwnd,SCI_GETSELTEXT,0,(LPARAM)pszText);
+ cpEdit = SendMessage(hwnd,SCI_GETCODEPAGE,0,0);
+ cchTextW = MultiByteToWideChar(cpEdit,0,pszText,iSelCount,pszTextW,LocalSize(pszTextW)/sizeof(WCHAR));
+
+ pszEscaped = LocalAlloc(LPTR,LocalSize(pszText) * 3);
+ if (pszEscaped == NULL) {
+ LocalFree(pszText);
+ LocalFree(pszTextW);
+ return;
+ }
+
+ pszEscapedW = LocalAlloc(LPTR,LocalSize(pszTextW) * 3);
+ if (pszEscapedW == NULL) {
+ LocalFree(pszText);
+ LocalFree(pszTextW);
+ LocalFree(pszEscaped);
+ return;
+ }
+
+ cchEscapedW = LocalSize(pszEscapedW) / sizeof(WCHAR);
+ UrlEscape(pszTextW,pszEscapedW,&cchEscapedW,URL_ESCAPE_SEGMENT_ONLY);
+
+ cchEscaped = WideCharToMultiByte(cpEdit,0,pszEscapedW,cchEscapedW,pszEscaped,LocalSize(pszEscaped),NULL,NULL);
+
+ if (iCurPos < iAnchorPos)
+ iAnchorPos = iCurPos + cchEscaped;
+ else
+ iCurPos = iAnchorPos + cchEscaped;
+
+ SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0);
+ SendMessage(hwnd,SCI_CLEAR,0,0);
+ SendMessage(hwnd,SCI_ADDTEXT,(WPARAM)cchEscaped,(LPARAM)pszEscaped);
+ SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos);
+ SendMessage(hwnd,SCI_ENDUNDOACTION,0,0);
+
+ LocalFree(pszText);
+ LocalFree(pszTextW);
+ LocalFree(pszEscaped);
+ LocalFree(pszEscapedW);
+ }
+ else
+ MsgBox(MBINFO,IDS_SELRECT);
+ }
+}
+
+
+//=============================================================================
+//
+// EditURLDecode()
+//
+void EditURLDecode(HWND hwnd)
+{
+ int cchTextW;
+ int iCurPos;
+ int iAnchorPos;
+ UINT cpEdit;
+
+ iCurPos = SendMessage(hwnd,SCI_GETCURRENTPOS,0,0);
+ iAnchorPos = SendMessage(hwnd,SCI_GETANCHOR,0,0);
+
+ if (iCurPos != iAnchorPos)
+ {
+ if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0))
+ {
+ int iSelCount = SendMessage(hwnd,SCI_GETSELECTIONEND,0,0) -
+ SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0);
+
+ char* pszText;
+ LPWSTR pszTextW;
+
+ DWORD cchUnescaped;
+ char* pszUnescaped;
+ DWORD cchUnescapedW;
+ LPWSTR pszUnescapedW;
+
+ pszText = LocalAlloc(LPTR,(iSelCount)+2);
+ if (pszText == NULL) {
+ return;
+ }
+
+ pszTextW = LocalAlloc(LPTR,(iSelCount*2)+2);
+ if (pszTextW == NULL) {
+ LocalFree(pszText);
+ return;
+ }
+
+ SendMessage(hwnd,SCI_GETSELTEXT,0,(LPARAM)pszText);
+ cpEdit = SendMessage(hwnd,SCI_GETCODEPAGE,0,0);
+ cchTextW = MultiByteToWideChar(cpEdit,0,pszText,iSelCount,pszTextW,LocalSize(pszTextW)/sizeof(WCHAR));
+
+ pszUnescaped = LocalAlloc(LPTR,LocalSize(pszText) * 3);
+ if (pszUnescaped == NULL) {
+ LocalFree(pszText);
+ LocalFree(pszTextW);
+ return;
+ }
+
+ pszUnescapedW = LocalAlloc(LPTR,LocalSize(pszTextW) * 3);
+ if (pszUnescapedW == NULL) {
+ LocalFree(pszText);
+ LocalFree(pszTextW);
+ LocalFree(pszUnescaped);
+ return;
+ }
+
+ cchUnescapedW = LocalSize(pszUnescapedW) / sizeof(WCHAR);
+ UrlUnescape(pszTextW,pszUnescapedW,&cchUnescapedW,0);
+
+ cchUnescaped = WideCharToMultiByte(cpEdit,0,pszUnescapedW,cchUnescapedW,pszUnescaped,LocalSize(pszUnescaped),NULL,NULL);
+
+ if (iCurPos < iAnchorPos)
+ iAnchorPos = iCurPos + cchUnescaped;
+ else
+ iCurPos = iAnchorPos + cchUnescaped;
+
+ SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0);
+ SendMessage(hwnd,SCI_CLEAR,0,0);
+ SendMessage(hwnd,SCI_ADDTEXT,(WPARAM)cchUnescaped,(LPARAM)pszUnescaped);
+ SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos);
+ SendMessage(hwnd,SCI_ENDUNDOACTION,0,0);
+
+ LocalFree(pszText);
+ LocalFree(pszTextW);
+ LocalFree(pszUnescaped);
+ LocalFree(pszUnescapedW);
+ }
+ else
+ MsgBox(MBINFO,IDS_SELRECT);
+ }
+}
+
+
+//=============================================================================
+//
+// EditEscapeCChars()
+//
+void EditEscapeCChars(HWND hwnd) {
+
+ if (SendMessage(hwnd,SCI_GETSELECTIONEND,0,0) - SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0))
+ {
+ if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0))
+ {
+ EDITFINDREPLACE efr = { "", "", "", "", 0, 0, 0, 0, 0, 0, hwnd };
+
+ SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0);
+
+ lstrcpyA(efr.szFind,"\\");
+ lstrcpyA(efr.szReplace,"\\\\");
+ EditReplaceAllInSelection(hwnd,&efr,FALSE);
+
+ lstrcpyA(efr.szFind,"\"");
+ lstrcpyA(efr.szReplace,"\\\"");
+ EditReplaceAllInSelection(hwnd,&efr,FALSE);
+
+ lstrcpyA(efr.szFind,"\'");
+ lstrcpyA(efr.szReplace,"\\\'");
+ EditReplaceAllInSelection(hwnd,&efr,FALSE);
+
+ SendMessage(hwnd,SCI_ENDUNDOACTION,0,0);
+ }
+ else
+ MsgBox(MBINFO,IDS_SELRECT);
+ }
+}
+
+
+//=============================================================================
+//
+// EditUnescapeCChars()
+//
+void EditUnescapeCChars(HWND hwnd) {
+
+ if (SendMessage(hwnd,SCI_GETSELECTIONEND,0,0) - SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0))
+ {
+ if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0))
+ {
+ EDITFINDREPLACE efr = { "", "", "", "", 0, 0, 0, 0, 0, 0, hwnd };
+
+ SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0);
+
+ lstrcpyA(efr.szFind,"\\\\");
+ lstrcpyA(efr.szReplace,"\\");
+ EditReplaceAllInSelection(hwnd,&efr,FALSE);
+
+ lstrcpyA(efr.szFind,"\\\"");
+ lstrcpyA(efr.szReplace,"\"");
+ EditReplaceAllInSelection(hwnd,&efr,FALSE);
+
+ lstrcpyA(efr.szFind,"\\\'");
+ lstrcpyA(efr.szReplace,"\'");
+ EditReplaceAllInSelection(hwnd,&efr,FALSE);
+
+ SendMessage(hwnd,SCI_ENDUNDOACTION,0,0);
+ }
+ else
+ MsgBox(MBINFO,IDS_SELRECT);
+ }
+}
+
+
+//=============================================================================
+//
+// EditModifyNumber()
+//
+void EditModifyNumber(HWND hwnd,BOOL bIncrease) {
+
+ if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) {
+
+ int iSelStart = SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0);
+ int iSelEnd = SendMessage(hwnd,SCI_GETSELECTIONEND,0,0);
+
+ if (iSelEnd - iSelStart) {
+
+ char chFormat[32] = "";
+ char chNumber[32];
+ int iNumber;
+ int iWidth;
+
+ if (SendMessage(hwnd,SCI_GETSELTEXT,0,0) <= COUNTOF(chNumber)) {
+ SendMessage(hwnd,SCI_GETSELTEXT,0,(LPARAM)chNumber);
+
+ if (StrChrIA(chNumber,'-'))
+ return;
+
+ if (!StrChrIA(chNumber,'x') && sscanf(chNumber,"%d",&iNumber) == 1) {
+ iWidth = lstrlenA(chNumber);
+ if (iNumber >= 0) {
+ if (bIncrease && iNumber < INT_MAX)
+ iNumber++;
+ if (!bIncrease && iNumber > 0)
+ iNumber--;
+ wsprintfA(chFormat,"%%0%ii",iWidth);
+ wsprintfA(chNumber,chFormat,iNumber);
+ SendMessage(hwnd,SCI_REPLACESEL,0,(LPARAM)chNumber);
+ SendMessage(hwnd,SCI_SETSEL,iSelStart,iSelStart+lstrlenA(chNumber));
+ }
+ }
+ else if (sscanf(chNumber,"%x",&iNumber) == 1) {
+ int i;
+ BOOL bUppercase = FALSE;
+ iWidth = lstrlenA(chNumber) - 2;
+ if (iNumber >= 0) {
+ if (bIncrease && iNumber < INT_MAX)
+ iNumber++;
+ if (!bIncrease && iNumber > 0)
+ iNumber--;
+ for (i = lstrlenA(chNumber) -1 ; i >= 0; i--) {
+ if (IsCharLowerA(chNumber[i]))
+ break;
+ else if (IsCharUpper(chNumber[i])) {
+ bUppercase = TRUE;
+ break;
+ }
+ }
+ if (bUppercase)
+ wsprintfA(chFormat,"%%#0%iX",iWidth);
+ else
+ wsprintfA(chFormat,"%%#0%ix",iWidth);
+ wsprintfA(chNumber,chFormat,iNumber);
+ SendMessage(hwnd,SCI_REPLACESEL,0,(LPARAM)chNumber);
+ SendMessage(hwnd,SCI_SETSEL,iSelStart,iSelStart+lstrlenA(chNumber));
+ }
+ }
+ }
+ }
+ }
+ else
+ MsgBox(MBINFO,IDS_SELRECT);
+}
+
+
+//=============================================================================
+//
+// EditTabsToSpaces()
+//
+void EditTabsToSpaces(HWND hwnd,int nTabWidth,BOOL bOnlyIndentingWS)
+{
+ char* pszText;
+ LPWSTR pszTextW;
+ int cchTextW;
+ int iTextW;
+ LPWSTR pszConvW;
+ int cchConvW;
+ int cchConvM;
+ int i,j;
+ int iLine;
+ int iCurPos;
+ int iAnchorPos;
+ int iSelStart;
+ int iSelEnd;
+ int iSelCount;
+ UINT cpEdit;
+ struct TextRange tr;
+ BOOL bIsLineStart = TRUE;
+ BOOL bModified = FALSE;
+
+ if (SC_SEL_RECTANGLE == SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) {
+ MsgBox(MBINFO,IDS_SELRECT);
+ return;
+ }
+
+ iCurPos = SendMessage(hwnd,SCI_GETCURRENTPOS,0,0);
+ iAnchorPos = SendMessage(hwnd,SCI_GETANCHOR,0,0);
+
+ if (iCurPos == iAnchorPos) /*{
+ iSelStart = 0;
+ iSelEnd = SendMessage(hwnd,SCI_GETLENGTH,0,0);
+ }*/
+ return;
+
+ else {
+ iSelStart = SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0);
+ iSelEnd = SendMessage(hwnd,SCI_GETSELECTIONEND,0,0);
+ }
+
+ iLine = SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0);
+ iSelStart = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0);
+
+ iSelCount = iSelEnd - iSelStart;
+
+ pszText = GlobalAlloc(GPTR,(iSelCount)+2);
+ if (pszText == NULL)
+ return;
+
+ pszTextW = GlobalAlloc(GPTR,(iSelCount*2)+2);
+ if (pszTextW == NULL) {
+ GlobalFree(pszText);
+ return;
+ }
+
+ tr.chrg.cpMin = iSelStart;
+ tr.chrg.cpMax = iSelEnd;
+ tr.lpstrText = pszText;
+ SendMessage(hwnd,SCI_GETTEXTRANGE,0,(LPARAM)&tr);
+
+ cpEdit = SendMessage(hwnd,SCI_GETCODEPAGE,0,0);
+
+ cchTextW = MultiByteToWideChar(cpEdit,0,pszText,iSelCount,pszTextW,GlobalSize(pszTextW)/sizeof(WCHAR));
+ GlobalFree(pszText);
+
+ pszConvW = GlobalAlloc(GPTR,cchTextW*sizeof(WCHAR)*nTabWidth+2);
+ if (pszConvW == NULL) {
+ GlobalFree(pszTextW);
+ return;
+ }
+
+ cchConvW = 0;
+
+ // Contributed by Homam
+ // Thank you very much!
+ i=0;
+ for (iTextW = 0; iTextW < cchTextW; iTextW++)
+ {
+ WCHAR w = pszTextW[iTextW];
+ if (w == L'\t' && (!bOnlyIndentingWS || bOnlyIndentingWS && bIsLineStart)) {
+ for (j = 0; j < nTabWidth - i % nTabWidth; j++)
+ pszConvW[cchConvW++] = L' ';
+ i = 0;
+ bModified = TRUE;
+ }
+ else {
+ i++;
+ if (w == L'\n' || w == L'\r') {
+ i = 0;
+ bIsLineStart = TRUE;
+ }
+ else if (w != L' ')
+ bIsLineStart = FALSE;
+ pszConvW[cchConvW++] = w;
+ }
+ }
+
+ GlobalFree(pszTextW);
+
+ if (bModified) {
+ pszText = GlobalAlloc(GPTR,cchConvW * 3);
+
+ cchConvM = WideCharToMultiByte(cpEdit,0,pszConvW,cchConvW,pszText,GlobalSize(pszText),NULL,NULL);
+ GlobalFree(pszConvW);
+
+ if (iAnchorPos > iCurPos) {
+ iCurPos = iSelStart;
+ iAnchorPos = iSelStart + cchConvM;
+ }
+ else {
+ iAnchorPos = iSelStart;
+ iCurPos = iSelStart + cchConvM;
+ }
+
+ SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0);
+ SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iSelStart,0);
+ SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iSelEnd,0);
+ SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)cchConvM,(LPARAM)pszText);
+ //SendMessage(hwnd,SCI_CLEAR,0,0);
+ //SendMessage(hwnd,SCI_ADDTEXT,(WPARAM)cchConvW,(LPARAM)pszText);
+ SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos);
+ SendMessage(hwnd,SCI_ENDUNDOACTION,0,0);
+
+ GlobalFree(pszText);
+ }
+
+ else
+ GlobalFree(pszConvW);
+}
+
+
+//=============================================================================
+//
+// EditSpacesToTabs()
+//
+void EditSpacesToTabs(HWND hwnd,int nTabWidth,BOOL bOnlyIndentingWS)
+{
+ char* pszText;
+ LPWSTR pszTextW;
+ int cchTextW;
+ int iTextW;
+ LPWSTR pszConvW;
+ int cchConvW;
+ int cchConvM;
+ int i,j,t;
+ int iLine;
+ int iCurPos;
+ int iAnchorPos;
+ int iSelStart;
+ int iSelEnd;
+ int iSelCount;
+ UINT cpEdit;
+ struct TextRange tr;
+ WCHAR space[256];
+ BOOL bIsLineStart = TRUE;
+ BOOL bModified = FALSE;
+
+ if (SC_SEL_RECTANGLE == SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) {
+ MsgBox(MBINFO,IDS_SELRECT);
+ return;
+ }
+
+ iCurPos = SendMessage(hwnd,SCI_GETCURRENTPOS,0,0);
+ iAnchorPos = SendMessage(hwnd,SCI_GETANCHOR,0,0);
+
+ if (iCurPos == iAnchorPos) /*{
+ iSelStart = 0;
+ iSelEnd = SendMessage(hwnd,SCI_GETLENGTH,0,0);
+ }*/
+ return;
+
+ else {
+ iSelStart = SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0);
+ iSelEnd = SendMessage(hwnd,SCI_GETSELECTIONEND,0,0);
+ }
+
+ iLine = SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0);
+ iSelStart = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0);
+
+ iSelCount = iSelEnd - iSelStart;
+
+ pszText = GlobalAlloc(GPTR,(iSelCount)+2);
+ if (pszText == NULL)
+ return;
+
+ pszTextW = GlobalAlloc(GPTR,(iSelCount*2)+2);
+ if (pszTextW == NULL) {
+ GlobalFree(pszText);
+ return;
+ }
+
+ tr.chrg.cpMin = iSelStart;
+ tr.chrg.cpMax = iSelEnd;
+ tr.lpstrText = pszText;
+ SendMessage(hwnd,SCI_GETTEXTRANGE,0,(LPARAM)&tr);
+
+ cpEdit = SendMessage(hwnd,SCI_GETCODEPAGE,0,0);
+
+ cchTextW = MultiByteToWideChar(cpEdit,0,pszText,iSelCount,pszTextW,GlobalSize(pszTextW)/sizeof(WCHAR));
+ GlobalFree(pszText);
+
+ pszConvW = GlobalAlloc(GPTR,cchTextW*sizeof(WCHAR)+2);
+ if (pszConvW == NULL) {
+ GlobalFree(pszTextW);
+ return;
+ }
+
+ cchConvW = 0;
+
+ // Contributed by Homam
+ // Thank you very much!
+ i = j = 0;
+ for (iTextW = 0; iTextW < cchTextW; iTextW++)
+ {
+ WCHAR w = pszTextW[iTextW];
+ if ((w == L' ' || w == L'\t') && (!bOnlyIndentingWS || bOnlyIndentingWS && bIsLineStart)) {
+ space[j++] = w;
+ if (j == nTabWidth - i % nTabWidth || w == L'\t') {
+ if (j > 1 || pszTextW[iTextW+1] == L' ' || pszTextW[iTextW+1] == L'\t')
+ pszConvW[cchConvW++] = L'\t';
+ else
+ pszConvW[cchConvW++] = w;
+ i = j = 0;
+ bModified = bModified || (w != pszConvW[cchConvW-1]);
+ }
+ }
+ else {
+ i += j + 1;
+ if (j > 0) {
+ //space[j] = '\0';
+ for (t = 0; t < j; t++)
+ pszConvW[cchConvW++] = space[t];
+ j = 0;
+ }
+ if (w == L'\n' || w == L'\r') {
+ i = 0;
+ bIsLineStart = TRUE;
+ }
+ else
+ bIsLineStart = FALSE;
+ pszConvW[cchConvW++] = w;
+ }
+ }
+ if (j > 0) {
+ for (t = 0; t < j; t++)
+ pszConvW[cchConvW++] = space[t];
+ }
+
+ GlobalFree(pszTextW);
+
+ if (bModified || cchConvW != cchTextW) {
+ pszText = GlobalAlloc(GPTR,cchConvW * 3);
+
+ cchConvM = WideCharToMultiByte(cpEdit,0,pszConvW,cchConvW,pszText,GlobalSize(pszText),NULL,NULL);
+ GlobalFree(pszConvW);
+
+ if (iAnchorPos > iCurPos) {
+ iCurPos = iSelStart;
+ iAnchorPos = iSelStart + cchConvM;
+ }
+ else {
+ iAnchorPos = iSelStart;
+ iCurPos = iSelStart + cchConvM;
+ }
+
+ SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0);
+ SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iSelStart,0);
+ SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iSelEnd,0);
+ SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)cchConvM,(LPARAM)pszText);
+ //SendMessage(hwnd,SCI_CLEAR,0,0);
+ //SendMessage(hwnd,SCI_ADDTEXT,(WPARAM)cchConvW,(LPARAM)pszText);
+ SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos);
+ SendMessage(hwnd,SCI_ENDUNDOACTION,0,0);
+
+ GlobalFree(pszText);
+ }
+
+ else
+ GlobalFree(pszConvW);
+}
+
+
+//=============================================================================
+//
+// EditMoveUp()
+//
+void EditMoveUp(HWND hwnd)
+{
+
+ int iCurPos = SendMessage(hwnd,SCI_GETCURRENTPOS,0,0);
+ int iAnchorPos = SendMessage(hwnd,SCI_GETANCHOR,0,0);
+ int iCurLine = SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iCurPos,0);
+ int iAnchorLine = SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iAnchorPos,0);
+
+ if (iCurLine == iAnchorLine) {
+
+ int iLineCurPos = iCurPos - SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iCurLine,0);
+ int iLineAnchorPos = iAnchorPos - SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iAnchorLine,0);
+ if (iCurLine > 0) {
+
+ SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0);
+ SendMessage(hwnd,SCI_LINETRANSPOSE,0,0);
+ SendMessage(hwnd,SCI_SETSEL,
+ (WPARAM)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iAnchorLine-1,0)+iLineAnchorPos,
+ (LPARAM)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iCurLine-1,0)+iLineCurPos);
+ SendMessage(hwnd,SCI_CHOOSECARETX,0,0);
+ SendMessage(hwnd,SCI_ENDUNDOACTION,0,0);
+ }
+ }
+ else if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) {
+
+ int iLineSrc = min(iCurLine,iAnchorLine) -1;
+ if (iLineSrc >= 0) {
+
+ DWORD cLine;
+ char *pLine;
+ int iLineSrcStart;
+ int iLineSrcEnd;
+ int iLineDest;
+ int iLineDestStart;
+
+ cLine = SendMessage(hwnd,SCI_GETLINE,(WPARAM)iLineSrc,0);
+ pLine = LocalAlloc(LPTR,cLine+1);
+ SendMessage(hwnd,SCI_GETLINE,(WPARAM)iLineSrc,(LPARAM)pLine);
+
+ iLineSrcStart = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineSrc,0);
+ iLineSrcEnd = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineSrc+1,0);
+
+ iLineDest = max(iCurLine,iAnchorLine);
+ if (max(iCurPos,iAnchorPos) <= SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineDest,0)) {
+ if (iLineDest >= 1)
+ iLineDest--;
+ }
+
+ SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0);
+
+ SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iLineSrcStart,0);
+ SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iLineSrcEnd,0);
+ SendMessage(hwnd,SCI_REPLACETARGET,0,(LPARAM)"");
+
+ iLineDestStart = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineDest,0);
+
+ SendMessage(hwnd,SCI_INSERTTEXT,(WPARAM)iLineDestStart,(LPARAM)pLine);
+
+ LocalFree(pLine);
+
+ if (iLineDest == SendMessage(hwnd,SCI_GETLINECOUNT,0,0) -1) {
+
+ char chaEOL[] = "\r\n";
+ int iEOLMode = SendMessage(hwnd,SCI_GETEOLMODE,0,0);
+ if (iEOLMode == SC_EOL_CR)
+ chaEOL[1] = 0;
+ else if (iEOLMode == SC_EOL_LF) {
+ chaEOL[0] = '\n';
+ chaEOL[1] = 0;
+ }
+
+ SendMessage(hwnd,SCI_INSERTTEXT,(WPARAM)iLineDestStart,(LPARAM)chaEOL);
+ SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)
+ SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLineDest,0),0);
+ SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)
+ SendMessage(hwnd,SCI_GETLENGTH,0,0),0);
+ SendMessage(hwnd,SCI_REPLACETARGET,0,(LPARAM)"");
+ }
+
+ if (iCurPos < iAnchorPos) {
+ iCurPos = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iCurLine-1,0);
+ iAnchorPos = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineDest,0);
+ }
+ else {
+ iAnchorPos = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iAnchorLine-1,0);
+ iCurPos = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineDest,0);
+ }
+ SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos);
+
+ SendMessage(hwnd,SCI_ENDUNDOACTION,0,0);
+ }
+ }
+ else
+ MsgBox(MBINFO,IDS_SELRECT);
+}
+
+
+//=============================================================================
+//
+// EditMoveDown()
+//
+void EditMoveDown(HWND hwnd)
+{
+
+ int iCurPos = SendMessage(hwnd,SCI_GETCURRENTPOS,0,0);
+ int iAnchorPos = SendMessage(hwnd,SCI_GETANCHOR,0,0);
+ int iCurLine = SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iCurPos,0);
+ int iAnchorLine = SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iAnchorPos,0);
+
+ if (iCurLine == iAnchorLine) {
+
+ int iLineCurPos = iCurPos - SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iCurLine,0);
+ int iLineAnchorPos = iAnchorPos - SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iAnchorLine,0);
+ if (iCurLine < SendMessage(hwndEdit,SCI_GETLINECOUNT,0,0) - 1) {
+ SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0);
+ SendMessage(hwnd,SCI_GOTOLINE,(WPARAM)iCurLine+1,0);
+ SendMessage(hwnd,SCI_LINETRANSPOSE,0,0);
+ SendMessage(hwnd,SCI_SETSEL,
+ (WPARAM)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iAnchorLine+1,0)+iLineAnchorPos,
+ (LPARAM)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iCurLine+1,0)+iLineCurPos);
+ SendMessage(hwnd,SCI_CHOOSECARETX,0,0);
+ SendMessage(hwnd,SCI_ENDUNDOACTION,0,0);
+ }
+ }
+ else if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) {
+
+ int iLineSrc = max(iCurLine,iAnchorLine) +1;
+ if (max(iCurPos,iAnchorPos) <= SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineSrc-1,0)) {
+ if (iLineSrc >= 1)
+ iLineSrc--;
+ }
+
+ if (iLineSrc <= SendMessage(hwnd,SCI_GETLINECOUNT,0,0) -1) {
+
+ DWORD cLine;
+ char *pLine;
+ int iLineSrcStart;
+ int iLineSrcEnd;
+ int iLineDest;
+ int iLineDestStart;
+
+ BOOL bLastLine = (iLineSrc == SendMessage(hwnd,SCI_GETLINECOUNT,0,0) -1);
+
+ if (bLastLine &&
+ (SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLineSrc,0) -
+ SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineSrc,0) == 0) &&
+ (SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLineSrc-1,0) -
+ SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineSrc-1,0) == 0))
+ return;
+
+ if (bLastLine) {
+ char chaEOL[] = "\r\n";
+ int iEOLMode = SendMessage(hwnd,SCI_GETEOLMODE,0,0);
+ if (iEOLMode == SC_EOL_CR)
+ chaEOL[1] = 0;
+ else if (iEOLMode == SC_EOL_LF) {
+ chaEOL[0] = '\n';
+ chaEOL[1] = 0;
+ }
+ SendMessage(hwnd,SCI_APPENDTEXT,(WPARAM)lstrlenA(chaEOL),(LPARAM)chaEOL);
+ }
+
+ cLine = SendMessage(hwnd,SCI_GETLINE,(WPARAM)iLineSrc,0);
+ pLine = LocalAlloc(LPTR,cLine+3);
+ SendMessage(hwnd,SCI_GETLINE,(WPARAM)iLineSrc,(LPARAM)pLine);
+
+ iLineSrcStart = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineSrc,0);
+ iLineSrcEnd = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineSrc+1,0);
+
+ iLineDest = min(iCurLine,iAnchorLine);
+
+ SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0);
+
+ SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iLineSrcStart,0);
+ SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iLineSrcEnd,0);
+ SendMessage(hwnd,SCI_REPLACETARGET,0,(LPARAM)"");
+
+ iLineDestStart = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineDest,0);
+
+ SendMessage(hwnd,SCI_INSERTTEXT,(WPARAM)iLineDestStart,(LPARAM)pLine);
+
+ if (bLastLine) {
+ SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)
+ SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)
+ SendMessage(hwnd,SCI_GETLINECOUNT,0,0)-2,0),0);
+ SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)
+ SendMessage(hwnd,SCI_GETLENGTH,0,0),0);
+ SendMessage(hwnd,SCI_REPLACETARGET,0,(LPARAM)"");
+ }
+
+ LocalFree(pLine);
+
+ if (iCurPos < iAnchorPos) {
+ iCurPos = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iCurLine+1,0);
+ iAnchorPos = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineSrc+1,0);
+ }
+ else {
+ iAnchorPos = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iAnchorLine+1,0);
+ iCurPos = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineSrc+1,0);
+ }
+ SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos);
+
+ SendMessage(hwnd,SCI_ENDUNDOACTION,0,0);
+ }
+ }
+ else
+ MsgBox(MBINFO,IDS_SELRECT);
+}
+
+
+//=============================================================================
+//
+// EditModifyLines()
+//
+void EditModifyLines(HWND hwnd,LPCWSTR pwszPrefix,LPCWSTR pwszAppend)
+{
+ char mszPrefix[256*3] = "";
+ char mszAppend[256*3] = "";
+ int mbcp;
+
+ int iSelStart = SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0);
+ int iSelEnd = SendMessage(hwnd,SCI_GETSELECTIONEND,0,0);
+
+ //if (iSelStart == iSelEnd) {
+ // iSelStart = 0;
+ // iSelEnd = SendMessage(hwnd,SCI_GETLENGTH,0,0);
+ //}
+
+ if (SendMessage(hwnd,SCI_GETCODEPAGE,0,0) == SC_CP_UTF8)
+ mbcp = CP_UTF8;
+ else
+ mbcp = CP_ACP;
+
+ if (lstrlen(pwszPrefix))
+ WideCharToMultiByte(mbcp,0,pwszPrefix,-1,mszPrefix,COUNTOF(mszPrefix),NULL,NULL);
+ if (lstrlen(pwszAppend))
+ WideCharToMultiByte(mbcp,0,pwszAppend,-1,mszAppend,COUNTOF(mszAppend),NULL,NULL);
+
+ if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0))
+ {
+ int iLine;
+
+ int iLineStart = SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0);
+ int iLineEnd = SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelEnd,0);
+
+ //if (iSelStart > SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0))
+ // iLineStart++;
+
+ if (iSelEnd <= SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd,0))
+ {
+ if (iLineEnd - iLineStart >= 1)
+ iLineEnd--;
+ }
+
+ SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0);
+
+ for (iLine = iLineStart; iLine <= iLineEnd; iLine++)
+ {
+ int iPos;
+
+ if (lstrlen(pwszPrefix)) {
+ iPos = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0);
+ SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iPos,0);
+ SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iPos,0);
+ SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)lstrlenA(mszPrefix),(LPARAM)mszPrefix);
+ }
+
+ if (lstrlen(pwszAppend)) {
+ iPos = SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0);
+ SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iPos,0);
+ SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iPos,0);
+ SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)lstrlenA(mszAppend),(LPARAM)mszAppend);
+ }
+ }
+ SendMessage(hwnd,SCI_ENDUNDOACTION,0,0);
+
+ //// Fix selection
+ //if (iSelStart != iSelEnd && SendMessage(hwnd,SCI_GETTARGETEND,0,0) > SendMessage(hwnd,SCI_GETSELECTIONEND,0,0))
+ //{
+ // int iCurPos = SendMessage(hwnd,SCI_GETCURRENTPOS,0,0);
+ // int iAnchorPos = SendMessage(hwnd,SCI_GETANCHOR,0,0);
+ // if (iCurPos > iAnchorPos)
+ // iCurPos = SendMessage(hwnd,SCI_GETTARGETEND,0,0);
+ // else
+ // iAnchorPos = SendMessage(hwnd,SCI_GETTARGETEND,0,0);
+ // SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos);
+ //}
+
+ // extend selection to start of first line
+ // the above code is not required when last line has been excluded
+ if (iSelStart != iSelEnd)
+ {
+ int iCurPos = SendMessage(hwnd,SCI_GETCURRENTPOS,0,0);
+ int iAnchorPos = SendMessage(hwnd,SCI_GETANCHOR,0,0);
+ if (iCurPos < iAnchorPos) {
+ iCurPos = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0);
+ iAnchorPos = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd+1,0);
+ }
+ else {
+ iAnchorPos = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0);
+ iCurPos = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd+1,0);
+ }
+ SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos);
+ }
+
+ }
+ else
+ MsgBox(MBINFO,IDS_SELRECT);
+}
+
+
+//=============================================================================
+//
+// EditEncloseSelection()
+//
+void EditEncloseSelection(HWND hwnd,LPCWSTR pwszOpen,LPCWSTR pwszClose)
+{
+ char mszOpen[256*3] = "";
+ char mszClose[256*3] = "";
+ int mbcp;
+
+ int iSelStart = SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0);
+ int iSelEnd = SendMessage(hwnd,SCI_GETSELECTIONEND,0,0);
+
+ if (SendMessage(hwnd,SCI_GETCODEPAGE,0,0) == SC_CP_UTF8)
+ mbcp = CP_UTF8;
+ else
+ mbcp = CP_ACP;
+
+ if (lstrlen(pwszOpen))
+ WideCharToMultiByte(mbcp,0,pwszOpen,-1,mszOpen,COUNTOF(mszOpen),NULL,NULL);
+ if (lstrlen(pwszClose))
+ WideCharToMultiByte(mbcp,0,pwszClose,-1,mszClose,COUNTOF(mszClose),NULL,NULL);
+
+ if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0))
+ {
+
+ SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0);
+
+ if (lstrlenA(mszOpen)) {
+ SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iSelStart,0);
+ SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iSelStart,0);
+ SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)lstrlenA(mszOpen),(LPARAM)mszOpen);
+ }
+
+ if (lstrlenA(mszClose)) {
+ SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iSelEnd + lstrlenA(mszOpen),0);
+ SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iSelEnd + lstrlenA(mszOpen),0);
+ SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)lstrlenA(mszClose),(LPARAM)mszClose);
+ }
+
+ SendMessage(hwnd,SCI_ENDUNDOACTION,0,0);
+
+ // Fix selection
+ if (iSelStart == iSelEnd)
+ SendMessage(hwnd,SCI_SETSEL,(WPARAM)iSelStart + lstrlenA(mszOpen),(WPARAM)iSelStart + lstrlenA(mszOpen));
+
+ else {
+ int iCurPos = SendMessage(hwnd,SCI_GETCURRENTPOS,0,0);
+ int iAnchorPos = SendMessage(hwnd,SCI_GETANCHOR,0,0);
+ if (iCurPos < iAnchorPos) {
+ iCurPos = iSelStart + lstrlenA(mszOpen);
+ iAnchorPos = iSelEnd + lstrlenA(mszOpen);
+ }
+ else {
+ iAnchorPos = iSelStart + lstrlenA(mszOpen);
+ iCurPos = iSelEnd + lstrlenA(mszOpen);
+ }
+ SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos);
+ }
+
+ }
+ else
+ MsgBox(MBINFO,IDS_SELRECT);
+}
+
+
+//=============================================================================
+//
+// EditToggleLineComments()
+//
+void EditToggleLineComments(HWND hwnd,LPCWSTR pwszComment,BOOL bInsertAtStart)
+{
+ char mszComment[256*3] = "";
+ int cchComment;
+ int mbcp;
+ int iAction = 0;
+
+ int iSelStart = SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0);
+ int iSelEnd = SendMessage(hwnd,SCI_GETSELECTIONEND,0,0);
+ int iCurPos = SendMessage(hwnd,SCI_GETCURRENTPOS,0,0);
+
+ if (SendMessage(hwnd,SCI_GETCODEPAGE,0,0) == SC_CP_UTF8)
+ mbcp = CP_UTF8;
+ else
+ mbcp = CP_ACP;
+
+ if (lstrlen(pwszComment))
+ WideCharToMultiByte(mbcp,0,pwszComment,-1,mszComment,COUNTOF(mszComment),NULL,NULL);
+ cchComment = lstrlenA(mszComment);
+
+ if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0) && cchComment)
+ {
+ int iLine;
+ int iCommentCol = 0;
+
+ int iLineStart = SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0);
+ int iLineEnd = SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelEnd,0);
+
+ if (iSelEnd <= SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd,0))
+ {
+ if (iLineEnd - iLineStart >= 1)
+ iLineEnd--;
+ }
+
+ if (!bInsertAtStart) {
+ iCommentCol = 1024;
+ for (iLine = iLineStart; iLine <= iLineEnd; iLine++) {
+ int iLineEndPos = SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0);
+ int iLineIndentPos = SendMessage(hwnd,SCI_GETLINEINDENTPOSITION,(WPARAM)iLine,0);
+ if (iLineIndentPos != iLineEndPos) {
+ int iIndentColumn = SendMessage(hwnd,SCI_GETCOLUMN,(WPARAM)iLineIndentPos,0);
+ iCommentCol = min(iCommentCol,iIndentColumn);
+ }
+ }
+ }
+
+ SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0);
+
+ for (iLine = iLineStart; iLine <= iLineEnd; iLine++)
+ {
+ int iCommentPos;
+ int iIndentPos = SendMessage(hwnd,SCI_GETLINEINDENTPOSITION,(WPARAM)iLine,0);
+ char tchBuf[32];
+ struct TextRange tr;
+
+ if (iIndentPos == SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0))
+ continue;
+
+ tr.chrg.cpMin = iIndentPos;
+ tr.chrg.cpMax = tr.chrg.cpMin + min(31,cchComment);
+ tr.lpstrText = tchBuf;
+ SendMessage(hwnd,SCI_GETTEXTRANGE,0,(LPARAM)&tr);
+
+ if (StrCmpNIA(tchBuf,mszComment,cchComment) == 0) {
+ switch (iAction) {
+ case 0:
+ iAction = 2;
+ case 2:
+ SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iIndentPos,0);
+ SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iIndentPos+cchComment,0);
+ SendMessage(hwnd,SCI_REPLACETARGET,0,(LPARAM)"");
+ break;
+ case 1:
+ break;
+ }
+ }
+ else {
+ switch (iAction) {
+ case 0:
+ iAction = 1;
+ case 1:
+ iCommentPos = SendMessage(hwnd,SCI_FINDCOLUMN,(WPARAM)iLine,(LPARAM)iCommentCol);
+ SendMessage(hwnd,SCI_INSERTTEXT,(WPARAM)iCommentPos,(LPARAM)mszComment);
+ break;
+ case 2:
+ break;
+ }
+ }
+ }
+ SendMessage(hwnd,SCI_ENDUNDOACTION,0,0);
+
+ // extend selection to start of first line
+ // the above code is not required when last line has been excluded
+ if (iSelStart != iSelEnd)
+ {
+ int iAnchorPos;
+ if (iCurPos == iSelStart) {
+ iCurPos = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0);
+ iAnchorPos = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd+1,0);
+ }
+ else {
+ iAnchorPos = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0);
+ iCurPos = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd+1,0);
+ }
+ SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos);
+ }
+
+ }
+ else
+ MsgBox(MBINFO,IDS_SELRECT);
+}
+
+
+//=============================================================================
+//
+// EditPadWithSpaces()
+//
+void EditPadWithSpaces(HWND hwnd)
+{
+ char *pmszPadStr;
+ int iMaxColumn = 0;
+ int iLine;
+ BOOL bIsRectangular = FALSE;
+
+ int iSelStart;
+ int iSelEnd;
+
+ int iLineStart;
+ int iLineEnd;
+
+ int iRcCurLine;
+ int iRcAnchorLine;
+ int iRcCurCol;
+ int iRcAnchorCol;
+
+ if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) {
+
+ iSelStart = SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0);
+ iSelEnd = SendMessage(hwnd,SCI_GETSELECTIONEND,0,0);
+
+ iLineStart = SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0);
+ iLineEnd = SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelEnd,0);
+
+ if (iLineStart == iLineEnd) {
+ iLineStart = 0;
+ iLineEnd = SendMessage(hwnd,SCI_GETLINECOUNT,0,0) -1;
+ }
+
+ for (iLine = iLineStart; iLine <= iLineEnd; iLine++) {
+
+ int iPos = SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0);
+ iMaxColumn = max(iMaxColumn,SendMessage(hwnd,SCI_GETCOLUMN,(WPARAM)iPos,0));
+ }
+ }
+ else {
+
+ int iCurPos = SendMessage(hwnd,SCI_GETCURRENTPOS,0,0);
+ int iAnchorPos = SendMessage(hwnd,SCI_GETANCHOR,0,0);
+
+ iRcCurLine = SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iCurPos,0);
+ iRcAnchorLine = SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iAnchorPos,0);
+
+ iRcCurCol = SendMessage(hwnd,SCI_GETCOLUMN,(WPARAM)iCurPos,0);
+ iRcAnchorCol = SendMessage(hwnd,SCI_GETCOLUMN,(WPARAM)iAnchorPos,0);
+
+ bIsRectangular = TRUE;
+
+ iLineStart = 0;
+ iLineEnd = SendMessage(hwnd,SCI_GETLINECOUNT,0,0) -1;
+
+ for (iLine = iLineStart; iLine <= iLineEnd; iLine++) {
+
+ int iPos = SendMessage(hwnd,SCI_GETLINESELENDPOSITION,(WPARAM)iLine,0);
+ if (iPos != INVALID_POSITION)
+ iMaxColumn = max(iMaxColumn,SendMessage(hwnd,SCI_GETCOLUMN,(WPARAM)iPos,0));
+ }
+ }
+
+ pmszPadStr = LocalAlloc(LPTR,(iMaxColumn +1 )* sizeof(char));
+ if (pmszPadStr) {
+
+ FillMemory(pmszPadStr,LocalSize(pmszPadStr),' ');
+
+ SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0);
+
+ for (iLine = iLineStart; iLine <= iLineEnd; iLine++) {
+
+ int iPos;
+ int iPadLen;
+ int iLineSelEndPos;
+
+ iLineSelEndPos = SendMessage(hwnd,SCI_GETLINESELENDPOSITION,(WPARAM)iLine,0);
+ if (bIsRectangular && INVALID_POSITION == iLineSelEndPos)
+ continue;
+
+ iPos = SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0);
+ if (bIsRectangular && iPos > iLineSelEndPos)
+ continue;
+
+ iPadLen = iMaxColumn - SendMessage(hwnd,SCI_GETCOLUMN,(WPARAM)iPos,0);
+
+ SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iPos,0);
+ SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iPos,0);
+ SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)iPadLen,(LPARAM)pmszPadStr);
+ }
+ SendMessage(hwnd,SCI_ENDUNDOACTION,0,0);
+ }
+
+ if (!bIsRectangular &&
+ SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0) !=
+ SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelEnd,0))
+ {
+ int iCurPos = SendMessage(hwnd,SCI_GETCURRENTPOS,0,0);
+ int iAnchorPos = SendMessage(hwnd,SCI_GETANCHOR,0,0);
+ if (iCurPos < iAnchorPos) {
+ iCurPos = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0);
+ iAnchorPos = SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLineEnd,0);
+ }
+ else {
+ iAnchorPos = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0);
+ iCurPos = SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLineEnd,0);
+ }
+ SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos);
+ }
+
+ else if (bIsRectangular) {
+ int iCurPos = SendMessage(hwnd,SCI_FINDCOLUMN,(WPARAM)iRcCurLine,(LPARAM)iRcCurCol);
+ int iAnchorPos = SendMessage(hwnd,SCI_FINDCOLUMN,(WPARAM)iRcAnchorLine,(LPARAM)iRcAnchorCol);
+ SendMessage(hwnd,SCI_SETRECTANGULARSELECTIONCARET,(WPARAM)iCurPos,0);
+ SendMessage(hwnd,SCI_SETRECTANGULARSELECTIONANCHOR,(WPARAM)iAnchorPos,0);
+ }
+}
+
+
+//=============================================================================
+//
+// EditStripFirstCharacter()
+//
+void EditStripFirstCharacter(HWND hwnd)
+{
+ int iSelStart = SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0);
+ int iSelEnd = SendMessage(hwnd,SCI_GETSELECTIONEND,0,0);
+
+ if (iSelStart == iSelEnd) {
+ iSelStart = 0;
+ iSelEnd = SendMessage(hwnd,SCI_GETLENGTH,0,0);
+ }
+
+ if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0))
+ {
+ int iLine;
+
+ int iLineStart = SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0);
+ int iLineEnd = SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelEnd,0);
+
+ if (iSelStart > SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0))
+ iLineStart++;
+
+ if (iSelEnd <= SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd,0))
+ iLineEnd--;
+
+ SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0);
+
+ for (iLine = iLineStart; iLine <= iLineEnd; iLine++)
+ {
+ int iPos = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0);
+ if (SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0)- iPos > 0)
+ {
+ SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iPos,0);
+ SendMessage(hwnd,SCI_SETTARGETEND,
+ (WPARAM)SendMessage(hwnd,SCI_POSITIONAFTER,(WPARAM)iPos,0),0);
+ SendMessage(hwnd,SCI_REPLACETARGET,0,(LPARAM)"");
+ }
+ }
+ SendMessage(hwnd,SCI_ENDUNDOACTION,0,0);
+ }
+ else
+ MsgBox(MBINFO,IDS_SELRECT);
+}
+
+
+//=============================================================================
+//
+// EditStripLastCharacter()
+//
+void EditStripLastCharacter(HWND hwnd)
+{
+ int iSelStart = SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0);
+ int iSelEnd = SendMessage(hwnd,SCI_GETSELECTIONEND,0,0);
+
+ if (iSelStart == iSelEnd) {
+ iSelStart = 0;
+ iSelEnd = SendMessage(hwnd,SCI_GETLENGTH,0,0);
+ }
+
+ if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0))
+ {
+ int iLine;
+
+ int iLineStart = SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0);
+ int iLineEnd = SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelEnd,0);
+
+ if (iSelStart >= SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLineStart,0))
+ iLineStart++;
+
+ if (iSelEnd < SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLineEnd,0))
+ iLineEnd--;
+
+ SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0);
+
+ for (iLine = iLineStart; iLine <= iLineEnd; iLine++)
+ {
+ int iStartPos = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0);
+ int iEndPos = SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0);
+ if (iEndPos - iStartPos > 0)
+ {
+ SendMessage(hwnd,SCI_SETTARGETSTART,
+ (WPARAM)SendMessage(hwnd,SCI_POSITIONBEFORE,(WPARAM)iEndPos,0),0);
+ SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iEndPos,0);
+ SendMessage(hwnd,SCI_REPLACETARGET,0,(LPARAM)"");
+ }
+ }
+ SendMessage(hwnd,SCI_ENDUNDOACTION,0,0);
+ }
+ else
+ MsgBox(MBINFO,IDS_SELRECT);
+}
+
+
+//=============================================================================
+//
+// EditStripTrailingBlanks()
+//
+void EditStripTrailingBlanks(HWND hwnd,BOOL bIgnoreSelection)
+{
+ // Check if there is any selection... simply use a regular expression replace!
+ if (!bIgnoreSelection &&
+ (SendMessage(hwnd,SCI_GETSELECTIONEND,0,0) - SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0) != 0))
+ {
+ if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0))
+ {
+ EDITFINDREPLACE efrTrim = { "[ \t]+$", "", "", "", SCFIND_REGEXP, 0, 0, 0, 0, 0, hwnd };
+ EditReplaceAllInSelection(hwnd,&efrTrim,FALSE);
+ }
+ else
+ MsgBox(MBINFO,IDS_SELRECT);
+ }
+ // Code from SciTE...
+ else
+ {
+ int line;
+ int maxLines;
+ int lineStart;
+ int lineEnd;
+ int i;
+ char ch;
+
+ SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0);
+ maxLines = SendMessage(hwnd,SCI_GETLINECOUNT,0,0);
+ for (line = 0; line < maxLines; line++)
+ {
+ lineStart = SendMessage(hwnd,SCI_POSITIONFROMLINE,line,0);
+ lineEnd = SendMessage(hwnd,SCI_GETLINEENDPOSITION,line,0);
+ i = lineEnd-1;
+ ch = (char)SendMessage(hwnd,SCI_GETCHARAT,i,0);
+ while ((i >= lineStart) && ((ch == ' ') || (ch == '\t')))
+ {
+ i--;
+ ch = (char)SendMessage(hwnd,SCI_GETCHARAT,i,0);
+ }
+ if (i < (lineEnd-1))
+ {
+ SendMessage(hwnd,SCI_SETTARGETSTART,i + 1,0);
+ SendMessage(hwnd,SCI_SETTARGETEND,lineEnd,0);
+ SendMessage(hwnd,SCI_REPLACETARGET,0,(LPARAM)"");
+ }
+ }
+ SendMessage(hwnd,SCI_ENDUNDOACTION,0,0);
+ }
+}
+
+
+//=============================================================================
+//
+// EditCompressSpaces()
+//
+void EditCompressSpaces(HWND hwnd)
+{
+ if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0))
+ {
+ int iSelStart = SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0);
+ int iSelEnd = SendMessage(hwnd,SCI_GETSELECTIONEND,0,0);
+ int iCurPos = SendMessage(hwnd,SCI_GETCURRENTPOS,0,0);
+ int iAnchorPos = SendMessage(hwnd,SCI_GETANCHOR,0,0);
+ int iLineStart = SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0);
+ int iLineEnd = SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelEnd,0);
+ int iLength = SendMessage(hwnd,SCI_GETLENGTH,0,0);
+
+ char* pszIn;
+ char* pszOut;
+ BOOL bIsLineStart, bIsLineEnd;
+ BOOL bModified = FALSE;
+
+ if (iSelStart != iSelEnd) {
+ int cch = SendMessage(hwnd,SCI_GETSELTEXT,0,0);
+ pszIn = LocalAlloc(LPTR,cch);
+ pszOut = LocalAlloc(LPTR,cch);
+ SendMessage(hwnd,SCI_GETSELTEXT,0,(LPARAM)pszIn);
+ bIsLineStart =
+ (iSelStart == SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0));
+ bIsLineEnd =
+ (iSelEnd == SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLineEnd,0));
+ }
+ else {
+ int cch = iLength + 1;
+ pszIn = LocalAlloc(GPTR,cch);
+ pszOut = LocalAlloc(GPTR,cch);
+ SendMessage(hwnd,SCI_GETTEXT,(WPARAM)cch,(LPARAM)pszIn);
+ bIsLineStart = TRUE;
+ bIsLineEnd = TRUE;
+ }
+
+ if (pszIn && pszOut) {
+ char *ci, *co = pszOut;
+ for (ci = pszIn; *ci; ci++) {
+ if (*ci == ' ' || *ci == '\t') {
+ if (*ci == '\t')
+ bModified = TRUE;
+ while (*(ci+1) == ' ' || *(ci+1) == '\t') {
+ ci++;
+ bModified = TRUE;
+ }
+ if (!bIsLineStart && (*(ci+1) != '\n' && *(ci+1) != '\r'))
+ *co++ = ' ';
+ else
+ bModified = TRUE;
+ }
+ else {
+ if (*ci == '\n' || *ci == '\r')
+ bIsLineStart = TRUE;
+ else
+ bIsLineStart = FALSE;
+ *co++ = *ci;
+ }
+ }
+ if (bIsLineEnd && co > pszOut && *(co-1) == ' ') {
+ *--co = 0;
+ bModified = TRUE;
+ }
+
+ if (bModified) {
+ if (iSelStart != iSelEnd)
+ SendMessage(hwnd,SCI_TARGETFROMSELECTION,0,0);
+ else {
+ SendMessage(hwnd,SCI_SETTARGETSTART,0,0);
+ SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iLength,0);
+ }
+ SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0);
+ SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)-1,(LPARAM)pszOut);
+ if (iCurPos > iAnchorPos) {
+ iCurPos = SendMessage(hwnd,SCI_GETTARGETEND,0,0);
+ iAnchorPos = SendMessage(hwnd,SCI_GETTARGETSTART,0,0);
+ SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos);
+ }
+ else if (iCurPos < iAnchorPos) {
+ iCurPos = SendMessage(hwnd,SCI_GETTARGETSTART,0,0);
+ iAnchorPos = SendMessage(hwnd,SCI_GETTARGETEND,0,0);
+ SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos);
+ }
+ SendMessage(hwnd,SCI_ENDUNDOACTION,0,0);
+ }
+ }
+ if (pszIn)
+ LocalFree(pszIn);
+ if (pszOut)
+ LocalFree(pszOut);
+ }
+ else
+ MsgBox(MBINFO,IDS_SELRECT);
+}
+
+
+//=============================================================================
+//
+// EditRemoveBlankLines()
+//
+void EditRemoveBlankLines(HWND hwnd)
+{
+ int iSelStart = SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0);
+ int iSelEnd = SendMessage(hwnd,SCI_GETSELECTIONEND,0,0);
+
+ if (iSelStart == iSelEnd) {
+ iSelStart = 0;
+ iSelEnd = SendMessage(hwnd,SCI_GETLENGTH,0,0);
+ }
+
+ if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0))
+ {
+ int iLine;
+
+ int iLineStart = SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0);
+ int iLineEnd = SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelEnd,0);
+
+ if (iSelStart > SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0))
+ iLineStart++;
+
+ if (iSelEnd <= SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd,0))
+ iLineEnd--;
+
+ SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0);
+
+ for (iLine = iLineStart; iLine <= iLineEnd; )
+ {
+ int iPos = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0);
+ if (SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0) == iPos)
+ {
+ int iPos2 = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine+1,0);
+ SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iPos,0);
+ SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iPos2,0);
+ SendMessage(hwnd,SCI_REPLACETARGET,0,(LPARAM)"");
+ iLineEnd--;
+ }
+ else
+ iLine++;
+ }
+ SendMessage(hwnd,SCI_ENDUNDOACTION,0,0);
+ }
+ else
+ MsgBox(MBINFO,IDS_SELRECT);
+}
+
+
+//=============================================================================
+//
+// EditWrapToColumn()
+//
+void EditWrapToColumn(HWND hwnd,int nColumn/*,int nTabWidth*/)
+{
+ char* pszText;
+ LPWSTR pszTextW;
+ int cchTextW;
+ int iTextW;
+ LPWSTR pszConvW;
+ int cchConvW;
+ int cchConvM;
+ int iLineLength;
+ int iLine;
+ int iCurPos;
+ int iAnchorPos;
+ int iSelStart;
+ int iSelEnd;
+ int iSelCount;
+ UINT cpEdit;
+ struct TextRange tr;
+ int cEOLMode;
+ WCHAR wszEOL[] = L"\r\n";
+ int cchEOL = 2;
+ BOOL bModified = FALSE;
+
+ if (SC_SEL_RECTANGLE == SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) {
+ MsgBox(MBINFO,IDS_SELRECT);
+ return;
+ }
+
+ iCurPos = SendMessage(hwnd,SCI_GETCURRENTPOS,0,0);
+ iAnchorPos = SendMessage(hwnd,SCI_GETANCHOR,0,0);
+
+ if (iCurPos == iAnchorPos) /*{
+ iSelStart = 0;
+ iSelEnd = SendMessage(hwnd,SCI_GETLENGTH,0,0);
+ }*/
+ return;
+
+ else {
+ iSelStart = SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0);
+ iSelEnd = SendMessage(hwnd,SCI_GETSELECTIONEND,0,0);
+ }
+
+ iLine = SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0);
+ iSelStart = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0);
+
+ iSelCount = iSelEnd - iSelStart;
+
+ pszText = GlobalAlloc(GPTR,(iSelCount)+2);
+ if (pszText == NULL)
+ return;
+
+ pszTextW = GlobalAlloc(GPTR,(iSelCount*2)+2);
+ if (pszTextW == NULL) {
+ GlobalFree(pszText);
+ return;
+ }
+
+ tr.chrg.cpMin = iSelStart;
+ tr.chrg.cpMax = iSelEnd;
+ tr.lpstrText = pszText;
+ SendMessage(hwnd,SCI_GETTEXTRANGE,0,(LPARAM)&tr);
+
+ cpEdit = SendMessage(hwnd,SCI_GETCODEPAGE,0,0);
+
+ cchTextW = MultiByteToWideChar(cpEdit,0,pszText,iSelCount,pszTextW,GlobalSize(pszTextW)/sizeof(WCHAR));
+ GlobalFree(pszText);
+
+ pszConvW = GlobalAlloc(GPTR,cchTextW*sizeof(WCHAR)*3+2);
+ if (pszConvW == NULL) {
+ GlobalFree(pszTextW);
+ return;
+ }
+
+ cEOLMode = SendMessage(hwnd,SCI_GETEOLMODE,0,0);
+ if (cEOLMode == SC_EOL_CR)
+ cchEOL = 1;
+ else if (cEOLMode == SC_EOL_LF) {
+ cchEOL = 1; wszEOL[0] = L'\n';
+ }
+
+ cchConvW = 0;
+ iLineLength = 0;
+
+#define ISDELIMITER(wc) StrChr(L",;.:-+%&¦|/*?!\"\'~´#=",wc)
+#define ISWHITE(wc) StrChr(L" \t",wc)
+#define ISWORDEND(wc) (/*ISDELIMITER(wc) ||*/ StrChr(L" \t\r\n",wc))
+
+ for (iTextW = 0; iTextW < cchTextW; iTextW++)
+ {
+ WCHAR w;
+ w = pszTextW[iTextW];
+
+ //if (ISDELIMITER(w))
+ //{
+ // int iNextWordLen = 0;
+ // WCHAR w2 = pszTextW[iTextW + 1];
+
+ // if (iLineLength + iNextWordLen + 1 > nColumn) {
+ // pszConvW[cchConvW++] = wszEOL[0];
+ // if (cchEOL > 1)
+ // pszConvW[cchConvW++] = wszEOL[1];
+ // iLineLength = 0;
+ // bModified = TRUE;
+ // }
+
+ // while (w2 != L'\0' && !ISWORDEND(w2)) {
+ // iNextWordLen++;
+ // w2 = pszTextW[iTextW + iNextWordLen + 1];
+ // }
+
+ // if (ISDELIMITER(w2) && iNextWordLen > 0) // delimiters go with the word
+ // iNextWordLen++;
+
+ // pszConvW[cchConvW++] = w;
+ // iLineLength++;
+
+ // if (iNextWordLen > 0)
+ // {
+ // if (iLineLength + iNextWordLen + 1 > nColumn) {
+ // pszConvW[cchConvW++] = wszEOL[0];
+ // if (cchEOL > 1)
+ // pszConvW[cchConvW++] = wszEOL[1];
+ // iLineLength = 0;
+ // bModified = TRUE;
+ // }
+ // }
+ //}
+
+ if (ISWHITE(w))
+ {
+ int iNextWordLen = 0;
+ WCHAR w2;
+
+ while (pszTextW[iTextW+1] == L' ' || pszTextW[iTextW+1] == L'\t') {
+ iTextW++;
+ bModified = TRUE;
+ } // Modified: left out some whitespaces
+
+ w2 = pszTextW[iTextW + 1];
+
+ while (w2 != L'\0' && !ISWORDEND(w2)) {
+ iNextWordLen++;
+ w2 = pszTextW[iTextW + iNextWordLen + 1];
+ }
+
+ //if (ISDELIMITER(w2) /*&& iNextWordLen > 0*/) // delimiters go with the word
+ // iNextWordLen++;
+
+ if (iNextWordLen > 0)
+ {
+ if (iLineLength + iNextWordLen + 1 > nColumn) {
+ pszConvW[cchConvW++] = wszEOL[0];
+ if (cchEOL > 1)
+ pszConvW[cchConvW++] = wszEOL[1];
+ iLineLength = 0;
+ bModified = TRUE;
+ }
+ else {
+ if (iLineLength > 0) {
+ pszConvW[cchConvW++] = L' ';
+ iLineLength++;
+ }
+ }
+ }
+ }
+ else
+ {
+ pszConvW[cchConvW++] = w;
+ if (w == L'\r' || w == L'\n') {
+ iLineLength = 0;
+ }
+ else {
+ iLineLength++;
+ }
+ }
+ }
+
+ GlobalFree(pszTextW);
+
+ if (bModified) {
+ pszText = GlobalAlloc(GPTR,cchConvW * 3);
+
+ cchConvM = WideCharToMultiByte(cpEdit,0,pszConvW,cchConvW,pszText,GlobalSize(pszText),NULL,NULL);
+ GlobalFree(pszConvW);
+
+ if (iAnchorPos > iCurPos) {
+ iCurPos = iSelStart;
+ iAnchorPos = iSelStart + cchConvM;
+ }
+ else {
+ iAnchorPos = iSelStart;
+ iCurPos = iSelStart + cchConvM;
+ }
+
+ SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0);
+ SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iSelStart,0);
+ SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iSelEnd,0);
+ SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)cchConvM,(LPARAM)pszText);
+ //SendMessage(hwnd,SCI_CLEAR,0,0);
+ //SendMessage(hwnd,SCI_ADDTEXT,(WPARAM)cchConvW,(LPARAM)pszText);
+ SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos);
+ SendMessage(hwnd,SCI_ENDUNDOACTION,0,0);
+
+ GlobalFree(pszText);
+ }
+
+ else
+ GlobalFree(pszConvW);
+}
+
+
+//=============================================================================
+//
+// EditJoinLinesEx()
+//
+void EditJoinLinesEx(HWND hwnd)
+{
+ char* pszText;
+ char* pszJoin;
+ int cchJoin = 0;
+ int i;
+ int iLine;
+ int iCurPos;
+ int iAnchorPos;
+ int iSelStart;
+ int iSelEnd;
+ int iSelCount;
+ struct TextRange tr;
+ int cEOLMode;
+ char szEOL[] = "\r\n";
+ int cchEOL = 2;
+ BOOL bModified = FALSE;
+
+ if (SC_SEL_RECTANGLE == SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) {
+ MsgBox(MBINFO,IDS_SELRECT);
+ return;
+ }
+
+ iCurPos = SendMessage(hwnd,SCI_GETCURRENTPOS,0,0);
+ iAnchorPos = SendMessage(hwnd,SCI_GETANCHOR,0,0);
+
+ if (iCurPos == iAnchorPos)
+ return;
+
+ else {
+ iSelStart = SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0);
+ iSelEnd = SendMessage(hwnd,SCI_GETSELECTIONEND,0,0);
+ }
+
+ iLine = SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0);
+ iSelStart = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0);
+
+ iSelCount = iSelEnd - iSelStart;
+
+ pszText = LocalAlloc(LPTR,(iSelCount)+2);
+ if (pszText == NULL)
+ return;
+
+ pszJoin = LocalAlloc(LPTR,LocalSize(pszText));
+ if (pszJoin == NULL) {
+ LocalFree(pszText);
+ return;
+ }
+
+ tr.chrg.cpMin = iSelStart;
+ tr.chrg.cpMax = iSelEnd;
+ tr.lpstrText = pszText;
+ SendMessage(hwnd,SCI_GETTEXTRANGE,0,(LPARAM)&tr);
+
+ cEOLMode = SendMessage(hwnd,SCI_GETEOLMODE,0,0);
+ if (cEOLMode == SC_EOL_CR)
+ cchEOL = 1;
+ else if (cEOLMode == SC_EOL_LF) {
+ cchEOL = 1;
+ szEOL[0] = '\n';
+ }
+
+ cchJoin = 0;
+ for (i = 0; i < iSelCount; i++)
+ {
+ if (pszText[i] == '\r' || pszText[i] == '\n') {
+ if (pszText[i] == '\r' && pszText[i+1] == '\n')
+ i++;
+ if (!StrChrA("\r\n",pszText[i+1]) && pszText[i+1] != 0) {
+ pszJoin[cchJoin++] = ' ';
+ bModified = TRUE;
+ }
+ else {
+ while (StrChrA("\r\n",pszText[i+1])) {
+ i++;
+ bModified = TRUE;
+ }
+ if (pszText[i+1] != 0) {
+ pszJoin[cchJoin++] = szEOL[0];
+ if (cchEOL > 1)
+ pszJoin[cchJoin++] = szEOL[1];
+ if (cchJoin > cchEOL) {
+ pszJoin[cchJoin++] = szEOL[0];
+ if (cchEOL > 1)
+ pszJoin[cchJoin++] = szEOL[1];
+ }
+ }
+ }
+ }
+ else {
+ pszJoin[cchJoin++] = pszText[i];
+ }
+ }
+
+ LocalFree(pszText);
+
+ if (bModified) {
+ if (iAnchorPos > iCurPos) {
+ iCurPos = iSelStart;
+ iAnchorPos = iSelStart + cchJoin;
+ }
+ else {
+ iAnchorPos = iSelStart;
+ iCurPos = iSelStart + cchJoin;
+ }
+
+ SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0);
+ SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iSelStart,0);
+ SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iSelEnd,0);
+ SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)cchJoin,(LPARAM)pszJoin);
+ SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos);
+ SendMessage(hwnd,SCI_ENDUNDOACTION,0,0);
+ }
+
+ LocalFree(pszJoin);
+}
+
+
+//=============================================================================
+//
+// EditSortLines()
+//
+static FARPROC pfnStrCmpLogicalW;
+
+int CmpStd(const void *s1, const void *s2) {
+ return StrCmp(*(WCHAR**)s1,*(WCHAR**)s2);
+}
+
+int CmpStdRev(const void *s1, const void *s2) {
+ return -1 * StrCmp(*(WCHAR**)s1,*(WCHAR**)s2);
+}
+
+int CmpLogical(const void *s1, const void *s2) {
+ int i = pfnStrCmpLogicalW(*(WCHAR**)s1,*(WCHAR**)s2);
+ if (i != 0)
+ return i;
+ else
+ return StrCmp(*(WCHAR**)s1,*(WCHAR**)s2);
+}
+
+int CmpLogicalRev(const void *s1, const void *s2) {
+ int i = -1 * pfnStrCmpLogicalW(*(WCHAR**)s1,*(WCHAR**)s2);
+ if (i != 0)
+ return i;
+ else
+ return -1 * StrCmp(*(WCHAR**)s1,*(WCHAR**)s2);
+}
+
+void EditSortLines(HWND hwnd,int iSortFlags)
+{
+ int iCurPos;
+ int iAnchorPos;
+ int iSelStart;
+ int iSelEnd;
+ int iLineStart;
+ int iLineEnd;
+ int iLineCount;
+
+ int i, iLine;
+ int cchTotal = 0;
+ int ichlMax = 3;
+
+ WCHAR **pwszLines;
+ char *pmszResult;
+ char *pmszBuf;
+
+ UINT uCodePage;
+ DWORD cEOLMode;
+ char mszEOL[] = "\r\n";
+
+ if (SC_SEL_RECTANGLE == SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) {
+ MsgBox(MBINFO,IDS_SELRECT);
+ return;
+ }
+
+ pfnStrCmpLogicalW = GetProcAddress(GetModuleHandle(L"shlwapi"),"StrCmpLogicalW");
+
+ iCurPos = SendMessage(hwnd,SCI_GETCURRENTPOS,0,0);
+ iAnchorPos = SendMessage(hwnd,SCI_GETANCHOR,0,0);
+
+ if (iCurPos == iAnchorPos)
+ return;
+
+ else {
+ iSelStart = SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0);
+ iSelEnd = SendMessage(hwnd,SCI_GETSELECTIONEND,0,0);
+ }
+
+ iLine = SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0);
+ iSelStart = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0);
+
+ iLineStart = SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0);
+ iLineEnd = SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelEnd,0);
+
+ if (iSelEnd <= SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd,0))
+ iLineEnd--;
+
+ iLineCount = iLineEnd - iLineStart +1;
+ if (iLineCount < 2)
+ return;
+
+ uCodePage = (SendMessage(hwnd,SCI_GETCODEPAGE,0,0) == SC_CP_UTF8) ? CP_UTF8 : CP_ACP;
+
+ cEOLMode = SendMessage(hwnd,SCI_GETEOLMODE,0,0);
+ if (cEOLMode == SC_EOL_CR) {
+ mszEOL[1] = 0;
+ }
+ else if (cEOLMode == SC_EOL_LF) {
+ mszEOL[0] = '\n';
+ mszEOL[1] = 0;
+ }
+
+ pwszLines = LocalAlloc(LPTR,sizeof(WCHAR*) * iLineCount);
+ i = 0;
+ for (iLine = iLineStart; iLine <= iLineEnd; iLine++) {
+
+ char *pmsz;
+ int cchw;
+ int cchm = SendMessage(hwnd,SCI_GETLINE,(WPARAM)iLine,0);
+
+ pmsz = LocalAlloc(LPTR,cchm+1);
+ SendMessage(hwnd,SCI_GETLINE,(WPARAM)iLine,(LPARAM)pmsz);
+ StrTrimA(pmsz,"\r\n");
+ cchTotal += cchm;
+ ichlMax = max(ichlMax,cchm);
+
+ cchw = MultiByteToWideChar(uCodePage,0,pmsz,-1,NULL,0) -1;
+ if (cchw > 0) {
+ pwszLines[i] = LocalAlloc(LPTR,sizeof(WCHAR) * (cchw +1));
+ MultiByteToWideChar(uCodePage,0,pmsz,-1,pwszLines[i],LocalSize(pwszLines[i])/sizeof(WCHAR));
+ }
+ else
+ pwszLines[i] = StrDup(L"");
+ LocalFree(pmsz);
+ i++;
+ }
+
+ if (iSortFlags & SORT_DESCENDING) {
+ if (iSortFlags & SORT_LOGICAL && pfnStrCmpLogicalW)
+ qsort(pwszLines,iLineCount,sizeof(WCHAR*),CmpLogicalRev);
+ else
+ qsort(pwszLines,iLineCount,sizeof(WCHAR*),CmpStdRev);
+ }
+ else {
+ if (iSortFlags & SORT_LOGICAL && pfnStrCmpLogicalW)
+ qsort(pwszLines,iLineCount,sizeof(WCHAR*),CmpLogical);
+ else
+ qsort(pwszLines,iLineCount,sizeof(WCHAR*),CmpStd);
+ }
+
+ pmszResult = LocalAlloc(LPTR,cchTotal + 2*iLineCount +1);
+ pmszBuf = LocalAlloc(LPTR,ichlMax +1);
+
+ for (i = 0; i < iLineCount; i++) {
+
+ BOOL bDuplicate = FALSE;
+ if (pwszLines[i] && lstrlen(pwszLines[i])) {
+
+ if (iSortFlags & SORT_UNIQ) {
+ if (i < iLineCount-1) {
+ if (StrCmp(pwszLines[i],pwszLines[i+1]) == 0) {
+ bDuplicate = TRUE;
+ }
+ }
+ }
+ if (!bDuplicate) {
+ WideCharToMultiByte(uCodePage,0,pwszLines[i],-1,pmszBuf,LocalSize(pmszBuf),NULL,NULL);
+ StrCatBuffA(pmszResult,pmszBuf,LocalSize(pmszResult));
+ StrCatBuffA(pmszResult,mszEOL,LocalSize(pmszResult));
+ }
+ }
+ }
+
+ LocalFree(pmszBuf);
+
+ for (i = 0; i < iLineCount; i++) {
+ if (pwszLines[i])
+ LocalFree(pwszLines[i]);
+ }
+ LocalFree(pwszLines);
+
+ if (iAnchorPos > iCurPos) {
+ iCurPos = iSelStart;
+ iAnchorPos = iSelStart + lstrlenA(pmszResult);
+ }
+ else {
+ iAnchorPos = iSelStart;
+ iCurPos = iSelStart + lstrlenA(pmszResult);
+ }
+
+ SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0);
+ SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0),0);
+ SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd+1,0),0);
+ SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)lstrlenA(pmszResult),(LPARAM)pmszResult);
+ SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos);
+ SendMessage(hwnd,SCI_ENDUNDOACTION,0,0);
+
+ LocalFree(pmszResult);
+}
+
+
+//=============================================================================
+//
+// EditJumpTo()
+//
+void EditJumpTo(HWND hwnd,int iNewLine,int iNewCol)
+{
+ //int iScrLines;
+ //int iTopLine;
+ int iMaxLine = SendMessage(hwnd,SCI_GETLINECOUNT,0,0);
+
+ // Jumpt to end with line set to -1
+ if (iNewLine == -1) {
+ SendMessage(hwnd,SCI_DOCUMENTEND,0,0);
+ return;
+ }
+
+ // Line maximum is iMaxLine
+ iNewLine = min(iNewLine,iMaxLine);
+
+ // Column minimum is 1
+ iNewCol = max(iNewCol,1);
+
+ if (iNewLine > 0 && iNewLine <= iMaxLine && iNewCol > 0)
+ {
+ int iNewPos = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iNewLine-1,0);
+ int iLineEndPos = SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iNewLine-1,0);
+
+ while (iNewCol-1 > SendMessage(hwnd,SCI_GETCOLUMN,(WPARAM)iNewPos,0))
+ {
+ if (iNewPos >= iLineEndPos)
+ break;
+
+ iNewPos = SendMessage(hwnd,SCI_POSITIONAFTER,(WPARAM)iNewPos,0);
+ }
+
+ SendMessage(hwnd,SCI_SETXCARETPOLICY,CARET_SLOP|CARET_STRICT|CARET_EVEN,50);
+ SendMessage(hwnd,SCI_SETYCARETPOLICY,CARET_SLOP|CARET_STRICT|CARET_EVEN,5);
+
+ iNewPos = min(iNewPos,iLineEndPos);
+ SendMessage(hwnd,SCI_GOTOPOS,(WPARAM)iNewPos,0);
+ SendMessage(hwnd,SCI_CHOOSECARETX,0,0);
+
+ //iScrLines = SendMessage(hwnd,SCI_LINESONSCREEN,0,0);
+ //iTopLine = SendMessage(hwnd,SCI_GETFIRSTVISIBLELINE,0,0);
+ //if (iScrLines > 20) {
+ // if (iNewLine - iTopLine < 5)
+ // SendMessage(hwnd,SCI_LINESCROLL,0,(LPARAM)max(iNewLine-5,0)-iTopLine);
+ // else if (iNewLine - (iTopLine + iScrLines) > -5)
+ // SendMessage(hwnd,SCI_LINESCROLL,0,(LPARAM)max(iNewLine-iScrLines+5,0)-iTopLine);
+ //}
+
+ SendMessage(hwnd,SCI_SETXCARETPOLICY,CARET_SLOP|CARET_EVEN,50);
+ SendMessage(hwnd,SCI_SETYCARETPOLICY,CARET_EVEN,0);
+ }
+}
+
+
+//=============================================================================
+//
+// EditSelectEx()
+//
+void EditSelectEx(HWND hwnd,int iAnchorPos,int iCurrentPos)
+{
+ //int iScrLines;
+ //int iTopLine;
+ //int iNewLine = SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iCurrentPos,0);
+
+ int iNewLine = SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iCurrentPos,0);
+ int iAnchorLine = SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iAnchorPos,0);
+
+ SendMessage(hwnd,SCI_SETXCARETPOLICY,CARET_SLOP|CARET_STRICT|CARET_EVEN,50);
+ SendMessage(hwnd,SCI_SETYCARETPOLICY,CARET_SLOP|CARET_STRICT|CARET_EVEN,5);
+ SendMessage(hwnd,SCI_SETSEL,iAnchorPos,iCurrentPos);
+ SendMessage(hwnd,SCI_SETXCARETPOLICY,CARET_SLOP|CARET_EVEN,50);
+ SendMessage(hwnd,SCI_SETYCARETPOLICY,CARET_EVEN,0);
+
+ //iScrLines = SendMessage(hwnd,SCI_LINESONSCREEN,0,0);
+ //iTopLine = SendMessage(hwnd,SCI_GETFIRSTVISIBLELINE,0,0);
+ //if (iScrLines > 20) {
+ // if (iNewLine - iTopLine < 5)
+ // SendMessage(hwnd,SCI_LINESCROLL,0,(LPARAM)max(iNewLine-5,0)-iTopLine);
+ // else if (iNewLine - (iTopLine + iScrLines) > -5)
+ // SendMessage(hwnd,SCI_LINESCROLL,0,(LPARAM)max(iNewLine-iScrLines+5,0)-iTopLine);
+ //}
+}
+
+
+//=============================================================================
+//
+// EditGetExcerpt()
+//
+void EditGetExcerpt(HWND hwnd,LPWSTR lpszExcerpt,DWORD cchExcerpt)
+{
+ WCHAR tch[256] = L"";
+ WCHAR *p;
+ DWORD cch = 0;
+ UINT cpEdit;
+ struct TextRange tr;
+ char* pszText;
+ LPWSTR pszTextW;
+
+ int iCurPos = SendMessage(hwnd,SCI_GETCURRENTPOS,0,0);
+ int iAnchorPos = SendMessage(hwnd,SCI_GETANCHOR,0,0);
+
+ if (iCurPos == iAnchorPos || SC_SEL_RECTANGLE == SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) {
+ lstrcpy(lpszExcerpt,L"");
+ return;
+ }
+
+ /*if (iCurPos != iAnchorPos && SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) {*/
+
+ tr.chrg.cpMin = SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0);
+ tr.chrg.cpMax = min(SendMessage(hwnd,SCI_GETSELECTIONEND,0,0),(LONG)(tr.chrg.cpMin + COUNTOF(tch)));
+ /*}
+ else {
+
+ int iLine = SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iCurPos,0);
+ tr.chrg.cpMin = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0);
+ tr.chrg.cpMax = min(SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0),(LONG)(tr.chrg.cpMin + COUNTOF(tch)));
+ }*/
+
+ tr.chrg.cpMax = min(SendMessage(hwnd,SCI_GETLENGTH,0,0),tr.chrg.cpMax);
+
+ pszText = LocalAlloc(LPTR,(tr.chrg.cpMax - tr.chrg.cpMin)+2);
+ pszTextW = LocalAlloc(LPTR,((tr.chrg.cpMax - tr.chrg.cpMin)*2)+2);
+
+ if (pszText && pszTextW) {
+
+ tr.lpstrText = pszText;
+ SendMessage(hwnd,SCI_GETTEXTRANGE,0,(LPARAM)&tr);
+ cpEdit = SendMessage(hwnd,SCI_GETCODEPAGE,0,0);
+ MultiByteToWideChar(cpEdit,0,pszText,tr.chrg.cpMax - tr.chrg.cpMin,pszTextW,GlobalSize(pszTextW)/sizeof(WCHAR));
+
+ for (p = pszTextW; *p && cch < COUNTOF(tch)-1; p++) {
+ if (*p == L'\r' || *p == L'\n' || *p == L'\t' || *p == L' ') {
+ tch[cch++] = L' ';
+ while (*(p+1) == L'\r' || *(p+1) == L'\n' || *(p+1) == L'\t' || *(p+1) == L' ')
+ p++;
+ }
+ else
+ tch[cch++] = *p;
+ }
+ tch[cch++] = L'\0';
+ StrTrim(tch,L" ");
+ }
+
+ if (cch == 1)
+ lstrcpy(tch,L" ... ");
+
+ if (cch > cchExcerpt) {
+ tch[cchExcerpt-2] = L'.';
+ tch[cchExcerpt-3] = L'.';
+ tch[cchExcerpt-4] = L'.';
+ }
+ StrCpyN(lpszExcerpt,tch,cchExcerpt);
+
+ if (pszText)
+ LocalFree(pszText);
+ if (pszTextW)
+ LocalFree(pszTextW);
+}
+
+
+//=============================================================================
+//
+// EditFindReplaceDlgProcW()
+//
+BOOL CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
+{
+
+ LPEDITFINDREPLACE lpefr;
+ int i;
+ WCHAR tch[512+32];
+ BOOL bCloseDlg;
+ BOOL bIsFindDlg;
+
+ static UINT uCPEdit;
+
+ switch(umsg)
+ {
+
+ case WM_INITDIALOG:
+ {
+ int cchSelection;
+ char *lpszSelection;
+ char *lpsz;
+
+ WCHAR tch[128];
+ HMENU hmenu;
+
+ SetWindowLongPtr(hwnd,DWLP_USER,lParam);
+ lpefr = (LPEDITFINDREPLACE)lParam;
+
+ // Get the current code page for Unicode conversion
+ uCPEdit = SendMessage(lpefr->hwnd,SCI_GETCODEPAGE,0,0);
+
+ // Load MRUs
+ for (i = 0; i < MRU_Enum(mruFind,0,NULL,0); i++) {
+ MRU_Enum(mruFind,i,tch,COUNTOF(tch));
+ SendDlgItemMessage(hwnd,IDC_FINDTEXT,CB_ADDSTRING,0,(LPARAM)tch);
+ }
+ for (i = 0; i < MRU_Enum(mruReplace,0,NULL,0); i++) {
+ MRU_Enum(mruReplace,i,tch,COUNTOF(tch));
+ SendDlgItemMessage(hwnd,IDC_REPLACETEXT,CB_ADDSTRING,0,(LPARAM)tch);
+ }
+
+ if (!bSwitchedFindReplace) {
+ cchSelection = SendMessage(lpefr->hwnd,SCI_GETSELECTIONEND,0,0) -
+ SendMessage(lpefr->hwnd,SCI_GETSELECTIONSTART,0,0);
+
+ if (cchSelection <= 500)
+ {
+ cchSelection = SendMessage(lpefr->hwnd,SCI_GETSELTEXT,0,0);
+ lpszSelection = GlobalAlloc(GPTR,cchSelection+2);
+ SendMessage(lpefr->hwnd,SCI_GETSELTEXT,0,(LPARAM)lpszSelection);
+
+ // Check lpszSelection and truncate bad chars
+ lpsz = StrChrA(lpszSelection,13);
+ if (lpsz) *lpsz = '\0';
+
+ lpsz = StrChrA(lpszSelection,10);
+ if (lpsz) *lpsz = '\0';
+
+ lpsz = StrChrA(lpszSelection,9);
+ if (lpsz) *lpsz = '\0';
+
+ SetDlgItemTextA2W(uCPEdit,hwnd,IDC_FINDTEXT,lpszSelection);
+ GlobalFree(lpszSelection);
+ }
+ }
+
+ SendDlgItemMessage(hwnd,IDC_FINDTEXT,CB_LIMITTEXT,500,0);
+ SendDlgItemMessage(hwnd,IDC_FINDTEXT,CB_SETEXTENDEDUI,TRUE,0);
+
+ if (!GetWindowTextLengthW(GetDlgItem(hwnd,IDC_FINDTEXT)))
+ SetDlgItemTextA2W(CP_UTF8,hwnd,IDC_FINDTEXT,lpefr->szFindUTF8);
+
+ if (GetDlgItem(hwnd,IDC_REPLACETEXT))
+ {
+ SendDlgItemMessage(hwnd,IDC_REPLACETEXT,CB_LIMITTEXT,500,0);
+ SendDlgItemMessage(hwnd,IDC_REPLACETEXT,CB_SETEXTENDEDUI,TRUE,0);
+ SetDlgItemTextA2W(CP_UTF8,hwnd,IDC_REPLACETEXT,lpefr->szReplaceUTF8);
+ }
+
+ if (lpefr->fuFlags & SCFIND_MATCHCASE)
+ CheckDlgButton(hwnd,IDC_FINDCASE,BST_CHECKED);
+
+ if (lpefr->fuFlags & SCFIND_WHOLEWORD)
+ CheckDlgButton(hwnd,IDC_FINDWORD,BST_CHECKED);
+
+ if (lpefr->fuFlags & SCFIND_WORDSTART)
+ CheckDlgButton(hwnd,IDC_FINDSTART,BST_CHECKED);
+
+ if (lpefr->fuFlags & SCFIND_REGEXP)
+ CheckDlgButton(hwnd,IDC_FINDREGEXP,BST_CHECKED);
+
+ if (lpefr->bTransformBS)
+ CheckDlgButton(hwnd,IDC_FINDTRANSFORMBS,BST_CHECKED);
+
+ if (lpefr->bNoFindWrap)
+ CheckDlgButton(hwnd,IDC_NOWRAP,BST_CHECKED);
+
+ if (GetDlgItem(hwnd,IDC_REPLACE)) {
+ if (bSwitchedFindReplace) {
+ if (lpefr->bFindClose)
+ CheckDlgButton(hwnd,IDC_FINDCLOSE,BST_CHECKED);
+ }
+ else {
+ if (lpefr->bReplaceClose)
+ CheckDlgButton(hwnd,IDC_FINDCLOSE,BST_CHECKED);
+ }
+ }
+ else {
+ if (bSwitchedFindReplace) {
+ if (lpefr->bReplaceClose)
+ CheckDlgButton(hwnd,IDC_FINDCLOSE,BST_CHECKED);
+ }
+ else {
+ if (lpefr->bFindClose)
+ CheckDlgButton(hwnd,IDC_FINDCLOSE,BST_CHECKED);
+ }
+ }
+
+ if (!bSwitchedFindReplace) {
+ if (xFindReplaceDlg == 0 || yFindReplaceDlg == 0)
+ CenterDlgInParent(hwnd);
+ else
+ SetDlgPos(hwnd,xFindReplaceDlg,yFindReplaceDlg);
+ }
+
+ else {
+ SetDlgPos(hwnd,xFindReplaceDlgSave,yFindReplaceDlgSave);
+ bSwitchedFindReplace = FALSE;
+ CopyMemory(lpefr,&efrSave,sizeof(EDITFINDREPLACE));
+ }
+
+ hmenu = GetSystemMenu(hwnd,FALSE);
+ GetString(SC_SAVEPOS,tch,COUNTOF(tch));
+ InsertMenu(hmenu,0,MF_BYPOSITION|MF_STRING|MF_ENABLED,SC_SAVEPOS,tch);
+ GetString(SC_RESETPOS,tch,COUNTOF(tch));
+ InsertMenu(hmenu,1,MF_BYPOSITION|MF_STRING|MF_ENABLED,SC_RESETPOS,tch);
+ InsertMenu(hmenu,2,MF_BYPOSITION|MF_SEPARATOR,0,NULL);
+ }
+ return TRUE;
+
+
+ case WM_COMMAND:
+
+ switch(LOWORD(wParam))
+ {
+
+ case IDC_FINDTEXT:
+ case IDC_REPLACETEXT:
+ {
+ BOOL bEnable = (GetWindowTextLengthW(GetDlgItem(hwnd,IDC_FINDTEXT)) ||
+ CB_ERR != SendDlgItemMessage(hwnd,IDC_FINDTEXT,CB_GETCURSEL,0,0));
+
+ EnableWindow(GetDlgItem(hwnd,IDOK),bEnable);
+ EnableWindow(GetDlgItem(hwnd,IDC_FINDPREV),bEnable);
+ EnableWindow(GetDlgItem(hwnd,IDC_SELECTTO),bEnable);
+ EnableWindow(GetDlgItem(hwnd,IDC_SELECTUP),bEnable);
+ EnableWindow(GetDlgItem(hwnd,IDC_REPLACE),bEnable);
+ EnableWindow(GetDlgItem(hwnd,IDC_REPLACEALL),bEnable);
+ EnableWindow(GetDlgItem(hwnd,IDC_REPLACEINSEL),bEnable);
+
+ if (HIWORD(wParam) == CBN_CLOSEUP) {
+ LONG lSelEnd;
+ SendDlgItemMessage(hwnd,LOWORD(wParam),CB_GETEDITSEL,0,(LPARAM)&lSelEnd);
+ SendDlgItemMessage(hwnd,LOWORD(wParam),CB_SETEDITSEL,0,MAKELPARAM(lSelEnd,lSelEnd));
+ }
+ }
+ break;
+
+ case IDC_FINDREGEXP:
+ if (IsDlgButtonChecked(hwnd,IDC_FINDREGEXP) == BST_CHECKED)
+ CheckDlgButton(hwnd,IDC_FINDTRANSFORMBS,BST_UNCHECKED);
+ break;
+
+ case IDC_FINDTRANSFORMBS:
+ if (IsDlgButtonChecked(hwnd,IDC_FINDTRANSFORMBS) == BST_CHECKED)
+ CheckDlgButton(hwnd,IDC_FINDREGEXP,BST_UNCHECKED);
+ break;
+
+ case IDOK:
+ case IDC_FINDPREV:
+ case IDC_SELECTTO:
+ case IDC_SELECTUP:
+ case IDC_REPLACE:
+ case IDC_REPLACEALL:
+ case IDC_REPLACEINSEL:
+ case IDMSG_SWITCHTOFIND:
+ case IDMSG_SWITCHTOREPLACE:
+
+ lpefr = (LPEDITFINDREPLACE)GetWindowLongPtr(hwnd,DWLP_USER);
+
+ bIsFindDlg = (GetDlgItem(hwnd,IDC_REPLACE) == NULL);
+
+ if ((bIsFindDlg && LOWORD(wParam) == IDMSG_SWITCHTOREPLACE ||
+ !bIsFindDlg && LOWORD(wParam) == IDMSG_SWITCHTOFIND)) {
+ GetDlgPos(hwnd,&xFindReplaceDlgSave,&yFindReplaceDlgSave);
+ bSwitchedFindReplace = TRUE;
+ CopyMemory(&efrSave,lpefr,sizeof(EDITFINDREPLACE));
+ }
+
+ // Get current code page for Unicode conversion
+ uCPEdit = SendMessage(lpefr->hwnd,SCI_GETCODEPAGE,0,0);
+ cpLastFind = uCPEdit;
+
+ if (!bSwitchedFindReplace &&
+ !GetDlgItemTextA2W(uCPEdit,hwnd,IDC_FINDTEXT,lpefr->szFind,COUNTOF(lpefr->szFind))) {
+
+ EnableWindow(GetDlgItem(hwnd,IDOK),FALSE);
+ EnableWindow(GetDlgItem(hwnd,IDC_FINDPREV),FALSE);
+ EnableWindow(GetDlgItem(hwnd,IDC_SELECTTO),FALSE);
+ EnableWindow(GetDlgItem(hwnd,IDC_SELECTUP),FALSE);
+ EnableWindow(GetDlgItem(hwnd,IDC_REPLACE),FALSE);
+ EnableWindow(GetDlgItem(hwnd,IDC_REPLACEALL),FALSE);
+ EnableWindow(GetDlgItem(hwnd,IDC_REPLACEINSEL),FALSE);
+ return TRUE;
+ }
+
+ if (GetDlgItem(hwnd,IDC_REPLACETEXT))
+ GetDlgItemTextA2W(uCPEdit,hwnd,IDC_REPLACETEXT,lpefr->szReplace,COUNTOF(lpefr->szReplace));
+
+ lpefr->fuFlags = 0;
+
+ if (IsDlgButtonChecked(hwnd,IDC_FINDCASE) == BST_CHECKED)
+ lpefr->fuFlags |= SCFIND_MATCHCASE;
+
+ if (IsDlgButtonChecked(hwnd,IDC_FINDWORD) == BST_CHECKED)
+ lpefr->fuFlags |= SCFIND_WHOLEWORD;
+
+ if (IsDlgButtonChecked(hwnd,IDC_FINDSTART) == BST_CHECKED)
+ lpefr->fuFlags |= SCFIND_WORDSTART;
+
+ if (IsDlgButtonChecked(hwnd,IDC_FINDREGEXP) == BST_CHECKED)
+ lpefr->fuFlags |= SCFIND_REGEXP;
+
+ lpefr->bTransformBS =
+ (IsDlgButtonChecked(hwnd,IDC_FINDTRANSFORMBS) == BST_CHECKED) ? TRUE : FALSE;
+
+ lpefr->bNoFindWrap = (IsDlgButtonChecked(hwnd,IDC_NOWRAP) == BST_CHECKED) ? TRUE : FALSE;
+
+ if (bIsFindDlg) {
+ lpefr->bFindClose = (IsDlgButtonChecked(hwnd,IDC_FINDCLOSE) == BST_CHECKED) ? TRUE : FALSE;
+ }
+ else {
+ lpefr->bReplaceClose = (IsDlgButtonChecked(hwnd,IDC_FINDCLOSE) == BST_CHECKED) ? TRUE : FALSE;
+ }
+
+ if (!bSwitchedFindReplace) {
+ // Save MRUs
+ if (lstrlenA(lpefr->szFind)) {
+ if (GetDlgItemTextA2W(CP_UTF8,hwnd,IDC_FINDTEXT,lpefr->szFindUTF8,COUNTOF(lpefr->szFindUTF8))) {
+ GetDlgItemText(hwnd,IDC_FINDTEXT,tch,COUNTOF(tch));
+ MRU_Add(mruFind,tch);
+ }
+ }
+ if (lstrlenA(lpefr->szReplace)) {
+ if (GetDlgItemTextA2W(CP_UTF8,hwnd,IDC_REPLACETEXT,lpefr->szReplaceUTF8,COUNTOF(lpefr->szReplaceUTF8))) {
+ GetDlgItemText(hwnd,IDC_REPLACETEXT,tch,COUNTOF(tch));
+ MRU_Add(mruReplace,tch);
+ }
+ }
+ else
+ lstrcpyA(lpefr->szReplaceUTF8,"");
+ }
+ else {
+ GetDlgItemTextA2W(CP_UTF8,hwnd,IDC_FINDTEXT,lpefr->szFindUTF8,COUNTOF(lpefr->szFindUTF8));
+ if (!GetDlgItemTextA2W(CP_UTF8,hwnd,IDC_REPLACETEXT,lpefr->szReplaceUTF8,COUNTOF(lpefr->szReplaceUTF8)))
+ lstrcpyA(lpefr->szReplaceUTF8,"");
+ }
+
+ if (bIsFindDlg) {
+ bCloseDlg = lpefr->bFindClose;
+ }
+ else {
+ if (LOWORD(wParam) == IDOK)
+ bCloseDlg = FALSE;
+ else
+ bCloseDlg = lpefr->bReplaceClose;
+ }
+
+ // Reload MRUs
+ SendDlgItemMessage(hwnd,IDC_FINDTEXT,CB_RESETCONTENT,0,0);
+ SendDlgItemMessage(hwnd,IDC_REPLACETEXT,CB_RESETCONTENT,0,0);
+
+ for (i = 0; i < MRU_Enum(mruFind,0,NULL,0); i++) {
+ MRU_Enum(mruFind,i,tch,COUNTOF(tch));
+ SendDlgItemMessage(hwnd,IDC_FINDTEXT,CB_ADDSTRING,0,(LPARAM)tch);
+ }
+ for (i = 0; i < MRU_Enum(mruReplace,0,NULL,0); i++) {
+ MRU_Enum(mruReplace,i,tch,COUNTOF(tch));
+ SendDlgItemMessage(hwnd,IDC_REPLACETEXT,CB_ADDSTRING,0,(LPARAM)tch);
+ }
+
+ SetDlgItemTextA2W(CP_UTF8,hwnd,IDC_FINDTEXT,lpefr->szFindUTF8);
+ SetDlgItemTextA2W(CP_UTF8,hwnd,IDC_REPLACETEXT,lpefr->szReplaceUTF8);
+
+ if (!bSwitchedFindReplace)
+ SendMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetFocus()),1);
+
+ if (bCloseDlg) {
+ //EndDialog(hwnd,LOWORD(wParam));
+ DestroyWindow(hwnd);
+ hDlgFindReplace = NULL;
+ }
+
+ switch (LOWORD(wParam))
+ {
+ case IDOK: // find next
+ EditFindNext(lpefr->hwnd,lpefr,FALSE);
+ break;
+
+ case IDC_FINDPREV: // find previous
+ EditFindPrev(lpefr->hwnd,lpefr,FALSE);
+ break;
+
+ case IDC_SELECTTO: // select to next
+ EditFindNext(lpefr->hwnd,lpefr,TRUE);
+ break;
+
+ case IDC_SELECTUP: // select to previous
+ EditFindPrev(lpefr->hwnd,lpefr,TRUE);
+ break;
+
+ case IDC_REPLACE:
+ bReplaceInitialized = TRUE;
+ EditReplace(lpefr->hwnd,lpefr);
+ break;
+
+ case IDC_REPLACEALL:
+ bReplaceInitialized = TRUE;
+ EditReplaceAll(lpefr->hwnd,lpefr,TRUE);
+ break;
+
+ case IDC_REPLACEINSEL:
+ bReplaceInitialized = TRUE;
+ EditReplaceAllInSelection(lpefr->hwnd,lpefr,TRUE);
+ break;
+ }
+ break;
+
+
+ case IDCANCEL:
+ //EndDialog(hwnd,IDCANCEL);
+ DestroyWindow(hwnd);
+ break;
+
+ case IDACC_FIND:
+ PostMessage(GetParent(hwnd),WM_COMMAND,MAKELONG(IDM_EDIT_FIND,1),0);
+ break;
+
+ case IDACC_REPLACE:
+ PostMessage(GetParent(hwnd),WM_COMMAND,MAKELONG(IDM_EDIT_REPLACE,1),0);
+ break;
+
+ case IDACC_SAVEPOS:
+ GetDlgPos(hwnd,&xFindReplaceDlg,&yFindReplaceDlg);
+ break;
+
+ case IDACC_RESETPOS:
+ CenterDlgInParent(hwnd);
+ xFindReplaceDlg = yFindReplaceDlg = 0;
+ break;
+
+ }
+
+ return TRUE;
+
+
+ case WM_SYSCOMMAND:
+ if (wParam == SC_SAVEPOS){
+ PostMessage(hwnd,WM_COMMAND,MAKELONG(IDACC_SAVEPOS,0),0);
+ return TRUE;
+ }
+ else if (wParam == SC_RESETPOS){
+ PostMessage(hwnd,WM_COMMAND,MAKELONG(IDACC_RESETPOS,0),0);
+ return TRUE;
+ }
+ else
+ return FALSE;
+
+
+ case WM_NOTIFY:
+ {
+ LPNMHDR pnmhdr = (LPNMHDR)lParam;
+ switch (pnmhdr->code) {
+
+ case NM_CLICK:
+ case NM_RETURN:
+ if (pnmhdr->idFrom == IDC_TOGGLEFINDREPLACE) {
+ if (GetDlgItem(hwnd,IDC_REPLACE))
+ PostMessage(GetParent(hwnd),WM_COMMAND,MAKELONG(IDM_EDIT_FIND,1),0);
+ else
+ PostMessage(GetParent(hwnd),WM_COMMAND,MAKELONG(IDM_EDIT_REPLACE,1),0);
+ }
+ break;
+ }
+ }
+ break;
+
+ }
+
+ return FALSE;
+
+}
+
+
+//=============================================================================
+//
+// EditFindReplaceDlg()
+//
+HWND EditFindReplaceDlg(HWND hwnd,LPCEDITFINDREPLACE lpefr,BOOL bReplace)
+{
+
+ HWND hDlg;
+
+ lpefr->hwnd = hwnd;
+
+ hDlg = CreateThemedDialogParam(g_hInstance,
+ (bReplace) ? MAKEINTRESOURCEW(IDD_REPLACE) : MAKEINTRESOURCEW(IDD_FIND),
+ GetParent(hwnd),
+ EditFindReplaceDlgProcW,
+ (LPARAM) lpefr);
+
+ ShowWindow(hDlg,SW_SHOW);
+
+ return hDlg;
+
+}
+
+
+//=============================================================================
+//
+// EditFindNext()
+//
+BOOL EditFindNext(HWND hwnd,LPCEDITFINDREPLACE lpefr,BOOL fExtendSelection)
+{
+
+ struct TextToFind ttf;
+ int iPos;
+ int iSelPos, iSelAnchor;
+ char szFind2[512];
+ BOOL bSuppressNotFound = FALSE;
+
+ if (!lstrlenA(lpefr->szFind))
+ return /*EditFindReplaceDlg(hwnd,lpefr,FALSE)*/FALSE;
+
+ lstrcpynA(szFind2,lpefr->szFind,COUNTOF(szFind2));
+ if (lpefr->bTransformBS)
+ TransformBackslashes(szFind2,(lpefr->fuFlags & SCFIND_REGEXP));
+
+ if (lstrlenA(szFind2) == 0)
+ {
+ InfoBox(0,L"MsgNotFound",IDS_NOTFOUND);
+ return FALSE;
+ }
+
+ iSelPos = SendMessage(hwnd,SCI_GETCURRENTPOS,0,0);
+ iSelAnchor = SendMessage(hwnd,SCI_GETANCHOR,0,0);
+
+ ZeroMemory(&ttf,sizeof(ttf));
+
+ ttf.chrg.cpMin = SendMessage(hwnd,SCI_GETSELECTIONEND,0,0);
+ ttf.chrg.cpMax = SendMessage(hwnd,SCI_GETLENGTH,0,0);
+ ttf.lpstrText = szFind2;
+
+ iPos = SendMessage(hwnd,SCI_FINDTEXT,lpefr->fuFlags,(LPARAM)&ttf);
+
+ if (iPos == -1 && ttf.chrg.cpMin > 0 && !lpefr->bNoFindWrap && !fExtendSelection) {
+ if (IDOK == InfoBox(MBOKCANCEL,L"MsgFindWrap1",IDS_FIND_WRAPFW)) {
+ ttf.chrg.cpMin = 0;
+ iPos = SendMessage(hwnd,SCI_FINDTEXT,lpefr->fuFlags,(LPARAM)&ttf);
+ }
+ else
+ bSuppressNotFound = TRUE;
+ }
+
+ if (iPos == -1)
+ {
+ // notfound
+ if (!bSuppressNotFound)
+ InfoBox(0,L"MsgNotFound",IDS_NOTFOUND);
+ return FALSE;
+ }
+
+ if (!fExtendSelection)
+ EditSelectEx(hwnd,ttf.chrgText.cpMin,ttf.chrgText.cpMax);
+ else
+ EditSelectEx(hwnd,min(iSelAnchor,iSelPos),ttf.chrgText.cpMax);
+
+ return TRUE;
+
+}
+
+
+//=============================================================================
+//
+// EditFindPrev()
+//
+BOOL EditFindPrev(HWND hwnd,LPCEDITFINDREPLACE lpefr,BOOL fExtendSelection)
+{
+
+ struct TextToFind ttf;
+ int iPos;
+ int iSelPos, iSelAnchor;
+ int iLength;
+ char szFind2[512];
+ BOOL bSuppressNotFound = FALSE;
+
+ if (!lstrlenA(lpefr->szFind))
+ return /*EditFindReplaceDlg(hwnd,lpefr,FALSE)*/FALSE;
+
+ lstrcpynA(szFind2,lpefr->szFind,COUNTOF(szFind2));
+ if (lpefr->bTransformBS)
+ TransformBackslashes(szFind2,(lpefr->fuFlags & SCFIND_REGEXP));
+
+ if (lstrlenA(szFind2) == 0)
+ {
+ InfoBox(0,L"MsgNotFound",IDS_NOTFOUND);
+ return FALSE;
+ }
+
+ iSelPos = SendMessage(hwnd,SCI_GETCURRENTPOS,0,0);
+ iSelAnchor = SendMessage(hwnd,SCI_GETANCHOR,0,0);
+
+ ZeroMemory(&ttf,sizeof(ttf));
+
+ ttf.chrg.cpMin = max(0,SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0));
+ ttf.chrg.cpMax = 0;
+ ttf.lpstrText = szFind2;
+
+ iPos = SendMessage(hwnd,SCI_FINDTEXT,lpefr->fuFlags,(LPARAM)&ttf);
+
+ iLength = SendMessage(hwnd,SCI_GETLENGTH,0,0);
+ if (iPos == -1 && ttf.chrg.cpMin < iLength && !lpefr->bNoFindWrap && !fExtendSelection) {
+ if (IDOK == InfoBox(MBOKCANCEL,L"MsgFindWrap2",IDS_FIND_WRAPRE)) {
+ ttf.chrg.cpMin = iLength;
+ iPos = SendMessage(hwnd,SCI_FINDTEXT,lpefr->fuFlags,(LPARAM)&ttf);
+ }
+ else
+ bSuppressNotFound = TRUE;
+ }
+
+ if (iPos == -1)
+ {
+ // notfound
+ if (!bSuppressNotFound)
+ InfoBox(0,L"MsgNotFound",IDS_NOTFOUND);
+ return FALSE;
+ }
+
+ if (!fExtendSelection)
+ EditSelectEx(hwnd,ttf.chrgText.cpMin,ttf.chrgText.cpMax);
+ else
+ EditSelectEx(hwnd,max(iSelPos,iSelAnchor),ttf.chrgText.cpMin);
+
+ return TRUE;
+
+}
+
+
+//=============================================================================
+//
+// EditReplace()
+//
+BOOL EditReplace(HWND hwnd,LPCEDITFINDREPLACE lpefr)
+{
+
+ struct TextToFind ttf;
+ int iPos;
+ int iSelStart;
+ int iSelEnd;
+ int iReplaceMsg = (lpefr->fuFlags & SCFIND_REGEXP) ? SCI_REPLACETARGETRE : SCI_REPLACETARGET;
+ char szFind2[512];
+ char *pszReplace2;
+ BOOL bSuppressNotFound = FALSE;
+
+ if (!lstrlenA(lpefr->szFind))
+ return /*EditFindReplaceDlg(hwnd,lpefr,TRUE)*/FALSE;
+
+ lstrcpynA(szFind2,lpefr->szFind,COUNTOF(szFind2));
+ if (lpefr->bTransformBS)
+ TransformBackslashes(szFind2,(lpefr->fuFlags & SCFIND_REGEXP));
+
+ if (lstrlenA(szFind2) == 0)
+ {
+ InfoBox(0,L"MsgNotFound",IDS_NOTFOUND);
+ return FALSE;
+ }
+
+ if (lstrcmpA(lpefr->szReplace,"^c") == 0) {
+ iReplaceMsg = SCI_REPLACETARGET;
+ pszReplace2 = EditGetClipboardText(hwnd);
+ }
+ else {
+ //lstrcpyA(szReplace2,lpefr->szReplace);
+ pszReplace2 = StrDupA(lpefr->szReplace);
+ if (lpefr->bTransformBS)
+ TransformBackslashes(pszReplace2,(lpefr->fuFlags & SCFIND_REGEXP));
+ }
+
+ if (!pszReplace2)
+ pszReplace2 = StrDupA("");
+
+ iSelStart = SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0);
+ iSelEnd = SendMessage(hwnd,SCI_GETSELECTIONEND,0,0);
+
+ ZeroMemory(&ttf,sizeof(ttf));
+
+ ttf.chrg.cpMin = SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); // Start!
+ ttf.chrg.cpMax = SendMessage(hwnd,SCI_GETLENGTH,0,0);
+ ttf.lpstrText = szFind2;
+
+ iPos = SendMessage(hwnd,SCI_FINDTEXT,lpefr->fuFlags,(LPARAM)&ttf);
+
+ if (iPos == -1 && ttf.chrg.cpMin > 0 && !lpefr->bNoFindWrap) {
+ if (IDOK == InfoBox(MBOKCANCEL,L"MsgFindWrap1",IDS_FIND_WRAPFW)) {
+ ttf.chrg.cpMin = 0;
+ iPos = SendMessage(hwnd,SCI_FINDTEXT,lpefr->fuFlags,(LPARAM)&ttf);
+ }
+ else
+ bSuppressNotFound = TRUE;
+ }
+
+ if (iPos == -1)
+ {
+ // notfound
+ LocalFree(pszReplace2);
+ if (!bSuppressNotFound)
+ InfoBox(0,L"MsgNotFound",IDS_NOTFOUND);
+ return FALSE;
+ }
+
+ if (iSelStart != ttf.chrgText.cpMin || iSelEnd != ttf.chrgText.cpMax) {
+ LocalFree(pszReplace2);
+ EditSelectEx(hwnd,ttf.chrgText.cpMin,ttf.chrgText.cpMax);
+ return FALSE;
+ }
+
+ SendMessage(hwnd,SCI_SETTARGETSTART,ttf.chrgText.cpMin,0);
+ SendMessage(hwnd,SCI_SETTARGETEND,ttf.chrgText.cpMax,0);
+ SendMessage(hwnd,iReplaceMsg,(WPARAM)-1,(LPARAM)pszReplace2);
+
+ ttf.chrg.cpMin = SendMessage(hwnd,SCI_GETTARGETEND,0,0);
+ ttf.chrg.cpMax = SendMessage(hwnd,SCI_GETLENGTH,0,0);
+
+ iPos = SendMessage(hwnd,SCI_FINDTEXT,lpefr->fuFlags,(LPARAM)&ttf);
+
+ bSuppressNotFound = FALSE;
+ if (iPos == -1 && ttf.chrg.cpMin > 0 && !lpefr->bNoFindWrap) {
+ if (IDOK == InfoBox(MBOKCANCEL,L"MsgFindWrap1",IDS_FIND_WRAPFW)) {
+ ttf.chrg.cpMin = 0;
+ iPos = SendMessage(hwnd,SCI_FINDTEXT,lpefr->fuFlags,(LPARAM)&ttf);
+ }
+ else
+ bSuppressNotFound = TRUE;
+ }
+
+ if (iPos != -1)
+ EditSelectEx(hwnd,ttf.chrgText.cpMin,ttf.chrgText.cpMax);
+
+ else {
+ EditSelectEx(hwnd,
+ SendMessage(hwnd,SCI_GETTARGETEND,0,0),
+ SendMessage(hwnd,SCI_GETTARGETEND,0,0));
+ if (!bSuppressNotFound)
+ InfoBox(0,L"MsgNotFound",IDS_NOTFOUND);
+ }
+
+ LocalFree(pszReplace2);
+ return TRUE;
+
+}
+
+
+//=============================================================================
+//
+// EditReplaceAll()
+//
+BOOL EditReplaceAll(HWND hwnd,LPCEDITFINDREPLACE lpefr,BOOL bShowInfo)
+{
+
+ struct TextToFind ttf;
+ int iPos;
+ int iCount = 0;
+ int iReplaceMsg = (lpefr->fuFlags & SCFIND_REGEXP) ? SCI_REPLACETARGETRE : SCI_REPLACETARGET;
+ char szFind2[512];
+ char *pszReplace2;
+ BOOL bRegexStartOfLine;
+ BOOL bRegexStartOrEndOfLine;
+
+ if (!lstrlenA(lpefr->szFind))
+ return /*EditFindReplaceDlg(hwnd,lpefr,TRUE)*/FALSE;
+
+ // Show wait cursor...
+ SendMessage(hwnd,SCI_SETCURSOR,SC_CURSORWAIT,0);
+
+ lstrcpynA(szFind2,lpefr->szFind,COUNTOF(szFind2));
+ if (lpefr->bTransformBS)
+ TransformBackslashes(szFind2,(lpefr->fuFlags & SCFIND_REGEXP));
+
+ if (lstrlenA(szFind2) == 0)
+ {
+ InfoBox(0,L"MsgNotFound",IDS_NOTFOUND);
+ return FALSE;
+ }
+
+ bRegexStartOfLine =
+ (szFind2[0] == '^');
+ bRegexStartOrEndOfLine =
+ (lpefr->fuFlags & SCFIND_REGEXP &&
+ (!lstrcmpA(szFind2,"$") || !lstrcmpA(szFind2,"^") || !lstrcmpA(szFind2,"^$")));
+
+ if (lstrcmpA(lpefr->szReplace,"^c") == 0) {
+ iReplaceMsg = SCI_REPLACETARGET;
+ pszReplace2 = EditGetClipboardText(hwnd);
+ }
+ else {
+ //lstrcpyA(szReplace2,lpefr->szReplace);
+ pszReplace2 = StrDupA(lpefr->szReplace);
+ if (lpefr->bTransformBS)
+ TransformBackslashes(pszReplace2,(lpefr->fuFlags & SCFIND_REGEXP));
+ }
+
+ if (!pszReplace2)
+ pszReplace2 = StrDupA("");
+
+ ZeroMemory(&ttf,sizeof(ttf));
+
+ ttf.chrg.cpMin = 0;
+ ttf.chrg.cpMax = SendMessage(hwnd,SCI_GETLENGTH,0,0);
+ ttf.lpstrText = szFind2;
+
+ while ((iPos = SendMessage(hwnd,SCI_FINDTEXT,lpefr->fuFlags,(LPARAM)&ttf)) != -1)
+ {
+ int iReplacedLen;
+ //char ch;
+
+ if (iCount == 0 && bRegexStartOrEndOfLine) {
+ if (0 == SendMessage(hwnd,SCI_GETLINEENDPOSITION,0,0)) {
+ iPos = 0;
+ ttf.chrgText.cpMin = 0;
+ ttf.chrgText.cpMax = 0;
+ }
+ }
+
+ if (++iCount == 1)
+ SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0);
+
+ SendMessage(hwnd,SCI_SETTARGETSTART,ttf.chrgText.cpMin,0);
+ SendMessage(hwnd,SCI_SETTARGETEND,ttf.chrgText.cpMax,0);
+ iReplacedLen = SendMessage(hwnd,iReplaceMsg,(WPARAM)-1,(LPARAM)pszReplace2);
+
+ ttf.chrg.cpMin = ttf.chrgText.cpMin + iReplacedLen;
+ ttf.chrg.cpMax = SendMessage(hwnd,SCI_GETLENGTH,0,0);
+
+ if (ttf.chrg.cpMin == ttf.chrg.cpMax)
+ break;
+
+ //ch = (char)SendMessage(hwnd,SCI_GETCHARAT,SendMessage(hwnd,SCI_GETTARGETEND,0,0),0);
+
+ if (/*ch == '\r' || ch == '\n' || iReplacedLen == 0 || */
+ ttf.chrgText.cpMin == ttf.chrgText.cpMax &&
+ !(bRegexStartOrEndOfLine && iReplacedLen > 0))
+ ttf.chrg.cpMin = SendMessage(hwnd,SCI_POSITIONAFTER,ttf.chrg.cpMin,0);
+ if (bRegexStartOfLine) {
+ int iLine = SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)ttf.chrg.cpMin,0);
+ int ilPos = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0);
+ if (ilPos == ttf.chrg.cpMin)
+ ttf.chrg.cpMin = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine+1,0);
+ if (ttf.chrg.cpMin == ttf.chrg.cpMax)
+ break;
+ }
+ }
+
+ if (iCount)
+ SendMessage(hwnd,SCI_ENDUNDOACTION,0,0);
+
+ // Remove wait cursor
+ SendMessage(hwnd,SCI_SETCURSOR,SC_CURSORNORMAL,0);
+
+ if (bShowInfo) {
+ if (iCount > 0)
+ InfoBox(0,L"MsgReplaceCount",IDS_REPLCOUNT,iCount);
+ else
+ InfoBox(0,L"MsgNotFound",IDS_NOTFOUND);
+ }
+
+ LocalFree(pszReplace2);
+ return TRUE;
+
+}
+
+
+//=============================================================================
+//
+// EditReplaceAllInSelection()
+//
+BOOL EditReplaceAllInSelection(HWND hwnd,LPCEDITFINDREPLACE lpefr,BOOL bShowInfo)
+{
+
+ struct TextToFind ttf;
+ int iPos;
+ int iCount = 0;
+ int iReplaceMsg = (lpefr->fuFlags & SCFIND_REGEXP) ? SCI_REPLACETARGETRE : SCI_REPLACETARGET;
+ BOOL fCancel = FALSE;
+ char szFind2[512];
+ char *pszReplace2;
+ BOOL bRegexStartOfLine;
+ BOOL bRegexStartOrEndOfLine;
+
+ if (SC_SEL_RECTANGLE == SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0))
+ {
+ MsgBox(MBINFO,IDS_SELRECT);
+ return FALSE;
+ }
+
+ if (!lstrlenA(lpefr->szFind))
+ return /*EditFindReplaceDlg(hwnd,lpefr,TRUE)*/FALSE;
+
+ // Show wait cursor...
+ SendMessage(hwnd,SCI_SETCURSOR,SC_CURSORWAIT,0);
+
+ lstrcpynA(szFind2,lpefr->szFind,COUNTOF(szFind2));
+ if (lpefr->bTransformBS)
+ TransformBackslashes(szFind2,(lpefr->fuFlags & SCFIND_REGEXP));
+
+ if (lstrlenA(szFind2) == 0)
+ {
+ InfoBox(0,L"MsgNotFound",IDS_NOTFOUND);
+ return FALSE;
+ }
+
+ bRegexStartOfLine =
+ (szFind2[0] == '^');
+ bRegexStartOrEndOfLine =
+ (lpefr->fuFlags & SCFIND_REGEXP &&
+ (!lstrcmpA(szFind2,"$") || !lstrcmpA(szFind2,"^") || !lstrcmpA(szFind2,"^$")));
+
+ if (lstrcmpA(lpefr->szReplace,"^c") == 0) {
+ iReplaceMsg = SCI_REPLACETARGET;
+ pszReplace2 = EditGetClipboardText(hwnd);
+ }
+ else {
+ //lstrcpyA(szReplace2,lpefr->szReplace);
+ pszReplace2 = StrDupA(lpefr->szReplace);
+ if (lpefr->bTransformBS)
+ TransformBackslashes(pszReplace2,(lpefr->fuFlags & SCFIND_REGEXP));
+ }
+
+ if (!pszReplace2)
+ pszReplace2 = StrDupA("");
+
+ ZeroMemory(&ttf,sizeof(ttf));
+
+ ttf.chrg.cpMin = SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0);
+ ttf.chrg.cpMax = SendMessage(hwnd,SCI_GETLENGTH,0,0);
+ ttf.lpstrText = szFind2;
+
+ while ((iPos = SendMessage(hwnd,SCI_FINDTEXT,lpefr->fuFlags,(LPARAM)&ttf)) != -1 && !fCancel)
+ {
+ if (ttf.chrgText.cpMin >= SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0) &&
+ ttf.chrgText.cpMax <= SendMessage(hwnd,SCI_GETSELECTIONEND,0,0))
+ {
+ int iReplacedLen;
+ //char ch;
+
+ if (ttf.chrg.cpMin == 0 && iCount == 0 && bRegexStartOrEndOfLine) {
+ if (0 == SendMessage(hwnd,SCI_GETLINEENDPOSITION,0,0)) {
+ iPos = 0;
+ ttf.chrgText.cpMin = 0;
+ ttf.chrgText.cpMax = 0;
+ }
+ }
+
+ if (++iCount == 1)
+ SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0);
+
+ SendMessage(hwnd,SCI_SETTARGETSTART,ttf.chrgText.cpMin,0);
+ SendMessage(hwnd,SCI_SETTARGETEND,ttf.chrgText.cpMax,0);
+ iReplacedLen = SendMessage(hwnd,iReplaceMsg,(WPARAM)-1,(LPARAM)pszReplace2);
+
+ ttf.chrg.cpMin = ttf.chrgText.cpMin + iReplacedLen;
+ ttf.chrg.cpMax = SendMessage(hwnd,SCI_GETLENGTH,0,0);
+
+ if (ttf.chrg.cpMin == ttf.chrg.cpMax)
+ fCancel = TRUE;
+
+ //ch = (char)SendMessage(hwnd,SCI_GETCHARAT,SendMessage(hwnd,SCI_GETTARGETEND,0,0),0);
+
+ if (/*ch == '\r' || ch == '\n' || iReplacedLen == 0 || */
+ ttf.chrgText.cpMin == ttf.chrgText.cpMax &&
+ !(bRegexStartOrEndOfLine && iReplacedLen > 0))
+ ttf.chrg.cpMin = SendMessage(hwnd,SCI_POSITIONAFTER,ttf.chrg.cpMin,0);
+ if (bRegexStartOfLine) {
+ int iLine = SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)ttf.chrg.cpMin,0);
+ int ilPos = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0);
+ if (ilPos == ttf.chrg.cpMin)
+ ttf.chrg.cpMin = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine+1,0);
+ if (ttf.chrg.cpMin == ttf.chrg.cpMax)
+ break;
+ }
+ }
+
+ else
+ // gone across selection, cancel
+ fCancel = TRUE;
+ }
+
+ if (iCount) {
+
+ if (SendMessage(hwnd,SCI_GETSELECTIONEND,0,0) <
+ SendMessage(hwnd,SCI_GETTARGETEND,0,0)) {
+
+ int iAnchorPos = SendMessage(hwnd,SCI_GETANCHOR,0,0);
+ int iCurrentPos = SendMessage(hwnd,SCI_GETCURRENTPOS,0,0);
+
+ if (iAnchorPos > iCurrentPos)
+ iAnchorPos = SendMessage(hwnd,SCI_GETTARGETEND,0,0);
+ else
+ iCurrentPos = SendMessage(hwnd,SCI_GETTARGETEND,0,0);
+
+ EditSelectEx(hwnd,iAnchorPos,iCurrentPos);
+ }
+
+ SendMessage(hwnd,SCI_ENDUNDOACTION,0,0);
+ }
+
+ // Remove wait cursor
+ SendMessage(hwnd,SCI_SETCURSOR,SC_CURSORNORMAL,0);
+
+ if (bShowInfo) {
+ if (iCount > 0)
+ InfoBox(0,L"MsgReplaceCount",IDS_REPLCOUNT,iCount);
+ else
+ InfoBox(0,L"MsgNotFound",IDS_NOTFOUND);
+ }
+
+ LocalFree(pszReplace2);
+ return TRUE;
+
+}
+
+
+//=============================================================================
+//
+// EditLinenumDlgProc()
+//
+BOOL CALLBACK EditLinenumDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
+{
+
+ switch(umsg)
+ {
+
+ case WM_INITDIALOG:
+ {
+
+ int iCurLine = SendMessage(hwndEdit,SCI_LINEFROMPOSITION,
+ SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0),0)+1;
+
+ SetDlgItemInt(hwnd,IDC_LINENUM,iCurLine,FALSE);
+ SendDlgItemMessage(hwnd,IDC_LINENUM,EM_LIMITTEXT,15,0);
+
+ SendDlgItemMessage(hwnd,IDC_COLNUM,EM_LIMITTEXT,15,0);
+
+ CenterDlgInParent(hwnd);
+
+ }
+ return TRUE;
+
+
+ case WM_COMMAND:
+
+ switch(LOWORD(wParam))
+ {
+
+ case IDOK: {
+
+ BOOL fTranslated;
+ BOOL fTranslated2;
+
+ int iNewCol;
+
+ int iNewLine = GetDlgItemInt(hwnd,IDC_LINENUM,&fTranslated,FALSE);
+ int iMaxLine = SendMessage(hwndEdit,SCI_GETLINECOUNT,0,0);
+
+ if (SendDlgItemMessage(hwnd,IDC_COLNUM,WM_GETTEXTLENGTH,0,0) > 0)
+ iNewCol = GetDlgItemInt(hwnd,IDC_COLNUM,&fTranslated2,FALSE);
+ else {
+ iNewCol = 1;
+ fTranslated2 = TRUE;
+ }
+
+ if (!fTranslated || !fTranslated2)
+ {
+ PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,(!fTranslated) ? IDC_LINENUM : IDC_COLNUM)),1);
+ return TRUE;
+ }
+
+ if (iNewLine > 0 && iNewLine <= iMaxLine && iNewCol > 0)
+ {
+ //int iNewPos = SendMessage(hwndEdit,SCI_POSITIONFROMLINE,(WPARAM)iNewLine-1,0);
+ //int iLineEndPos = SendMessage(hwndEdit,SCI_GETLINEENDPOSITION,(WPARAM)iNewLine-1,0);
+
+ //while (iNewCol-1 > SendMessage(hwndEdit,SCI_GETCOLUMN,(WPARAM)iNewPos,0))
+ //{
+ // if (iNewPos >= iLineEndPos)
+ // break;
+
+ // iNewPos = SendMessage(hwndEdit,SCI_POSITIONAFTER,(WPARAM)iNewPos,0);
+ //}
+
+ //iNewPos = min(iNewPos,iLineEndPos);
+ //SendMessage(hwndEdit,SCI_GOTOPOS,(WPARAM)iNewPos,0);
+ //SendMessage(hwndEdit,SCI_CHOOSECARETX,0,0);
+
+ EditJumpTo(hwndEdit,iNewLine,iNewCol);
+
+ EndDialog(hwnd,IDOK);
+ }
+
+ else
+ PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,(!(iNewLine > 0 && iNewLine <= iMaxLine)) ? IDC_LINENUM : IDC_COLNUM)),1);
+
+ }
+ break;
+
+
+ case IDCANCEL:
+ EndDialog(hwnd,IDCANCEL);
+ break;
+
+ }
+
+ return TRUE;
+
+ }
+
+ return FALSE;
+
+}
+
+
+//=============================================================================
+//
+// EditLinenumDlg()
+//
+BOOL EditLinenumDlg(HWND hwnd)
+{
+
+ if (IDOK == ThemedDialogBoxParam(g_hInstance,MAKEINTRESOURCE(IDD_LINENUM),
+ GetParent(hwnd),EditLinenumDlgProc,(LPARAM)hwnd))
+ return TRUE;
+
+ else
+ return FALSE;
+
+}
+
+
+//=============================================================================
+//
+// EditModifyLinesDlg()
+//
+// Controls: 100 Input
+// 101 Input
+//
+typedef struct _modlinesdata {
+ LPWSTR pwsz1;
+ LPWSTR pwsz2;
+} MODLINESDATA, *PMODLINESDATA;
+
+
+BOOL CALLBACK EditModifyLinesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
+{
+ static PMODLINESDATA pdata;
+ switch(umsg)
+ {
+ case WM_INITDIALOG:
+ {
+ pdata = (PMODLINESDATA)lParam;
+ SetDlgItemTextW(hwnd,100,pdata->pwsz1);
+ SendDlgItemMessage(hwnd,100,EM_LIMITTEXT,255,0);
+ SetDlgItemTextW(hwnd,101,pdata->pwsz2);
+ SendDlgItemMessage(hwnd,101,EM_LIMITTEXT,255,0);
+ CenterDlgInParent(hwnd);
+ }
+ return TRUE;
+ case WM_COMMAND:
+ switch(LOWORD(wParam))
+ {
+ case IDOK: {
+ GetDlgItemTextW(hwnd,100,pdata->pwsz1,256);
+ GetDlgItemTextW(hwnd,101,pdata->pwsz2,256);
+ EndDialog(hwnd,IDOK);
+ }
+ break;
+ case IDCANCEL:
+ EndDialog(hwnd,IDCANCEL);
+ break;
+ }
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+//=============================================================================
+//
+// EditModifyLinesDlg()
+//
+BOOL EditModifyLinesDlg(HWND hwnd,LPWSTR pwsz1,LPWSTR pwsz2)
+{
+
+ int iResult;
+ MODLINESDATA data = { pwsz1, pwsz2 };
+
+ iResult = ThemedDialogBoxParam(
+ g_hInstance,
+ MAKEINTRESOURCEW(IDD_MODIFYLINES),
+ hwnd,
+ EditModifyLinesDlgProc,
+ (LPARAM)&data);
+
+ return (iResult == IDOK) ? TRUE : FALSE;
+
+}
+
+
+//=============================================================================
+//
+// EditEncloseSelectionDlgProc()
+//
+// Controls: 100 Input
+// 101 Input
+//
+typedef struct _encloseselectiondata {
+ LPWSTR pwsz1;
+ LPWSTR pwsz2;
+} ENCLOSESELDATA, *PENCLOSESELDATA;
+
+
+BOOL CALLBACK EditEncloseSelectionDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
+{
+ static PENCLOSESELDATA pdata;
+ switch(umsg)
+ {
+ case WM_INITDIALOG:
+ {
+ pdata = (PENCLOSESELDATA)lParam;
+ SendDlgItemMessage(hwnd,100,EM_LIMITTEXT,255,0);
+ SetDlgItemTextW(hwnd,100,pdata->pwsz1);
+ SendDlgItemMessage(hwnd,101,EM_LIMITTEXT,255,0);
+ SetDlgItemTextW(hwnd,101,pdata->pwsz2);
+ CenterDlgInParent(hwnd);
+ }
+ return TRUE;
+ case WM_COMMAND:
+ switch(LOWORD(wParam))
+ {
+ case IDOK: {
+ GetDlgItemTextW(hwnd,100,pdata->pwsz1,256);
+ GetDlgItemTextW(hwnd,101,pdata->pwsz2,256);
+ EndDialog(hwnd,IDOK);
+ }
+ break;
+ case IDCANCEL:
+ EndDialog(hwnd,IDCANCEL);
+ break;
+ }
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+//=============================================================================
+//
+// EditEncloseSelectionDlg()
+//
+BOOL EditEncloseSelectionDlg(HWND hwnd,LPWSTR pwszOpen,LPWSTR pwszClose)
+{
+
+ int iResult;
+ ENCLOSESELDATA data = { pwszOpen, pwszClose };
+
+ iResult = ThemedDialogBoxParam(
+ g_hInstance,
+ MAKEINTRESOURCEW(IDD_ENCLOSESELECTION),
+ hwnd,
+ EditEncloseSelectionDlgProc,
+ (LPARAM)&data);
+
+ return (iResult == IDOK) ? TRUE : FALSE;
+
+}
+
+
+//=============================================================================
+//
+// EditInsertTagDlgProc()
+//
+// Controls: 100 Input
+// 101 Input
+//
+typedef struct _tagsdata {
+ LPWSTR pwsz1;
+ LPWSTR pwsz2;
+} TAGSDATA, *PTAGSDATA;
+
+
+BOOL CALLBACK EditInsertTagDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
+{
+ static PTAGSDATA pdata;
+ switch(umsg)
+ {
+ case WM_INITDIALOG:
+ {
+ pdata = (PTAGSDATA)lParam;
+ SendDlgItemMessage(hwnd,100,EM_LIMITTEXT,254,0);
+ SetDlgItemTextW(hwnd,100,L"<tag>");
+ SendDlgItemMessage(hwnd,101,EM_LIMITTEXT,255,0);
+ SetDlgItemTextW(hwnd,101,L"</tag>");
+ SetFocus(GetDlgItem(hwnd,100));
+ PostMessage(GetDlgItem(hwnd,100),EM_SETSEL,1,4);
+ CenterDlgInParent(hwnd);
+ }
+ return FALSE;
+ case WM_COMMAND:
+ switch(LOWORD(wParam))
+ {
+ case 100: {
+ if (HIWORD(wParam) == EN_CHANGE) {
+
+ WCHAR wchBuf[256];
+ WCHAR wchIns[256] = L"</";
+ int cchIns = 2;
+ BOOL bClear = TRUE;
+
+ GetDlgItemTextW(hwnd,100,wchBuf,256);
+ if (lstrlen(wchBuf) >= 3) {
+
+ if (wchBuf[0] == L'<') {
+
+ const WCHAR* pwCur = &wchBuf[1];
+
+ while (
+ *pwCur &&
+ *pwCur != L'<' &&
+ *pwCur != L'>' &&
+ *pwCur != L' ' &&
+ *pwCur != L'\t' &&
+ (StrChr(L":_-.",*pwCur) || IsCharAlphaNumericW(*pwCur)))
+
+ wchIns[cchIns++] = *pwCur++;
+
+ while (
+ *pwCur &&
+ *pwCur != L'>')
+
+ pwCur++;
+
+ if (*pwCur == L'>' && *(pwCur-1) != L'/') {
+ wchIns[cchIns++] = L'>';
+ wchIns[cchIns] = L'\0';
+
+ if (cchIns > 3 &&
+ lstrcmpi(wchIns,L"</base>") &&
+ lstrcmpi(wchIns,L"</bgsound>") &&
+ lstrcmpi(wchIns,L"</br>") &&
+ lstrcmpi(wchIns,L"</embed>") &&
+ lstrcmpi(wchIns,L"</hr>") &&
+ lstrcmpi(wchIns,L"</img>") &&
+ lstrcmpi(wchIns,L"</input>") &&
+ lstrcmpi(wchIns,L"</link>") &&
+ lstrcmpi(wchIns,L"</meta>")) {
+
+ SetDlgItemTextW(hwnd,101,wchIns);
+ bClear = FALSE;
+ }
+ }
+ }
+ }
+ if (bClear)
+ SetDlgItemTextW(hwnd,101,L"");
+ }
+ }
+ break;
+ case IDOK: {
+ GetDlgItemTextW(hwnd,100,pdata->pwsz1,256);
+ GetDlgItemTextW(hwnd,101,pdata->pwsz2,256);
+ EndDialog(hwnd,IDOK);
+ }
+ break;
+ case IDCANCEL:
+ EndDialog(hwnd,IDCANCEL);
+ break;
+ }
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+//=============================================================================
+//
+// EditInsertTagDlg()
+//
+BOOL EditInsertTagDlg(HWND hwnd,LPWSTR pwszOpen,LPWSTR pwszClose)
+{
+
+ int iResult;
+ TAGSDATA data = { pwszOpen, pwszClose };
+
+ iResult = ThemedDialogBoxParam(
+ g_hInstance,
+ MAKEINTRESOURCEW(IDD_INSERTTAG),
+ hwnd,
+ EditInsertTagDlgProc,
+ (LPARAM)&data);
+
+ return (iResult == IDOK) ? TRUE : FALSE;
+
+}
+
+
+//=============================================================================
+//
+// EditSortDlgProc()
+//
+// Controls: 100 Radio Button
+// 101 Radio Button
+// 102 Check Box
+// 103 Check Box
+//
+BOOL CALLBACK EditSortDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
+{
+ static int *piSortFlags;
+ switch(umsg)
+ {
+ case WM_INITDIALOG:
+ {
+ piSortFlags = (int*)lParam;
+ if (*piSortFlags & SORT_DESCENDING)
+ CheckRadioButton(hwnd,100,101,101);
+ else
+ CheckRadioButton(hwnd,100,101,100);
+ if (*piSortFlags & SORT_UNIQ)
+ CheckDlgButton(hwnd,102,BST_CHECKED);
+ if (GetProcAddress(GetModuleHandle(L"shlwapi"),"StrCmpLogicalW")) {
+ if (*piSortFlags & SORT_LOGICAL)
+ CheckDlgButton(hwnd,103,BST_CHECKED);
+ }
+ else
+ EnableWindow(GetDlgItem(hwnd,103),FALSE);
+ CenterDlgInParent(hwnd);
+ }
+ return TRUE;
+ case WM_COMMAND:
+ switch(LOWORD(wParam))
+ {
+ case IDOK: {
+ *piSortFlags = 0;
+ if (IsDlgButtonChecked(hwnd,101) == BST_CHECKED)
+ *piSortFlags |= SORT_DESCENDING;
+ if (IsDlgButtonChecked(hwnd,102) == BST_CHECKED)
+ *piSortFlags |= SORT_UNIQ;
+ if (IsWindowEnabled(GetDlgItem(hwnd,103))) {
+ if (IsDlgButtonChecked(hwnd,103) == BST_CHECKED)
+ *piSortFlags |= SORT_LOGICAL;
+ }
+ EndDialog(hwnd,IDOK);
+ }
+ break;
+ case IDCANCEL:
+ EndDialog(hwnd,IDCANCEL);
+ break;
+ }
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+//=============================================================================
+//
+// EditSortDlg()
+//
+BOOL EditSortDlg(HWND hwnd,int *piSortFlags)
+{
+
+ int iResult;
+
+ iResult = ThemedDialogBoxParam(
+ g_hInstance,
+ MAKEINTRESOURCEW(IDD_SORT),
+ hwnd,
+ EditSortDlgProc,
+ (LPARAM)piSortFlags);
+
+ return (iResult == IDOK) ? TRUE : FALSE;
+
+}
+
+
+//=============================================================================
+//
+// FileVars_Init()
+//
+extern BOOL bNoEncodingTags;
+extern int fNoFileVariables;
+
+BOOL FileVars_Init(char *lpData,DWORD cbData,LPFILEVARS lpfv) {
+
+ int i;
+ char tch[512];
+
+ ZeroMemory(lpfv,sizeof(FILEVARS));
+ if ((fNoFileVariables && bNoEncodingTags) || !lpData || !cbData)
+ return(TRUE);
+
+ lstrcpynA(tch,lpData,min(cbData+1,COUNTOF(tch)));
+
+ if (!fNoFileVariables) {
+ if (FileVars_ParseInt(tch,"tab-width",&i)) {
+ lpfv->iTabWidth = max(min(i,256),1);
+ lpfv->mask |= FV_TABWIDTH;
+ }
+
+ if (FileVars_ParseInt(tch,"c-basic-indent",&i)) {
+ lpfv->iIndentWidth = max(min(i,256),0);
+ lpfv->mask |= FV_INDENTWIDTH;
+ }
+
+ if (FileVars_ParseInt(tch,"indent-tabs-mode",&i)) {
+ lpfv->bTabsAsSpaces = (i) ? FALSE : TRUE;
+ lpfv->mask |= FV_TABSASSPACES;
+ }
+
+ if (FileVars_ParseInt(tch,"fill-column",&i)) {
+ lpfv->iLongLinesLimit = max(min(i,4096),0);
+ lpfv->mask |= FV_LONGLINESLIMIT;
+ }
+ }
+
+ if (!IsUTF8Signature(lpData) && !bNoEncodingTags) {
+
+ if (FileVars_ParseStr(tch,"encoding",lpfv->tchEncoding,COUNTOF(lpfv->tchEncoding)))
+ lpfv->mask |= FV_ENCODING;
+ else if (FileVars_ParseStr(tch,"charset",lpfv->tchEncoding,COUNTOF(lpfv->tchEncoding)))
+ lpfv->mask |= FV_ENCODING;
+ else if (FileVars_ParseStr(tch,"coding",lpfv->tchEncoding,COUNTOF(lpfv->tchEncoding)))
+ lpfv->mask |= FV_ENCODING;
+ }
+
+ if (!fNoFileVariables) {
+ if (FileVars_ParseStr(tch,"mode",lpfv->tchMode,COUNTOF(lpfv->tchMode)))
+ lpfv->mask |= FV_MODE;
+ }
+
+ if (lpfv->mask == 0 && cbData > COUNTOF(tch)) {
+
+ lstrcpynA(tch,lpData+cbData-COUNTOF(tch)+1,COUNTOF(tch));
+
+ if (!fNoFileVariables) {
+ if (FileVars_ParseInt(tch,"tab-width",&i)) {
+ lpfv->iTabWidth = max(min(i,256),1);
+ lpfv->mask |= FV_TABWIDTH;
+ }
+
+ if (FileVars_ParseInt(tch,"c-basic-indent",&i)) {
+ lpfv->iIndentWidth = max(min(i,256),0);
+ lpfv->mask |= FV_INDENTWIDTH;
+ }
+
+ if (FileVars_ParseInt(tch,"indent-tabs-mode",&i)) {
+ lpfv->bTabsAsSpaces = (i) ? FALSE : TRUE;
+ lpfv->mask |= FV_TABSASSPACES;
+ }
+
+ if (FileVars_ParseInt(tch,"fill-column",&i)) {
+ lpfv->iLongLinesLimit = max(min(i,4096),0);
+ lpfv->mask |= FV_LONGLINESLIMIT;
+ }
+ }
+
+ if (!IsUTF8Signature(lpData) && !bNoEncodingTags) {
+
+ if (FileVars_ParseStr(tch,"encoding",lpfv->tchEncoding,COUNTOF(lpfv->tchEncoding)))
+ lpfv->mask |= FV_ENCODING;
+ else if (FileVars_ParseStr(tch,"charset",lpfv->tchEncoding,COUNTOF(lpfv->tchEncoding)))
+ lpfv->mask |= FV_ENCODING;
+ else if (FileVars_ParseStr(tch,"coding",lpfv->tchEncoding,COUNTOF(lpfv->tchEncoding)))
+ lpfv->mask |= FV_ENCODING;
+ }
+
+ if (!fNoFileVariables) {
+ if (FileVars_ParseStr(tch,"mode",lpfv->tchMode,COUNTOF(lpfv->tchMode)))
+ lpfv->mask |= FV_MODE;
+ }
+ }
+
+ if (lpfv->mask & FV_ENCODING)
+ lpfv->iEncoding = Encoding_MatchA(lpfv->tchEncoding);
+
+ return(TRUE);
+}
+
+
+//=============================================================================
+//
+// FileVars_Apply()
+//
+extern int iTabWidth;
+extern int iTabWidthG;
+extern int iIndentWidth;
+extern int iIndentWidthG;
+extern BOOL bTabsAsSpaces;
+extern BOOL bTabsAsSpacesG;
+extern int iLongLinesLimit;
+extern int iLongLinesLimitG;
+extern int iWrapCol;
+
+BOOL FileVars_Apply(HWND hwnd,LPFILEVARS lpfv) {
+
+ if (lpfv->mask & FV_TABWIDTH)
+ iTabWidth = lpfv->iTabWidth;
+ else
+ iTabWidth = iTabWidthG;
+ SendMessage(hwnd,SCI_SETTABWIDTH,iTabWidth,0);
+
+ if (lpfv->mask & FV_INDENTWIDTH)
+ iIndentWidth = lpfv->iIndentWidth;
+ else
+ iIndentWidth = iIndentWidthG;
+ SendMessage(hwnd,SCI_SETINDENT,iIndentWidth,0);
+
+ if (lpfv->mask & FV_TABSASSPACES)
+ bTabsAsSpaces = lpfv->bTabsAsSpaces;
+ else
+ bTabsAsSpaces = bTabsAsSpacesG;
+ SendMessage(hwnd,SCI_SETUSETABS,!bTabsAsSpaces,0);
+
+ if (lpfv->mask & FV_LONGLINESLIMIT)
+ iLongLinesLimit = lpfv->iLongLinesLimit;
+ else
+ iLongLinesLimit = iLongLinesLimitG;
+ SendMessage(hwnd,SCI_SETEDGECOLUMN,iLongLinesLimit,0);
+
+ iWrapCol = 0;
+
+ return(TRUE);
+}
+
+
+//=============================================================================
+//
+// FileVars_ParseInt()
+//
+BOOL FileVars_ParseInt(char* pszData,char* pszName,int* piValue) {
+
+ char tch[32];
+ char *pvStart = pszData;
+ char chPrev;
+ char *pvEnd;
+ int itok;
+
+ while (pvStart = StrStrIA(pvStart,pszName)) {
+ chPrev = (pvStart > pszData) ? *(pvStart-1) : 0;
+ if (!IsCharAlphaNumericA(chPrev) && chPrev != '-' && chPrev != '_') {
+ pvStart += lstrlenA(pszName);
+ while (*pvStart == ' ')
+ pvStart++;
+ if (*pvStart == ':' || *pvStart == '=')
+ break;
+ }
+ else
+ pvStart += lstrlenA(pszName);
+ }
+
+ if (pvStart) {
+
+ while (*pvStart && StrChrIA(":=\"' \t",*pvStart))
+ pvStart++;
+
+ lstrcpynA(tch,pvStart,COUNTOF(tch));
+
+ pvEnd = tch;
+ while (*pvEnd && IsCharAlphaNumericA(*pvEnd))
+ pvEnd++;
+ *pvEnd = 0;
+ StrTrimA(tch," \t:=\"'");
+
+ itok = sscanf(tch,"%i",piValue);
+ if (itok == 1)
+ return(TRUE);
+
+ if (tch[0] == 't') {
+ *piValue = 1;
+ return(TRUE);
+ }
+
+ if (tch[0] == 'n' || tch[0] == 'f') {
+ *piValue = 0;
+ return(TRUE);
+ }
+ }
+ return(FALSE);
+}
+
+
+//=============================================================================
+//
+// FileVars_ParseStr()
+//
+BOOL FileVars_ParseStr(char* pszData,char* pszName,char* pszValue,int cchValue) {
+
+ char tch[32];
+ char *pvStart = pszData;
+ char chPrev;
+ char *pvEnd;
+ BOOL bQuoted = FALSE;
+
+ while (pvStart = StrStrIA(pvStart,pszName)) {
+ chPrev = (pvStart > pszData) ? *(pvStart-1) : 0;
+ if (!IsCharAlphaNumericA(chPrev) && chPrev != '-' && chPrev != '_') {
+ pvStart += lstrlenA(pszName);
+ while (*pvStart == ' ')
+ pvStart++;
+ if (*pvStart == ':' || *pvStart == '=')
+ break;
+ }
+ else
+ pvStart += lstrlenA(pszName);
+ }
+
+ if (pvStart) {
+
+ while (*pvStart && StrChrIA(":=\"' \t",*pvStart)) {
+ if (*pvStart == '\'' || *pvStart == '"')
+ bQuoted = TRUE;
+ pvStart++;
+ }
+ lstrcpynA(tch,pvStart,COUNTOF(tch));
+
+ pvEnd = tch;
+ while (*pvEnd && (IsCharAlphaNumericA(*pvEnd) || StrChrIA("+-/_",*pvEnd) || (bQuoted && *pvEnd == ' ')))
+ pvEnd++;
+ *pvEnd = 0;
+ StrTrimA(tch," \t:=\"'");
+
+ lstrcpynA(pszValue,tch,cchValue);
+ return(TRUE);
+ }
+ return(FALSE);
+}
+
+
+//=============================================================================
+//
+// FileVars_IsUTF8()
+//
+BOOL FileVars_IsUTF8(LPFILEVARS lpfv) {
+ if (lpfv->mask & FV_ENCODING) {
+ if (lstrcmpiA(lpfv->tchEncoding,"utf-8") == 0 ||
+ lstrcmpiA(lpfv->tchEncoding,"utf8") == 0)
+ return(TRUE);
+ }
+ return(FALSE);
+}
+
+
+//=============================================================================
+//
+// FileVars_IsNonUTF8()
+//
+BOOL FileVars_IsNonUTF8(LPFILEVARS lpfv) {
+ if (lpfv->mask & FV_ENCODING) {
+ if (lstrlenA(lpfv->tchEncoding) &&
+ lstrcmpiA(lpfv->tchEncoding,"utf-8") != 0 &&
+ lstrcmpiA(lpfv->tchEncoding,"utf8") != 0)
+ return(TRUE);
+ }
+ return(FALSE);
+}
+
+
+//=============================================================================
+//
+// FileVars_IsValidEncoding()
+//
+BOOL FileVars_IsValidEncoding(LPFILEVARS lpfv) {
+ CPINFO cpi;
+ if (lpfv->mask & FV_ENCODING &&
+ lpfv->iEncoding >= 0 &&
+ lpfv->iEncoding < COUNTOF(mEncoding)) {
+ if ((mEncoding[lpfv->iEncoding].uFlags & NCP_INTERNAL) ||
+ IsValidCodePage(mEncoding[lpfv->iEncoding].uCodePage) &&
+ GetCPInfo(mEncoding[lpfv->iEncoding].uCodePage,&cpi)) {
+ return(TRUE);
+ }
+ }
+ return(FALSE);
+}
+
+
+//=============================================================================
+//
+// FileVars_GetEncoding()
+//
+int FileVars_GetEncoding(LPFILEVARS lpfv) {
+ if (lpfv->mask & FV_ENCODING)
+ return(lpfv->iEncoding);
+ else
+ return(-1);
+}
+
+
+//=============================================================================
+//
+// SciInitThemes()
+//
+//WNDPROC pfnSciWndProc = NULL;
+//
+//FARPROC pfnOpenThemeData = NULL;
+//FARPROC pfnCloseThemeData = NULL;
+//FARPROC pfnDrawThemeBackground = NULL;
+//FARPROC pfnGetThemeBackgroundContentRect = NULL;
+//FARPROC pfnIsThemeActive = NULL;
+//FARPROC pfnDrawThemeParentBackground = NULL;
+//FARPROC pfnIsThemeBackgroundPartiallyTransparent = NULL;
+//
+//BOOL bThemesPresent = FALSE;
+//extern BOOL bIsAppThemed;
+//extern HMODULE hModUxTheme;
+//
+//void SciInitThemes(HWND hwnd)
+//{
+// if (hModUxTheme) {
+//
+// pfnOpenThemeData = GetProcAddress(hModUxTheme,"OpenThemeData");
+// pfnCloseThemeData = GetProcAddress(hModUxTheme,"CloseThemeData");
+// pfnDrawThemeBackground = GetProcAddress(hModUxTheme,"DrawThemeBackground");
+// pfnGetThemeBackgroundContentRect = GetProcAddress(hModUxTheme,"GetThemeBackgroundContentRect");
+// pfnIsThemeActive = GetProcAddress(hModUxTheme,"IsThemeActive");
+// pfnDrawThemeParentBackground = GetProcAddress(hModUxTheme,"DrawThemeParentBackground");
+// pfnIsThemeBackgroundPartiallyTransparent = GetProcAddress(hModUxTheme,"IsThemeBackgroundPartiallyTransparent");
+//
+// pfnSciWndProc = (WNDPROC)SetWindowLongPtrW(hwnd,GWLP_WNDPROC,(LONG_PTR)&SciThemedWndProc);
+// bThemesPresent = TRUE;
+// }
+//}
+//
+//
+////=============================================================================
+////
+//// SciThemedWndProc()
+////
+//LRESULT CALLBACK SciThemedWndProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
+//{
+// static RECT rcContent;
+//
+// if (umsg == WM_NCCALCSIZE) {
+// if (wParam) {
+// LRESULT lresult = CallWindowProcW(pfnSciWndProc,hwnd,WM_NCCALCSIZE,wParam,lParam);
+// NCCALCSIZE_PARAMS *csp = (NCCALCSIZE_PARAMS*)lParam;
+//
+// if (bThemesPresent && bIsAppThemed) {
+// HANDLE hTheme = (HANDLE)pfnOpenThemeData(hwnd,L"edit");
+// if(hTheme) {
+// BOOL bSuccess = FALSE;
+// RECT rcClient;
+//
+// if(pfnGetThemeBackgroundContentRect(
+// hTheme,NULL,/*EP_EDITTEXT*/1,/*ETS_NORMAL*/1,&csp->rgrc[0],&rcClient) == S_OK) {
+// InflateRect(&rcClient,-1,-1);
+//
+// rcContent.left = rcClient.left-csp->rgrc[0].left;
+// rcContent.top = rcClient.top-csp->rgrc[0].top;
+// rcContent.right = csp->rgrc[0].right-rcClient.right;
+// rcContent.bottom = csp->rgrc[0].bottom-rcClient.bottom;
+//
+// CopyRect(&csp->rgrc[0],&rcClient);
+// bSuccess = TRUE;
+// }
+// pfnCloseThemeData(hTheme);
+//
+// if (bSuccess)
+// return WVR_REDRAW;
+// }
+// }
+// return lresult;
+// }
+// }
+//
+// else if (umsg == WM_NCPAINT) {
+// LRESULT lresult = CallWindowProcW(pfnSciWndProc,hwnd,WM_NCPAINT,wParam,lParam);
+// if(bThemesPresent && bIsAppThemed) {
+//
+// HANDLE hTheme = (HANDLE)pfnOpenThemeData(hwnd,L"edit");
+// if(hTheme) {
+// RECT rcBorder;
+// RECT rcClient;
+// int nState;
+//
+// HDC hdc = GetWindowDC(hwnd);
+//
+// GetWindowRect(hwnd,&rcBorder);
+// OffsetRect(&rcBorder,-rcBorder.left,-rcBorder.top);
+//
+// CopyRect(&rcClient,&rcBorder);
+// rcClient.left += rcContent.left;
+// rcClient.top += rcContent.top;
+// rcClient.right -= rcContent.right;
+// rcClient.bottom -= rcContent.bottom;
+//
+// ExcludeClipRect(hdc,rcClient.left,rcClient.top,rcClient.right,rcClient.bottom);
+//
+// if(pfnIsThemeBackgroundPartiallyTransparent(hTheme,/*EP_EDITTEXT*/1,/*ETS_NORMAL*/1))
+// pfnDrawThemeParentBackground(hwnd,hdc,&rcBorder);
+//
+// /*
+// ETS_NORMAL = 1
+// ETS_HOT = 2
+// ETS_SELECTED = 3
+// ETS_DISABLED = 4
+// ETS_FOCUSED = 5
+// ETS_READONLY = 6
+// ETS_ASSIST = 7
+// */
+//
+// if(!IsWindowEnabled(hwnd))
+// nState = /*ETS_DISABLED*/4;
+// else if (GetFocus() == hwnd)
+// nState = /*ETS_FOCUSED*/5;
+// else if(SendMessage(hwnd,SCI_GETREADONLY,0,0))
+// nState = /*ETS_READONLY*/6;
+// else
+// nState = /*ETS_NORMAL*/1;
+//
+// pfnDrawThemeBackground(hTheme,hdc,/*EP_EDITTEXT*/1,nState,&rcBorder,NULL);
+// pfnCloseThemeData(hTheme);
+//
+// ReleaseDC(hwnd,hdc);
+// return 0;
+// }
+// }
+// return lresult;
+// }
+//
+// return CallWindowProcW(pfnSciWndProc,hwnd,umsg,wParam,lParam);
+//}
+
+
+
+/// End of Edit.c \\\
diff --git a/src/Edit.h b/src/Edit.h new file mode 100644 index 0000000..e3d3a51 --- /dev/null +++ b/src/Edit.h @@ -0,0 +1,198 @@ +/******************************************************************************
+*
+*
+* Notepad2
+*
+* Edit.h
+* Text File Editing Helper Stuff
+*
+* See Readme.txt for more information about this source code.
+* Please send me your comments to this work.
+*
+* See License.txt for details about distribution and modification.
+*
+* (c) Florian Balmer 1996-2010
+* florian.balmer@gmail.com
+* http://www.flos-freeware.ch
+*
+*
+******************************************************************************/
+
+
+
+// extern "C" declarations of Scintilla functions
+BOOL Scintilla_RegisterClasses(HINSTANCE);
+BOOL Scintilla_ReleaseResources();
+
+
+typedef struct _editfindreplace
+{
+ char szFind[512];
+ char szReplace[512];
+ char szFindUTF8[3*512];
+ char szReplaceUTF8[3*512];
+ UINT fuFlags;
+ BOOL bTransformBS;
+ BOOL bObsolete /* was bFindUp */;
+ BOOL bFindClose;
+ BOOL bReplaceClose;
+ BOOL bNoFindWrap;
+ HWND hwnd;
+ //HANDLE hMRUFind;
+ //HANDLE hMRUReplace;
+
+} EDITFINDREPLACE, *LPEDITFINDREPLACE, *LPCEDITFINDREPLACE;
+
+
+#define IDMSG_SWITCHTOFIND 204
+#define IDMSG_SWITCHTOREPLACE 205
+
+
+#define SORT_ASCENDING 0
+#define SORT_DESCENDING 1
+#define SORT_UNIQ 2
+#define SORT_LOGICAL 4
+
+
+HWND EditCreate(HWND);
+void EditSetNewText(HWND,char*,DWORD);
+BOOL EditConvertText(HWND,UINT,UINT,BOOL);
+BOOL EditSetNewEncoding(HWND,int,int,BOOL,BOOL);
+char* EditGetClipboardText(HWND);
+BOOL EditCopyAppend(HWND);
+int EditDetectEOLMode(HWND,char*,DWORD);
+BOOL EditLoadFile(HWND,LPCWSTR,BOOL,int*,int*,BOOL*,BOOL*);
+BOOL EditSaveFile(HWND,LPCWSTR,int,BOOL*,BOOL);
+
+void EditMakeUppercase(HWND);
+void EditMakeLowercase(HWND);
+void EditInvertCase(HWND);
+void EditTitleCase(HWND);
+void EditSentenceCase(HWND);
+
+void EditURLEncode(HWND);
+void EditURLDecode(HWND);
+void EditEscapeCChars(HWND);
+void EditUnescapeCChars(HWND);
+void EditModifyNumber(HWND,BOOL);
+
+void EditTabsToSpaces(HWND,int,BOOL);
+void EditSpacesToTabs(HWND,int,BOOL);
+
+void EditMoveUp(HWND);
+void EditMoveDown(HWND);
+void EditModifyLines(HWND,LPCWSTR,LPCWSTR);
+void EditEncloseSelection(HWND,LPCWSTR,LPCWSTR);
+void EditToggleLineComments(HWND,LPCWSTR,BOOL);
+void EditPadWithSpaces(HWND);
+void EditStripFirstCharacter(HWND);
+void EditStripLastCharacter(HWND);
+void EditStripTrailingBlanks(HWND,BOOL);
+void EditCompressSpaces(HWND);
+void EditRemoveBlankLines(HWND);
+void EditWrapToColumn(HWND,int);
+void EditJoinLinesEx(HWND);
+void EditSortLines(HWND,int);
+
+void EditJumpTo(HWND,int,int);
+void EditSelectEx(HWND,int,int);
+void EditGetExcerpt(HWND,LPWSTR,DWORD);
+
+HWND EditFindReplaceDlg(HWND,LPCEDITFINDREPLACE,BOOL);
+BOOL EditFindNext(HWND,LPCEDITFINDREPLACE,BOOL);
+BOOL EditFindPrev(HWND,LPCEDITFINDREPLACE,BOOL);
+BOOL EditReplace(HWND,LPCEDITFINDREPLACE);
+BOOL EditReplaceAll(HWND,LPCEDITFINDREPLACE,BOOL);
+BOOL EditReplaceAllInSelection(HWND,LPCEDITFINDREPLACE,BOOL);
+BOOL EditLinenumDlg(HWND);
+BOOL EditModifyLinesDlg(HWND,LPWSTR,LPWSTR);
+BOOL EditEncloseSelectionDlg(HWND,LPWSTR,LPWSTR);
+BOOL EditInsertTagDlg(HWND,LPWSTR,LPWSTR);
+BOOL EditSortDlg(HWND,int*);
+BOOL EditPrint(HWND,LPCWSTR,LPCWSTR);
+void EditPrintSetup(HWND);
+void EditPrintInit();
+
+#define NCP_DEFAULT 1
+#define NCP_UTF8 2
+#define NCP_UTF8_SIGN 4
+#define NCP_UNICODE 8
+#define NCP_UNICODE_REVERSE 16
+#define NCP_UNICODE_BOM 32
+#define NCP_8BIT 64
+#define NCP_INTERNAL (NCP_DEFAULT|NCP_UTF8|NCP_UTF8_SIGN|NCP_UNICODE|NCP_UNICODE_REVERSE|NCP_UNICODE_BOM)
+#define NCP_RECODE 128
+#define CPI_NONE -1
+#define CPI_DEFAULT 0
+#define CPI_OEM 1
+#define CPI_UNICODEBOM 2
+#define CPI_UNICODEBEBOM 3
+#define CPI_UNICODE 4
+#define CPI_UNICODEBE 5
+#define CPI_UTF8 6
+#define CPI_UTF8SIGN 7
+#define CPI_UTF7 8
+
+#define IDS_ENCODINGNAME0 61000
+#define IDS_EOLMODENAME0 62000
+
+typedef struct _np2encoding {
+ UINT uFlags;
+ UINT uCodePage;
+ char* pszParseNames;
+ int idsName;
+ WCHAR wchLabel[32];
+} NP2ENCODING;
+
+void Encoding_InitDefaults();
+int Encoding_MapIniSetting(BOOL,int);
+void Encoding_GetLabel(int);
+int Encoding_MatchW(LPCWSTR);
+int Encoding_MatchA(char*);
+BOOL Encoding_IsValid(int);
+void Encoding_AddToListView(HWND,int,BOOL);
+BOOL Encoding_GetFromListView(HWND,int *);
+void Encoding_AddToComboboxEx(HWND,int,BOOL);
+BOOL Encoding_GetFromComboboxEx(HWND,int *);
+
+BOOL IsUnicode(const char*,int,LPBOOL,LPBOOL);
+BOOL IsUTF8(const char*,int);
+BOOL IsUTF7(const char*,int);
+
+
+//void SciInitThemes(HWND);
+//LRESULT CALLBACK SciThemedWndProc(HWND,UINT,WPARAM,LPARAM);
+
+
+#define FV_TABWIDTH 1
+#define FV_INDENTWIDTH 2
+#define FV_TABSASSPACES 4
+#define FV_LONGLINESLIMIT 8
+#define FV_ENCODING 16
+#define FV_MODE 32
+
+typedef struct _filevars {
+
+ int mask;
+ int iTabWidth;
+ int iIndentWidth;
+ BOOL bTabsAsSpaces;
+ int iLongLinesLimit;
+ char tchEncoding[32];
+ int iEncoding;
+ char tchMode[32];
+
+} FILEVARS, *LPFILEVARS;
+
+BOOL FileVars_Init(char*,DWORD,LPFILEVARS);
+BOOL FileVars_Apply(HWND,LPFILEVARS);
+BOOL FileVars_ParseInt(char*,char*,int*);
+BOOL FileVars_ParseStr(char*,char*,char*,int);
+BOOL FileVars_IsUTF8(LPFILEVARS);
+BOOL FileVars_IsNonUTF8(LPFILEVARS);
+BOOL FileVars_IsValidEncoding(LPFILEVARS);
+int FileVars_GetEncoding(LPFILEVARS);
+
+
+
+/// End of Edit.h \\\
diff --git a/src/Helpers.c b/src/Helpers.c new file mode 100644 index 0000000..16de67a --- /dev/null +++ b/src/Helpers.c @@ -0,0 +1,2265 @@ +/******************************************************************************
+*
+*
+* Notepad2
+*
+* Helpers.c
+* General helper functions
+* Parts taken from SciTE, (c) Neil Hodgson, http://www.scintilla.org
+* MinimizeToTray (c) 2000 Matthew Ellis
+*
+* See Readme.txt for more information about this source code.
+* Please send me your comments to this work.
+*
+* See License.txt for details about distribution and modification.
+*
+* (c) Florian Balmer 1996-2010
+* florian.balmer@gmail.com
+* http://www.flos-freeware.ch
+*
+*
+******************************************************************************/
+#define _WIN32_WINNT 0x501
+#include <windows.h>
+#include <shlobj.h>
+#include <shlwapi.h>
+#include <commctrl.h>
+#include <uxtheme.h>
+#include <stdio.h>
+#include <string.h>
+#include "helpers.h"
+#include "resource.h"
+
+
+
+//=============================================================================
+//
+// Manipulation of (cached) ini file sections
+//
+int IniSectionGetString(
+ LPCWSTR lpCachedIniSection,
+ LPCWSTR lpName,
+ LPCWSTR lpDefault,
+ LPWSTR lpReturnedString,
+ int cchReturnedString)
+{
+ WCHAR *p = (WCHAR *)lpCachedIniSection;
+ WCHAR tch[256];
+ int ich;
+
+ if (p) {
+ lstrcpy(tch,lpName);
+ lstrcat(tch,L"=");
+ ich = lstrlen(tch);
+
+ while (*p) {
+ if (StrCmpNI(p,tch,ich) == 0) {
+ lstrcpyn(lpReturnedString,p + ich,cchReturnedString);
+ return(lstrlen(lpReturnedString));
+ }
+ else
+ p = StrEnd(p) + 1;
+ }
+ }
+ lstrcpyn(lpReturnedString,lpDefault,cchReturnedString);
+ return(lstrlen(lpReturnedString));
+}
+
+
+int IniSectionGetInt(
+ LPCWSTR lpCachedIniSection,
+ LPCWSTR lpName,
+ int iDefault)
+{
+ WCHAR *p = (WCHAR *)lpCachedIniSection;
+ WCHAR tch[256];
+ int ich;
+ int i;
+
+ if (p) {
+ lstrcpy(tch,lpName);
+ lstrcat(tch,L"=");
+ ich = lstrlen(tch);
+
+ while (*p) {
+ if (StrCmpNI(p,tch,ich) == 0) {
+ if (swscanf(p + ich,L"%i",&i) == 1)
+ return(i);
+ else
+ return(iDefault);
+ }
+ else
+ p = StrEnd(p) + 1;
+ }
+ }
+ return(iDefault);
+}
+
+
+BOOL IniSectionSetString(LPWSTR lpCachedIniSection,LPCWSTR lpName,LPCWSTR lpString)
+{
+ WCHAR tch[32+512*3+32];
+ WCHAR *p = lpCachedIniSection;
+
+ if (p) {
+ while (*p) {
+ p = StrEnd(p) + 1;
+ }
+ wsprintf(tch,L"%s=%s",lpName,lpString);
+ lstrcpy(p,tch);
+ p = StrEnd(p) + 1;
+ *p = 0;
+ return(TRUE);
+ }
+ return(FALSE);
+}
+
+
+//=============================================================================
+//
+// BeginWaitCursor()
+//
+void BeginWaitCursor()
+{
+
+ DestroyCursor(
+ SetCursor(
+ LoadCursor(NULL,IDC_WAIT)));
+
+}
+
+
+//=============================================================================
+//
+// EndWaitCursor()
+//
+void EndWaitCursor()
+{
+
+ DestroyCursor(
+ SetCursor(
+ LoadCursor(NULL,IDC_ARROW)));
+
+}
+
+
+//=============================================================================
+//
+// PrivateIsAppThemed()
+//
+extern HMODULE hModUxTheme;
+BOOL PrivateIsAppThemed()
+{
+ FARPROC pfnIsAppThemed;
+ BOOL bIsAppThemed = FALSE;
+
+ if (hModUxTheme) {
+ pfnIsAppThemed = GetProcAddress(hModUxTheme,"IsAppThemed");
+
+ if (pfnIsAppThemed)
+ bIsAppThemed = pfnIsAppThemed();
+ }
+ return bIsAppThemed;
+}
+
+
+//=============================================================================
+//
+// PrivateSetCurrentProcessExplicitAppUserModelID()
+//
+HRESULT PrivateSetCurrentProcessExplicitAppUserModelID(PCWSTR AppID)
+{
+ FARPROC pfnSetCurrentProcessExplicitAppUserModelID;
+
+ if (lstrlen(AppID) == 0)
+ return(S_OK);
+
+ if (lstrcmpi(AppID,L"(default)") == 0)
+ return(S_OK);
+
+ pfnSetCurrentProcessExplicitAppUserModelID =
+ GetProcAddress(GetModuleHandleA("shell32.dll"),"SetCurrentProcessExplicitAppUserModelID");
+
+ if (pfnSetCurrentProcessExplicitAppUserModelID)
+ return(pfnSetCurrentProcessExplicitAppUserModelID(AppID));
+
+ else
+ return(S_OK);
+}
+
+
+//=============================================================================
+//
+// IsElevated()
+//
+BOOL IsElevated() {
+
+ BOOL bIsElevated = FALSE;
+ HANDLE hToken = NULL;
+
+ if (!IsVista())
+ return(FALSE);
+
+ if (OpenProcessToken(GetCurrentProcess(),TOKEN_QUERY,&hToken)) {
+
+ struct {
+ DWORD TokenIsElevated;
+ } /*TOKEN_ELEVATION*/te;
+ DWORD dwReturnLength = 0;
+
+ if (GetTokenInformation(hToken,/*TokenElevation*/20,&te,sizeof(te),&dwReturnLength)) {
+ if (dwReturnLength == sizeof(te))
+ bIsElevated = te.TokenIsElevated;
+ }
+ CloseHandle( hToken );
+ }
+ return bIsElevated;
+}
+
+
+
+//=============================================================================
+//
+// SetExplorerTheme()
+//
+//BOOL SetExplorerTheme(HWND hwnd)
+//{
+// FARPROC pfnSetWindowTheme;
+//
+// if (IsVista()) {
+// if (hModUxTheme) {
+// pfnSetWindowTheme = GetProcAddress(hModUxTheme,"SetWindowTheme");
+//
+// if (pfnSetWindowTheme)
+// return (S_OK == pfnSetWindowTheme(hwnd,L"Explorer",NULL));
+// }
+// }
+// return FALSE;
+//}
+
+
+//=============================================================================
+//
+// VerifyContrast()
+// Check if two colors can be distinguished
+//
+BOOL VerifyContrast(COLORREF cr1,COLORREF cr2)
+{
+ BYTE r1 = GetRValue(cr1);
+ BYTE g1 = GetGValue(cr1);
+ BYTE b1 = GetBValue(cr1);
+ BYTE r2 = GetRValue(cr2);
+ BYTE g2 = GetGValue(cr2);
+ BYTE b2 = GetBValue(cr2);
+
+ return(
+ ((abs((3*r1 + 5*g1 + 1*b1) - (3*r2 + 6*g2 + 1*b2))) >= 400) ||
+ ((abs(r1-r2) + abs(b1-b2) + abs(g1-g2)) >= 400));
+}
+
+
+//=============================================================================
+//
+// SetWindowTitle()
+//
+BOOL bFreezeAppTitle = FALSE;
+
+BOOL SetWindowTitle(HWND hwnd,UINT uIDAppName,BOOL bIsElevated,UINT uIDUntitled,
+ LPCWSTR lpszFile,int iFormat,BOOL bModified,
+ UINT uIDReadOnly,BOOL bReadOnly,LPCWSTR lpszExcerpt)
+{
+
+ WCHAR szUntitled[128];
+ WCHAR szExcrptQuot[256];
+ WCHAR szExcrptFmt[32];
+ WCHAR szAppName[128];
+ WCHAR szElevatedAppName[128];
+ WCHAR szReadOnly[32];
+ WCHAR szTitle[512];
+ static const WCHAR *pszSep = L" - ";
+ static const WCHAR *pszMod = L"* ";
+
+ if (bFreezeAppTitle)
+ return FALSE;
+
+ if (!GetString(uIDAppName,szAppName,COUNTOF(szAppName)) ||
+ !GetString(uIDUntitled,szUntitled,COUNTOF(szUntitled)))
+ return FALSE;
+
+ if (bIsElevated) {
+ FormatString(szElevatedAppName,COUNTOF(szElevatedAppName),IDS_APPTITLE_ELEVATED,szAppName);
+ StrCpyN(szAppName,szElevatedAppName,COUNTOF(szAppName));
+ }
+
+ if (bModified)
+ lstrcpy(szTitle,pszMod);
+ else
+ lstrcpy(szTitle,L"");
+
+ if (lstrlen(lpszExcerpt)) {
+ GetString(IDS_TITLEEXCERPT,szExcrptFmt,COUNTOF(szExcrptFmt));
+ wsprintf(szExcrptQuot,szExcrptFmt,lpszExcerpt);
+ StrCat(szTitle,szExcrptQuot);
+ }
+
+ else if (lstrlen(lpszFile))
+ {
+ if (iFormat < 2 && !PathIsRoot(lpszFile))
+ {
+ SHFILEINFO shfi;
+ if (SHGetFileInfo2(lpszFile,0,&shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME))
+ lstrcat(szTitle,shfi.szDisplayName);
+ else
+ lstrcat(szTitle,PathFindFileName(lpszFile));
+ if (iFormat == 1) {
+ WCHAR tchPath[MAX_PATH];
+ StrCpyN(tchPath,lpszFile,COUNTOF(tchPath));
+ PathRemoveFileSpec(tchPath);
+ StrCat(szTitle,L" [");
+ StrCat(szTitle,tchPath);
+ StrCat(szTitle,L"]");
+ }
+ }
+ else
+ lstrcat(szTitle,lpszFile);
+ }
+
+ else
+ lstrcat(szTitle,szUntitled);
+
+ if (bReadOnly && GetString(uIDReadOnly,szReadOnly,COUNTOF(szReadOnly)))
+ {
+ lstrcat(szTitle,L" ");
+ lstrcat(szTitle,szReadOnly);
+ }
+
+ lstrcat(szTitle,pszSep);
+ lstrcat(szTitle,szAppName);
+
+ return SetWindowText(hwnd,szTitle);
+
+}
+
+
+//=============================================================================
+//
+// SetWindowTransparentMode()
+//
+void SetWindowTransparentMode(HWND hwnd,BOOL bTransparentMode)
+{
+ FARPROC fp;
+ int iAlphaPercent;
+ BYTE bAlpha;
+
+ if (bTransparentMode) {
+ if (fp = GetProcAddress(GetModuleHandle(L"User32"),"SetLayeredWindowAttributes")) {
+ SetWindowLong(hwnd,GWL_EXSTYLE,
+ GetWindowLong(hwnd,GWL_EXSTYLE) | WS_EX_LAYERED);
+
+ // get opacity level from registry
+ iAlphaPercent = IniGetInt(L"Settings2",L"OpacityLevel",75);
+ if (iAlphaPercent < 0 || iAlphaPercent > 100)
+ iAlphaPercent = 75;
+ bAlpha = iAlphaPercent * 255 / 100;
+
+ fp(hwnd,0,bAlpha,LWA_ALPHA);
+ }
+ }
+
+ else
+ SetWindowLong(hwnd,GWL_EXSTYLE,
+ GetWindowLong(hwnd,GWL_EXSTYLE) & ~WS_EX_LAYERED);
+}
+
+
+//=============================================================================
+//
+// CenterDlgInParent()
+//
+void CenterDlgInParent(HWND hDlg)
+{
+
+ RECT rcDlg;
+ HWND hParent;
+ RECT rcParent;
+ MONITORINFO mi;
+ HMONITOR hMonitor;
+
+ int xMin, yMin, xMax, yMax, x, y;
+
+ GetWindowRect(hDlg,&rcDlg);
+
+ hParent = GetParent(hDlg);
+ GetWindowRect(hParent,&rcParent);
+
+ hMonitor = MonitorFromRect(&rcParent,MONITOR_DEFAULTTONEAREST);
+ mi.cbSize = sizeof(mi);
+ GetMonitorInfo(hMonitor,&mi);
+
+ xMin = mi.rcWork.left;
+ yMin = mi.rcWork.top;
+
+ xMax = (mi.rcWork.right) - (rcDlg.right - rcDlg.left);
+ yMax = (mi.rcWork.bottom) - (rcDlg.bottom - rcDlg.top);
+
+ if ((rcParent.right - rcParent.left) - (rcDlg.right - rcDlg.left) > 20)
+ x = rcParent.left + (((rcParent.right - rcParent.left) - (rcDlg.right - rcDlg.left)) / 2);
+ else
+ x = rcParent.left + 70;
+
+ if ((rcParent.bottom - rcParent.top) - (rcDlg.bottom - rcDlg.top) > 20)
+ y = rcParent.top + (((rcParent.bottom - rcParent.top) - (rcDlg.bottom - rcDlg.top)) / 2);
+ else
+ y = rcParent.top + 60;
+
+ SetWindowPos(hDlg,NULL,max(xMin,min(xMax,x)),max(yMin,min(yMax,y)),0,0,SWP_NOZORDER|SWP_NOSIZE);
+
+}
+
+
+//=============================================================================
+//
+// GetDlgPos()
+//
+void GetDlgPos(HWND hDlg,LPINT xDlg,LPINT yDlg)
+{
+
+ RECT rcDlg;
+ HWND hParent;
+ RECT rcParent;
+
+ GetWindowRect(hDlg,&rcDlg);
+
+ hParent = GetParent(hDlg);
+ GetWindowRect(hParent,&rcParent);
+
+ // return positions relative to parent window
+ *xDlg = rcDlg.left - rcParent.left;
+ *yDlg = rcDlg.top - rcParent.top;
+
+}
+
+
+//=============================================================================
+//
+// SetDlgPos()
+//
+void SetDlgPos(HWND hDlg,int xDlg,int yDlg)
+{
+
+ RECT rcDlg;
+ HWND hParent;
+ RECT rcParent;
+ MONITORINFO mi;
+ HMONITOR hMonitor;
+
+ int xMin, yMin, xMax, yMax, x, y;
+
+ GetWindowRect(hDlg,&rcDlg);
+
+ hParent = GetParent(hDlg);
+ GetWindowRect(hParent,&rcParent);
+
+ hMonitor = MonitorFromRect(&rcParent,MONITOR_DEFAULTTONEAREST);
+ mi.cbSize = sizeof(mi);
+ GetMonitorInfo(hMonitor,&mi);
+
+ xMin = mi.rcWork.left;
+ yMin = mi.rcWork.top;
+
+ xMax = (mi.rcWork.right) - (rcDlg.right - rcDlg.left);
+ yMax = (mi.rcWork.bottom) - (rcDlg.bottom - rcDlg.top);
+
+ // desired positions relative to parent window
+ x = rcParent.left + xDlg;
+ y = rcParent.top + yDlg;
+
+ SetWindowPos(hDlg,NULL,max(xMin,min(xMax,x)),max(yMin,min(yMax,y)),0,0,SWP_NOZORDER|SWP_NOSIZE);
+
+}
+
+
+//=============================================================================
+//
+// Resize Dialog Helpers()
+//
+typedef struct _resizedlg {
+ int cxClient;
+ int cyClient;
+ int cxFrame;
+ int cyFrame;
+ int mmiPtMinX;
+ int mmiPtMinY;
+} RESIZEDLG, *PRESIZEDLG;
+
+void ResizeDlg_Init(HWND hwnd,int cxFrame,int cyFrame,int nIdGrip)
+{
+ RECT rc;
+ WCHAR wch[64];
+ int cGrip;
+ RESIZEDLG *pm = LocalAlloc(LPTR,sizeof(RESIZEDLG));
+
+ GetClientRect(hwnd,&rc);
+ pm->cxClient = rc.right - rc.left;
+ pm->cyClient = rc.bottom - rc.top;
+
+ pm->cxFrame = cxFrame;
+ pm->cyFrame = cyFrame;
+
+ AdjustWindowRectEx(&rc,GetWindowLongPtr(hwnd,GWL_STYLE)|WS_THICKFRAME,FALSE,0);
+ pm->mmiPtMinX = rc.right-rc.left;
+ pm->mmiPtMinY = rc.bottom-rc.top;
+
+ if (pm->cxFrame < (rc.right-rc.left))
+ pm->cxFrame = rc.right-rc.left;
+ if (pm->cyFrame < (rc.bottom-rc.top))
+ pm->cyFrame = rc.bottom-rc.top;
+
+ SetProp(hwnd,L"ResizeDlg",(HANDLE)pm);
+
+ SetWindowPos(hwnd,NULL,rc.left,rc.top,pm->cxFrame,pm->cyFrame,SWP_NOZORDER);
+
+ SetWindowLongPtr(hwnd,GWL_STYLE,GetWindowLongPtr(hwnd,GWL_STYLE)|WS_THICKFRAME);
+ SetWindowPos(hwnd,NULL,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED);
+ GetMenuString(GetSystemMenu(GetParent(hwnd),FALSE),SC_SIZE,wch,COUNTOF(wch),MF_BYCOMMAND);
+ InsertMenu(GetSystemMenu(hwnd,FALSE),SC_CLOSE,MF_BYCOMMAND|MF_STRING|MF_ENABLED,SC_SIZE,wch);
+ InsertMenu(GetSystemMenu(hwnd,FALSE),SC_CLOSE,MF_BYCOMMAND|MF_SEPARATOR,0,NULL);
+
+ SetWindowLongPtr(GetDlgItem(hwnd,nIdGrip),GWL_STYLE,
+ GetWindowLongPtr(GetDlgItem(hwnd,nIdGrip),GWL_STYLE)|SBS_SIZEGRIP|WS_CLIPSIBLINGS);
+ cGrip = GetSystemMetrics(SM_CXHTHUMB);
+ SetWindowPos(GetDlgItem(hwnd,nIdGrip),NULL,pm->cxClient-cGrip,pm->cyClient-cGrip,cGrip,cGrip,SWP_NOZORDER);
+}
+
+void ResizeDlg_Destroy(HWND hwnd,int *cxFrame,int *cyFrame)
+{
+ RECT rc;
+ PRESIZEDLG pm = GetProp(hwnd,L"ResizeDlg");
+
+ GetWindowRect(hwnd,&rc);
+ *cxFrame = rc.right-rc.left;
+ *cyFrame = rc.bottom-rc.top;
+
+ RemoveProp(hwnd,L"ResizeDlg");
+ LocalFree(pm);
+}
+
+void ResizeDlg_Size(HWND hwnd,LPARAM lParam,int *cx,int *cy)
+{
+ PRESIZEDLG pm = GetProp(hwnd,L"ResizeDlg");
+
+ *cx = LOWORD(lParam) - pm->cxClient;
+ *cy = HIWORD(lParam) - pm->cyClient;
+ pm->cxClient = LOWORD(lParam);
+ pm->cyClient = HIWORD(lParam);
+}
+
+void ResizeDlg_GetMinMaxInfo(HWND hwnd,LPARAM lParam)
+{
+ PRESIZEDLG pm = GetProp(hwnd,L"ResizeDlg");
+
+ LPMINMAXINFO lpmmi = (LPMINMAXINFO)lParam;
+ lpmmi->ptMinTrackSize.x = pm->mmiPtMinX;
+ lpmmi->ptMinTrackSize.y = pm->mmiPtMinY;
+}
+
+HDWP DeferCtlPos(HDWP hdwp,HWND hwndDlg,int nCtlId,int dx,int dy,UINT uFlags)
+{
+ RECT rc;
+ HWND hwndCtl = GetDlgItem(hwndDlg,nCtlId);
+ GetWindowRect(hwndCtl,&rc);
+ MapWindowPoints(NULL,hwndDlg,(LPPOINT)&rc,2);
+ if (uFlags & SWP_NOSIZE)
+ return(DeferWindowPos(hdwp,hwndCtl,NULL,rc.left+dx,rc.top+dy,0,0,SWP_NOZORDER|SWP_NOSIZE));
+ else
+ return(DeferWindowPos(hdwp,hwndCtl,NULL,0,0,rc.right-rc.left+dx,rc.bottom-rc.top+dy,SWP_NOZORDER|SWP_NOMOVE));
+}
+
+
+//=============================================================================
+//
+// MakeBitmapButton()
+//
+void MakeBitmapButton(HWND hwnd,int nCtlId,HINSTANCE hInstance,UINT uBmpId)
+{
+ HWND hwndCtl = GetDlgItem(hwnd,nCtlId);
+ BITMAP bmp;
+ BUTTON_IMAGELIST bi;
+ HBITMAP hBmp = LoadImage(hInstance,MAKEINTRESOURCE(uBmpId),IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION);
+ GetObject(hBmp,sizeof(BITMAP),&bmp);
+ bi.himl = ImageList_Create(bmp.bmWidth,bmp.bmHeight,ILC_COLOR32|ILC_MASK,1,0);
+ ImageList_AddMasked(bi.himl,hBmp,CLR_DEFAULT);
+ DeleteObject(hBmp);
+ SetRect(&bi.margin,0,0,0,0);
+ bi.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER;
+ SendMessage(hwndCtl,BCM_SETIMAGELIST,0,(LPARAM)&bi);
+}
+
+
+//=============================================================================
+//
+// MakeColorPickButton()
+//
+void MakeColorPickButton(HWND hwnd,int nCtlId,HINSTANCE hInstance,COLORREF crColor)
+{
+ HWND hwndCtl = GetDlgItem(hwnd,nCtlId);
+ BUTTON_IMAGELIST bi;
+ HIMAGELIST himlOld = NULL;
+ HBITMAP hBmp;
+ COLORMAP colormap[2];
+
+ if (SendMessage(hwndCtl,BCM_GETIMAGELIST,0,(LPARAM)&bi))
+ himlOld = bi.himl;
+
+ if (IsWindowEnabled(hwndCtl) && crColor != -1) {
+ colormap[0].from = RGB(0x00,0x00,0x00);
+ colormap[0].to = GetSysColor(COLOR_3DSHADOW);
+ }
+ else {
+ colormap[0].from = RGB(0x00,0x00,0x00);
+ colormap[0].to = RGB(0xFF,0xFF,0xFF);
+ }
+
+ if (IsWindowEnabled(hwndCtl) && crColor != -1) {
+ if (crColor == RGB(0xFF,0xFF,0xFF))
+ crColor = RGB(0xFF,0xFF,0xFE);
+
+ colormap[1].from = RGB(0xFF,0xFF,0xFF);
+ colormap[1].to = crColor;
+ }
+ else {
+ colormap[1].from = RGB(0xFF,0xFF,0xFF);
+ colormap[1].to = RGB(0xFF,0xFF,0xFF);
+ }
+
+ hBmp = CreateMappedBitmap(hInstance,IDB_PICK,0,colormap,2);
+
+ bi.himl = ImageList_Create(10,10,ILC_COLORDDB|ILC_MASK,1,0);
+ ImageList_AddMasked(bi.himl,hBmp,RGB(0xFF,0xFF,0xFF));
+ DeleteObject(hBmp);
+
+ SetRect(&bi.margin,0,0,4,0);
+ bi.uAlign = BUTTON_IMAGELIST_ALIGN_RIGHT;
+
+ SendMessage(hwndCtl,BCM_SETIMAGELIST,0,(LPARAM)&bi);
+ InvalidateRect(hwndCtl,NULL,TRUE);
+
+ if (himlOld)
+ ImageList_Destroy(himlOld);
+}
+
+
+//=============================================================================
+//
+// DeleteBitmapButton()
+//
+void DeleteBitmapButton(HWND hwnd,int nCtlId)
+{
+ HWND hwndCtl = GetDlgItem(hwnd,nCtlId);
+ BUTTON_IMAGELIST bi;
+ if (SendMessage(hwndCtl,BCM_GETIMAGELIST,0,(LPARAM)&bi))
+ ImageList_Destroy(bi.himl);
+}
+
+
+//=============================================================================
+//
+// StatusSetText()
+//
+BOOL StatusSetText(HWND hwnd,UINT nPart,LPCWSTR lpszText)
+{
+
+ UINT uFlags = (nPart == 255) ? nPart|SBT_NOBORDERS : nPart;
+ return SendMessage(hwnd,SB_SETTEXT,uFlags,(LPARAM)lpszText);
+
+}
+
+
+//=============================================================================
+//
+// SendWMSize()
+//
+LRESULT SendWMSize(HWND hwnd)
+{
+ RECT rc; GetClientRect(hwnd,&rc);
+ return(SendMessage(hwnd,WM_SIZE,SIZE_RESTORED,
+ MAKELPARAM(rc.right,rc.bottom)));
+}
+
+
+//=============================================================================
+//
+// StatusSetTextID()
+//
+BOOL StatusSetTextID(HWND hwnd,UINT nPart,UINT uID)
+{
+
+ WCHAR szText[256];
+ UINT uFlags = (nPart == 255) ? nPart|SBT_NOBORDERS : nPart;
+
+ if (!uID)
+ {
+ SendMessage(hwnd,SB_SETTEXT,uFlags,0);
+ return TRUE;
+ }
+
+ if (!GetString(uID,szText,256))
+ return FALSE;
+
+ return SendMessage(hwnd,SB_SETTEXT,uFlags,(LPARAM)szText);
+
+}
+
+
+//=============================================================================
+//
+// StatusCalcPaneWidth()
+//
+int StatusCalcPaneWidth(HWND hwnd,LPCWSTR lpsz)
+{
+ SIZE size;
+ HDC hdc = GetDC(hwnd);
+ HFONT hfont = (HFONT)SendMessage(hwnd,WM_GETFONT,0,0);
+ HFONT hfold = SelectObject(hdc,hfont);
+ int mmode = SetMapMode(hdc,MM_TEXT);
+
+ GetTextExtentPoint32(hdc,lpsz,lstrlen(lpsz),&size);
+
+ SetMapMode(hdc,mmode);
+ SelectObject(hdc,hfold);
+ ReleaseDC(hwnd,hdc);
+
+ return(size.cx + 9);
+}
+
+
+//=============================================================================
+//
+// Toolbar_Get/SetButtons()
+//
+int Toolbar_GetButtons(HWND hwnd,int cmdBase,LPWSTR lpszButtons,int cchButtons)
+{
+ WCHAR tchButtons[512];
+ WCHAR tchItem[32];
+ int i,c;
+ TBBUTTON tbb;
+
+ lstrcpy(tchButtons,L"");
+ c = min(50,SendMessage(hwnd,TB_BUTTONCOUNT,0,0));
+
+ for (i = 0; i < c; i++) {
+ SendMessage(hwnd,TB_GETBUTTON,(WPARAM)i,(LPARAM)&tbb);
+ wsprintf(tchItem,L"%i ",
+ (tbb.idCommand==0)?0:tbb.idCommand-cmdBase+1);
+ lstrcat(tchButtons,tchItem);
+ }
+ TrimString(tchButtons);
+ lstrcpyn(lpszButtons,tchButtons,cchButtons);
+ return(c);
+}
+
+int Toolbar_SetButtons(HWND hwnd,int cmdBase,LPCWSTR lpszButtons,LPCTBBUTTON ptbb,int ctbb)
+{
+ WCHAR tchButtons[512];
+ WCHAR *p;
+ int i,c;
+ int iCmd;
+
+ ZeroMemory(tchButtons,COUNTOF(tchButtons)*sizeof(tchButtons[0]));
+ lstrcpyn(tchButtons,lpszButtons,COUNTOF(tchButtons)-2);
+ TrimString(tchButtons);
+ while (p = StrStr(tchButtons,L" "))
+ MoveMemory((WCHAR*)p,(WCHAR*)p+1,(lstrlen(p) + 1) * sizeof(WCHAR));
+
+ c = SendMessage(hwnd,TB_BUTTONCOUNT,0,0);
+ for (i = 0; i < c; i++)
+ SendMessage(hwnd,TB_DELETEBUTTON,0,0);
+
+ for (i = 0; i < COUNTOF(tchButtons); i++)
+ if (tchButtons[i] == L' ') tchButtons[i] = 0;
+
+ p = tchButtons;
+ while (*p) {
+ if (swscanf(p,L"%i",&iCmd) == 1) {
+ iCmd = (iCmd==0)?0:iCmd+cmdBase-1;
+ for (i = 0; i < ctbb; i++) {
+ if (ptbb[i].idCommand == iCmd) {
+ SendMessage(hwnd,TB_ADDBUTTONS,(WPARAM)1,(LPARAM)&ptbb[i]);
+ break;
+ }
+ }
+ }
+ p = StrEnd(p)+1;
+ }
+ return(SendMessage(hwnd,TB_BUTTONCOUNT,0,0));
+}
+
+
+//=============================================================================
+//
+// IsCmdEnabled()
+//
+BOOL IsCmdEnabled(HWND hwnd,UINT uId)
+{
+
+ HMENU hmenu;
+ UINT ustate;
+
+ hmenu = GetMenu(hwnd);
+
+ SendMessage(hwnd,WM_INITMENU,(WPARAM)hmenu,0);
+
+ ustate = GetMenuState(hmenu,uId,MF_BYCOMMAND);
+
+ if (ustate == 0xFFFFFFFF)
+ return TRUE;
+
+ else
+ return (!(ustate & (MF_GRAYED|MF_DISABLED)));
+
+}
+
+
+//=============================================================================
+//
+// FormatString()
+//
+int FormatString(LPWSTR lpOutput,int nOutput,UINT uIdFormat,...)
+{
+
+ WCHAR *p = LocalAlloc(LPTR,sizeof(WCHAR)*nOutput);
+
+ if (GetString(uIdFormat,p,nOutput))
+ wvsprintf(lpOutput,p,(LPVOID)((PUINT_PTR)&uIdFormat+1));
+
+ LocalFree(p);
+
+ return lstrlen(lpOutput);
+
+}
+
+
+//=============================================================================
+//
+// PathRelativeToApp()
+//
+void PathRelativeToApp(
+ LPWSTR lpszSrc,LPWSTR lpszDest,int cchDest,BOOL bSrcIsFile,
+ BOOL bUnexpandEnv,BOOL bUnexpandMyDocs) {
+
+ WCHAR wchAppPath[MAX_PATH];
+ WCHAR wchWinDir[MAX_PATH];
+ WCHAR wchUserFiles[MAX_PATH];
+ WCHAR wchPath[MAX_PATH];
+ WCHAR wchResult[MAX_PATH];
+ DWORD dwAttrTo = (bSrcIsFile) ? 0 : FILE_ATTRIBUTE_DIRECTORY;
+
+ GetModuleFileName(NULL,wchAppPath,COUNTOF(wchAppPath));
+ PathRemoveFileSpec(wchAppPath);
+ GetWindowsDirectory(wchWinDir,COUNTOF(wchWinDir));
+ SHGetFolderPath(NULL,CSIDL_PERSONAL,NULL,SHGFP_TYPE_CURRENT,wchUserFiles);
+
+ if (bUnexpandMyDocs &&
+ !PathIsRelative(lpszSrc) &&
+ !PathIsPrefix(wchUserFiles,wchAppPath) &&
+ PathIsPrefix(wchUserFiles,lpszSrc) &&
+ PathRelativePathTo(wchPath,wchUserFiles,FILE_ATTRIBUTE_DIRECTORY,lpszSrc,dwAttrTo)) {
+ lstrcpy(wchUserFiles,L"%CSIDL:MYDOCUMENTS%");
+ PathAppend(wchUserFiles,wchPath);
+ lstrcpy(wchPath,wchUserFiles);
+ }
+ else if (PathIsRelative(lpszSrc) || PathCommonPrefix(wchAppPath,wchWinDir,NULL))
+ lstrcpyn(wchPath,lpszSrc,COUNTOF(wchPath));
+ else {
+ if (!PathRelativePathTo(wchPath,wchAppPath,FILE_ATTRIBUTE_DIRECTORY,lpszSrc,dwAttrTo))
+ lstrcpyn(wchPath,lpszSrc,COUNTOF(wchPath));
+ }
+
+ if (bUnexpandEnv) {
+ if (!PathUnExpandEnvStrings(wchPath,wchResult,COUNTOF(wchResult)))
+ lstrcpyn(wchResult,wchPath,COUNTOF(wchResult));
+ }
+ else
+ lstrcpyn(wchResult,wchPath,COUNTOF(wchResult));
+
+ if (lpszDest == NULL || lpszSrc == lpszDest)
+ lstrcpyn(lpszSrc,wchResult,(cchDest == 0) ? MAX_PATH : cchDest);
+ else
+ lstrcpyn(lpszDest,wchResult,(cchDest == 0) ? MAX_PATH : cchDest);
+}
+
+
+//=============================================================================
+//
+// PathAbsoluteFromApp()
+//
+void PathAbsoluteFromApp(LPWSTR lpszSrc,LPWSTR lpszDest,int cchDest,BOOL bExpandEnv) {
+
+ WCHAR wchPath[MAX_PATH];
+ WCHAR wchResult[MAX_PATH];
+
+ if (StrCmpNI(lpszSrc,L"%CSIDL:MYDOCUMENTS%",COUNTOF("%CSIDL:MYDOCUMENTS%")-1) == 0) {
+ SHGetFolderPath(NULL,CSIDL_PERSONAL,NULL,SHGFP_TYPE_CURRENT,wchPath);
+ PathAppend(wchPath,lpszSrc+COUNTOF("%CSIDL:MYDOCUMENTS%")-1);
+ }
+ else
+ lstrcpyn(wchPath,lpszSrc,COUNTOF(wchPath));
+
+ if (bExpandEnv)
+ ExpandEnvironmentStringsEx(wchPath,COUNTOF(wchPath));
+
+ if (PathIsRelative(wchPath)) {
+ GetModuleFileName(NULL,wchResult,COUNTOF(wchResult));
+ PathRemoveFileSpec(wchResult);
+ PathAppend(wchResult,wchPath);
+ }
+ else
+ lstrcpyn(wchResult,wchPath,COUNTOF(wchResult));
+
+ PathCanonicalizeEx(wchResult);
+ if (PathGetDriveNumber(wchResult) != -1)
+ CharUpperBuff(wchResult,1);
+
+ if (lpszDest == NULL || lpszSrc == lpszDest)
+ lstrcpyn(lpszSrc,wchResult,(cchDest == 0) ? MAX_PATH : cchDest);
+ else
+ lstrcpyn(lpszDest,wchResult,(cchDest == 0) ? MAX_PATH : cchDest);
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+//
+//
+// Name: PathIsLnkFile()
+//
+// Purpose: Determine wheter pszPath is a Windows Shell Link File by
+// comparing the filename extension with L".lnk"
+//
+// Manipulates:
+//
+BOOL PathIsLnkFile(LPCWSTR pszPath)
+{
+
+ //WCHAR *pszExt;
+
+ WCHAR tchResPath[256];
+
+ if (!pszPath || !*pszPath)
+ return FALSE;
+
+/*pszExt = StrRChr(pszPath,NULL,L'.');
+
+ if (!pszExt)
+ return FALSE;
+
+ if (!lstrcmpi(pszExt,L".lnk"))
+ return TRUE;
+
+ else
+ return FALSE;*/
+
+ //if (!lstrcmpi(PathFindExtension(pszPath),L".lnk"))
+ // return TRUE;
+
+ //else
+ // return FALSE;
+
+ if (lstrcmpi(PathFindExtension(pszPath),L".lnk"))
+ return FALSE;
+
+ else
+ return PathGetLnkPath(pszPath,tchResPath,COUNTOF(tchResPath));
+
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+//
+//
+// Name: PathGetLnkPath()
+//
+// Purpose: Try to get the path to which a lnk-file is linked
+//
+//
+// Manipulates: pszResPath
+//
+BOOL PathGetLnkPath(LPCWSTR pszLnkFile,LPWSTR pszResPath,int cchResPath)
+{
+
+ IShellLink *psl;
+ WIN32_FIND_DATA fd;
+ BOOL bSucceeded = FALSE;
+
+ if (SUCCEEDED(CoCreateInstance(&CLSID_ShellLink,NULL,
+ CLSCTX_INPROC_SERVER,
+ &IID_IShellLink,&psl)))
+ {
+ IPersistFile *ppf;
+
+ if (SUCCEEDED(psl->lpVtbl->QueryInterface(psl,&IID_IPersistFile,&ppf)))
+ {
+ WORD wsz[MAX_PATH];
+
+ /*MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,
+ pszLnkFile,-1,wsz,MAX_PATH);*/
+ lstrcpy(wsz,pszLnkFile);
+
+ if (SUCCEEDED(ppf->lpVtbl->Load(ppf,wsz,STGM_READ)))
+ {
+ if (NOERROR == psl->lpVtbl->GetPath(psl,pszResPath,cchResPath,&fd,0))
+ bSucceeded = TRUE;
+ }
+ ppf->lpVtbl->Release(ppf);
+ }
+ psl->lpVtbl->Release(psl);
+ }
+
+ // This additional check seems reasonable
+ if (!lstrlen(pszResPath))
+ bSucceeded = FALSE;
+
+ if (bSucceeded) {
+ ExpandEnvironmentStringsEx(pszResPath,cchResPath);
+ PathCanonicalizeEx(pszResPath);
+ }
+
+ return(bSucceeded);
+
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+//
+//
+// Name: PathIsLnkToDirectory()
+//
+// Purpose: Determine wheter pszPath is a Windows Shell Link File which
+// refers to a directory
+//
+// Manipulates: pszResPath
+//
+BOOL PathIsLnkToDirectory(LPCWSTR pszPath,LPWSTR pszResPath,int cchResPath)
+{
+
+ WCHAR tchResPath[MAX_PATH];
+
+ if (PathIsLnkFile(pszPath)) {
+
+ if (PathGetLnkPath(pszPath,tchResPath,sizeof(WCHAR)*COUNTOF(tchResPath))) {
+
+ if (PathIsDirectory(tchResPath)) {
+
+ lstrcpyn(pszResPath,tchResPath,cchResPath);
+ return (TRUE);
+ }
+
+ else
+ return FALSE;
+ }
+
+ else
+ return FALSE;
+ }
+
+ else
+ return FALSE;
+
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+//
+//
+// Name: PathCreateDeskLnk()
+//
+// Purpose: Modified to create a desktop link to Notepad2
+//
+// Manipulates:
+//
+BOOL PathCreateDeskLnk(LPCWSTR pszDocument)
+{
+
+ WCHAR tchExeFile[MAX_PATH];
+ WCHAR tchDocTemp[MAX_PATH];
+ WCHAR tchArguments[MAX_PATH+16];
+ WCHAR tchLinkDir[MAX_PATH];
+ WCHAR tchDescription[64];
+
+ WCHAR tchLnkFileName[MAX_PATH];
+
+ IShellLink *psl;
+ BOOL bSucceeded = FALSE;
+ BOOL fMustCopy;
+
+ if (!pszDocument || lstrlen(pszDocument) == 0)
+ return TRUE;
+
+ // init strings
+ GetModuleFileName(NULL,tchExeFile,COUNTOF(tchExeFile));
+
+ lstrcpy(tchDocTemp,pszDocument);
+ PathQuoteSpaces(tchDocTemp);
+
+ lstrcpy(tchArguments,L"-n ");
+ lstrcat(tchArguments,tchDocTemp);
+
+ SHGetSpecialFolderPath(NULL,tchLinkDir,CSIDL_DESKTOP,TRUE);
+
+ GetString(IDS_LINKDESCRIPTION,tchDescription,COUNTOF(tchDescription));
+
+ // Try to construct a valid filename...
+ if (!SHGetNewLinkInfo(pszDocument,tchLinkDir,tchLnkFileName,&fMustCopy,SHGNLI_PREFIXNAME))
+ return(FALSE);
+
+ if (SUCCEEDED(CoCreateInstance(&CLSID_ShellLink,NULL,
+ CLSCTX_INPROC_SERVER,
+ &IID_IShellLink,&psl)))
+ {
+ IPersistFile *ppf;
+
+ if (SUCCEEDED(psl->lpVtbl->QueryInterface(psl,&IID_IPersistFile,&ppf)))
+ {
+ WORD wsz[MAX_PATH];
+
+ /*MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,
+ tchLnkFileName,-1,wsz,MAX_PATH);*/
+ lstrcpy(wsz,tchLnkFileName);
+
+ psl->lpVtbl->SetPath(psl,tchExeFile);
+ psl->lpVtbl->SetArguments(psl,tchArguments);
+ psl->lpVtbl->SetDescription(psl,tchDescription);
+
+ if (SUCCEEDED(ppf->lpVtbl->Save(ppf,wsz,TRUE)))
+ bSucceeded = TRUE;
+
+ ppf->lpVtbl->Release(ppf);
+ }
+ psl->lpVtbl->Release(psl);
+ }
+
+ return(bSucceeded);
+
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+//
+//
+// Name: PathCreateFavLnk()
+//
+// Purpose: Modified to create a Notepad2 favorites link
+//
+// Manipulates:
+//
+BOOL PathCreateFavLnk(LPCWSTR pszName,LPCWSTR pszTarget,LPCWSTR pszDir)
+{
+
+ WCHAR tchLnkFileName[MAX_PATH];
+
+ IShellLink *psl;
+ BOOL bSucceeded = FALSE;
+
+ if (!pszName || lstrlen(pszName) == 0)
+ return TRUE;
+
+ lstrcpy(tchLnkFileName,pszDir);
+ PathAppend(tchLnkFileName,pszName);
+ lstrcat(tchLnkFileName,L".lnk");
+
+ if (PathFileExists(tchLnkFileName))
+ return FALSE;
+
+ if (SUCCEEDED(CoCreateInstance(&CLSID_ShellLink,NULL,
+ CLSCTX_INPROC_SERVER,
+ &IID_IShellLink,&psl)))
+ {
+ IPersistFile *ppf;
+
+ if (SUCCEEDED(psl->lpVtbl->QueryInterface(psl,&IID_IPersistFile,&ppf)))
+ {
+ WORD wsz[MAX_PATH];
+
+ /*MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,
+ tchLnkFileName,-1,wsz,MAX_PATH);*/
+ lstrcpy(wsz,tchLnkFileName);
+
+ psl->lpVtbl->SetPath(psl,pszTarget);
+
+ if (SUCCEEDED(ppf->lpVtbl->Save(ppf,wsz,TRUE)))
+ bSucceeded = TRUE;
+
+ ppf->lpVtbl->Release(ppf);
+ }
+ psl->lpVtbl->Release(psl);
+ }
+
+ return(bSucceeded);
+
+}
+
+
+//=============================================================================
+//
+// TrimString()
+//
+BOOL TrimString(LPWSTR lpString)
+{
+
+ LPWSTR psz;
+
+
+ if (!lpString || !*lpString)
+ return FALSE;
+
+ // Trim left
+ psz = lpString;
+
+ while (*psz == L' ')
+ psz = CharNext(psz);
+
+ MoveMemory(lpString,psz,sizeof(WCHAR)*(lstrlen(psz) + 1));
+
+ // Trim right
+ psz = StrEnd(lpString);
+
+ while (*(psz = CharPrev(lpString,psz)) == L' ')
+ *psz = L'\0';
+
+ return TRUE;
+
+}
+
+
+//=============================================================================
+//
+// ExtractFirstArgument()
+//
+BOOL ExtractFirstArgument(LPCWSTR lpArgs,LPWSTR lpArg1,LPWSTR lpArg2)
+{
+
+ LPWSTR psz;
+ BOOL bQuoted = FALSE;
+
+ lstrcpy(lpArg1,lpArgs);
+ if (lpArg2)
+ *lpArg2 = L'\0';
+
+ if (!TrimString(lpArg1))
+ return FALSE;
+
+ if (*lpArg1 == L'\"')
+ {
+ *lpArg1 = L' ';
+ TrimString(lpArg1);
+ bQuoted = TRUE;
+ }
+
+ if (bQuoted)
+ psz = StrChr(lpArg1,L'\"');
+ else
+ psz = StrChr(lpArg1,L' ');;
+
+ if (psz)
+ {
+ *psz = L'\0';
+ if (lpArg2)
+ lstrcpy(lpArg2,psz + 1);
+ }
+
+ TrimString(lpArg1);
+
+ if (lpArg2)
+ TrimString(lpArg2);
+
+ return TRUE;
+
+}
+
+
+//=============================================================================
+//
+// PrepareFilterStr()
+//
+void PrepareFilterStr(LPWSTR lpFilter)
+{
+ LPWSTR psz = StrEnd(lpFilter);
+ while (psz != lpFilter)
+ {
+ if (*(psz = CharPrev(lpFilter,psz)) == L'|')
+ *psz = L'\0';
+ }
+}
+
+
+//=============================================================================
+//
+// StrTab2Space() - in place conversion
+//
+void StrTab2Space(LPWSTR lpsz)
+{
+ WCHAR *c;
+ while (c = StrChr(lpsz,L'\t'))
+ *c = L' ';
+}
+
+
+//=============================================================================
+//
+// ExpandEnvironmentStringsEx()
+//
+// Adjusted for Windows 95
+//
+void ExpandEnvironmentStringsEx(LPWSTR lpSrc,DWORD dwSrc)
+{
+ WCHAR szBuf[312];
+
+ if (ExpandEnvironmentStrings(lpSrc,szBuf,COUNTOF(szBuf)))
+ lstrcpyn(lpSrc,szBuf,dwSrc);
+}
+
+
+//=============================================================================
+//
+// PathCanonicalizeEx()
+//
+//
+void PathCanonicalizeEx(LPWSTR lpSrc)
+{
+ WCHAR szDst[MAX_PATH];
+
+ if (PathCanonicalize(szDst,lpSrc))
+ lstrcpy(lpSrc,szDst);
+}
+
+
+//=============================================================================
+//
+// GetLongPathNameEx()
+//
+// Works fine with Windows 95!
+//
+extern LPMALLOC g_lpMalloc;
+
+DWORD GetLongPathNameEx(LPCWSTR lpszShortPath,LPWSTR lpszLongPath,DWORD cchBuffer)
+{
+ WCHAR wszShortPath[MAX_PATH];
+ WCHAR *pwchSep;
+ LPSHELLFOLDER lpsfDesktop;
+ ULONG chParsed = 0;
+ ULONG dwAttributes = 0;
+ LPITEMIDLIST pidl = NULL;
+ BOOL fSucceeded = FALSE;
+
+ //MessageBox(GetFocus(),lpszShortPath,L"GetLongPathNameEx(): lpszShortPath",0);
+
+ // Convert lpszShortPath to a UNICODE string
+ /*MultiByteToWideChar(
+ CP_ACP,MB_PRECOMPOSED,lpszShortPath,-1,wszShortPath,MAX_PATH);*/
+ lstrcpy(wszShortPath,lpszShortPath);
+
+ // convert slashes to backlsashes
+ while (pwchSep = StrChr(wszShortPath,L'/'))
+ *pwchSep = L'\\';
+
+ // Get Desktop Folder
+ if (NOERROR == SHGetDesktopFolder(&lpsfDesktop))
+ {
+ // Convert wszShortPath to a pidl
+ if (NOERROR == lpsfDesktop->lpVtbl->ParseDisplayName(
+ lpsfDesktop,NULL,NULL,wszShortPath,&chParsed,&pidl,&dwAttributes))
+ {
+ if (SHGetPathFromIDList(pidl,lpszLongPath))
+ fSucceeded = FALSE;
+ g_lpMalloc->lpVtbl->Free(g_lpMalloc,pidl);
+ }
+ }
+
+ //MessageBox(GetFocus(),lpszLongPath,L"GetLongPathNameEx(): lpszLongPath",0);
+
+ if (fSucceeded)
+ return(lstrlen(lpszLongPath));
+ else {
+ if (lpszShortPath != lpszLongPath)
+ lstrcpy(lpszLongPath,lpszShortPath);
+ return(0);
+ }
+
+ cchBuffer;
+}
+
+
+//=============================================================================
+//
+// SHGetFileInfo2() - return a default name when the file has been removed
+//
+DWORD_PTR SHGetFileInfo2(LPCWSTR pszPath,DWORD dwFileAttributes,
+ SHFILEINFO *psfi,UINT cbFileInfo,UINT uFlags)
+{
+
+ if (PathFileExists(pszPath))
+ return SHGetFileInfo(pszPath,dwFileAttributes,psfi,cbFileInfo,uFlags);
+
+ else
+ return SHGetFileInfo(pszPath,FILE_ATTRIBUTE_NORMAL,
+ psfi,cbFileInfo,uFlags|SHGFI_USEFILEATTRIBUTES);
+
+}
+
+
+//=============================================================================
+//
+// FormatNumberStr()
+//
+int FormatNumberStr(LPWSTR lpNumberStr)
+{
+ WCHAR *c;
+ WCHAR szSep[8];
+ int i = 0;
+
+ if (!lstrlen(lpNumberStr))
+ return(0);
+
+ if (!GetLocaleInfo(LOCALE_USER_DEFAULT,
+ LOCALE_STHOUSAND,
+ szSep,
+ COUNTOF(szSep)))
+ szSep[0] = L'\'';
+
+ c = StrEnd(lpNumberStr);
+
+ while ((c = CharPrev(lpNumberStr,c)) != lpNumberStr)
+ {
+ if (++i == 3)
+ {
+ i = 0;
+ MoveMemory(c+1,c,sizeof(WCHAR)*(lstrlen(c)+1));
+ *c = szSep[0];
+ }
+ }
+
+ return(lstrlen(lpNumberStr));
+}
+
+
+//=============================================================================
+//
+// SetDlgItemIntEx()
+//
+BOOL SetDlgItemIntEx(HWND hwnd,int nIdItem,UINT uValue)
+{
+ WCHAR szBuf[64];
+
+ wsprintf(szBuf,L"%u",uValue);
+ FormatNumberStr(szBuf);
+
+ return(SetDlgItemText(hwnd,nIdItem,szBuf));
+}
+
+
+//=============================================================================
+//
+// A2W: Convert Dialog Item Text form Unicode to UTF-8 and vice versa
+//
+UINT GetDlgItemTextA2W(UINT uCP,HWND hDlg,int nIDDlgItem,LPSTR lpString,int nMaxCount)
+{
+ WCHAR wsz[1024] = L"";
+ UINT uRet = GetDlgItemTextW(hDlg,nIDDlgItem,wsz,COUNTOF(wsz));
+ ZeroMemory(lpString,nMaxCount);
+ WCharToMBCS(uCP,wsz,lpString,nMaxCount-2);
+ return uRet;
+}
+
+UINT SetDlgItemTextA2W(UINT uCP,HWND hDlg,int nIDDlgItem,LPSTR lpString)
+{
+ WCHAR wsz[1024] = L"";
+ MBCSToWChar(uCP,lpString,wsz,COUNTOF(wsz));
+ return SetDlgItemTextW(hDlg,nIDDlgItem,wsz);
+}
+
+LRESULT ComboBox_AddStringA2W(UINT uCP,HWND hwnd,LPCSTR lpString)
+{
+ WCHAR wsz[1024] = L"";
+ MBCSToWChar(uCP,lpString,wsz,COUNTOF(wsz));
+ return SendMessageW(hwnd,CB_ADDSTRING,0,(LPARAM)wsz);
+}
+
+
+//=============================================================================
+//
+// CodePageFromCharSet()
+//
+UINT CodePageFromCharSet(UINT uCharSet)
+{
+ CHARSETINFO ci;
+ if (TranslateCharsetInfo((DWORD*)uCharSet,&ci,TCI_SRCCHARSET))
+ return(ci.ciACP);
+ else
+ return(GetACP());
+}
+
+
+//=============================================================================
+//
+// MRU functions
+//
+LPMRULIST MRU_Create(LPCWSTR pszRegKey,int iFlags,int iSize) {
+
+ LPMRULIST pmru = LocalAlloc(LPTR,sizeof(MRULIST));
+ ZeroMemory(pmru,sizeof(MRULIST));
+ lstrcpyn(pmru->szRegKey,pszRegKey,COUNTOF(pmru->szRegKey));
+ pmru->iFlags = iFlags;
+ pmru->iSize = min(iSize,MRU_MAXITEMS);
+ return(pmru);
+}
+
+BOOL MRU_Destroy(LPMRULIST pmru) {
+
+ int i;
+ for (i = 0; i < pmru->iSize; i++) {
+ if (pmru->pszItems[i])
+ LocalFree(pmru->pszItems[i]);
+ }
+ ZeroMemory(pmru,sizeof(MRULIST));
+ LocalFree(pmru);
+ return(1);
+}
+
+int MRU_Compare(LPMRULIST pmru,LPCWSTR psz1,LPCWSTR psz2) {
+
+ if (pmru->iFlags & MRU_NOCASE)
+ return(lstrcmpi(psz1,psz2));
+ else
+ return(lstrcmp(psz1,psz2));
+}
+
+BOOL MRU_Add(LPMRULIST pmru,LPCWSTR pszNew) {
+
+ int i;
+ for (i = 0; i < pmru->iSize; i++) {
+ if (MRU_Compare(pmru,pmru->pszItems[i],pszNew) == 0) {
+ LocalFree(pmru->pszItems[i]);
+ break;
+ }
+ }
+ i = min(i,pmru->iSize-1);
+ for (; i > 0; i--)
+ pmru->pszItems[i] = pmru->pszItems[i-1];
+ pmru->pszItems[0] = StrDup(pszNew);
+ return(1);
+}
+
+BOOL MRU_AddFile(LPMRULIST pmru,LPCWSTR pszFile,BOOL bRelativePath,BOOL bUnexpandMyDocs) {
+
+ int i;
+ for (i = 0; i < pmru->iSize; i++) {
+ if (lstrcmpi(pmru->pszItems[i],pszFile) == 0) {
+ LocalFree(pmru->pszItems[i]);
+ break;
+ }
+ else {
+ WCHAR wchItem[MAX_PATH];
+ PathAbsoluteFromApp(pmru->pszItems[i],wchItem,COUNTOF(wchItem),TRUE);
+ if (lstrcmpi(wchItem,pszFile) == 0) {
+ LocalFree(pmru->pszItems[i]);
+ break;
+ }
+ }
+ }
+ i = min(i,pmru->iSize-1);
+ for (; i > 0; i--)
+ pmru->pszItems[i] = pmru->pszItems[i-1];
+
+ if (bRelativePath) {
+ WCHAR wchFile[MAX_PATH];
+ PathRelativeToApp((LPWSTR)pszFile,wchFile,COUNTOF(wchFile),TRUE,TRUE,bUnexpandMyDocs);
+ pmru->pszItems[0] = StrDup(wchFile);
+ }
+ else
+ pmru->pszItems[0] = StrDup(pszFile);
+ return(1);
+}
+
+BOOL MRU_Delete(LPMRULIST pmru,int iIndex) {
+
+ int i;
+ if (iIndex < 0 || iIndex > pmru->iSize-1)
+ return(0);
+ if (pmru->pszItems[iIndex])
+ LocalFree(pmru->pszItems[iIndex]);
+ for (i = iIndex; i < pmru->iSize-1; i++) {
+ pmru->pszItems[i] = pmru->pszItems[i+1];
+ pmru->pszItems[i+1] = NULL;
+ }
+ return(1);
+}
+
+BOOL MRU_DeleteFileFromStore(LPMRULIST pmru,LPCWSTR pszFile) {
+
+ int i = 0;
+ LPMRULIST pmruStore;
+ WCHAR wchItem[256];
+
+ pmruStore = MRU_Create(pmru->szRegKey,pmru->iFlags,pmru->iSize);
+ MRU_Load(pmruStore);
+
+ while (MRU_Enum(pmruStore,i,wchItem,COUNTOF(wchItem)) != -1) {
+ PathAbsoluteFromApp(wchItem,wchItem,COUNTOF(wchItem),TRUE);
+ if (lstrcmpi(wchItem,pszFile) == 0)
+ MRU_Delete(pmruStore,i);
+ else
+ i++;
+ }
+
+ MRU_Save(pmruStore);
+ MRU_Destroy(pmruStore);
+ return(1);
+}
+
+BOOL MRU_Empty(LPMRULIST pmru) {
+
+ int i;
+ for (i = 0; i < pmru->iSize; i++) {
+ if (pmru->pszItems[i]) {
+ LocalFree(pmru->pszItems[i]);
+ pmru->pszItems[i] = NULL;
+ }
+ }
+ return(1);
+}
+
+int MRU_Enum(LPMRULIST pmru,int iIndex,LPWSTR pszItem,int cchItem) {
+
+ if (pszItem == NULL || cchItem == 0) {
+ int i = 0;
+ while (pmru->pszItems[i] && i < pmru->iSize)
+ i++;
+ return(i);
+ }
+ else {
+ if (iIndex < 0 || iIndex > pmru->iSize-1 || !pmru->pszItems[iIndex])
+ return(-1);
+ else {
+ lstrcpyn(pszItem,pmru->pszItems[iIndex],cchItem);
+ return(lstrlen(pszItem));
+ }
+ }
+}
+
+BOOL MRU_Load(LPMRULIST pmru) {
+
+ int i,n = 0;
+ WCHAR tchName[32];
+ WCHAR tchItem[1024];
+ WCHAR *pIniSection = LocalAlloc(LPTR,sizeof(WCHAR)*32*1024);
+
+ MRU_Empty(pmru);
+ LoadIniSection(pmru->szRegKey,pIniSection,LocalSize(pIniSection)/sizeof(WCHAR));
+
+ for (i = 0; i < pmru->iSize; i++) {
+ wsprintf(tchName,L"%.2i",i+1);
+ if (IniSectionGetString(pIniSection,tchName,L"",tchItem,COUNTOF(tchItem))) {
+ /*if (pmru->iFlags & MRU_UTF8) {
+ WCHAR wchItem[1024];
+ int cbw = MultiByteToWideChar(CP_UTF7,0,tchItem,-1,wchItem,COUNTOF(wchItem));
+ WideCharToMultiByte(CP_UTF8,0,wchItem,cbw,tchItem,COUNTOF(tchItem),NULL,NULL);
+ pmru->pszItems[n++] = StrDup(tchItem);
+ }
+ else*/
+ pmru->pszItems[n++] = StrDup(tchItem);
+ }
+ }
+ LocalFree(pIniSection);
+ return(1);
+}
+
+BOOL MRU_Save(LPMRULIST pmru) {
+
+ int i;
+ WCHAR tchName[32];
+ WCHAR *pIniSection = LocalAlloc(LPTR,sizeof(WCHAR)*32*1024);
+
+ //IniDeleteSection(pmru->szRegKey);
+
+ for (i = 0; i < pmru->iSize; i++) {
+ if (pmru->pszItems[i]) {
+ wsprintf(tchName,L"%.2i",i+1);
+ /*if (pmru->iFlags & MRU_UTF8) {
+ WCHAR tchItem[1024];
+ WCHAR wchItem[1024];
+ int cbw = MultiByteToWideChar(CP_UTF8,0,pmru->pszItems[i],-1,wchItem,COUNTOF(wchItem));
+ WideCharToMultiByte(CP_UTF7,0,wchItem,cbw,tchItem,COUNTOF(tchItem),NULL,NULL);
+ IniSectionSetString(pIniSection,tchName,tchItem);
+ }
+ else*/
+ IniSectionSetString(pIniSection,tchName,pmru->pszItems[i]);
+ }
+ }
+ SaveIniSection(pmru->szRegKey,pIniSection);
+ LocalFree(pIniSection);
+ return(1);
+}
+
+
+BOOL MRU_MergeSave(LPMRULIST pmru,BOOL bAddFiles,BOOL bRelativePath,BOOL bUnexpandMyDocs) {
+
+ int i;
+ LPMRULIST pmruBase;
+
+ pmruBase = MRU_Create(pmru->szRegKey,pmru->iFlags,pmru->iSize);
+ MRU_Load(pmruBase);
+
+ if (bAddFiles) {
+ for (i = pmru->iSize-1; i >= 0; i--) {
+ if (pmru->pszItems[i]) {
+ WCHAR wchItem[MAX_PATH];
+ PathAbsoluteFromApp(pmru->pszItems[i],wchItem,COUNTOF(wchItem),TRUE);
+ MRU_AddFile(pmruBase,wchItem,bRelativePath,bUnexpandMyDocs);
+ }
+ }
+ }
+
+ else {
+ for (i = pmru->iSize-1; i >= 0; i--) {
+ if (pmru->pszItems[i])
+ MRU_Add(pmruBase,pmru->pszItems[i]);
+ }
+ }
+
+ MRU_Save(pmruBase);
+ MRU_Destroy(pmruBase);
+ return(1);
+}
+
+
+/*
+
+ Themed Dialogs
+ Modify dialog templates to use current theme font
+ Based on code of MFC helper class CDialogTemplate
+
+*/
+
+BOOL GetThemedDialogFont(LPWSTR lpFaceName,WORD* wSize)
+{
+ HDC hDC;
+ int iLogPixelsY;
+ HMODULE hModUxTheme;
+ HTHEME hTheme;
+ LOGFONT lf;
+ BOOL bSucceed = FALSE;
+
+ hDC = GetDC(NULL);
+ iLogPixelsY = GetDeviceCaps(hDC,LOGPIXELSY);
+ ReleaseDC(NULL,hDC);
+
+ if (hModUxTheme = GetModuleHandle(L"uxtheme.dll")) {
+ if ((BOOL)(GetProcAddress(hModUxTheme,"IsAppThemed"))()) {
+ hTheme = (HTHEME)(GetProcAddress(hModUxTheme,"OpenThemeData"))(NULL,L"WINDOWSTYLE;WINDOW");
+ if (hTheme) {
+ if (S_OK == (HRESULT)(GetProcAddress(hModUxTheme,"GetThemeSysFont"))(hTheme,/*TMT_MSGBOXFONT*/805,&lf)) {
+ if (lf.lfHeight < 0)
+ lf.lfHeight = -lf.lfHeight;
+ *wSize = (WORD)MulDiv(lf.lfHeight,72,iLogPixelsY);
+ if (*wSize == 0)
+ *wSize = 8;
+ StrCpyN(lpFaceName,lf.lfFaceName,LF_FACESIZE);
+ bSucceed = TRUE;
+ }
+ (GetProcAddress(hModUxTheme,"CloseThemeData"))(hTheme);
+ }
+ }
+ }
+
+ /*
+ if (!bSucceed) {
+ NONCLIENTMETRICS ncm;
+ ncm.cbSize = sizeof(NONCLIENTMETRICS);
+ SystemParametersInfo(SPI_GETNONCLIENTMETRICS,sizeof(NONCLIENTMETRICS),&ncm,0);
+ if (ncm.lfMessageFont.lfHeight < 0)
+ ncm.lfMessageFont.lfHeight = -ncm.lfMessageFont.lfHeight;
+ *wSize = (WORD)MulDiv(ncm.lfMessageFont.lfHeight,72,iLogPixelsY);
+ if (*wSize == 0)
+ *wSize = 8;
+ StrCpyN(lpFaceName,ncm.lfMessageFont.lfFaceName,LF_FACESIZE);
+ }*/
+
+ return(bSucceed);
+}
+
+__inline BOOL DialogTemplate_IsDialogEx(const DLGTEMPLATE* pTemplate) {
+
+ return ((DLGTEMPLATEEX*)pTemplate)->signature == 0xFFFF;
+}
+
+__inline BOOL DialogTemplate_HasFont(const DLGTEMPLATE* pTemplate) {
+
+ return (DS_SETFONT &
+ (DialogTemplate_IsDialogEx(pTemplate) ? ((DLGTEMPLATEEX*)pTemplate)->style : pTemplate->style));
+}
+
+__inline int DialogTemplate_FontAttrSize(BOOL bDialogEx) {
+
+ return (int)sizeof(WORD) * (bDialogEx ? 3 : 1);
+}
+
+__inline BYTE* DialogTemplate_GetFontSizeField(const DLGTEMPLATE* pTemplate) {
+
+ BOOL bDialogEx = DialogTemplate_IsDialogEx(pTemplate);
+ WORD* pw;
+
+ if (bDialogEx)
+ pw = (WORD*)((DLGTEMPLATEEX*)pTemplate + 1);
+ else
+ pw = (WORD*)(pTemplate + 1);
+
+ if (*pw == (WORD)-1)
+ pw += 2;
+ else
+ while(*pw++);
+
+ if (*pw == (WORD)-1)
+ pw += 2;
+ else
+ while(*pw++);
+
+ while (*pw++);
+
+ return (BYTE*)pw;
+}
+
+DLGTEMPLATE* LoadThemedDialogTemplate(LPCTSTR lpDialogTemplateID,HINSTANCE hInstance) {
+
+ HRSRC hRsrc;
+ HGLOBAL hRsrcMem;
+ DLGTEMPLATE *pRsrcMem;
+ DLGTEMPLATE *pTemplate;
+ UINT dwTemplateSize = 0;
+ WCHAR wchFaceName[LF_FACESIZE];
+ WORD wFontSize;
+ BOOL bDialogEx;
+ BOOL bHasFont;
+ int cbFontAttr;
+ int cbNew;
+ int cbOld;
+ BYTE* pbNew;
+ BYTE* pb;
+ BYTE* pOldControls;
+ BYTE* pNewControls;
+ WORD nCtrl;
+
+ hRsrc = FindResource(hInstance,lpDialogTemplateID,RT_DIALOG);
+ if (hRsrc == NULL)
+ return(NULL);
+
+ hRsrcMem = LoadResource(hInstance,hRsrc);
+ pRsrcMem = (DLGTEMPLATE*)LockResource(hRsrcMem);
+ dwTemplateSize = (UINT)SizeofResource(hInstance,hRsrc);
+
+ if ((dwTemplateSize == 0) ||
+ (pTemplate = LocalAlloc(LPTR,dwTemplateSize+LF_FACESIZE*2)) == NULL) {
+ UnlockResource(hRsrcMem);
+ FreeResource(hRsrcMem);
+ return(NULL);
+ }
+
+ CopyMemory((BYTE*)pTemplate,pRsrcMem,(size_t)dwTemplateSize);
+ UnlockResource(hRsrcMem);
+ FreeResource(hRsrcMem);
+
+ if (!GetThemedDialogFont(wchFaceName,&wFontSize))
+ return(pTemplate);
+
+ bDialogEx = DialogTemplate_IsDialogEx(pTemplate);
+ bHasFont = DialogTemplate_HasFont(pTemplate);
+ cbFontAttr = DialogTemplate_FontAttrSize(bDialogEx);
+
+ if (bDialogEx)
+ ((DLGTEMPLATEEX*)pTemplate)->style |= DS_SHELLFONT;
+ else
+ pTemplate->style |= DS_SHELLFONT;
+
+ cbNew = cbFontAttr + ((lstrlen(wchFaceName) + 1) * sizeof(WCHAR));
+ pbNew = (BYTE*)wchFaceName;
+
+ pb = DialogTemplate_GetFontSizeField(pTemplate);
+ cbOld = (int)(bHasFont ? cbFontAttr + 2 * (lstrlen((WCHAR*)(pb + cbFontAttr)) + 1) : 0);
+
+ pOldControls = (BYTE*)(((DWORD_PTR)pb + cbOld + 3) & ~(DWORD_PTR)3);
+ pNewControls = (BYTE*)(((DWORD_PTR)pb + cbNew + 3) & ~(DWORD_PTR)3);
+
+ nCtrl = bDialogEx ?
+ (WORD)((DLGTEMPLATEEX*)pTemplate)->cDlgItems :
+ (WORD)pTemplate->cdit;
+
+ if (cbNew != cbOld && nCtrl > 0)
+ MoveMemory(pNewControls,pOldControls,(size_t)(dwTemplateSize - (pOldControls - (BYTE*)pTemplate)));
+
+ *(WORD*)pb = wFontSize;
+ MoveMemory(pb + cbFontAttr,pbNew,(size_t)(cbNew - cbFontAttr));
+
+ return(pTemplate);
+}
+
+INT_PTR ThemedDialogBoxParam(
+ HINSTANCE hInstance,
+ LPCTSTR lpTemplate,
+ HWND hWndParent,
+ DLGPROC lpDialogFunc,
+ LPARAM dwInitParam) {
+
+ INT ret;
+ DLGTEMPLATE *pDlgTemplate;
+
+ pDlgTemplate = LoadThemedDialogTemplate(lpTemplate,hInstance);
+ ret = DialogBoxIndirectParam(hInstance,pDlgTemplate,hWndParent,lpDialogFunc,dwInitParam);
+ if (pDlgTemplate)
+ LocalFree(pDlgTemplate);
+
+ return(ret);
+}
+
+HWND CreateThemedDialogParam(
+ HINSTANCE hInstance,
+ LPCTSTR lpTemplate,
+ HWND hWndParent,
+ DLGPROC lpDialogFunc,
+ LPARAM dwInitParam) {
+
+ HWND hwnd;
+ DLGTEMPLATE *pDlgTemplate;
+
+ pDlgTemplate = LoadThemedDialogTemplate(lpTemplate,hInstance);
+ hwnd = CreateDialogIndirectParam(hInstance,pDlgTemplate,hWndParent,lpDialogFunc,dwInitParam);
+ if (pDlgTemplate)
+ LocalFree(pDlgTemplate);
+
+ return(hwnd);
+}
+
+
+/******************************************************************************
+*
+* UnSlash functions
+* Mostly taken from SciTE, (c) Neil Hodgson, http://www.scintilla.org
+*
+/
+
+/**
+ * Is the character an octal digit?
+ */
+static BOOL IsOctalDigit(char ch) {
+ return ch >= '0' && ch <= '7';
+}
+
+/**
+ * If the character is an hexa digit, get its value.
+ */
+static int GetHexaDigit(char ch) {
+ if (ch >= '0' && ch <= '9') {
+ return ch - '0';
+ }
+ if (ch >= 'A' && ch <= 'F') {
+ return ch - 'A' + 10;
+ }
+ if (ch >= 'a' && ch <= 'f') {
+ return ch - 'a' + 10;
+ }
+ return -1;
+}
+
+/**
+ * Convert C style \a, \b, \f, \n, \r, \t, \v, \ooo and \xhh into their indicated characters.
+ */
+unsigned int UnSlash(char *s) {
+ char *sStart = s;
+ char *o = s;
+
+ while (*s) {
+ if (*s == '\\') {
+ s++;
+ if (*s == 'a') {
+ *o = '\a';
+ } else if (*s == 'b') {
+ *o = '\b';
+ } else if (*s == 'f') {
+ *o = '\f';
+ } else if (*s == 'n') {
+ *o = '\n';
+ } else if (*s == 'r') {
+ *o = '\r';
+ } else if (*s == 't') {
+ *o = '\t';
+ } else if (*s == 'v') {
+ *o = '\v';
+ } else if (IsOctalDigit(*s)) {
+ int val = *s - '0';
+ if (IsOctalDigit(*(s + 1))) {
+ s++;
+ val *= 8;
+ val += *s - '0';
+ if (IsOctalDigit(*(s + 1))) {
+ s++;
+ val *= 8;
+ val += *s - '0';
+ }
+ }
+ *o = (char)(val);
+ } else if (*s == 'x') {
+ int val, ghd;
+ s++;
+ val = 0;
+ ghd = GetHexaDigit(*s);
+ if (ghd >= 0) {
+ s++;
+ val = ghd;
+ ghd = GetHexaDigit(*s);
+ if (ghd >= 0) {
+ s++;
+ val *= 16;
+ val += ghd;
+ }
+ }
+ *o = (char)(val);
+ } else {
+ *o = *s;
+ }
+ } else {
+ *o = *s;
+ }
+ o++;
+ if (*s) {
+ s++;
+ }
+ }
+ *o = '\0';
+ return o - sStart;
+}
+
+/**
+ * Convert C style \0oo into their indicated characters.
+ * This is used to get control characters into the regular expresion engine.
+ */
+unsigned int UnSlashLowOctal(char *s) {
+ char *sStart = s;
+ char *o = s;
+ while (*s) {
+ if ((s[0] == '\\') && (s[1] == '0') && IsOctalDigit(s[2]) && IsOctalDigit(s[3])) {
+ *o = (char)(8 * (s[2] - '0') + (s[3] - '0'));
+ s += 3;
+ } else {
+ *o = *s;
+ }
+ o++;
+ if (*s)
+ s++;
+ }
+ *o = '\0';
+ return o - sStart;
+}
+
+void TransformBackslashes(char* pszInput,BOOL bRegEx)
+{
+ if (bRegEx)
+ UnSlashLowOctal(pszInput);
+ else
+ UnSlash(pszInput);
+}
+
+
+/*
+
+ MinimizeToTray - Copyright 2000 Matthew Ellis <m.t.ellis@bigfoot.com>
+
+ Changes made by flo:
+ - Commented out: #include "stdafx.h"
+ - Moved variable declaration: APPBARDATA appBarData;
+
+*/
+
+// MinimizeToTray
+//
+// A couple of routines to show how to make it produce a custom caption
+// animation to make it look like we are minimizing to and maximizing
+// from the system tray
+//
+// These routines are public domain, but it would be nice if you dropped
+// me a line if you use them!
+//
+// 1.0 29.06.2000 Initial version
+// 1.1 01.07.2000 The window retains it's place in the Z-order of windows
+// when minimized/hidden. This means that when restored/shown, it doen't
+// always appear as the foreground window unless we call SetForegroundWindow
+//
+// Copyright 2000 Matthew Ellis <m.t.ellis@bigfoot.com>
+/*#include "stdafx.h"*/
+
+// Odd. VC++6 winuser.h has IDANI_CAPTION defined (as well as IDANI_OPEN and
+// IDANI_CLOSE), but the Platform SDK only has IDANI_OPEN...
+
+// I don't know what IDANI_OPEN or IDANI_CLOSE do. Trying them in this code
+// produces nothing. Perhaps they were intended for window opening and closing
+// like the MAC provides...
+#ifndef IDANI_OPEN
+#define IDANI_OPEN 1
+#endif
+#ifndef IDANI_CLOSE
+#define IDANI_CLOSE 2
+#endif
+#ifndef IDANI_CAPTION
+#define IDANI_CAPTION 3
+#endif
+
+#define DEFAULT_RECT_WIDTH 150
+#define DEFAULT_RECT_HEIGHT 30
+
+// Returns the rect of where we think the system tray is. This will work for
+// all current versions of the shell. If explorer isn't running, we try our
+// best to work with a 3rd party shell. If we still can't find anything, we
+// return a rect in the lower right hand corner of the screen
+static VOID GetTrayWndRect(LPRECT lpTrayRect)
+{
+ APPBARDATA appBarData;
+ // First, we'll use a quick hack method. We know that the taskbar is a window
+ // of class Shell_TrayWnd, and the status tray is a child of this of class
+ // TrayNotifyWnd. This provides us a window rect to minimize to. Note, however,
+ // that this is not guaranteed to work on future versions of the shell. If we
+ // use this method, make sure we have a backup!
+ HWND hShellTrayWnd=FindWindowEx(NULL,NULL,TEXT("Shell_TrayWnd"),NULL);
+ if(hShellTrayWnd)
+ {
+ HWND hTrayNotifyWnd=FindWindowEx(hShellTrayWnd,NULL,TEXT("TrayNotifyWnd"),NULL);
+ if(hTrayNotifyWnd)
+ {
+ GetWindowRect(hTrayNotifyWnd,lpTrayRect);
+ return;
+ }
+ }
+
+ // OK, we failed to get the rect from the quick hack. Either explorer isn't
+ // running or it's a new version of the shell with the window class names
+ // changed (how dare Microsoft change these undocumented class names!) So, we
+ // try to find out what side of the screen the taskbar is connected to. We
+ // know that the system tray is either on the right or the bottom of the
+ // taskbar, so we can make a good guess at where to minimize to
+ /*APPBARDATA appBarData;*/
+ appBarData.cbSize=sizeof(appBarData);
+ if(SHAppBarMessage(ABM_GETTASKBARPOS,&appBarData))
+ {
+ // We know the edge the taskbar is connected to, so guess the rect of the
+ // system tray. Use various fudge factor to make it look good
+ switch(appBarData.uEdge)
+ {
+ case ABE_LEFT:
+ case ABE_RIGHT:
+ // We want to minimize to the bottom of the taskbar
+ lpTrayRect->top=appBarData.rc.bottom-100;
+ lpTrayRect->bottom=appBarData.rc.bottom-16;
+ lpTrayRect->left=appBarData.rc.left;
+ lpTrayRect->right=appBarData.rc.right;
+ break;
+
+ case ABE_TOP:
+ case ABE_BOTTOM:
+ // We want to minimize to the right of the taskbar
+ lpTrayRect->top=appBarData.rc.top;
+ lpTrayRect->bottom=appBarData.rc.bottom;
+ lpTrayRect->left=appBarData.rc.right-100;
+ lpTrayRect->right=appBarData.rc.right-16;
+ break;
+ }
+
+ return;
+ }
+
+ // Blimey, we really aren't in luck. It's possible that a third party shell
+ // is running instead of explorer. This shell might provide support for the
+ // system tray, by providing a Shell_TrayWnd window (which receives the
+ // messages for the icons) So, look for a Shell_TrayWnd window and work out
+ // the rect from that. Remember that explorer's taskbar is the Shell_TrayWnd,
+ // and stretches either the width or the height of the screen. We can't rely
+ // on the 3rd party shell's Shell_TrayWnd doing the same, in fact, we can't
+ // rely on it being any size. The best we can do is just blindly use the
+ // window rect, perhaps limiting the width and height to, say 150 square.
+ // Note that if the 3rd party shell supports the same configuraion as
+ // explorer (the icons hosted in NotifyTrayWnd, which is a child window of
+ // Shell_TrayWnd), we would already have caught it above
+ hShellTrayWnd=FindWindowEx(NULL,NULL,TEXT("Shell_TrayWnd"),NULL);
+ if(hShellTrayWnd)
+ {
+ GetWindowRect(hShellTrayWnd,lpTrayRect);
+ if(lpTrayRect->right-lpTrayRect->left>DEFAULT_RECT_WIDTH)
+ lpTrayRect->left=lpTrayRect->right-DEFAULT_RECT_WIDTH;
+ if(lpTrayRect->bottom-lpTrayRect->top>DEFAULT_RECT_HEIGHT)
+ lpTrayRect->top=lpTrayRect->bottom-DEFAULT_RECT_HEIGHT;
+
+ return;
+ }
+
+ // OK. Haven't found a thing. Provide a default rect based on the current work
+ // area
+ SystemParametersInfo(SPI_GETWORKAREA,0,lpTrayRect,0);
+ lpTrayRect->left=lpTrayRect->right-DEFAULT_RECT_WIDTH;
+ lpTrayRect->top=lpTrayRect->bottom-DEFAULT_RECT_HEIGHT;
+}
+
+// Check to see if the animation has been disabled
+static BOOL GetDoAnimateMinimize(VOID)
+{
+ ANIMATIONINFO ai;
+
+ ai.cbSize=sizeof(ai);
+ SystemParametersInfo(SPI_GETANIMATION,sizeof(ai),&ai,0);
+
+ return ai.iMinAnimate?TRUE:FALSE;
+}
+
+VOID MinimizeWndToTray(HWND hWnd)
+{
+ if(GetDoAnimateMinimize())
+ {
+ RECT rcFrom,rcTo;
+
+ // Get the rect of the window. It is safe to use the rect of the whole
+ // window - DrawAnimatedRects will only draw the caption
+ GetWindowRect(hWnd,&rcFrom);
+ GetTrayWndRect(&rcTo);
+
+ // Get the system to draw our animation for us
+ DrawAnimatedRects(hWnd,IDANI_CAPTION,&rcFrom,&rcTo);
+ }
+
+ // Add the tray icon. If we add it before the call to DrawAnimatedRects,
+ // the taskbar gets erased, but doesn't get redrawn until DAR finishes.
+ // This looks untidy, so call the functions in this order
+
+ // Hide the window
+ ShowWindow(hWnd,SW_HIDE);
+}
+
+VOID RestoreWndFromTray(HWND hWnd)
+{
+ if(GetDoAnimateMinimize())
+ {
+ // Get the rect of the tray and the window. Note that the window rect
+ // is still valid even though the window is hidden
+ RECT rcFrom,rcTo;
+ GetTrayWndRect(&rcFrom);
+ GetWindowRect(hWnd,&rcTo);
+
+ // Get the system to draw our animation for us
+ DrawAnimatedRects(hWnd,IDANI_CAPTION,&rcFrom,&rcTo);
+ }
+
+ // Show the window, and make sure we're the foreground window
+ ShowWindow(hWnd,SW_SHOW);
+ SetActiveWindow(hWnd);
+ SetForegroundWindow(hWnd);
+
+ // Remove the tray icon. As described above, remove the icon after the
+ // call to DrawAnimatedRects, or the taskbar will not refresh itself
+ // properly until DAR finished
+}
+
+
+
+/// End of Helpers.c \\\
diff --git a/src/Helpers.h b/src/Helpers.h new file mode 100644 index 0000000..9644588 --- /dev/null +++ b/src/Helpers.h @@ -0,0 +1,219 @@ +/******************************************************************************
+*
+*
+* Notepad2
+*
+* Helpers.h
+* Definitions for general helper functions and macros
+*
+* See Readme.txt for more information about this source code.
+* Please send me your comments to this work.
+*
+* See License.txt for details about distribution and modification.
+*
+* (c) Florian Balmer 1996-2010
+* florian.balmer@gmail.com
+* http://www.flos-freeware.ch
+*
+*
+******************************************************************************/
+
+
+
+extern HINSTANCE g_hInstance;
+extern UINT16 g_uWinVer;
+
+
+#define COUNTOF(ar) (sizeof(ar)/sizeof(ar[0]))
+
+
+extern WCHAR szIniFile[MAX_PATH];
+#define IniGetString(lpSection,lpName,lpDefault,lpReturnedStr,nSize) \
+ GetPrivateProfileString(lpSection,lpName,lpDefault,lpReturnedStr,nSize,szIniFile)
+#define IniGetInt(lpSection,lpName,nDefault) \
+ GetPrivateProfileInt(lpSection,lpName,nDefault,szIniFile)
+#define IniSetString(lpSection,lpName,lpString) \
+ WritePrivateProfileString(lpSection,lpName,lpString,szIniFile)
+#define IniDeleteSection(lpSection) \
+ WritePrivateProfileSection(lpSection,NULL,szIniFile)
+__inline BOOL IniSetInt(LPCWSTR lpSection,LPCWSTR lpName,int i) {
+ WCHAR tch[32]; wsprintf(tch,L"%i",i); return IniSetString(lpSection,lpName,tch);
+}
+#define LoadIniSection(lpSection,lpBuf,cchBuf) \
+ GetPrivateProfileSection(lpSection,lpBuf,cchBuf,szIniFile);
+#define SaveIniSection(lpSection,lpBuf) \
+ WritePrivateProfileSection(lpSection,lpBuf,szIniFile)
+int IniSectionGetString(LPCWSTR,LPCWSTR,LPCWSTR,LPWSTR,int);
+int IniSectionGetInt(LPCWSTR,LPCWSTR,int);
+BOOL IniSectionSetString(LPWSTR,LPCWSTR,LPCWSTR);
+__inline BOOL IniSectionSetInt(LPWSTR lpCachedIniSection,LPCWSTR lpName,int i) {
+ WCHAR tch[32]; wsprintf(tch,L"%i",i); return IniSectionSetString(lpCachedIniSection,lpName,tch);
+}
+
+
+void BeginWaitCursor();
+void EndWaitCursor();
+
+
+#define Is2k() (g_uWinVer >= 0x0500)
+#define IsXP() (g_uWinVer >= 0x0501)
+#define IsVista() (g_uWinVer >= 0x0600)
+#define IsW7() (g_uWinVer >= 0x0601)
+
+
+BOOL PrivateIsAppThemed();
+HRESULT PrivateSetCurrentProcessExplicitAppUserModelID(PCWSTR);
+BOOL IsElevated();
+//BOOL SetExplorerTheme(HWND);
+
+
+BOOL VerifyContrast();
+
+
+BOOL SetWindowTitle(HWND,UINT,BOOL,UINT,LPCWSTR,int,BOOL,UINT,BOOL,LPCWSTR);
+void SetWindowTransparentMode(HWND,BOOL);
+
+
+void CenterDlgInParent(HWND);
+void GetDlgPos(HWND,LPINT,LPINT);
+void SetDlgPos(HWND,int,int);
+void ResizeDlg_Init(HWND,int,int,int);
+void ResizeDlg_Destroy(HWND,int*,int*);
+void ResizeDlg_Size(HWND,LPARAM,int*,int*);
+void ResizeDlg_GetMinMaxInfo(HWND,LPARAM);
+HDWP DeferCtlPos(HDWP,HWND,int,int,int,UINT);
+void MakeBitmapButton(HWND,int,HINSTANCE,UINT);
+void MakeColorPickButton(HWND,int,HINSTANCE,COLORREF);
+void DeleteBitmapButton(HWND,int);
+
+
+#define StatusSetSimple(hwnd,b) SendMessage(hwnd,SB_SIMPLE,(WPARAM)b,0)
+BOOL StatusSetText(HWND,UINT,LPCWSTR);
+BOOL StatusSetTextID(HWND,UINT,UINT);
+int StatusCalcPaneWidth(HWND,LPCWSTR);
+
+int Toolbar_GetButtons(HWND,int,LPWSTR,int);
+int Toolbar_SetButtons(HWND,int,LPCWSTR,void*,int);
+
+LRESULT SendWMSize(HWND);
+
+#define EnableCmd(hmenu,id,b) EnableMenuItem(hmenu,id,(b)\
+ ?MF_BYCOMMAND|MF_ENABLED:MF_BYCOMMAND|MF_GRAYED)
+
+#define CheckCmd(hmenu,id,b) CheckMenuItem(hmenu,id,(b)\
+ ?MF_BYCOMMAND|MF_CHECKED:MF_BYCOMMAND|MF_UNCHECKED)
+
+BOOL IsCmdEnabled(HWND, UINT);
+
+
+#define GetString(id,pb,cb) LoadString(g_hInstance,id,pb,cb)
+
+#define StrEnd(pStart) (pStart + lstrlen(pStart))
+
+int FormatString(LPWSTR,int,UINT,...);
+
+
+void PathRelativeToApp(LPWSTR,LPWSTR,int,BOOL,BOOL,BOOL);
+void PathAbsoluteFromApp(LPWSTR,LPWSTR,int,BOOL);
+
+
+BOOL PathIsLnkFile(LPCWSTR);
+BOOL PathGetLnkPath(LPCWSTR,LPWSTR,int);
+BOOL PathIsLnkToDirectory(LPCWSTR,LPWSTR,int);
+BOOL PathCreateDeskLnk(LPCWSTR);
+BOOL PathCreateFavLnk(LPCWSTR,LPCWSTR,LPCWSTR);
+
+
+BOOL TrimString(LPWSTR);
+BOOL ExtractFirstArgument(LPCWSTR, LPWSTR, LPWSTR);
+
+void PrepareFilterStr(LPWSTR);
+
+void StrTab2Space(LPWSTR);
+
+
+void ExpandEnvironmentStringsEx(LPWSTR,DWORD);
+void PathCanonicalizeEx(LPWSTR);
+DWORD GetLongPathNameEx(LPCWSTR,LPWSTR,DWORD);
+DWORD_PTR SHGetFileInfo2(LPCWSTR,DWORD,SHFILEINFO*,UINT,UINT);
+
+
+int FormatNumberStr(LPWSTR);
+BOOL SetDlgItemIntEx(HWND,int,UINT);
+
+
+#define MBCSToWChar(c,a,w,i) MultiByteToWideChar(c,0,a,-1,w,i)
+#define WCharToMBCS(c,w,a,i) WideCharToMultiByte(c,0,w,-1,a,i,NULL,NULL)
+
+UINT GetDlgItemTextA2W(UINT,HWND,int,LPSTR,int);
+UINT SetDlgItemTextA2W(UINT,HWND,int,LPSTR);
+LRESULT ComboBox_AddStringA2W(UINT,HWND,LPCSTR);
+
+
+UINT CodePageFromCharSet(UINT);
+
+
+//==== MRU Functions ==========================================================
+#define MRU_MAXITEMS 24
+#define MRU_NOCASE 1
+#define MRU_UTF8 2
+
+typedef struct _mrulist {
+
+ WCHAR szRegKey[256];
+ int iFlags;
+ int iSize;
+ LPWSTR pszItems[MRU_MAXITEMS];
+
+} MRULIST, *PMRULIST, *LPMRULIST;
+
+LPMRULIST MRU_Create(LPCWSTR,int,int);
+BOOL MRU_Destroy(LPMRULIST);
+BOOL MRU_Add(LPMRULIST,LPCWSTR);
+BOOL MRU_AddFile(LPMRULIST,LPCWSTR,BOOL,BOOL);
+BOOL MRU_Delete(LPMRULIST,int);
+BOOL MRU_DeleteFileFromStore(LPMRULIST,LPCWSTR);
+BOOL MRU_Empty(LPMRULIST);
+int MRU_Enum(LPMRULIST,int,LPWSTR,int);
+BOOL MRU_Load(LPMRULIST);
+BOOL MRU_Save(LPMRULIST);
+BOOL MRU_MergeSave(LPMRULIST,BOOL,BOOL,BOOL);
+
+
+//==== Themed Dialogs =========================================================
+#ifndef DLGTEMPLATEEX
+#pragma pack(push, 1)
+typedef struct {
+ WORD dlgVer;
+ WORD signature;
+ DWORD helpID;
+ DWORD exStyle;
+ DWORD style;
+ WORD cDlgItems;
+ short x;
+ short y;
+ short cx;
+ short cy;
+} DLGTEMPLATEEX;
+#pragma pack(pop)
+#endif
+
+BOOL GetThemedDialogFont(LPWSTR,WORD*);
+DLGTEMPLATE* LoadThemedDialogTemplate(LPCTSTR,HINSTANCE);
+#define ThemedDialogBox(hInstance,lpTemplate,hWndParent,lpDialogFunc) \
+ ThemedDialogBoxParam(hInstance,lpTemplate,hWndParent,lpDialogFunc,0)
+INT_PTR ThemedDialogBoxParam(HINSTANCE,LPCTSTR,HWND,DLGPROC,LPARAM);
+HWND CreateThemedDialogParam(HINSTANCE,LPCTSTR,HWND,DLGPROC,LPARAM);
+
+
+//==== UnSlash Functions ======================================================
+void TransformBackslashes(char*,BOOL);
+
+
+//==== MinimizeToTray Functions - see comments in Helpers.c ===================
+VOID MinimizeWndToTray(HWND hWnd);
+VOID RestoreWndFromTray(HWND hWnd);
+
+
+
+/// End of Helpers.h \\\
diff --git a/src/Notepad2.c b/src/Notepad2.c new file mode 100644 index 0000000..12eee84 --- /dev/null +++ b/src/Notepad2.c @@ -0,0 +1,6915 @@ +/******************************************************************************
+*
+*
+* Notepad2
+*
+* Notepad2.c
+* Main application window functionality
+*
+* See Readme.txt for more information about this source code.
+* Please send me your comments to this work.
+*
+* See License.txt for details about distribution and modification.
+*
+* (c) Florian Balmer 1996-2010
+* florian.balmer@gmail.com
+* http://www.flos-freeware.ch
+*
+*
+******************************************************************************/
+#define _WIN32_WINNT 0x501
+#include <windows.h>
+#include <commctrl.h>
+#include <shlobj.h>
+#include <shlwapi.h>
+#include <shellapi.h>
+#include <commdlg.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+#include "scintilla.h"
+#include "scilexer.h"
+#include "edit.h"
+#include "styles.h"
+#include "helpers.h"
+#include "dialogs.h"
+#include "notepad2.h"
+#include "resource.h"
+
+
+
+/******************************************************************************
+*
+* Local and global Variables for Notepad2.c
+*
+*/
+HWND hwndStatus;
+HWND hwndToolbar;
+HWND hwndReBar;
+HWND hwndEdit;
+HWND hwndEditFrame;
+HWND hwndMain;
+HWND hwndNextCBChain = NULL;
+HWND hDlgFindReplace = NULL;
+
+#define NUMTOOLBITMAPS 23
+#define NUMINITIALTOOLS 24
+
+TBBUTTON tbbMainWnd[] = { {0,IDT_FILE_NEW,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
+ {1,IDT_FILE_OPEN,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
+ {2,IDT_FILE_BROWSE,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
+ {3,IDT_FILE_SAVE,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
+ {0,0,0,TBSTYLE_SEP,0,0},
+ {4,IDT_EDIT_UNDO,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
+ {5,IDT_EDIT_REDO,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
+ {0,0,0,TBSTYLE_SEP,0,0},
+ {6,IDT_EDIT_CUT,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
+ {7,IDT_EDIT_COPY,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
+ {8,IDT_EDIT_PASTE,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
+ {0,0,0,TBSTYLE_SEP,0,0},
+ {9,IDT_EDIT_FIND,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
+ {10,IDT_EDIT_REPLACE,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
+ {0,0,0,TBSTYLE_SEP,0,0},
+ {11,IDT_VIEW_WORDWRAP,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
+ {0,0,0,TBSTYLE_SEP,0,0},
+ {12,IDT_VIEW_ZOOMIN,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
+ {13,IDT_VIEW_ZOOMOUT,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
+ {0,0,0,TBSTYLE_SEP,0,0},
+ {14,IDT_VIEW_SCHEME,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
+ {15,IDT_VIEW_SCHEMECONFIG,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
+ {0,0,0,TBSTYLE_SEP,0,0},
+ {16,IDT_FILE_EXIT,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
+ {17,IDT_FILE_SAVEAS,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
+ {18,IDT_FILE_SAVECOPY,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
+ {19,IDT_EDIT_CLEAR,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
+ {20,IDT_FILE_PRINT,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
+ {21,IDT_FILE_OPENFAV,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
+ {22,IDT_FILE_ADDTOFAV,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0} };
+
+WCHAR szIniFile[MAX_PATH] = L"";
+WCHAR szIniFile2[MAX_PATH] = L"";
+BOOL bSaveSettings;
+BOOL bSaveRecentFiles;
+BOOL bSaveFindReplace;
+WCHAR tchLastSaveCopyDir[MAX_PATH] = L"";
+WCHAR tchOpenWithDir[MAX_PATH];
+WCHAR tchFavoritesDir[MAX_PATH];
+WCHAR tchDefaultDir[MAX_PATH];
+WCHAR tchDefaultExtension[64];
+WCHAR tchFileDlgFilters[5*1024];
+WCHAR tchToolbarButtons[512];
+WCHAR tchToolbarBitmap[MAX_PATH];
+WCHAR tchToolbarBitmapHot[MAX_PATH];
+WCHAR tchToolbarBitmapDisabled[MAX_PATH];
+int iPathNameFormat;
+BOOL fWordWrap;
+int iWordWrapMode;
+int iWordWrapIndent;
+int iWordWrapSymbols;
+BOOL bShowWordWrapSymbols;
+BOOL bMatchBraces;
+BOOL bAutoIndent;
+BOOL bAutoCloseTags;
+BOOL bShowIndentGuides;
+BOOL bHiliteCurrentLine;
+BOOL bTabsAsSpaces;
+BOOL bTabsAsSpacesG;
+BOOL bTabIndents;
+int iTabWidth;
+int iTabWidthG;
+int iIndentWidth;
+int iIndentWidthG;
+BOOL bMarkLongLines;
+int iLongLinesLimit;
+int iLongLinesLimitG;
+int iLongLineMode;
+int iWrapCol = 0;
+BOOL bShowSelectionMargin;
+BOOL bShowLineNumbers;
+BOOL bViewWhiteSpace;
+BOOL bViewEOLs;
+int iDefaultEncoding;
+BOOL bSkipUnicodeDetection;
+BOOL bLoadASCIIasUTF8;
+BOOL bNoEncodingTags;
+int iSrcEncoding = -1;
+int iWeakSrcEncoding = -1;
+int iDefaultEOLMode;
+BOOL bFixLineEndings;
+BOOL bAutoStripBlanks;
+int iPrintHeader;
+int iPrintFooter;
+int iPrintColor;
+int iPrintZoom;
+RECT pagesetupMargin;
+BOOL bSaveBeforeRunningTools;
+int iFileWatchingMode;
+BOOL bResetFileWatching;
+int iFileCheckInverval;
+int iEscFunction;
+BOOL bAlwaysOnTop;
+BOOL bMinimizeToTray;
+BOOL bTransparentMode;
+BOOL bTransparentModeAvailable;
+BOOL bShowToolbar;
+BOOL bShowStatusbar;
+
+typedef struct _wi
+{
+ int x;
+ int y;
+ int cx;
+ int cy;
+ int max;
+} WININFO;
+
+WININFO wi;
+BOOL bStickyWinPos;
+
+BOOL bIsAppThemed;
+int cyReBar;
+int cyReBarFrame;
+int cxEditFrame;
+int cyEditFrame;
+
+int cxEncodingDlg;
+int cyEncodingDlg;
+int cxRecodeDlg;
+int cyRecodeDlg;
+int cxFileMRUDlg;
+int cyFileMRUDlg;
+int cxOpenWithDlg;
+int cyOpenWithDlg;
+int cxFavoritesDlg;
+int cyFavoritesDlg;
+int xFindReplaceDlg;
+int yFindReplaceDlg;
+
+LPWSTR lpFileList[32];
+int cFileList = 0;
+int cchiFileList = 0;
+LPWSTR lpFileArg = NULL;
+LPWSTR lpSchemeArg = NULL;
+LPWSTR lpMatchArg = NULL;
+LPWSTR lpEncodingArg = NULL;
+LPMRULIST pFileMRU;
+LPMRULIST mruFind;
+LPMRULIST mruReplace;
+
+DWORD dwLastIOError;
+WCHAR szCurFile[MAX_PATH+40];
+FILEVARS fvCurFile;
+BOOL bModified;
+BOOL bReadOnly = FALSE;
+int iEncoding;
+int iOriginalEncoding;
+int iEOLMode;
+
+int iDefaultCodePage;
+int iDefaultCharSet;
+
+int iInitialLine;
+int iInitialColumn;
+
+int iInitialLexer;
+
+BOOL bLastCopyFromMe = FALSE;
+DWORD dwLastCopyTime;
+
+UINT uidsAppTitle = IDS_APPTITLE;
+WCHAR szTitleExcerpt[128] = L"";
+int fKeepTitleExcerpt = 0;
+
+HANDLE hChangeHandle = NULL;
+BOOL bRunningWatch = FALSE;
+WIN32_FIND_DATA fdCurFile;
+
+UINT msgTaskbarCreated = 0;
+
+HMODULE hModUxTheme = NULL;
+
+EDITFINDREPLACE efrData = { "", "", "", "", 0, 0, 0, 0, 0, 0, NULL };
+UINT cpLastFind = 0;
+BOOL bReplaceInitialized = FALSE;
+
+extern NP2ENCODING mEncoding[];
+
+int iLineEndings[3] = {
+ SC_EOL_CRLF,
+ SC_EOL_LF,
+ SC_EOL_CR
+};
+
+WCHAR wchPrefixSelection[256] = L"";
+WCHAR wchAppendSelection[256] = L"";
+
+WCHAR wchPrefixLines[256] = L"";
+WCHAR wchAppendLines[256] = L"";
+
+int iSortOptions = 0;
+
+BOOL fIsElevated = FALSE;
+WCHAR wchWndClass[16] = WC_NOTEPAD2;
+
+LPMALLOC g_lpMalloc;
+HINSTANCE g_hInstance;
+UINT16 g_uWinVer;
+WCHAR g_wchAppUserModelID[64];
+
+
+
+//=============================================================================
+//
+// Flags
+//
+int flagNoReuseWindow = 0;
+int flagReuseWindow = 0;
+int flagMultiFileArg = 0;
+int flagSingleFileInstance = 0;
+int flagStartAsTrayIcon = 0;
+int flagRelativeFileMRU = 0;
+int flagPortableMyDocs = 0;
+int flagNoFadeHidden = 0;
+int flagSimpleIndentGuides = 0;
+int fNoHTMLGuess = 0;
+int fNoCGIGuess = 0;
+int fNoFileVariables = 0;
+int flagPosParam = 0;
+int flagDefaultPos = 0;
+int flagNewFromClipboard = 0;
+int flagPasteBoard = 0;
+int flagSetEncoding = 0;
+int flagSetEOLMode = 0;
+int flagJumpTo = 0;
+int flagMatchText = 0;
+int flagLexerSpecified = 0;
+int flagQuietCreate = 0;
+int flagUseSystemMRU = 0;
+int flagRelaunchElevated = 0;
+int flagDisplayHelp = 0;
+
+
+
+//=============================================================================
+//
+// WinMain()
+//
+//
+int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInst,
+ LPSTR lpCmdLine,int nCmdShow)
+{
+
+ MSG msg;
+ HWND hwnd;
+ HACCEL hAccMain;
+ HACCEL hAccFindReplace;
+ INITCOMMONCONTROLSEX icex;
+ //HMODULE hSciLexer;
+
+ // Set global variable g_hInstance
+ g_hInstance = hInstance;
+
+ // Set the Windows version global variable
+ g_uWinVer = LOWORD(GetVersion());
+ g_uWinVer = MAKEWORD(HIBYTE(g_uWinVer),LOBYTE(g_uWinVer));
+
+ SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX);
+
+ // check if running at least on Windows 2000
+ if (!Is2k()) {
+ LPVOID lpMsgBuf;
+ FormatMessage(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER|
+ FORMAT_MESSAGE_FROM_SYSTEM|
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ ERROR_OLD_WIN_VERSION,
+ MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), // Default language
+ (LPWSTR)&lpMsgBuf,
+ 0,
+ NULL);
+ MessageBox(NULL,(LPCWSTR)lpMsgBuf,L"Notepad2",MB_OK|MB_ICONEXCLAMATION);
+ LocalFree(lpMsgBuf);
+ return(0);
+ }
+
+ // Check if running with elevated privileges
+ fIsElevated = IsElevated();
+
+ // Default Encodings (may already be used for command line parsing)
+ Encoding_InitDefaults();
+
+ // Command Line, Ini File and Flags
+ ParseCommandLine();
+ FindIniFile();
+ TestIniFile();
+ CreateIniFile();
+ LoadFlags();
+
+ // set AppUserModelID
+ PrivateSetCurrentProcessExplicitAppUserModelID(g_wchAppUserModelID);
+
+ // Command Line Help Dialog
+ if (flagDisplayHelp) {
+ DisplayCmdLineHelp();
+ return(0);
+ }
+
+ // Adapt window class name
+ if (fIsElevated)
+ StrCat(wchWndClass,L"U");
+ if (flagPasteBoard)
+ StrCat(wchWndClass,L"B");
+
+ // Relaunch with elevated privileges
+ if (RelaunchElevated())
+ return(0);
+
+ // Try to run multiple instances
+ if (RelaunchMultiInst())
+ return(0);
+
+ // Try to activate another window
+ if (ActivatePrevInst())
+ return(0);
+
+ // Init OLE and Common Controls
+ OleInitialize(NULL);
+ SHGetMalloc(&g_lpMalloc);
+
+ icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
+ icex.dwICC = ICC_WIN95_CLASSES|ICC_COOL_CLASSES|ICC_BAR_CLASSES|ICC_USEREX_CLASSES;
+ InitCommonControlsEx(&icex);
+
+ msgTaskbarCreated = RegisterWindowMessage(L"TaskbarCreated");
+
+ hModUxTheme = LoadLibrary(L"uxtheme.dll");
+
+ Scintilla_RegisterClasses(hInstance);
+
+ // Load Settings
+ LoadSettings();
+
+ if (!InitApplication(hInstance))
+ return FALSE;
+
+ if (!(hwnd = InitInstance(hInstance,lpCmdLine,nCmdShow)))
+ return FALSE;
+
+ hAccMain = LoadAccelerators(hInstance,MAKEINTRESOURCE(IDR_MAINWND));
+ hAccFindReplace = LoadAccelerators(hInstance,MAKEINTRESOURCE(IDR_ACCFINDREPLACE));
+
+ while (GetMessage(&msg,NULL,0,0))
+ {
+ if (IsWindow(hDlgFindReplace) && (msg.hwnd == hDlgFindReplace || IsChild(hDlgFindReplace,msg.hwnd)))
+ if (TranslateAccelerator(hDlgFindReplace,hAccFindReplace,&msg) || IsDialogMessage(hDlgFindReplace,&msg))
+ continue;
+
+ if (!TranslateAccelerator(hwnd,hAccMain,&msg)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ }
+
+ // Save Settings is done elsewhere
+
+ Scintilla_ReleaseResources();
+ UnregisterClass(wchWndClass,hInstance);
+
+ if (hModUxTheme)
+ FreeLibrary(hModUxTheme);
+
+ g_lpMalloc->lpVtbl->Release(g_lpMalloc);
+ OleUninitialize();
+
+ return(msg.wParam);
+
+ hPrevInst;
+
+}
+
+
+//=============================================================================
+//
+// InitApplication()
+//
+//
+BOOL InitApplication(HINSTANCE hInstance)
+{
+
+ WNDCLASS wc;
+
+ wc.style = CS_BYTEALIGNWINDOW | CS_DBLCLKS;
+ wc.lpfnWndProc = (WNDPROC)MainWndProc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+ wc.hInstance = hInstance;
+ wc.hIcon = LoadIcon(hInstance,MAKEINTRESOURCE(IDR_MAINWND));
+ wc.hCursor = LoadCursor(NULL,IDC_ARROW);
+ wc.hbrBackground = (HBRUSH)(COLOR_3DFACE+1);
+ wc.lpszMenuName = MAKEINTRESOURCE(IDR_MAINWND);
+ wc.lpszClassName = wchWndClass;
+
+ return RegisterClass(&wc);
+
+}
+
+
+//=============================================================================
+//
+// InitInstance()
+//
+//
+HWND InitInstance(HINSTANCE hInstance,LPSTR pszCmdLine,int nCmdShow)
+{
+
+ RECT rc = { wi.x, wi.y, wi.x+wi.cx, wi.y+wi.cy };
+ RECT rc2;
+ MONITORINFO mi;
+
+ HMONITOR hMonitor = MonitorFromRect(&rc,MONITOR_DEFAULTTONEAREST);
+ mi.cbSize = sizeof(mi);
+ GetMonitorInfo(hMonitor,&mi);
+
+ if (flagDefaultPos == 1) {
+ wi.x = wi.y = wi.cx = wi.cy = CW_USEDEFAULT;
+ wi.max = 0;
+ }
+
+ else if (flagDefaultPos >= 4) {
+ SystemParametersInfo(SPI_GETWORKAREA,0,&rc,0);
+ if (flagDefaultPos & 8)
+ wi.x = (rc.right - rc.left) / 2;
+ else
+ wi.x = rc.left;
+ wi.cx = rc.right - rc.left;
+ if (flagDefaultPos & (4|8))
+ wi.cx /= 2;
+ if (flagDefaultPos & 32)
+ wi.y = (rc.bottom - rc.top) / 2;
+ else
+ wi.y = rc.top;
+ wi.cy = rc.bottom - rc.top;
+ if (flagDefaultPos & (16|32))
+ wi.cy /= 2;
+ if (flagDefaultPos & 64) {
+ wi.x = rc.left;
+ wi.y = rc.top;
+ wi.cx = rc.right - rc.left;
+ wi.cy = rc.bottom - rc.top;
+ }
+ if (flagDefaultPos & 128) {
+ wi.x += (flagDefaultPos & 8) ? 4 : 8;
+ wi.cx -= (flagDefaultPos & (4|8)) ? 12 : 16;
+ wi.y += (flagDefaultPos & 32) ? 4 : 8;
+ wi.cy -= (flagDefaultPos & (16|32)) ? 12 : 16;
+ }
+ }
+
+ else if (flagDefaultPos == 2 || flagDefaultPos == 3 ||
+ wi.x == CW_USEDEFAULT || wi.y == CW_USEDEFAULT ||
+ wi.cx == CW_USEDEFAULT || wi.cy == CW_USEDEFAULT) {
+
+ // default window position
+ SystemParametersInfo(SPI_GETWORKAREA,0,&rc,0);
+ wi.y = rc.top + 16;
+ wi.cy = rc.bottom - rc.top - 32;
+ wi.cx = min(rc.right - rc.left - 32,wi.cy);
+ wi.x = (flagDefaultPos == 3) ? 16 : rc.right - wi.cx - 16;
+ }
+
+ else {
+
+ // fit window into working area of current monitor
+ wi.x += (mi.rcWork.left - mi.rcMonitor.left);
+ wi.y += (mi.rcWork.top - mi.rcMonitor.top);
+ if (wi.x < mi.rcWork.left)
+ wi.x = mi.rcWork.left;
+ if (wi.y < mi.rcWork.top)
+ wi.y = mi.rcWork.top;
+ if (wi.x + wi.cx > mi.rcWork.right) {
+ wi.x -= (wi.x + wi.cx - mi.rcWork.right);
+ if (wi.x < mi.rcWork.left)
+ wi.x = mi.rcWork.left;
+ if (wi.x + wi.cx > mi.rcWork.right)
+ wi.cx = mi.rcWork.right - wi.x;
+ }
+ if (wi.y + wi.cy > mi.rcWork.bottom) {
+ wi.y -= (wi.y + wi.cy - mi.rcWork.bottom);
+ if (wi.y < mi.rcWork.top)
+ wi.y = mi.rcWork.top;
+ if (wi.y + wi.cy > mi.rcWork.bottom)
+ wi.cy = mi.rcWork.bottom - wi.y;
+ }
+ SetRect(&rc,wi.x,wi.y,wi.x+wi.cx,wi.y+wi.cy);
+ if (!IntersectRect(&rc2,&rc,&mi.rcWork)) {
+ wi.y = mi.rcWork.top + 16;
+ wi.cy = mi.rcWork.bottom - mi.rcWork.top - 32;
+ wi.cx = min(mi.rcWork.right - mi.rcWork.left - 32,wi.cy);
+ wi.x = mi.rcWork.right - wi.cx - 16;
+ }
+ }
+
+ hwndMain = CreateWindowEx(
+ 0,
+ wchWndClass,
+ L"Notepad2",
+ WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
+ wi.x,
+ wi.y,
+ wi.cx,
+ wi.cy,
+ NULL,
+ NULL,
+ hInstance,
+ NULL);
+
+ if (wi.max)
+ nCmdShow = SW_SHOWMAXIMIZED;
+
+ if (bAlwaysOnTop)
+ SetWindowPos(hwndMain,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
+
+ if (bTransparentMode)
+ SetWindowTransparentMode(hwndMain,TRUE);
+
+ // Current file information -- moved in front of ShowWindow()
+ FileLoad(TRUE,TRUE,FALSE,FALSE,L"");
+
+ if (!flagStartAsTrayIcon) {
+ ShowWindow(hwndMain,nCmdShow);
+ UpdateWindow(hwndMain);
+ }
+ else {
+ ShowWindow(hwndMain,SW_HIDE); // trick ShowWindow()
+ ShowNotifyIcon(hwndMain,TRUE);
+ }
+
+ // Source Encoding
+ if (lpEncodingArg)
+ iSrcEncoding = Encoding_MatchW(lpEncodingArg);
+
+ // Pathname parameter
+ if (lpFileArg /*&& !flagNewFromClipboard*/)
+ {
+ // Open from Directory
+ if (PathIsDirectory(lpFileArg)) {
+ WCHAR tchFile[MAX_PATH];
+ if (OpenFileDlg(hwndMain,tchFile,COUNTOF(tchFile),lpFileArg))
+ FileLoad(FALSE,FALSE,FALSE,FALSE,tchFile);
+ }
+ else {
+ if (FileLoad(FALSE,FALSE,FALSE,FALSE,lpFileArg)) {
+ if (flagJumpTo) // Jump to position
+ EditJumpTo(hwndEdit,iInitialLine,iInitialColumn);
+ }
+ }
+ GlobalFree(lpFileArg);
+ }
+
+ else {
+ if (iSrcEncoding != -1) {
+ iEncoding = iSrcEncoding;
+ iOriginalEncoding = iSrcEncoding;
+ SendMessage(hwndEdit,SCI_SETCODEPAGE,(iEncoding == CPI_DEFAULT) ? iDefaultCodePage : SC_CP_UTF8,0);
+ }
+ }
+
+ // reset
+ iSrcEncoding = -1;
+ flagQuietCreate = 0;
+ fKeepTitleExcerpt = 0;
+
+ // Check for /c [if no file is specified] -- even if a file is specified
+ /*else */if (flagNewFromClipboard) {
+ if (SendMessage(hwndEdit,SCI_CANPASTE,0,0)) {
+ BOOL bAutoIndent2 = bAutoIndent;
+ bAutoIndent = 0;
+ EditJumpTo(hwndEdit,-1,0);
+ SendMessage(hwndEdit,SCI_BEGINUNDOACTION,0,0);
+ if (SendMessage(hwndEdit,SCI_GETLENGTH,0,0) > 0)
+ SendMessage(hwndEdit,SCI_NEWLINE,0,0);
+ SendMessage(hwndEdit,SCI_PASTE,0,0);
+ SendMessage(hwndEdit,SCI_NEWLINE,0,0);
+ SendMessage(hwndEdit,SCI_ENDUNDOACTION,0,0);
+ bAutoIndent = bAutoIndent2;
+ }
+ }
+
+ // Encoding
+ if (0 != flagSetEncoding) {
+ SendMessage(
+ hwndMain,
+ WM_COMMAND,
+ MAKELONG(IDM_ENCODING_ANSI + flagSetEncoding -1,1),
+ 0);
+ flagSetEncoding = 0;
+ }
+
+ // EOL mode
+ if (0 != flagSetEOLMode) {
+ SendMessage(
+ hwndMain,
+ WM_COMMAND,
+ MAKELONG(IDM_LINEENDINGS_CRLF + flagSetEOLMode -1,1),
+ 0);
+ flagSetEOLMode = 0;
+ }
+
+ // Match Text
+ if (flagMatchText && lpMatchArg) {
+ if (lstrlen(lpMatchArg) && SendMessage(hwndEdit,SCI_GETLENGTH,0,0)) {
+
+ UINT cp = SendMessage(hwndEdit,SCI_GETCODEPAGE,0,0);
+ WideCharToMultiByte(cp,0,lpMatchArg,-1,efrData.szFind,COUNTOF(efrData.szFind),NULL,NULL);
+ WideCharToMultiByte(CP_UTF8,0,lpMatchArg,-1,efrData.szFindUTF8,COUNTOF(efrData.szFindUTF8),NULL,NULL);
+ cpLastFind = cp;
+
+ if (flagMatchText & 4)
+ efrData.fuFlags |= SCFIND_REGEXP;
+ else if (flagMatchText & 8)
+ efrData.bTransformBS = TRUE;
+
+ if (flagMatchText & 2) {
+ EditJumpTo(hwndEdit,-1,0);
+ EditFindPrev(hwndEdit,&efrData,FALSE);
+ }
+ else {
+ SendMessage(hwndEdit,SCI_DOCUMENTSTART,0,0);
+ EditFindNext(hwndEdit,&efrData,FALSE);
+ }
+ }
+ GlobalFree(lpMatchArg);
+ }
+
+ // Check for Paste Board option -- after loading files
+ if (flagPasteBoard) {
+ bLastCopyFromMe = TRUE;
+ hwndNextCBChain = SetClipboardViewer(hwndMain);
+ uidsAppTitle = IDS_APPTITLE_PASTEBOARD;
+ SetWindowTitle(hwndMain,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile,
+ iPathNameFormat,bModified || iEncoding != iOriginalEncoding,
+ IDS_READONLY,bReadOnly,szTitleExcerpt);
+ bLastCopyFromMe = FALSE;
+
+ dwLastCopyTime = 0;
+ SetTimer(hwndMain,ID_PASTEBOARDTIMER,100,PasteBoardTimer);
+ }
+
+ // check if a lexer was specified from the command line
+ if (flagLexerSpecified) {
+ if (lpSchemeArg) {
+ Style_SetLexerFromName(hwndEdit,szCurFile,lpSchemeArg);
+ LocalFree(lpSchemeArg);
+ }
+ else if (iInitialLexer >=0 && iInitialLexer < NUMLEXERS)
+ Style_SetLexerFromID(hwndEdit,iInitialLexer);
+ flagLexerSpecified = 0;
+ }
+
+ // If start as tray icon, set current filename as tooltip
+ if (flagStartAsTrayIcon)
+ SetNotifyIconTitle(hwndMain);
+
+ UpdateToolbar();
+ UpdateStatusbar();
+
+ return(hwndMain);
+
+}
+
+
+//=============================================================================
+//
+// MainWndProc()
+//
+// Messages are distributed to the MsgXXX-handlers
+//
+//
+LRESULT CALLBACK MainWndProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
+{
+ static BOOL bShutdownOK;
+
+ switch(umsg)
+ {
+
+ // Quickly handle painting and sizing messages, found in ScintillaWin.cxx
+ // Cool idea, don't know if this has any effect... ;-)
+ case WM_MOVE:
+ case WM_MOUSEACTIVATE:
+ case WM_NCHITTEST:
+ case WM_NCCALCSIZE:
+ case WM_NCPAINT:
+ case WM_PAINT:
+ case WM_ERASEBKGND:
+ case WM_NCMOUSEMOVE:
+ case WM_NCLBUTTONDOWN:
+ case WM_WINDOWPOSCHANGING:
+ case WM_WINDOWPOSCHANGED:
+ return DefWindowProc(hwnd,umsg,wParam,lParam);
+
+ case WM_CREATE:
+ return MsgCreate(hwnd,wParam,lParam);
+
+
+ case WM_DESTROY:
+ case WM_ENDSESSION:
+ if (!bShutdownOK) {
+
+ WINDOWPLACEMENT wndpl;
+
+ // Terminate file watching
+ InstallFileWatching(NULL);
+
+ // GetWindowPlacement
+ wndpl.length = sizeof(WINDOWPLACEMENT);
+ GetWindowPlacement(hwnd,&wndpl);
+
+ wi.x = wndpl.rcNormalPosition.left;
+ wi.y = wndpl.rcNormalPosition.top;
+ wi.cx = wndpl.rcNormalPosition.right - wndpl.rcNormalPosition.left;
+ wi.cy = wndpl.rcNormalPosition.bottom - wndpl.rcNormalPosition.top;
+ wi.max = (IsZoomed(hwnd) || (wndpl.flags & WPF_RESTORETOMAXIMIZED));
+
+ DragAcceptFiles(hwnd,FALSE);
+
+ // Terminate clipboard watching
+ if (flagPasteBoard) {
+ KillTimer(hwnd,ID_PASTEBOARDTIMER);
+ ChangeClipboardChain(hwnd,hwndNextCBChain);
+ }
+
+ // Destroy find / replace dialog
+ if (IsWindow(hDlgFindReplace))
+ DestroyWindow(hDlgFindReplace);
+
+ // call SaveSettings() when hwndToolbar is still valid
+ SaveSettings(FALSE);
+
+ if (lstrlen(szIniFile) != 0) {
+
+ // Cleanup unwanted MRU's
+ if (!bSaveRecentFiles) {
+ MRU_Empty(pFileMRU);
+ MRU_Save(pFileMRU);
+ }
+ else
+ MRU_MergeSave(pFileMRU,TRUE,flagRelativeFileMRU,flagPortableMyDocs);
+ MRU_Destroy(pFileMRU);
+
+ if (!bSaveFindReplace) {
+ MRU_Empty(mruFind);
+ MRU_Empty(mruReplace);
+ MRU_Save(mruFind);
+ MRU_Save(mruReplace);
+ }
+ else {
+ MRU_MergeSave(mruFind,FALSE,FALSE,FALSE);
+ MRU_MergeSave(mruReplace,FALSE,FALSE,FALSE);
+ }
+ MRU_Destroy(mruFind);
+ MRU_Destroy(mruReplace);
+ }
+
+ // Remove tray icon if necessary
+ ShowNotifyIcon(hwnd,FALSE);
+
+ bShutdownOK = TRUE;
+ }
+ if (umsg == WM_DESTROY)
+ PostQuitMessage(0);
+ break;
+
+
+ case WM_CLOSE:
+ if (FileSave(FALSE,TRUE,FALSE,FALSE))
+ DestroyWindow(hwnd);
+ break;
+
+
+ case WM_QUERYENDSESSION:
+ if (FileSave(FALSE,TRUE,FALSE,FALSE))
+ return TRUE;
+ else
+ return FALSE;
+
+
+ // Reinitialize theme-dependent values and resize windows
+ case WM_THEMECHANGED:
+ MsgThemeChanged(hwnd,wParam,lParam);
+ break;
+
+
+ // update Scintilla colors
+ case WM_SYSCOLORCHANGE:
+ {
+ extern PEDITLEXER pLexCurrent;
+ Style_SetLexer(hwndEdit,pLexCurrent);
+ return DefWindowProc(hwnd,umsg,wParam,lParam);
+ }
+
+
+ //case WM_TIMER:
+ // break;
+
+
+ case WM_SIZE:
+ MsgSize(hwnd,wParam,lParam);
+ break;
+
+
+ case WM_SETFOCUS:
+ SetFocus(hwndEdit);
+
+ UpdateToolbar();
+ UpdateStatusbar();
+
+ //if (bPendingChangeNotify)
+ // PostMessage(hwnd,WM_CHANGENOTIFY,0,0);
+ break;
+
+
+ case WM_DROPFILES:
+ {
+ WCHAR szBuf[MAX_PATH+40];
+ HDROP hDrop = (HDROP)wParam;
+
+ // Reset Change Notify
+ //bPendingChangeNotify = FALSE;
+
+ if (IsIconic(hwnd))
+ ShowWindow(hwnd,SW_RESTORE);
+
+ //SetForegroundWindow(hwnd);
+
+ DragQueryFile(hDrop,0,szBuf,COUNTOF(szBuf));
+
+ if (PathIsDirectory(szBuf)) {
+ WCHAR tchFile[MAX_PATH];
+ if (OpenFileDlg(hwndMain,tchFile,COUNTOF(tchFile),szBuf))
+ FileLoad(FALSE,FALSE,FALSE,FALSE,tchFile);
+ }
+
+ else
+ FileLoad(FALSE,FALSE,FALSE,FALSE,szBuf);
+
+ if (DragQueryFile(hDrop,(UINT)(-1),NULL,0) > 1)
+ MsgBox(MBINFO,IDS_ERR_DROP);
+
+ DragFinish(hDrop);
+ }
+ break;
+
+
+ case WM_COPYDATA:
+ {
+ PCOPYDATASTRUCT pcds = (PCOPYDATASTRUCT)lParam;
+
+ // Reset Change Notify
+ //bPendingChangeNotify = FALSE;
+
+ SetDlgItemInt(hwnd,IDC_REUSELOCK,GetTickCount(),FALSE);
+
+ if (pcds->dwData == DATA_NOTEPAD2_PARAMS) {
+ LPNP2PARAMS params = LocalAlloc(LPTR,pcds->cbData);
+ CopyMemory(params,pcds->lpData,pcds->cbData);
+
+ if (params->flagLexerSpecified)
+ flagLexerSpecified = 1;
+
+ if (params->flagQuietCreate)
+ flagQuietCreate = 1;
+
+ if (params->flagFileSpecified) {
+
+ BOOL bOpened = FALSE;
+ iSrcEncoding = params->iSrcEncoding;
+
+ if (PathIsDirectory(¶ms->wchData)) {
+ WCHAR tchFile[MAX_PATH];
+ if (OpenFileDlg(hwndMain,tchFile,COUNTOF(tchFile),¶ms->wchData))
+ bOpened = FileLoad(FALSE,FALSE,FALSE,FALSE,tchFile);
+ }
+
+ else
+ bOpened = FileLoad(FALSE,FALSE,FALSE,FALSE,¶ms->wchData);
+
+ if (bOpened) {
+
+ if (0 != params->flagSetEncoding) {
+ flagSetEncoding = params->flagSetEncoding;
+ SendMessage(
+ hwnd,
+ WM_COMMAND,
+ MAKELONG(IDM_ENCODING_ANSI + flagSetEncoding -1,1),
+ 0);
+ flagSetEncoding = 0;
+ }
+
+ if (0 != params->flagSetEOLMode) {
+ flagSetEOLMode = params->flagSetEOLMode;
+ SendMessage(
+ hwndMain,
+ WM_COMMAND,
+ MAKELONG(IDM_LINEENDINGS_CRLF + flagSetEOLMode -1,1),
+ 0);
+ flagSetEOLMode = 0;
+ }
+
+ if (params->flagLexerSpecified) {
+ if (params->iInitialLexer < 0) {
+ WCHAR wchExt[32] = L".";
+ lstrcpyn(CharNext(wchExt),StrEnd(¶ms->wchData)+1,30);
+ Style_SetLexerFromName(hwndEdit,¶ms->wchData,wchExt);
+ }
+ else if (params->iInitialLexer >=0 && params->iInitialLexer < NUMLEXERS)
+ Style_SetLexerFromID(hwndEdit,params->iInitialLexer);
+ }
+
+ if (params->flagTitleExcerpt) {
+ lstrcpyn(szTitleExcerpt,StrEnd(¶ms->wchData)+1,COUNTOF(szTitleExcerpt));
+ SetWindowTitle(hwnd,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile,
+ iPathNameFormat,bModified || iEncoding != iOriginalEncoding,
+ IDS_READONLY,bReadOnly,szTitleExcerpt);
+ }
+ }
+ // reset
+ iSrcEncoding = -1;
+ }
+
+ if (params->flagJumpTo) {
+ if (params->iInitialLine == 0)
+ params->iInitialLine = 1;
+ EditJumpTo(hwndEdit,params->iInitialLine,params->iInitialColumn);
+ }
+
+ flagLexerSpecified = 0;
+ flagQuietCreate = 0;
+
+ LocalFree(params);
+
+ UpdateStatusbar();
+ }
+ }
+ return TRUE;
+
+
+ case WM_CONTEXTMENU:
+ {
+ HMENU hmenu;
+ int imenu = 0;
+ POINT pt;
+ int nID = GetDlgCtrlID((HWND)wParam);
+
+ if ((nID != IDC_EDIT) && (nID != IDC_STATUSBAR) &&
+ (nID != IDC_REBAR) && (nID != IDC_TOOLBAR))
+ return DefWindowProc(hwnd,umsg,wParam,lParam);
+
+ hmenu = LoadMenu(g_hInstance,MAKEINTRESOURCE(IDR_POPUPMENU));
+ //SetMenuDefaultItem(GetSubMenu(hmenu,1),0,FALSE);
+
+ pt.x = (int)(short)LOWORD(lParam);
+ pt.y = (int)(short)HIWORD(lParam);
+
+ switch(nID)
+ {
+ case IDC_EDIT:
+ {
+ int iSelStart = SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0);
+ int iSelEnd = SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0);
+
+ if (iSelStart == iSelEnd && pt.x != -1 && pt.y != -1)
+ {
+ int iNewPos;
+ POINT ptc = { pt.x, pt.y };
+ ScreenToClient(hwndEdit,&ptc);
+ iNewPos = SendMessage(hwndEdit,SCI_POSITIONFROMPOINT,(WPARAM)ptc.x,(LPARAM)ptc.y);
+ SendMessage(hwndEdit,SCI_GOTOPOS,(WPARAM)iNewPos,0);
+ }
+
+ if (pt.x == -1 && pt.y == -1)
+ {
+ int iCurrentPos = SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0);
+ pt.x = SendMessage(hwndEdit,SCI_POINTXFROMPOSITION,0,(LPARAM)iCurrentPos);
+ pt.y = SendMessage(hwndEdit,SCI_POINTYFROMPOSITION,0,(LPARAM)iCurrentPos);
+ ClientToScreen(hwndEdit,&pt);
+ }
+ imenu = 0;
+ }
+ break;
+
+ case IDC_TOOLBAR:
+ case IDC_STATUSBAR:
+ case IDC_REBAR:
+ if (pt.x == -1 && pt.y == -1)
+ GetCursorPos(&pt);
+ imenu = 1;
+ break;
+ }
+
+ TrackPopupMenuEx(GetSubMenu(hmenu,imenu),
+ TPM_LEFTBUTTON | TPM_RIGHTBUTTON,pt.x+1,pt.y+1,hwnd,NULL);
+
+ DestroyMenu(hmenu);
+ }
+ break;
+
+
+ case WM_INITMENU:
+ MsgInitMenu(hwnd,wParam,lParam);
+ break;
+
+
+ case WM_NOTIFY:
+ return MsgNotify(hwnd,wParam,lParam);
+
+
+ case WM_COMMAND:
+ return MsgCommand(hwnd,wParam,lParam);
+
+
+ case WM_SYSCOMMAND:
+ switch (wParam)
+ {
+ case SC_MINIMIZE:
+ ShowOwnedPopups(hwnd,FALSE);
+ if (bMinimizeToTray) {
+ MinimizeWndToTray(hwnd);
+ ShowNotifyIcon(hwnd,TRUE);
+ SetNotifyIconTitle(hwnd);
+ return(0);
+ }
+ else
+ return DefWindowProc(hwnd,umsg,wParam,lParam);
+
+ case SC_RESTORE: {
+ LRESULT lrv = DefWindowProc(hwnd,umsg,wParam,lParam);
+ ShowOwnedPopups(hwnd,TRUE);
+ return(lrv);
+ }
+ }
+ return DefWindowProc(hwnd,umsg,wParam,lParam);
+
+
+ case WM_CHANGENOTIFY:
+ if (iFileWatchingMode == 1 || bModified || iEncoding != iOriginalEncoding)
+ SetForegroundWindow(hwnd);
+
+ if (PathFileExists(szCurFile)) {
+
+ if ((iFileWatchingMode == 2 && !bModified && iEncoding == iOriginalEncoding) ||
+ MsgBox(MBYESNO,IDS_FILECHANGENOTIFY) == IDYES) {
+
+ int iCurPos = SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0);
+ int iAnchorPos = SendMessage(hwndEdit,SCI_GETANCHOR,0,0);
+ int iCurTopLine = SendMessage(hwndEdit,SCI_GETFIRSTVISIBLELINE,0,0);
+ int iXOffset = SendMessage(hwndEdit,SCI_GETXOFFSET,0,0);
+ BOOL bIsTail = (iCurPos == iAnchorPos) && (iCurPos == SendMessage(hwndEdit,SCI_GETLENGTH,0,0));
+
+ iWeakSrcEncoding = iEncoding;
+ if (FileLoad(TRUE,FALSE,TRUE,FALSE,szCurFile)) {
+
+ if (bIsTail && iFileWatchingMode == 2)
+ EditJumpTo(hwndEdit,-1,0);
+
+ else if (SendMessage(hwndEdit,SCI_GETLENGTH,0,0) >= 4) {
+ char tch[5] = "";
+ SendMessage(hwndEdit,SCI_GETTEXT,5,(LPARAM)tch);
+ if (lstrcmpiA(tch,".LOG") != 0) {
+ int iTopLineAfterLoad;
+ SendMessage(hwndEdit,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos);
+ iTopLineAfterLoad = SendMessage(hwndEdit,SCI_GETFIRSTVISIBLELINE,0,0);
+ SendMessage(hwndEdit,SCI_LINESCROLL,0,(LPARAM)(iCurTopLine - iTopLineAfterLoad));
+ SendMessage(hwndEdit,SCI_SETXOFFSET,(WPARAM)iXOffset,0);
+ }
+ }
+ }
+ }
+ }
+ else {
+
+ if (MsgBox(MBYESNO,IDS_FILECHANGENOTIFY2) == IDYES)
+ FileSave(TRUE,FALSE,FALSE,FALSE);
+ }
+
+ if (!bRunningWatch)
+ InstallFileWatching(szCurFile);
+ break;
+
+
+ //// This message is posted before Notepad2 reactivates itself
+ //case WM_CHANGENOTIFYCLEAR:
+ // bPendingChangeNotify = FALSE;
+ // break;
+
+
+ case WM_DRAWCLIPBOARD:
+ if (!bLastCopyFromMe)
+ dwLastCopyTime = GetTickCount();
+ else
+ bLastCopyFromMe = FALSE;
+ if (hwndNextCBChain)
+ SendMessage(hwndNextCBChain,WM_DRAWCLIPBOARD,wParam,lParam);
+ break;
+
+
+ case WM_CHANGECBCHAIN:
+ if ((HWND)wParam == hwndNextCBChain)
+ hwndNextCBChain = (HWND)lParam;
+ if (hwndNextCBChain)
+ SendMessage(hwndNextCBChain,WM_CHANGECBCHAIN,lParam,wParam);
+ break;
+
+
+ case WM_TRAYMESSAGE:
+ switch(lParam)
+ {
+ case WM_RBUTTONUP: {
+
+ HMENU hMenu = LoadMenu(g_hInstance,MAKEINTRESOURCE(IDR_POPUPMENU));
+ HMENU hMenuPopup = GetSubMenu(hMenu,2);
+
+ POINT pt;
+ int iCmd;
+
+ SetForegroundWindow(hwnd);
+
+ GetCursorPos(&pt);
+ SetMenuDefaultItem(hMenuPopup,IDM_TRAY_RESTORE,FALSE);
+ iCmd = TrackPopupMenu(hMenuPopup,
+ TPM_NONOTIFY|TPM_RETURNCMD|TPM_LEFTBUTTON|TPM_RIGHTBUTTON,
+ pt.x,pt.y,0,hwnd,NULL);
+
+ PostMessage(hwnd,WM_NULL,0,0);
+
+ DestroyMenu(hMenu);
+
+ if (iCmd == IDM_TRAY_RESTORE) {
+ ShowNotifyIcon(hwnd,FALSE);
+ RestoreWndFromTray(hwnd);
+ ShowOwnedPopups(hwnd,TRUE);
+ }
+
+ else if (iCmd == IDM_TRAY_EXIT) {
+ //ShowNotifyIcon(hwnd,FALSE);
+ SendMessage(hwnd,WM_CLOSE,0,0);
+ }
+ }
+ return TRUE;
+
+ case WM_LBUTTONUP:
+ ShowNotifyIcon(hwnd,FALSE);
+ RestoreWndFromTray(hwnd);
+ ShowOwnedPopups(hwnd,TRUE);
+ return TRUE;
+ }
+ break;
+
+
+ default:
+
+ if (umsg == msgTaskbarCreated) {
+ if (!IsWindowVisible(hwnd))
+ ShowNotifyIcon(hwnd,TRUE);
+ SetNotifyIconTitle(hwnd);
+ return(0);
+ }
+
+ return DefWindowProc(hwnd,umsg,wParam,lParam);
+
+ }
+
+ return(0);
+
+}
+
+
+//=============================================================================
+//
+// MsgCreate() - Handles WM_CREATE
+//
+//
+LRESULT MsgCreate(HWND hwnd,WPARAM wParam,LPARAM lParam)
+{
+
+ HINSTANCE hInstance = ((LPCREATESTRUCT)lParam)->hInstance;
+
+ // Setup edit control
+ hwndEdit = EditCreate(hwnd);
+
+ // Tabs
+ SendMessage(hwndEdit,SCI_SETUSETABS,!bTabsAsSpaces,0);
+ SendMessage(hwndEdit,SCI_SETTABINDENTS,bTabIndents,0);
+ SendMessage(hwndEdit,SCI_SETTABWIDTH,iTabWidth,0);
+ SendMessage(hwndEdit,SCI_SETINDENT,iIndentWidth,0);
+
+ // Indent Guides
+ Style_SetIndentGuides(hwndEdit,bShowIndentGuides);
+
+ // Word wrap
+ if (!fWordWrap)
+ SendMessage(hwndEdit,SCI_SETWRAPMODE,SC_WRAP_NONE,0);
+ else
+ SendMessage(hwndEdit,SCI_SETWRAPMODE,(iWordWrapMode == 0) ? SC_WRAP_WORD : SC_WRAP_CHAR,0);
+ if (iWordWrapIndent == 5)
+ SendMessage(hwndEdit,SCI_SETWRAPINDENTMODE,SC_WRAPINDENT_SAME,0);
+ else if (iWordWrapIndent == 6)
+ SendMessage(hwndEdit,SCI_SETWRAPINDENTMODE,SC_WRAPINDENT_INDENT,0);
+ else {
+ int i = 0;
+ switch (iWordWrapIndent) {
+ case 1: i = 1; break;
+ case 2: i = 2; break;
+ case 3: i = (iIndentWidth) ? 1 * iIndentWidth : 1 * iTabWidth; break;
+ case 4: i = (iIndentWidth) ? 2 * iIndentWidth : 2 * iTabWidth; break;
+ }
+ SendMessage(hwndEdit,SCI_SETWRAPSTARTINDENT,i,0);
+ SendMessage(hwndEdit,SCI_SETWRAPINDENTMODE,SC_WRAPINDENT_FIXED,0);
+ }
+ if (bShowWordWrapSymbols) {
+ int wrapVisualFlags = 0;
+ int wrapVisualFlagsLocation = 0;
+ if (iWordWrapSymbols == 0)
+ iWordWrapSymbols = 22;
+ switch (iWordWrapSymbols%10) {
+ case 1: wrapVisualFlags |= SC_WRAPVISUALFLAG_END; wrapVisualFlagsLocation |= SC_WRAPVISUALFLAGLOC_END_BY_TEXT; break;
+ case 2: wrapVisualFlags |= SC_WRAPVISUALFLAG_END; break;
+ }
+ switch (((iWordWrapSymbols%100)-(iWordWrapSymbols%10))/10) {
+ case 1: wrapVisualFlags |= SC_WRAPVISUALFLAG_START; wrapVisualFlagsLocation |= SC_WRAPVISUALFLAGLOC_START_BY_TEXT; break;
+ case 2: wrapVisualFlags |= SC_WRAPVISUALFLAG_START; break;
+ }
+ SendMessage(hwndEdit,SCI_SETWRAPVISUALFLAGSLOCATION,wrapVisualFlagsLocation,0);
+ SendMessage(hwndEdit,SCI_SETWRAPVISUALFLAGS,wrapVisualFlags,0);
+ }
+ else {
+ SendMessage(hwndEdit,SCI_SETWRAPVISUALFLAGS,0,0);
+ }
+
+ // Long Lines
+ if (bMarkLongLines)
+ SendMessage(hwndEdit,SCI_SETEDGEMODE,(iLongLineMode == EDGE_LINE)?EDGE_LINE:EDGE_BACKGROUND,0);
+ else
+ SendMessage(hwndEdit,SCI_SETEDGEMODE,EDGE_NONE,0);
+ SendMessage(hwndEdit,SCI_SETEDGECOLUMN,iLongLinesLimit,0);
+
+ // Margins
+ SendMessage(hwndEdit,SCI_SETMARGINWIDTHN,2,0);
+ SendMessage(hwndEdit,SCI_SETMARGINWIDTHN,1,(bShowSelectionMargin)?16:0);
+ UpdateLineNumberWidth();
+ //SendMessage(hwndEdit,SCI_SETMARGINWIDTHN,0,
+ // (bShowLineNumbers)?SendMessage(hwndEdit,SCI_TEXTWIDTH,STYLE_LINENUMBER,(LPARAM)L"_999999_"):0);
+
+ // Nonprinting characters
+ SendMessage(hwndEdit,SCI_SETVIEWWS,(bViewWhiteSpace)?SCWS_VISIBLEALWAYS:SCWS_INVISIBLE,0);
+ SendMessage(hwndEdit,SCI_SETVIEWEOL,bViewEOLs,0);
+
+ hwndEditFrame = CreateWindowEx(
+ WS_EX_CLIENTEDGE,
+ WC_LISTVIEW,
+ NULL,
+ WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN,
+ 0,0,100,100,
+ hwnd,
+ (HMENU)IDC_EDITFRAME,
+ hInstance,
+ NULL);
+
+ if (PrivateIsAppThemed()) {
+
+ RECT rc, rc2;
+
+ bIsAppThemed = TRUE;
+
+ SetWindowLongPtr(hwndEdit,GWL_EXSTYLE,GetWindowLongPtr(hwndEdit,GWL_EXSTYLE) & ~WS_EX_CLIENTEDGE);
+ SetWindowPos(hwndEdit,NULL,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED);
+
+ if (IsVista()) {
+ cxEditFrame = 0;
+ cyEditFrame = 0;
+ }
+
+ else {
+ GetClientRect(hwndEditFrame,&rc);
+ GetWindowRect(hwndEditFrame,&rc2);
+
+ cxEditFrame = ((rc2.right-rc2.left) - (rc.right-rc.left)) / 2;
+ cyEditFrame = ((rc2.bottom-rc2.top) - (rc.bottom-rc.top)) / 2;
+ }
+ }
+ else {
+ bIsAppThemed = FALSE;
+
+ cxEditFrame = 0;
+ cyEditFrame = 0;
+ }
+
+ // Create Toolbar and Statusbar
+ CreateBars(hwnd,hInstance);
+
+ // Window Initialization
+
+ CreateWindow(
+ WC_STATIC,
+ NULL,
+ WS_CHILD|WS_CLIPSIBLINGS|WS_CLIPCHILDREN,
+ 0,0,10,10,
+ hwnd,
+ (HMENU)IDC_FILENAME,
+ hInstance,
+ NULL);
+
+ SetDlgItemText(hwnd,IDC_FILENAME,szCurFile);
+
+ CreateWindow(
+ WC_STATIC,
+ NULL,
+ WS_CHILD|WS_CLIPSIBLINGS|WS_CLIPCHILDREN,
+ 10,10,10,10,
+ hwnd,
+ (HMENU)IDC_REUSELOCK,
+ hInstance,
+ NULL);
+
+ SetDlgItemInt(hwnd,IDC_REUSELOCK,GetTickCount(),FALSE);
+
+ // Menu
+ //SetMenuDefaultItem(GetSubMenu(GetMenu(hwnd),0),0);
+
+ // Drag & Drop
+ DragAcceptFiles(hwnd,TRUE);
+
+ // File MRU
+ pFileMRU = MRU_Create(L"Recent Files",MRU_NOCASE,32);
+ MRU_Load(pFileMRU);
+
+ mruFind = MRU_Create(L"Recent Find",(/*IsWindowsNT()*/1) ? MRU_UTF8 : 0,16);
+ MRU_Load(mruFind);
+
+ mruReplace = MRU_Create(L"Recent Replace",(/*IsWindowsNT()*/1) ? MRU_UTF8 : 0,16);
+ MRU_Load(mruReplace);
+
+ if (hwndEdit == NULL || hwndEditFrame == NULL ||
+ hwndStatus == NULL || hwndToolbar == NULL || hwndReBar == NULL)
+ return(-1);
+
+ return(0);
+
+}
+
+
+//=============================================================================
+//
+// CreateBars() - Create Toolbar and Statusbar
+//
+//
+void CreateBars(HWND hwnd,HINSTANCE hInstance)
+{
+ RECT rc;
+
+ REBARINFO rbi;
+ REBARBANDINFO rbBand;
+
+ BITMAP bmp;
+ HBITMAP hbmp;
+ HIMAGELIST himl;
+ WCHAR szTmp[MAX_PATH];
+ BOOL bExternalBitmap = TRUE;
+
+ DWORD dwToolbarStyle = WS_TOOLBAR;
+ DWORD dwStatusbarStyle = WS_CHILD | WS_CLIPSIBLINGS;
+ DWORD dwReBarStyle = WS_REBAR;
+
+ BOOL bIsAppThemed = PrivateIsAppThemed();
+
+ int i,n;
+ WCHAR tchDesc[256];
+ WCHAR tchIndex[256];
+
+ WCHAR *pIniSection = NULL;
+ int cchIniSection = 0;
+
+ if (bShowToolbar)
+ dwReBarStyle |= WS_VISIBLE;
+
+ hwndToolbar = CreateWindowEx(0,TOOLBARCLASSNAME,NULL,dwToolbarStyle,
+ 0,0,0,0,hwnd,(HMENU)IDC_TOOLBAR,hInstance,NULL);
+
+ SendMessage(hwndToolbar,TB_BUTTONSTRUCTSIZE,(WPARAM)sizeof(TBBUTTON),0);
+
+ // Add normal Toolbar Bitmap
+ hbmp = NULL;
+ if (lstrlen(tchToolbarBitmap))
+ {
+ if (!SearchPath(NULL,tchToolbarBitmap,NULL,COUNTOF(szTmp),szTmp,NULL))
+ lstrcpy(szTmp,tchToolbarBitmap);
+ hbmp = LoadImage(NULL,szTmp,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_LOADFROMFILE);
+ }
+ if (!hbmp) {
+ hbmp = LoadImage(hInstance,MAKEINTRESOURCE(IDR_MAINWND),IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION);
+ bExternalBitmap = FALSE;
+ }
+ GetObject(hbmp,sizeof(BITMAP),&bmp);
+ himl = ImageList_Create(bmp.bmWidth/NUMTOOLBITMAPS,bmp.bmHeight,ILC_COLOR32|ILC_MASK,0,0);
+ ImageList_AddMasked(himl,hbmp,CLR_DEFAULT);
+ DeleteObject(hbmp);
+ SendMessage(hwndToolbar,TB_SETIMAGELIST,0,(LPARAM)himl);
+
+ // Optionally add hot Toolbar Bitmap
+ hbmp = NULL;
+ if (lstrlen(tchToolbarBitmapHot))
+ {
+ if (!SearchPath(NULL,tchToolbarBitmapHot,NULL,COUNTOF(szTmp),szTmp,NULL))
+ lstrcpy(szTmp,tchToolbarBitmapHot);
+ if (hbmp = LoadImage(NULL,szTmp,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_LOADFROMFILE))
+ {
+ GetObject(hbmp,sizeof(BITMAP),&bmp);
+ himl = ImageList_Create(bmp.bmWidth/NUMTOOLBITMAPS,bmp.bmHeight,ILC_COLOR32|ILC_MASK,0,0);
+ ImageList_AddMasked(himl,hbmp,CLR_DEFAULT);
+ DeleteObject(hbmp);
+ SendMessage(hwndToolbar,TB_SETHOTIMAGELIST,0,(LPARAM)himl);
+ }
+ }
+
+ // Optionally add disabled Toolbar Bitmap
+ hbmp = NULL;
+ if (lstrlen(tchToolbarBitmapDisabled))
+ {
+ if (!SearchPath(NULL,tchToolbarBitmapDisabled,NULL,COUNTOF(szTmp),szTmp,NULL))
+ lstrcpy(szTmp,tchToolbarBitmapDisabled);
+ if (hbmp = LoadImage(NULL,szTmp,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_LOADFROMFILE))
+ {
+ GetObject(hbmp,sizeof(BITMAP),&bmp);
+ himl = ImageList_Create(bmp.bmWidth/NUMTOOLBITMAPS,bmp.bmHeight,ILC_COLOR32|ILC_MASK,0,0);
+ ImageList_AddMasked(himl,hbmp,CLR_DEFAULT);
+ DeleteObject(hbmp);
+ SendMessage(hwndToolbar,TB_SETDISABLEDIMAGELIST,0,(LPARAM)himl);
+ }
+ }
+
+ // Load toolbar labels
+ pIniSection = LocalAlloc(LPTR,sizeof(WCHAR)*32*1024);
+ cchIniSection = LocalSize(pIniSection)/sizeof(WCHAR);
+ LoadIniSection(L"Toolbar Labels",pIniSection,cchIniSection);
+ n = 1;
+ for (i = 0; i < COUNTOF(tbbMainWnd); i++) {
+
+ if (tbbMainWnd[i].fsStyle == TBSTYLE_SEP)
+ continue;
+
+ wsprintf(tchIndex,L"%02i",n++);
+
+ if (IniSectionGetString(pIniSection,tchIndex,L"",tchDesc,COUNTOF(tchDesc))) {
+ tbbMainWnd[i].iString = SendMessage(hwndToolbar,TB_ADDSTRING,0,(LPARAM)tchDesc);
+ tbbMainWnd[i].fsStyle |= BTNS_AUTOSIZE | BTNS_SHOWTEXT;
+ }
+
+ else
+ tbbMainWnd[i].fsStyle &= ~(BTNS_AUTOSIZE | BTNS_SHOWTEXT);
+ }
+ LocalFree(pIniSection);
+
+ SendMessage(hwndToolbar,TB_SETEXTENDEDSTYLE,0,
+ SendMessage(hwndToolbar,TB_GETEXTENDEDSTYLE,0,0) | TBSTYLE_EX_MIXEDBUTTONS);
+
+ SendMessage(hwndToolbar,TB_ADDBUTTONS,NUMINITIALTOOLS,(LPARAM)tbbMainWnd);
+ if (Toolbar_SetButtons(hwndToolbar,IDT_FILE_NEW,tchToolbarButtons,tbbMainWnd,COUNTOF(tbbMainWnd)) == 0)
+ SendMessage(hwndToolbar,TB_ADDBUTTONS,NUMINITIALTOOLS,(LPARAM)tbbMainWnd);
+ SendMessage(hwndToolbar,TB_GETITEMRECT,0,(LPARAM)&rc);
+ //SendMessage(hwndToolbar,TB_SETINDENT,2,0);
+
+ if (bShowStatusbar)
+ dwStatusbarStyle |= WS_VISIBLE;
+
+ hwndStatus = CreateStatusWindow(dwStatusbarStyle,NULL,hwnd,IDC_STATUSBAR);
+
+ // Create ReBar and add Toolbar
+ hwndReBar = CreateWindowEx(WS_EX_TOOLWINDOW,REBARCLASSNAME,NULL,dwReBarStyle,
+ 0,0,0,0,hwnd,(HMENU)IDC_REBAR,hInstance,NULL);
+
+ rbi.cbSize = sizeof(REBARINFO);
+ rbi.fMask = 0;
+ rbi.himl = (HIMAGELIST)NULL;
+ SendMessage(hwndReBar,RB_SETBARINFO,0,(LPARAM)&rbi);
+
+ rbBand.cbSize = sizeof(REBARBANDINFO);
+ rbBand.fMask = /*RBBIM_COLORS | RBBIM_TEXT | RBBIM_BACKGROUND | */
+ RBBIM_STYLE | RBBIM_CHILD | RBBIM_CHILDSIZE /*| RBBIM_SIZE*/;
+ rbBand.fStyle = /*RBBS_CHILDEDGE |*//* RBBS_BREAK |*/ RBBS_FIXEDSIZE /*| RBBS_GRIPPERALWAYS*/;
+ if (bIsAppThemed)
+ rbBand.fStyle |= RBBS_CHILDEDGE;
+ rbBand.hbmBack = NULL;
+ rbBand.lpText = L"Toolbar";
+ rbBand.hwndChild = hwndToolbar;
+ rbBand.cxMinChild = (rc.right - rc.left) * COUNTOF(tbbMainWnd);
+ rbBand.cyMinChild = (rc.bottom - rc.top) + 2 * rc.top;
+ rbBand.cx = 0;
+ SendMessage(hwndReBar,RB_INSERTBAND,(WPARAM)-1,(LPARAM)&rbBand);
+
+ SetWindowPos(hwndReBar,NULL,0,0,0,0,SWP_NOZORDER);
+ GetWindowRect(hwndReBar,&rc);
+ cyReBar = rc.bottom - rc.top;
+
+ cyReBarFrame = bIsAppThemed ? 0 : 2;
+}
+
+
+//=============================================================================
+//
+// MsgThemeChanged() - Handle WM_THEMECHANGED
+//
+//
+void MsgThemeChanged(HWND hwnd,WPARAM wParam,LPARAM lParam)
+{
+ RECT rc, rc2;
+ HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtr(hwnd,GWLP_HINSTANCE);
+
+ // reinitialize edit frame
+
+ if (PrivateIsAppThemed()) {
+ bIsAppThemed = TRUE;
+
+ SetWindowLongPtr(hwndEdit,GWL_EXSTYLE,GetWindowLongPtr(hwndEdit,GWL_EXSTYLE) & ~WS_EX_CLIENTEDGE);
+ SetWindowPos(hwndEdit,NULL,0,0,0,0,SWP_NOZORDER|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE);
+
+ if (IsVista()) {
+ cxEditFrame = 0;
+ cyEditFrame = 0;
+ }
+
+ else {
+ SetWindowPos(hwndEditFrame,NULL,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED);
+ GetClientRect(hwndEditFrame,&rc);
+ GetWindowRect(hwndEditFrame,&rc2);
+
+ cxEditFrame = ((rc2.right-rc2.left) - (rc.right-rc.left)) / 2;
+ cyEditFrame = ((rc2.bottom-rc2.top) - (rc.bottom-rc.top)) / 2;
+ }
+ }
+
+ else {
+ bIsAppThemed = FALSE;
+
+ SetWindowLongPtr(hwndEdit,GWL_EXSTYLE,WS_EX_CLIENTEDGE|GetWindowLongPtr(hwndEdit,GWL_EXSTYLE));
+ SetWindowPos(hwndEdit,NULL,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED);
+
+ cxEditFrame = 0;
+ cyEditFrame = 0;
+ }
+
+ // recreate toolbar and statusbar
+ Toolbar_GetButtons(hwndToolbar,IDT_FILE_NEW,tchToolbarButtons,COUNTOF(tchToolbarButtons));
+
+ DestroyWindow(hwndToolbar);
+ DestroyWindow(hwndReBar);
+ DestroyWindow(hwndStatus);
+ CreateBars(hwnd,hInstance);
+ UpdateToolbar();
+
+ GetClientRect(hwnd,&rc);
+ SendMessage(hwnd,WM_SIZE,SIZE_RESTORED,MAKELONG(rc.right,rc.bottom));
+ UpdateStatusbar();
+}
+
+
+//=============================================================================
+//
+// MsgSize() - Handles WM_SIZE
+//
+//
+void MsgSize(HWND hwnd,WPARAM wParam,LPARAM lParam)
+{
+
+ RECT rc;
+ int x,y,cx,cy;
+ HDWP hdwp;
+
+ // Statusbar
+ int aWidth[6];
+
+ if (wParam == SIZE_MINIMIZED)
+ return;
+
+ x = 0;
+ y = 0;
+
+ cx = LOWORD(lParam);
+ cy = HIWORD(lParam);
+
+ if (bShowToolbar)
+ {
+/* SendMessage(hwndToolbar,WM_SIZE,0,0);
+ GetWindowRect(hwndToolbar,&rc);
+ y = (rc.bottom - rc.top);
+ cy -= (rc.bottom - rc.top);*/
+
+ //SendMessage(hwndToolbar,TB_GETITEMRECT,0,(LPARAM)&rc);
+ SetWindowPos(hwndReBar,NULL,0,0,LOWORD(lParam),cyReBar,SWP_NOZORDER);
+ // the ReBar automatically sets the correct height
+ // calling SetWindowPos() with the height of one toolbar button
+ // causes the control not to temporarily use the whole client area
+ // and prevents flickering
+
+ //GetWindowRect(hwndReBar,&rc);
+ y = cyReBar + cyReBarFrame; // define
+ cy -= cyReBar + cyReBarFrame; // border
+ }
+
+ if (bShowStatusbar)
+ {
+ SendMessage(hwndStatus,WM_SIZE,0,0);
+ GetWindowRect(hwndStatus,&rc);
+ cy -= (rc.bottom - rc.top);
+ }
+
+ hdwp = BeginDeferWindowPos(2);
+
+ DeferWindowPos(hdwp,hwndEditFrame,NULL,x,y,cx,cy,
+ SWP_NOZORDER | SWP_NOACTIVATE);
+
+ DeferWindowPos(hdwp,hwndEdit,NULL,x+cxEditFrame,y+cyEditFrame,
+ cx-2*cxEditFrame,cy-2*cyEditFrame,
+ SWP_NOZORDER | SWP_NOACTIVATE);
+
+ EndDeferWindowPos(hdwp);
+
+ // Statusbar width
+ aWidth[0] = max(120,min(cx/3,StatusCalcPaneWidth(hwndStatus,L"Ln 9'999'999 : 9'999'999 Col 9'999'999 : 999 Sel 9'999'999")));
+ aWidth[1] = aWidth[0] + StatusCalcPaneWidth(hwndStatus,L"9'999'999 Bytes");
+ aWidth[2] = aWidth[1] + StatusCalcPaneWidth(hwndStatus,L"Unicode BE BOM");
+ aWidth[3] = aWidth[2] + StatusCalcPaneWidth(hwndStatus,L"CR+LF");
+ aWidth[4] = aWidth[3] + StatusCalcPaneWidth(hwndStatus,L"OVR");
+ aWidth[5] = -1;
+
+ SendMessage(hwndStatus,SB_SETPARTS,COUNTOF(aWidth),(LPARAM)aWidth);
+
+ //UpdateStatusbar();
+
+}
+
+
+//=============================================================================
+//
+// MsgInitMenu() - Handles WM_INITMENU
+//
+//
+void MsgInitMenu(HWND hwnd,WPARAM wParam,LPARAM lParam)
+{
+
+ int i,i2;
+ HMENU hmenu = (HMENU)wParam;
+
+ i = lstrlen(szCurFile);
+ EnableCmd(hmenu,IDM_FILE_REVERT,i);
+ EnableCmd(hmenu,IDM_FILE_LAUNCH,i);
+ EnableCmd(hmenu,IDM_FILE_PROPERTIES,i);
+ EnableCmd(hmenu,IDM_FILE_CREATELINK,i);
+ EnableCmd(hmenu,IDM_FILE_ADDTOFAV,i);
+
+ EnableCmd(hmenu,IDM_FILE_READONLY,i);
+ CheckCmd(hmenu,IDM_FILE_READONLY,bReadOnly);
+
+ //EnableCmd(hmenu,IDM_ENCODING_UNICODEREV,!bReadOnly);
+ //EnableCmd(hmenu,IDM_ENCODING_UNICODE,!bReadOnly);
+ //EnableCmd(hmenu,IDM_ENCODING_UTF8SIGN,!bReadOnly);
+ //EnableCmd(hmenu,IDM_ENCODING_UTF8,!bReadOnly);
+ //EnableCmd(hmenu,IDM_ENCODING_ANSI,!bReadOnly);
+ //EnableCmd(hmenu,IDM_LINEENDINGS_CRLF,!bReadOnly);
+ //EnableCmd(hmenu,IDM_LINEENDINGS_LF,!bReadOnly);
+ //EnableCmd(hmenu,IDM_LINEENDINGS_CR,!bReadOnly);
+
+ EnableCmd(hmenu,IDM_ENCODING_RECODE,i);
+
+ if (mEncoding[iEncoding].uFlags & NCP_UNICODE_REVERSE)
+ i = IDM_ENCODING_UNICODEREV;
+ else if (mEncoding[iEncoding].uFlags & NCP_UNICODE)
+ i = IDM_ENCODING_UNICODE;
+ else if (mEncoding[iEncoding].uFlags & NCP_UTF8_SIGN)
+ i = IDM_ENCODING_UTF8SIGN;
+ else if (mEncoding[iEncoding].uFlags & NCP_UTF8)
+ i = IDM_ENCODING_UTF8;
+ else if (mEncoding[iEncoding].uFlags & NCP_DEFAULT)
+ i = IDM_ENCODING_ANSI;
+ else
+ i = -1;
+ CheckMenuRadioItem(hmenu,IDM_ENCODING_ANSI,IDM_ENCODING_UTF8SIGN,i,MF_BYCOMMAND);
+
+ if (iEOLMode == SC_EOL_CRLF)
+ i = IDM_LINEENDINGS_CRLF;
+ else if (iEOLMode == SC_EOL_LF)
+ i = IDM_LINEENDINGS_LF;
+ else
+ i = IDM_LINEENDINGS_CR;
+ CheckMenuRadioItem(hmenu,IDM_LINEENDINGS_CRLF,IDM_LINEENDINGS_CR,i,MF_BYCOMMAND);
+
+ EnableCmd(hmenu,IDM_FILE_RECENT,(MRU_Enum(pFileMRU,0,NULL,0) > 0));
+
+ EnableCmd(hmenu,IDM_EDIT_UNDO,SendMessage(hwndEdit,SCI_CANUNDO,0,0) /*&& !bReadOnly*/);
+ EnableCmd(hmenu,IDM_EDIT_REDO,SendMessage(hwndEdit,SCI_CANREDO,0,0) /*&& !bReadOnly*/);
+
+ i = SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0) - SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0);
+ i2 = SendMessage(hwndEdit,SCI_CANPASTE,0,0);
+
+ EnableCmd(hmenu,IDM_EDIT_CUT,i /*&& !bReadOnly*/);
+ EnableCmd(hmenu,IDM_EDIT_COPY,i /*&& !bReadOnly*/);
+ EnableCmd(hmenu,IDM_EDIT_COPYALL,SendMessage(hwndEdit,SCI_GETLENGTH,0,0) /*&& !bReadOnly*/);
+ EnableCmd(hmenu,IDM_EDIT_COPYADD,i /*&& !bReadOnly*/);
+ EnableCmd(hmenu,IDM_EDIT_PASTE,i2 /*&& !bReadOnly*/);
+ EnableCmd(hmenu,IDM_EDIT_SWAP,i || i2 /*&& !bReadOnly*/);
+ EnableCmd(hmenu,IDM_EDIT_CLEAR,i /*&& !bReadOnly*/);
+
+ OpenClipboard(hwnd);
+ EnableCmd(hmenu,IDM_EDIT_CLEARCLIPBOARD,CountClipboardFormats());
+ CloseClipboard();
+
+ //EnableCmd(hmenu,IDM_EDIT_MOVELINEUP,!bReadOnly);
+ //EnableCmd(hmenu,IDM_EDIT_MOVELINEDOWN,!bReadOnly);
+ //EnableCmd(hmenu,IDM_EDIT_DUPLICATELINE,!bReadOnly);
+ //EnableCmd(hmenu,IDM_EDIT_CUTLINE,!bReadOnly);
+ //EnableCmd(hmenu,IDM_EDIT_COPYLINE,!bReadOnly);
+ //EnableCmd(hmenu,IDM_EDIT_DELETELINE,!bReadOnly);
+
+ //EnableCmd(hmenu,IDM_EDIT_INDENT,!bReadOnly);
+ //EnableCmd(hmenu,IDM_EDIT_UNINDENT,!bReadOnly);
+
+ //EnableCmd(hmenu,IDM_EDIT_PADWITHSPACES,!bReadOnly);
+ //EnableCmd(hmenu,IDM_EDIT_STRIP1STCHAR,!bReadOnly);
+ //EnableCmd(hmenu,IDM_EDIT_STRIPLASTCHAR,!bReadOnly);
+ //EnableCmd(hmenu,IDM_EDIT_TRIMLINES,!bReadOnly);
+ //EnableCmd(hmenu,IDM_EDIT_REMOVEBLANKLINES,!bReadOnly);
+
+ EnableCmd(hmenu,IDM_EDIT_SORTLINES,
+ SendMessage(hwndEdit,SCI_LINEFROMPOSITION,(WPARAM)SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0),0) -
+ SendMessage(hwndEdit,SCI_LINEFROMPOSITION,(WPARAM)SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0),0) >= 1);
+
+ EnableCmd(hmenu,IDM_EDIT_COLUMNWRAP,i /*&& IsWindowsNT()*/);
+ EnableCmd(hmenu,IDM_EDIT_SPLITLINES,i /*&& !bReadOnly*/);
+ EnableCmd(hmenu,IDM_EDIT_JOINLINES,i /*&& !bReadOnly*/);
+ EnableCmd(hmenu,IDM_EDIT_JOINLINESEX,i /*&& !bReadOnly*/);
+
+ EnableCmd(hmenu,IDM_EDIT_CONVERTUPPERCASE,i /*&& !bReadOnly*/);
+ EnableCmd(hmenu,IDM_EDIT_CONVERTLOWERCASE,i /*&& !bReadOnly*/);
+ EnableCmd(hmenu,IDM_EDIT_INVERTCASE,i /*&& !bReadOnly*/ /*&& IsWindowsNT()*/);
+ EnableCmd(hmenu,IDM_EDIT_TITLECASE,i /*&& !bReadOnly*/ /*&& IsWindowsNT()*/);
+ EnableCmd(hmenu,IDM_EDIT_SENTENCECASE,i /*&& !bReadOnly*/ /*&& IsWindowsNT()*/);
+
+ EnableCmd(hmenu,IDM_EDIT_CONVERTTABS,i /*&& !bReadOnly*/);
+ EnableCmd(hmenu,IDM_EDIT_CONVERTSPACES,i /*&& !bReadOnly*/);
+ EnableCmd(hmenu,IDM_EDIT_CONVERTTABS2,i /*&& !bReadOnly*/);
+ EnableCmd(hmenu,IDM_EDIT_CONVERTSPACES2,i /*&& !bReadOnly*/);
+
+ EnableCmd(hmenu,IDM_EDIT_URLENCODE,i /*&& !bReadOnly*/);
+ EnableCmd(hmenu,IDM_EDIT_URLDECODE,i /*&& !bReadOnly*/);
+
+ EnableCmd(hmenu,IDM_EDIT_ESCAPECCHARS,i /*&& !bReadOnly*/);
+ EnableCmd(hmenu,IDM_EDIT_UNESCAPECCHARS,i /*&& !bReadOnly*/);
+
+ //EnableCmd(hmenu,IDM_EDIT_INCREASENUM,i /*&& !bReadOnly*/);
+ //EnableCmd(hmenu,IDM_EDIT_DECREASENUM,i /*&& !bReadOnly*/);
+
+ EnableCmd(hmenu,IDM_VIEW_SHOWEXCERPT,i);
+
+ i = SendMessage(hwndEdit,SCI_GETLEXER,0,0);
+ EnableCmd(hmenu,IDM_EDIT_LINECOMMENT,
+ !(i == SCLEX_NULL || i == SCLEX_CSS || i == SCLEX_DIFF));
+ EnableCmd(hmenu,IDM_EDIT_STREAMCOMMENT,
+ !(i == SCLEX_NULL || i == SCLEX_VBSCRIPT || i == SCLEX_MAKEFILE || i == SCLEX_VB || i == SCLEX_ASM ||
+ i == SCLEX_SQL || i == SCLEX_PERL || i == SCLEX_PYTHON || i == SCLEX_PROPERTIES ||i == SCLEX_CONF ||
+ i == SCLEX_POWERSHELL || i == SCLEX_BATCH || i == SCLEX_DIFF));
+
+ EnableCmd(hmenu,IDM_EDIT_INSERT_ENCODING,*mEncoding[iEncoding].pszParseNames);
+
+ //EnableCmd(hmenu,IDM_EDIT_INSERT_SHORTDATE,!bReadOnly);
+ //EnableCmd(hmenu,IDM_EDIT_INSERT_LONGDATE,!bReadOnly);
+ //EnableCmd(hmenu,IDM_EDIT_INSERT_FILENAME,!bReadOnly);
+ //EnableCmd(hmenu,IDM_EDIT_INSERT_PATHNAME,!bReadOnly);
+
+ i = SendMessage(hwndEdit,SCI_GETLENGTH,0,0);
+ EnableCmd(hmenu,IDM_EDIT_FIND,i);
+ EnableCmd(hmenu,IDM_EDIT_SAVEFIND,i);
+ EnableCmd(hmenu,IDM_EDIT_FINDNEXT,i);
+ EnableCmd(hmenu,IDM_EDIT_FINDPREV,i && lstrlenA(efrData.szFind));
+ EnableCmd(hmenu,IDM_EDIT_SELTONEXT,i);
+ EnableCmd(hmenu,IDM_EDIT_SELTOPREV,i && lstrlenA(efrData.szFind));
+ EnableCmd(hmenu,IDM_EDIT_REPLACE,i /*&& !bReadOnly*/);
+
+ CheckCmd(hmenu,IDM_VIEW_USE2NDDEFAULT,Style_GetUse2ndDefault(hwndEdit));
+
+ CheckCmd(hmenu,IDM_VIEW_WORDWRAP,fWordWrap);
+ CheckCmd(hmenu,IDM_VIEW_LONGLINEMARKER,bMarkLongLines);
+ CheckCmd(hmenu,IDM_VIEW_TABSASSPACES,bTabsAsSpaces);
+ CheckCmd(hmenu,IDM_VIEW_SHOWINDENTGUIDES,bShowIndentGuides);
+ CheckCmd(hmenu,IDM_VIEW_AUTOINDENTTEXT,bAutoIndent);
+ CheckCmd(hmenu,IDM_VIEW_LINENUMBERS,bShowLineNumbers);
+ CheckCmd(hmenu,IDM_VIEW_MARGIN,bShowSelectionMargin);
+ CheckCmd(hmenu,IDM_VIEW_SHOWWHITESPACE,bViewWhiteSpace);
+ CheckCmd(hmenu,IDM_VIEW_SHOWEOLS,bViewEOLs);
+ CheckCmd(hmenu,IDM_VIEW_WORDWRAPSYMBOLS,bShowWordWrapSymbols);
+ CheckCmd(hmenu,IDM_VIEW_MATCHBRACES,bMatchBraces);
+ CheckCmd(hmenu,IDM_VIEW_TOOLBAR,bShowToolbar);
+ EnableCmd(hmenu,IDM_VIEW_CUSTOMIZETB,bShowToolbar);
+ CheckCmd(hmenu,IDM_VIEW_STATUSBAR,bShowStatusbar);
+
+ i = SendMessage(hwndEdit,SCI_GETLEXER,0,0);
+ //EnableCmd(hmenu,IDM_VIEW_AUTOCLOSETAGS,(i == SCLEX_HTML || i == SCLEX_XML));
+ CheckCmd(hmenu,IDM_VIEW_AUTOCLOSETAGS,bAutoCloseTags /*&& (i == SCLEX_HTML || i == SCLEX_XML)*/);
+ CheckCmd(hmenu,IDM_VIEW_HILITECURRENTLINE,bHiliteCurrentLine);
+
+ i = IniGetInt(L"Settings2",L"ReuseWindow",0);
+ CheckCmd(hmenu,IDM_VIEW_REUSEWINDOW,i);
+ i = IniGetInt(L"Settings2",L"SingleFileInstance",0);
+ CheckCmd(hmenu,IDM_VIEW_SINGLEFILEINSTANCE,i);
+ bStickyWinPos = IniGetInt(L"Settings2",L"StickyWindowPosition",0);
+ CheckCmd(hmenu,IDM_VIEW_STICKYWINPOS,bStickyWinPos);
+ CheckCmd(hmenu,IDM_VIEW_ALWAYSONTOP,bAlwaysOnTop);
+ CheckCmd(hmenu,IDM_VIEW_MINTOTRAY,bMinimizeToTray);
+ CheckCmd(hmenu,IDM_VIEW_TRANSPARENT,bTransparentMode && bTransparentModeAvailable);
+ EnableCmd(hmenu,IDM_VIEW_TRANSPARENT,bTransparentModeAvailable);
+
+ CheckCmd(hmenu,IDM_VIEW_NOSAVERECENT,bSaveRecentFiles);
+ CheckCmd(hmenu,IDM_VIEW_NOSAVEFINDREPL,bSaveFindReplace);
+ CheckCmd(hmenu,IDM_VIEW_SAVEBEFORERUNNINGTOOLS,bSaveBeforeRunningTools);
+
+ CheckCmd(hmenu,IDM_VIEW_CHANGENOTIFY,iFileWatchingMode);
+
+ if (lstrlen(szTitleExcerpt))
+ i = IDM_VIEW_SHOWEXCERPT;
+ else if (iPathNameFormat == 0)
+ i = IDM_VIEW_SHOWFILENAMEONLY;
+ else if (iPathNameFormat == 1)
+ i = IDM_VIEW_SHOWFILENAMEFIRST;
+ else
+ i = IDM_VIEW_SHOWFULLPATH;
+ CheckMenuRadioItem(hmenu,IDM_VIEW_SHOWFILENAMEONLY,IDM_VIEW_SHOWEXCERPT,i,MF_BYCOMMAND);
+
+ if (iEscFunction == 1)
+ i = IDM_VIEW_ESCMINIMIZE;
+ else if (iEscFunction == 2)
+ i = IDM_VIEW_ESCEXIT;
+ else
+ i = IDM_VIEW_NOESCFUNC;
+ CheckMenuRadioItem(hmenu,IDM_VIEW_NOESCFUNC,IDM_VIEW_ESCEXIT,i,MF_BYCOMMAND);
+
+ i = lstrlen(szIniFile);
+ CheckCmd(hmenu,IDM_VIEW_SAVESETTINGS,bSaveSettings && i);
+
+ EnableCmd(hmenu,IDM_VIEW_REUSEWINDOW,i);
+ EnableCmd(hmenu,IDM_VIEW_STICKYWINPOS,i);
+ EnableCmd(hmenu,IDM_VIEW_SINGLEFILEINSTANCE,i);
+ EnableCmd(hmenu,IDM_VIEW_NOSAVERECENT,i);
+ EnableCmd(hmenu,IDM_VIEW_NOSAVEFINDREPL,i);
+ EnableCmd(hmenu,IDM_VIEW_SAVESETTINGS,i);
+
+ i = (lstrlen(szIniFile) > 0 || lstrlen(szIniFile2) > 0);
+ EnableCmd(hmenu,IDM_VIEW_SAVESETTINGSNOW,i);
+
+}
+
+
+//=============================================================================
+//
+// MsgCommand() - Handles WM_COMMAND
+//
+//
+LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
+{
+
+ switch(LOWORD(wParam))
+ {
+
+ case IDM_FILE_NEW:
+ FileLoad(FALSE,TRUE,FALSE,FALSE,L"");
+ break;
+
+
+ case IDM_FILE_OPEN:
+ FileLoad(FALSE,FALSE,FALSE,FALSE,L"");
+ break;
+
+
+ case IDM_FILE_REVERT:
+ {
+ if (lstrlen(szCurFile)) {
+
+ WCHAR tchCurFile2[MAX_PATH];
+
+ int iCurPos = SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0);
+ int iAnchorPos = SendMessage(hwndEdit,SCI_GETANCHOR,0,0);
+ int iCurTopLine = SendMessage(hwndEdit,SCI_GETFIRSTVISIBLELINE,0,0);
+ int iXOffset = SendMessage(hwndEdit,SCI_GETXOFFSET,0,0);
+
+ if ((bModified || iEncoding != iOriginalEncoding) && MsgBox(MBOKCANCEL,IDS_ASK_REVERT) != IDOK)
+ return(0);
+
+ lstrcpy(tchCurFile2,szCurFile);
+
+ iWeakSrcEncoding = iEncoding;
+ if (FileLoad(TRUE,FALSE,TRUE,FALSE,tchCurFile2))
+ {
+ if (SendMessage(hwndEdit,SCI_GETLENGTH,0,0) >= 4) {
+ char tch[5] = "";
+ SendMessage(hwndEdit,SCI_GETTEXT,5,(LPARAM)tch);
+ if (lstrcmpiA(tch,".LOG") != 0) {
+ int iTopLineAfterLoad;
+ SendMessage(hwndEdit,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos);
+ iTopLineAfterLoad = SendMessage(hwndEdit,SCI_GETFIRSTVISIBLELINE,0,0);
+ SendMessage(hwndEdit,SCI_LINESCROLL,0,(LPARAM)(iCurTopLine - iTopLineAfterLoad));
+ SendMessage(hwndEdit,SCI_SETXOFFSET,(WPARAM)iXOffset,0);
+ }
+ }
+ }
+ }
+ }
+ break;
+
+
+ case IDM_FILE_SAVE:
+ FileSave(TRUE,FALSE,FALSE,FALSE);
+ break;
+
+
+ case IDM_FILE_SAVEAS:
+ FileSave(TRUE,FALSE,TRUE,FALSE);
+ break;
+
+
+ case IDM_FILE_SAVECOPY:
+ FileSave(TRUE,FALSE,TRUE,TRUE);
+ break;
+
+
+ case IDM_FILE_READONLY:
+ //bReadOnly = (bReadOnly) ? FALSE : TRUE;
+ //SendMessage(hwndEdit,SCI_SETREADONLY,bReadOnly,0);
+ //UpdateToolbar();
+ //UpdateStatusbar();
+ if (lstrlen(szCurFile))
+ {
+ BOOL bSuccess = FALSE;
+ DWORD dwFileAttributes = GetFileAttributes(szCurFile);
+ if (dwFileAttributes != INVALID_FILE_ATTRIBUTES) {
+ if (bReadOnly)
+ dwFileAttributes = (dwFileAttributes & ~FILE_ATTRIBUTE_READONLY);
+ else
+ dwFileAttributes |= FILE_ATTRIBUTE_READONLY;
+ if (!SetFileAttributes(szCurFile,dwFileAttributes))
+ MsgBox(MBWARN,IDS_READONLY_MODIFY,szCurFile);
+ }
+ else
+ MsgBox(MBWARN,IDS_READONLY_MODIFY,szCurFile);
+
+ dwFileAttributes = GetFileAttributes(szCurFile);
+ if (dwFileAttributes != INVALID_FILE_ATTRIBUTES)
+ bReadOnly = (dwFileAttributes & FILE_ATTRIBUTE_READONLY);
+
+ SetWindowTitle(hwnd,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile,
+ iPathNameFormat,bModified || iEncoding != iOriginalEncoding,
+ IDS_READONLY,bReadOnly,szTitleExcerpt);
+ }
+ break;
+
+
+ case IDM_FILE_BROWSE:
+ {
+ SHELLEXECUTEINFO sei;
+ WCHAR tchParam[MAX_PATH+4];
+ WCHAR tchExeFile[MAX_PATH+4];
+
+ lstrcpy(tchParam,szCurFile);
+ PathQuoteSpaces(tchParam);
+
+ if (!IniGetString(L"Settings2",L"filebrowser.exe",L"",tchExeFile,COUNTOF(tchExeFile))) {
+ if (!SearchPath(NULL,L"metapath.exe",NULL,COUNTOF(tchExeFile),tchExeFile,NULL)) {
+ GetModuleFileName(NULL,tchExeFile,COUNTOF(tchExeFile));
+ PathRemoveFileSpec(tchExeFile);
+ PathAppend(tchExeFile,L"metapath.exe");
+ }
+ }
+
+ else if (PathIsRelative(tchExeFile)) {
+ WCHAR tch[MAX_PATH];
+ if (!SearchPath(NULL,tchExeFile,NULL,COUNTOF(tch),tch,NULL)) {
+ GetModuleFileName(NULL,tch,COUNTOF(tch));
+ PathRemoveFileSpec(tch);
+ PathAppend(tch,tchExeFile);
+ lstrcpy(tchExeFile,tch);
+ }
+ else
+ lstrcpy(tchExeFile,tch);
+ }
+
+ ZeroMemory(&sei,sizeof(SHELLEXECUTEINFO));
+
+ sei.cbSize = sizeof(SHELLEXECUTEINFO);
+ sei.fMask = SEE_MASK_FLAG_NO_UI | /*SEE_MASK_NOZONECHECKS*/0x00800000;
+ sei.hwnd = hwnd;
+ sei.lpVerb = NULL;
+ sei.lpFile = tchExeFile;
+ sei.lpParameters = tchParam;
+ sei.lpDirectory = NULL;
+ sei.nShow = SW_SHOWNORMAL;
+
+ ShellExecuteEx(&sei);
+
+ if ((int)sei.hInstApp < 32)
+ MsgBox(MBWARN,IDS_ERR_BROWSE);
+ }
+ break;
+
+
+ case IDM_FILE_NEWWINDOW:
+ case IDM_FILE_NEWWINDOW2:
+ {
+ SHELLEXECUTEINFO sei;
+ WCHAR szModuleName[MAX_PATH];
+ WCHAR szFileName[MAX_PATH];
+ WCHAR szParameters[2*MAX_PATH+64];
+
+ MONITORINFO mi;
+ HMONITOR hMonitor;
+ WINDOWPLACEMENT wndpl;
+ int x,y,cx,cy,imax;
+ WCHAR tch[64];
+
+ if (bSaveBeforeRunningTools && !FileSave(FALSE,TRUE,FALSE,FALSE))
+ break;
+
+ GetModuleFileName(NULL,szModuleName,COUNTOF(szModuleName));
+
+ lstrcpy(szParameters,L"-f");
+ if (lstrlen(szIniFile)) {
+ lstrcat(szParameters,L" \"");
+ lstrcat(szParameters,szIniFile);
+ lstrcat(szParameters,L"\"");
+ }
+ else
+ lstrcat(szParameters,L"0");
+
+ lstrcat(szParameters,L" -n");
+
+ wndpl.length = sizeof(WINDOWPLACEMENT);
+ GetWindowPlacement(hwnd,&wndpl);
+
+ hMonitor = MonitorFromRect(&wndpl.rcNormalPosition,MONITOR_DEFAULTTONEAREST);
+ mi.cbSize = sizeof(mi);
+ GetMonitorInfo(hMonitor,&mi);
+
+ // offset new window position +10/+10
+ x = wndpl.rcNormalPosition.left + 10;
+ y = wndpl.rcNormalPosition.top + 10;
+ cx = wndpl.rcNormalPosition.right - wndpl.rcNormalPosition.left;
+ cy = wndpl.rcNormalPosition.bottom - wndpl.rcNormalPosition.top;
+
+ // check if window fits monitor
+ if ((x + cx) > mi.rcWork.right || (y + cy) > mi.rcWork.bottom) {
+ x = mi.rcMonitor.left;
+ y = mi.rcMonitor.top;
+ }
+
+ imax = IsZoomed(hwnd);
+
+ wsprintf(tch,L" -p %i,%i,%i,%i,%i",x,y,cx,cy,imax);
+ lstrcat(szParameters,tch);
+
+ if (LOWORD(wParam) != IDM_FILE_NEWWINDOW2 && lstrlen(szCurFile)) {
+ lstrcpy(szFileName,szCurFile);
+ PathQuoteSpaces(szFileName);
+ lstrcat(szParameters,L" ");
+ lstrcat(szParameters,szFileName);
+ }
+
+ ZeroMemory(&sei,sizeof(SHELLEXECUTEINFO));
+
+ sei.cbSize = sizeof(SHELLEXECUTEINFO);
+ sei.fMask = /*SEE_MASK_NOZONECHECKS*/0x00800000;
+ sei.hwnd = hwnd;
+ sei.lpVerb = NULL;
+ sei.lpFile = szModuleName;
+ sei.lpParameters = szParameters;
+ sei.lpDirectory = NULL;
+ sei.nShow = SW_SHOWNORMAL;
+
+ ShellExecuteEx(&sei);
+ }
+ break;
+
+
+ case IDM_FILE_LAUNCH:
+ {
+ SHELLEXECUTEINFO sei;
+ WCHAR wchDirectory[MAX_PATH] = L"";
+
+ if (!lstrlen(szCurFile))
+ break;
+
+ if (bSaveBeforeRunningTools && !FileSave(FALSE,TRUE,FALSE,FALSE))
+ break;
+
+ if (lstrlen(szCurFile)) {
+ lstrcpy(wchDirectory,szCurFile);
+ PathRemoveFileSpec(wchDirectory);
+ }
+
+ ZeroMemory(&sei,sizeof(SHELLEXECUTEINFO));
+
+ sei.cbSize = sizeof(SHELLEXECUTEINFO);
+ sei.fMask = 0;
+ sei.hwnd = hwnd;
+ sei.lpVerb = NULL;
+ sei.lpFile = szCurFile;
+ sei.lpParameters = NULL;
+ sei.lpDirectory = NULL;
+ sei.nShow = SW_SHOWNORMAL;
+
+ ShellExecuteEx(&sei);
+ }
+ break;
+
+
+ case IDM_FILE_RUN:
+ {
+ WCHAR tchCmdLine[MAX_PATH+4];
+
+ if (bSaveBeforeRunningTools && !FileSave(FALSE,TRUE,FALSE,FALSE))
+ break;
+
+ lstrcpy(tchCmdLine,szCurFile);
+ PathQuoteSpaces(tchCmdLine);
+
+ RunDlg(hwnd,tchCmdLine);
+ }
+ break;
+
+
+ case IDM_FILE_OPENWITH:
+ if (bSaveBeforeRunningTools && !FileSave(FALSE,TRUE,FALSE,FALSE))
+ break;
+ OpenWithDlg(hwnd,szCurFile);
+ break;
+
+
+ case IDM_FILE_PAGESETUP:
+ EditPrintSetup(hwndEdit);
+ break;
+
+ case IDM_FILE_PRINT:
+ {
+ SHFILEINFO shfi;
+ WCHAR *pszTitle;
+ WCHAR tchUntitled[32];
+ WCHAR tchPageFmt[32];
+
+ if (lstrlen(szCurFile)) {
+ SHGetFileInfo2(szCurFile,0,&shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME);
+ pszTitle = shfi.szDisplayName;
+ }
+ else {
+ GetString(IDS_UNTITLED,tchUntitled,COUNTOF(tchUntitled));
+ pszTitle = tchUntitled;
+ }
+
+ GetString(IDS_PRINT_PAGENUM,tchPageFmt,COUNTOF(tchPageFmt));
+
+ if (!EditPrint(hwndEdit,pszTitle,tchPageFmt))
+ MsgBox(MBWARN,IDS_PRINT_ERROR,pszTitle);
+ }
+ break;
+
+
+ case IDM_FILE_PROPERTIES:
+ {
+ SHELLEXECUTEINFO sei;
+
+ if (lstrlen(szCurFile) == 0)
+ break;
+
+ ZeroMemory(&sei,sizeof(SHELLEXECUTEINFO));
+
+ sei.cbSize = sizeof(SHELLEXECUTEINFO);
+ sei.fMask = SEE_MASK_INVOKEIDLIST;
+ sei.hwnd = hwnd;
+ sei.lpVerb = L"properties";
+ sei.lpFile = szCurFile;
+ sei.nShow = SW_SHOWNORMAL;
+
+ ShellExecuteEx(&sei);
+ }
+ break;
+
+ case IDM_FILE_CREATELINK:
+ {
+ if (!lstrlen(szCurFile))
+ break;
+
+ if (!PathCreateDeskLnk(szCurFile))
+ MsgBox(MBWARN,IDS_ERR_CREATELINK);
+ }
+ break;
+
+
+ case IDM_FILE_OPENFAV:
+ if (FileSave(FALSE,TRUE,FALSE,FALSE)) {
+
+ WCHAR tchSelItem[MAX_PATH];
+
+ if (FavoritesDlg(hwnd,tchSelItem))
+ {
+ if (PathIsLnkToDirectory(tchSelItem,NULL,0))
+ PathGetLnkPath(tchSelItem,tchSelItem,COUNTOF(tchSelItem));
+
+ if (PathIsDirectory(tchSelItem))
+ {
+ WCHAR tchFile[MAX_PATH];
+
+ if (OpenFileDlg(hwndMain,tchFile,COUNTOF(tchFile),tchSelItem))
+ FileLoad(TRUE,FALSE,FALSE,FALSE,tchFile);
+ }
+ else
+ FileLoad(TRUE,FALSE,FALSE,FALSE,tchSelItem);
+ }
+ }
+ break;
+
+
+ case IDM_FILE_ADDTOFAV:
+ if (lstrlen(szCurFile)) {
+ SHFILEINFO shfi;
+ SHGetFileInfo2(szCurFile,0,&shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME);
+ AddToFavDlg(hwnd,shfi.szDisplayName,szCurFile);
+ }
+ break;
+
+
+ case IDM_FILE_MANAGEFAV:
+ {
+ SHELLEXECUTEINFO sei;
+ ZeroMemory(&sei,sizeof(SHELLEXECUTEINFO));
+
+ sei.cbSize = sizeof(SHELLEXECUTEINFO);
+ sei.fMask = 0;
+ sei.hwnd = hwnd;
+ sei.lpVerb = NULL;
+ sei.lpFile = tchFavoritesDir;
+ sei.lpParameters = NULL;
+ sei.lpDirectory = NULL;
+ sei.nShow = SW_SHOWNORMAL;
+
+ // Run favorites directory
+ ShellExecuteEx(&sei);
+ }
+ break;
+
+
+ case IDM_FILE_RECENT:
+ if (MRU_Enum(pFileMRU,0,NULL,0) > 0) {
+ if (FileSave(FALSE,TRUE,FALSE,FALSE)) {
+ WCHAR tchFile[MAX_PATH];
+ if (FileMRUDlg(hwnd,tchFile))
+ FileLoad(TRUE,FALSE,FALSE,FALSE,tchFile);
+ }
+ }
+ break;
+
+
+ case IDM_FILE_EXIT:
+ SendMessage(hwnd,WM_CLOSE,0,0);
+ break;
+
+
+ case IDM_ENCODING_ANSI:
+ case IDM_ENCODING_UNICODE:
+ case IDM_ENCODING_UNICODEREV:
+ case IDM_ENCODING_UTF8:
+ case IDM_ENCODING_UTF8SIGN:
+ case IDM_ENCODING_SELECT:
+ {
+ int iNewEncoding = iEncoding;
+ if (LOWORD(wParam) == IDM_ENCODING_SELECT && !SelectEncodingDlg(hwnd,&iNewEncoding))
+ break;
+ else {
+ switch (LOWORD(wParam)) {
+ case IDM_ENCODING_UNICODE: iNewEncoding = CPI_UNICODEBOM; break;
+ case IDM_ENCODING_UNICODEREV: iNewEncoding = CPI_UNICODEBEBOM; break;
+ case IDM_ENCODING_UTF8: iNewEncoding = CPI_UTF8; break;
+ case IDM_ENCODING_UTF8SIGN: iNewEncoding = CPI_UTF8SIGN; break;
+ case IDM_ENCODING_ANSI: iNewEncoding = CPI_DEFAULT; break;
+ }
+ }
+
+ if (EditSetNewEncoding(hwndEdit,
+ iEncoding,iNewEncoding,
+ (flagSetEncoding),lstrlen(szCurFile) == 0)) {
+
+ if (SendMessage(hwndEdit,SCI_GETLENGTH,0,0) == 0) {
+ iEncoding = iNewEncoding;
+ iOriginalEncoding = iNewEncoding;
+ }
+ else {
+ if (iEncoding == CPI_DEFAULT || iNewEncoding == CPI_DEFAULT)
+ iOriginalEncoding = -1;
+ iEncoding = iNewEncoding;
+ }
+
+ UpdateToolbar();
+ UpdateStatusbar();
+
+ SetWindowTitle(hwnd,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile,
+ iPathNameFormat,bModified || iEncoding != iOriginalEncoding,
+ IDS_READONLY,bReadOnly,szTitleExcerpt);
+ }
+ }
+ break;
+
+
+ case IDM_ENCODING_RECODE:
+ {
+ if (lstrlen(szCurFile)) {
+
+ WCHAR tchCurFile2[MAX_PATH];
+
+ int iNewEncoding = -1;
+ if (iEncoding != CPI_DEFAULT)
+ iNewEncoding = iEncoding;
+ if (iEncoding == CPI_UTF8SIGN)
+ iNewEncoding = CPI_UTF8;
+
+ if ((bModified || iEncoding != iOriginalEncoding) && MsgBox(MBOKCANCEL,IDS_ASK_RECODE) != IDOK)
+ return(0);
+
+ if (RecodeDlg(hwnd,&iNewEncoding)) {
+
+ lstrcpy(tchCurFile2,szCurFile);
+ iSrcEncoding = iNewEncoding;
+ FileLoad(TRUE,FALSE,TRUE,FALSE,tchCurFile2);
+ }
+ }
+ }
+ break;
+
+
+ case IDM_ENCODING_SETDEFAULT:
+ SelectDefEncodingDlg(hwnd,&iDefaultEncoding);
+ break;
+
+
+ case IDM_LINEENDINGS_CRLF:
+ case IDM_LINEENDINGS_LF:
+ case IDM_LINEENDINGS_CR:
+ {
+ int iNewEOLMode = iLineEndings[LOWORD(wParam)-IDM_LINEENDINGS_CRLF];
+ iEOLMode = iNewEOLMode;
+ SendMessage(hwndEdit,SCI_SETEOLMODE,iEOLMode,0);
+ SendMessage(hwndEdit,SCI_CONVERTEOLS,iEOLMode,0);
+ UpdateToolbar();
+ UpdateStatusbar();
+ SetWindowTitle(hwnd,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile,
+ iPathNameFormat,bModified || iEncoding != iOriginalEncoding,
+ IDS_READONLY,bReadOnly,szTitleExcerpt);
+ }
+ break;
+
+
+ case IDM_LINEENDINGS_SETDEFAULT:
+ SelectDefLineEndingDlg(hwnd,&iDefaultEOLMode);
+ break;
+
+
+ case IDM_EDIT_UNDO:
+ SendMessage(hwndEdit,SCI_UNDO,0,0);
+ break;
+
+
+ case IDM_EDIT_REDO:
+ SendMessage(hwndEdit,SCI_REDO,0,0);
+ break;
+
+
+ case IDM_EDIT_CUT:
+ if (flagPasteBoard)
+ bLastCopyFromMe = TRUE;
+ SendMessage(hwndEdit,SCI_CUT,0,0);
+ break;
+
+
+ case IDM_EDIT_COPY:
+ if (flagPasteBoard)
+ bLastCopyFromMe = TRUE;
+ SendMessage(hwndEdit,SCI_COPY,0,0);
+ UpdateToolbar();
+ break;
+
+
+ case IDM_EDIT_COPYALL:
+ if (flagPasteBoard)
+ bLastCopyFromMe = TRUE;
+ SendMessage(hwndEdit,SCI_COPYRANGE,0,SendMessage(hwndEdit,SCI_GETLENGTH,0,0));
+ UpdateToolbar();
+ break;
+
+
+ case IDM_EDIT_COPYADD:
+ if (flagPasteBoard)
+ bLastCopyFromMe = TRUE;
+ EditCopyAppend(hwndEdit);
+ UpdateToolbar();
+ break;
+
+
+ case IDM_EDIT_PASTE:
+ SendMessage(hwndEdit,SCI_PASTE,0,0);
+ break;
+
+
+ case IDM_EDIT_SWAP:
+ if (SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0) -
+ SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0) == 0) {
+ int iNewPos = -1;
+ int iPos = SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0);
+ SendMessage(hwndEdit,SCI_PASTE,0,0);
+ iNewPos = SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0);
+ SendMessage(hwndEdit,SCI_SETSEL,iPos,iNewPos);
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_CLEARCLIPBOARD,1),0);
+ }
+ else {
+ int iPos = SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0);
+ int iAnchor = SendMessage(hwndEdit,SCI_GETANCHOR,0,0);
+ char *pClip = EditGetClipboardText(hwndEdit);
+ if (flagPasteBoard)
+ bLastCopyFromMe = TRUE;
+ SendMessage(hwndEdit,SCI_BEGINUNDOACTION,0,0);
+ SendMessage(hwndEdit,SCI_CUT,0,0);
+ SendMessage(hwndEdit,SCI_REPLACESEL,(WPARAM)0,(LPARAM)pClip);
+ if (iPos > iAnchor)
+ SendMessage(hwndEdit,SCI_SETSEL,iAnchor,iAnchor + lstrlenA(pClip));
+ else
+ SendMessage(hwndEdit,SCI_SETSEL,iPos + lstrlenA(pClip),iPos);
+ SendMessage(hwndEdit,SCI_ENDUNDOACTION,0,0);
+ LocalFree(pClip);
+ }
+ break;
+
+
+ case IDM_EDIT_CLEAR:
+ SendMessage(hwndEdit,SCI_CLEAR,0,0);
+ break;
+
+
+ case IDM_EDIT_CLEARCLIPBOARD:
+ if (OpenClipboard(hwnd)) {
+ if (CountClipboardFormats() > 0) {
+ EmptyClipboard();
+ UpdateToolbar();
+ UpdateStatusbar();
+ }
+ CloseClipboard();
+ }
+ break;
+
+
+ case IDM_EDIT_SELECTALL:
+ SendMessage(hwndEdit,SCI_SELECTALL,0,0);
+ //SendMessage(hwndEdit,SCI_SETSEL,0,(LPARAM)-1);
+ break;
+
+
+ case IDM_EDIT_SELECTWORD:
+ {
+ int iSel =
+ SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0) -
+ SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0);
+
+ int iPos = SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0);
+
+ if (iSel == 0) {
+
+ int iWordStart = SendMessage(hwndEdit,SCI_WORDSTARTPOSITION,iPos,TRUE);
+ int iWordEnd = SendMessage(hwndEdit,SCI_WORDENDPOSITION,iPos,TRUE);
+
+ if (iWordStart == iWordEnd) // we are in whitespace salad...
+ {
+ iWordStart = SendMessage(hwndEdit,SCI_WORDENDPOSITION,iPos,FALSE);
+ iWordEnd = SendMessage(hwndEdit,SCI_WORDENDPOSITION,iWordStart,TRUE);
+ if (iWordStart != iWordEnd) {
+ //if (SCLEX_HTML == SendMessage(hwndEdit,SCI_GETLEXER,0,0) &&
+ // SCE_HPHP_VARIABLE == SendMessage(hwndEdit,SCI_GETSTYLEAT,(WPARAM)iWordStart,0) &&
+ // '$' == (char)SendMessage(hwndEdit,SCI_GETCHARAT,(WPARAM)iWordStart-1,0))
+ // iWordStart--;
+ SendMessage(hwndEdit,SCI_SETSEL,iWordStart,iWordEnd);
+ }
+ }
+ else {
+ //if (SCLEX_HTML == SendMessage(hwndEdit,SCI_GETLEXER,0,0) &&
+ // SCE_HPHP_VARIABLE == SendMessage(hwndEdit,SCI_GETSTYLEAT,(WPARAM)iWordStart,0) &&
+ // '$' == (char)SendMessage(hwndEdit,SCI_GETCHARAT,(WPARAM)iWordStart-1,0))
+ // iWordStart--;
+ SendMessage(hwndEdit,SCI_SETSEL,iWordStart,iWordEnd);
+ }
+
+ iSel =
+ SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0) -
+ SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0);
+
+ if (iSel == 0) {
+ int iLine = SendMessage(hwndEdit,SCI_LINEFROMPOSITION,iPos,0);
+ int iLineStart = SendMessage(hwndEdit,SCI_GETLINEINDENTPOSITION,iLine,0);
+ int iLineEnd = SendMessage(hwndEdit,SCI_GETLINEENDPOSITION,iLine,0);
+ SendMessage(hwndEdit,SCI_SETSEL,iLineStart,iLineEnd);
+ }
+ }
+ else {
+ int iLine = SendMessage(hwndEdit,SCI_LINEFROMPOSITION,iPos,0);
+ int iLineStart = SendMessage(hwndEdit,SCI_GETLINEINDENTPOSITION,iLine,0);
+ int iLineEnd = SendMessage(hwndEdit,SCI_GETLINEENDPOSITION,iLine,0);
+ SendMessage(hwndEdit,SCI_SETSEL,iLineStart,iLineEnd);
+ }
+ }
+
+ break;
+
+
+ case IDM_EDIT_SELECTLINE:
+ {
+ int iSelStart = SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0);
+ int iSelEnd = SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0);
+ int iLineStart = SendMessage(hwndEdit,SCI_LINEFROMPOSITION,iSelStart,0);
+ int iLineEnd = SendMessage(hwndEdit,SCI_LINEFROMPOSITION,iSelEnd,0);
+ iSelStart = SendMessage(hwndEdit,SCI_POSITIONFROMLINE,iLineStart,0);
+ iSelEnd = SendMessage(hwndEdit,SCI_POSITIONFROMLINE,iLineEnd+1,0);
+ SendMessage(hwndEdit,SCI_SETSEL,iSelStart,iSelEnd);
+ SendMessage(hwndEdit,SCI_CHOOSECARETX,0,0);
+ }
+ break;
+
+
+ case IDM_EDIT_MOVELINEUP:
+ EditMoveUp(hwndEdit);
+ break;
+
+
+ case IDM_EDIT_MOVELINEDOWN:
+ EditMoveDown(hwndEdit);
+ break;
+
+
+ case IDM_EDIT_DUPLICATELINE:
+ SendMessage(hwndEdit,SCI_LINEDUPLICATE,0,0);
+ break;
+
+
+ case IDM_EDIT_CUTLINE:
+ if (flagPasteBoard)
+ bLastCopyFromMe = TRUE;
+ SendMessage(hwndEdit,SCI_LINECUT,0,0);
+ break;
+
+
+ case IDM_EDIT_COPYLINE:
+ if (flagPasteBoard)
+ bLastCopyFromMe = TRUE;
+ SendMessage(hwndEdit,SCI_LINECOPY,0,0);
+ UpdateToolbar();
+ break;
+
+
+ case IDM_EDIT_DELETELINE:
+ SendMessage(hwndEdit,SCI_LINEDELETE,0,0);
+ break;
+
+
+ case IDM_EDIT_DELETELINELEFT:
+ SendMessage(hwndEdit,SCI_DELLINELEFT,0,0);
+ break;
+
+
+ case IDM_EDIT_DELETELINERIGHT:
+ SendMessage(hwndEdit,SCI_DELLINERIGHT,0,0);
+ break;
+
+
+ case IDM_EDIT_INDENT:
+ {
+ int iLineSelStart = SendMessage(hwndEdit,SCI_LINEFROMPOSITION,
+ SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0),0);
+ int iLineSelEnd = SendMessage(hwndEdit,SCI_LINEFROMPOSITION,
+ SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0),0);
+
+ SendMessage(hwndEdit,SCI_SETTABINDENTS,TRUE,0);
+ if (iLineSelStart == iLineSelEnd) {
+ SendMessage(hwndEdit,SCI_VCHOME,0,0);
+ SendMessage(hwndEdit,SCI_TAB,0,0);
+ }
+ else
+ SendMessage(hwndEdit,SCI_TAB,0,0);
+ SendMessage(hwndEdit,SCI_SETTABINDENTS,bTabIndents,0);
+ }
+ break;
+
+
+ case IDM_EDIT_UNINDENT:
+ {
+ int iLineSelStart = SendMessage(hwndEdit,SCI_LINEFROMPOSITION,
+ SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0),0);
+ int iLineSelEnd = SendMessage(hwndEdit,SCI_LINEFROMPOSITION,
+ SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0),0);
+
+ SendMessage(hwndEdit,SCI_SETTABINDENTS,TRUE,0);
+ if (iLineSelStart == iLineSelEnd) {
+ SendMessage(hwndEdit,SCI_VCHOME,0,0);
+ SendMessage(hwndEdit,SCI_BACKTAB,0,0);
+ }
+ else
+ SendMessage(hwndEdit,SCI_BACKTAB,0,0);
+ SendMessage(hwndEdit,SCI_SETTABINDENTS,bTabIndents,0);
+ }
+ break;
+
+
+ case IDM_EDIT_ENCLOSESELECTION:
+ if (EditEncloseSelectionDlg(hwnd,wchPrefixSelection,wchAppendSelection)) {
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORWAIT,0);
+ EditEncloseSelection(hwndEdit,wchPrefixSelection,wchAppendSelection);
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORNORMAL,0);
+ }
+ break;
+
+
+ case IDM_EDIT_SELECTIONDUPLICATE:
+ SendMessage(hwndEdit,SCI_BEGINUNDOACTION,0,0);
+ SendMessage(hwndEdit,SCI_SELECTIONDUPLICATE,0,0);
+ SendMessage(hwndEdit,SCI_ENDUNDOACTION,0,0);
+ break;
+
+
+ case IDM_EDIT_PADWITHSPACES:
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORWAIT,0);
+ EditPadWithSpaces(hwndEdit);
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORNORMAL,0);
+ break;
+
+
+ case IDM_EDIT_STRIP1STCHAR:
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORWAIT,0);
+ EditStripFirstCharacter(hwndEdit);
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORNORMAL,0);
+ break;
+
+
+ case IDM_EDIT_STRIPLASTCHAR:
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORWAIT,0);
+ EditStripLastCharacter(hwndEdit);
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORNORMAL,0);
+ break;
+
+
+ case IDM_EDIT_TRIMLINES:
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORWAIT,0);
+ EditStripTrailingBlanks(hwndEdit,FALSE);
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORNORMAL,0);
+ break;
+
+
+ case IDM_EDIT_COMPRESSWS:
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORWAIT,0);
+ EditCompressSpaces(hwndEdit);
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORNORMAL,0);
+ break;
+
+
+ case IDM_EDIT_REMOVEBLANKLINES:
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORWAIT,0);
+ EditRemoveBlankLines(hwndEdit);
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORNORMAL,0);
+ break;
+
+
+ case IDM_EDIT_MODIFYLINES:
+ if (EditModifyLinesDlg(hwnd,wchPrefixLines,wchAppendLines)) {
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORWAIT,0);
+ EditModifyLines(hwndEdit,wchPrefixLines,wchAppendLines);
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORNORMAL,0);
+ }
+ break;
+
+
+ case IDM_EDIT_SORTLINES:
+ if (EditSortDlg(hwnd,&iSortOptions)) {
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORWAIT,0);
+ StatusSetText(hwndStatus,255,L"...");
+ StatusSetSimple(hwndStatus,TRUE);
+ InvalidateRect(hwndStatus,NULL,TRUE);
+ UpdateWindow(hwndStatus);
+ EditSortLines(hwndEdit,iSortOptions);
+ StatusSetSimple(hwndStatus,FALSE);
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORNORMAL,0);
+ }
+ break;
+
+
+ case IDM_EDIT_COLUMNWRAP:
+ {
+ if (iWrapCol == 0)
+ iWrapCol = iLongLinesLimit;
+
+ if (ColumnWrapDlg(hwnd,IDD_COLUMNWRAP,&iWrapCol))
+ {
+ iWrapCol = max(min(iWrapCol,512),1);
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORWAIT,0);
+ EditWrapToColumn(hwndEdit,iWrapCol);
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORNORMAL,0);
+ }
+ }
+ break;
+
+
+ case IDM_EDIT_SPLITLINES:
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORWAIT,0);
+ SendMessage(hwndEdit,SCI_TARGETFROMSELECTION,0,0);
+ SendMessage(hwndEdit,SCI_LINESSPLIT,0,0);
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORNORMAL,0);
+ break;
+
+
+ case IDM_EDIT_JOINLINES:
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORWAIT,0);
+ SendMessage(hwndEdit,SCI_TARGETFROMSELECTION,0,0);
+ SendMessage(hwndEdit,SCI_LINESJOIN,0,0);
+ EditJoinLinesEx(hwndEdit);
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORNORMAL,0);
+ break;
+
+
+ case IDM_EDIT_JOINLINESEX:
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORWAIT,0);
+ EditJoinLinesEx(hwndEdit);
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORNORMAL,0);
+ break;
+
+
+ case IDM_EDIT_CONVERTUPPERCASE:
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORWAIT,0);
+ EditMakeUppercase(hwndEdit);
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORNORMAL,0);
+ break;
+
+
+ case IDM_EDIT_CONVERTLOWERCASE:
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORWAIT,0);
+ EditMakeLowercase(hwndEdit);
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORNORMAL,0);
+ break;
+
+
+ case IDM_EDIT_INVERTCASE:
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORWAIT,0);
+ EditInvertCase(hwndEdit);
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORNORMAL,0);
+ break;
+
+
+ case IDM_EDIT_TITLECASE:
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORWAIT,0);
+ EditTitleCase(hwndEdit);
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORNORMAL,0);
+ break;
+
+
+ case IDM_EDIT_SENTENCECASE:
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORWAIT,0);
+ EditSentenceCase(hwndEdit);
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORNORMAL,0);
+ break;
+
+
+ case IDM_EDIT_CONVERTTABS:
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORWAIT,0);
+ EditTabsToSpaces(hwndEdit,iTabWidth,FALSE);
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORNORMAL,0);
+ break;
+
+
+ case IDM_EDIT_CONVERTSPACES:
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORWAIT,0);
+ EditSpacesToTabs(hwndEdit,iTabWidth,FALSE);
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORNORMAL,0);
+ break;
+
+
+ case IDM_EDIT_CONVERTTABS2:
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORWAIT,0);
+ EditTabsToSpaces(hwndEdit,iTabWidth,TRUE);
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORNORMAL,0);
+ break;
+
+
+ case IDM_EDIT_CONVERTSPACES2:
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORWAIT,0);
+ EditSpacesToTabs(hwndEdit,iTabWidth,TRUE);
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORNORMAL,0);
+ break;
+
+
+ case IDM_EDIT_INSERT_TAG:
+ {
+ WCHAR wszOpen[256] = L"";
+ WCHAR wszClose[256] = L"";
+ if (EditInsertTagDlg(hwnd,wszOpen,wszClose))
+ EditEncloseSelection(hwndEdit,wszOpen,wszClose);
+ }
+ break;
+
+
+ case IDM_EDIT_INSERT_ENCODING:
+ {
+ if (*mEncoding[iEncoding].pszParseNames) {
+ char msz[32];
+ char *p;
+ int iSelStart;
+ lstrcpynA(msz,mEncoding[iEncoding].pszParseNames,COUNTOF(msz));
+ if (p = StrChrA(msz,','))
+ *p = 0;
+ iSelStart = SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0);
+ SendMessage(hwndEdit,SCI_REPLACESEL,0,(LPARAM)msz);
+ SendMessage(hwndEdit,SCI_SETANCHOR,(WPARAM)iSelStart,0);
+ }
+ }
+ break;
+
+
+ case IDM_EDIT_INSERT_SHORTDATE:
+ case IDM_EDIT_INSERT_LONGDATE:
+ {
+ WCHAR tchDate[128];
+ WCHAR tchTime[128];
+ WCHAR tchDateTime[256];
+ WCHAR tchTemplate[256];
+ SYSTEMTIME st;
+ char mszBuf[MAX_PATH*3];
+ UINT uCP;
+ int iSelStart;
+
+ GetLocalTime(&st);
+
+ if (IniGetString(L"Settings2",
+ (LOWORD(wParam) == IDM_EDIT_INSERT_SHORTDATE) ? L"DateTimeShort" : L"DateTimeLong",
+ L"",tchTemplate,COUNTOF(tchTemplate))) {
+ struct tm sst;
+ sst.tm_isdst = -1;
+ sst.tm_sec = (int)st.wSecond;
+ sst.tm_min = (int)st.wMinute;
+ sst.tm_hour = (int)st.wHour;
+ sst.tm_mday = (int)st.wDay;
+ sst.tm_mon = (int)st.wMonth - 1;
+ sst.tm_year = (int)st.wYear - 1900;
+ sst.tm_wday = (int)st.wDayOfWeek;
+ mktime(&sst);
+ wcsftime(tchDateTime,COUNTOF(tchDateTime),tchTemplate,&sst);
+ }
+ else {
+ GetDateFormat(LOCALE_USER_DEFAULT,(
+ LOWORD(wParam) == IDM_EDIT_INSERT_SHORTDATE) ? DATE_SHORTDATE : DATE_LONGDATE,
+ &st,NULL,tchDate,COUNTOF(tchDate));
+ GetTimeFormat(LOCALE_USER_DEFAULT,TIME_NOSECONDS,&st,NULL,tchTime,COUNTOF(tchTime));
+
+ wsprintf(tchDateTime,L"%s %s",tchTime,tchDate);
+ }
+
+ uCP = (SendMessage(hwndEdit,SCI_GETCODEPAGE,0,0) == SC_CP_UTF8) ? CP_UTF8 : CP_ACP;
+ WideCharToMultiByte(uCP,0,tchDateTime,-1,mszBuf,COUNTOF(mszBuf),NULL,NULL);
+ iSelStart = SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0);
+ SendMessage(hwndEdit,SCI_REPLACESEL,0,(LPARAM)mszBuf);
+ SendMessage(hwndEdit,SCI_SETANCHOR,(WPARAM)iSelStart,0);
+ }
+ break;
+
+
+ case IDM_EDIT_INSERT_FILENAME:
+ case IDM_EDIT_INSERT_PATHNAME:
+ {
+ SHFILEINFO shfi;
+ WCHAR *pszInsert;
+ WCHAR tchUntitled[32];
+ char mszBuf[MAX_PATH*3];
+ UINT uCP;
+ int iSelStart;
+
+ if (lstrlen(szCurFile)) {
+ if (LOWORD(wParam) == IDM_EDIT_INSERT_FILENAME) {
+ SHGetFileInfo2(szCurFile,0,&shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME);
+ pszInsert = shfi.szDisplayName;
+ }
+ else
+ pszInsert = szCurFile;
+ }
+
+ else {
+ GetString(IDS_UNTITLED,tchUntitled,COUNTOF(tchUntitled));
+ pszInsert = tchUntitled;
+ }
+
+ uCP = (SendMessage(hwndEdit,SCI_GETCODEPAGE,0,0) == SC_CP_UTF8) ? CP_UTF8 : CP_ACP;
+ WideCharToMultiByte(uCP,0,pszInsert,-1,mszBuf,COUNTOF(mszBuf),NULL,NULL);
+ iSelStart = SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0);
+ SendMessage(hwndEdit,SCI_REPLACESEL,0,(LPARAM)mszBuf);
+ SendMessage(hwndEdit,SCI_SETANCHOR,(WPARAM)iSelStart,0);
+ }
+ break;
+
+
+ case IDM_EDIT_LINECOMMENT:
+ switch (SendMessage(hwndEdit,SCI_GETLEXER,0,0)) {
+ case SCLEX_NULL:
+ case SCLEX_CSS:
+ case SCLEX_DIFF:
+ break;
+ case SCLEX_HTML:
+ case SCLEX_XML:
+ case SCLEX_CPP:
+ case SCLEX_PASCAL:
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORWAIT,0);
+ EditToggleLineComments(hwndEdit,L"//",FALSE);
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORNORMAL,0);
+ break;
+ case SCLEX_VBSCRIPT:
+ case SCLEX_VB:
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORWAIT,0);
+ EditToggleLineComments(hwndEdit,L"'",FALSE);
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORNORMAL,0);
+ break;
+ case SCLEX_MAKEFILE:
+ case SCLEX_PERL:
+ case SCLEX_PYTHON:
+ case SCLEX_CONF:
+ case SCLEX_POWERSHELL:
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORWAIT,0);
+ EditToggleLineComments(hwndEdit,L"#",TRUE);
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORNORMAL,0);
+ break;
+ case SCLEX_ASM:
+ case SCLEX_PROPERTIES:
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORWAIT,0);
+ EditToggleLineComments(hwndEdit,L";",TRUE);
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORNORMAL,0);
+ break;
+ case SCLEX_SQL:
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORWAIT,0);
+ EditToggleLineComments(hwndEdit,L"--",TRUE);
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORNORMAL,0);
+ break;
+ case SCLEX_BATCH:
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORWAIT,0);
+ EditToggleLineComments(hwndEdit,L"rem ",TRUE);
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORNORMAL,0);
+ break;
+ }
+ break;
+
+
+ case IDM_EDIT_STREAMCOMMENT:
+ switch (SendMessage(hwndEdit,SCI_GETLEXER,0,0)) {
+ case SCLEX_NULL:
+ case SCLEX_VBSCRIPT:
+ case SCLEX_MAKEFILE:
+ case SCLEX_VB:
+ case SCLEX_ASM:
+ case SCLEX_SQL:
+ case SCLEX_PERL:
+ case SCLEX_PYTHON:
+ case SCLEX_PROPERTIES:
+ case SCLEX_CONF:
+ case SCLEX_POWERSHELL:
+ case SCLEX_BATCH:
+ case SCLEX_DIFF:
+ break;
+ case SCLEX_HTML:
+ case SCLEX_XML:
+ case SCLEX_CSS:
+ case SCLEX_CPP:
+ EditEncloseSelection(hwndEdit,L"/*",L"*/");
+ break;
+ case SCLEX_PASCAL:
+ EditEncloseSelection(hwndEdit,L"{",L"}");
+ }
+ break;
+
+
+ case IDM_EDIT_URLENCODE:
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORWAIT,0);
+ EditURLEncode(hwndEdit);
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORNORMAL,0);
+ break;
+
+
+ case IDM_EDIT_URLDECODE:
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORWAIT,0);
+ EditURLDecode(hwndEdit);
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORNORMAL,0);
+ break;
+
+
+ case IDM_EDIT_ESCAPECCHARS:
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORWAIT,0);
+ EditEscapeCChars(hwndEdit);
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORNORMAL,0);
+ break;
+
+
+ case IDM_EDIT_UNESCAPECCHARS:
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORWAIT,0);
+ EditUnescapeCChars(hwndEdit);
+ SendMessage(hwndEdit,SCI_SETCURSOR,SC_CURSORNORMAL,0);
+ break;
+
+
+ case IDM_EDIT_FINDMATCHINGBRACE:
+ {
+ int iBrace2 = -1;
+ int iPos = SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0);
+ char c = (char)SendMessage(hwndEdit,SCI_GETCHARAT,iPos,0);
+ if (StrChrA("()[]{}",c))
+ iBrace2 = SendMessage(hwndEdit,SCI_BRACEMATCH,iPos,0);
+ // Try one before
+ else {
+ iPos = SendMessage(hwndEdit,SCI_POSITIONBEFORE,iPos,0);
+ c = (char)SendMessage(hwndEdit,SCI_GETCHARAT,iPos,0);
+ if (StrChrA("()[]{}",c))
+ iBrace2 = SendMessage(hwndEdit,SCI_BRACEMATCH,iPos,0);
+ }
+ if (iBrace2 != -1)
+ SendMessage(hwndEdit,SCI_GOTOPOS,(WPARAM)iBrace2,0);
+ }
+ break;
+
+
+ case IDM_EDIT_SELTOMATCHINGBRACE:
+ {
+ int iBrace2 = -1;
+ int iPos = SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0);
+ char c = (char)SendMessage(hwndEdit,SCI_GETCHARAT,iPos,0);
+ if (StrChrA("()[]{}",c))
+ iBrace2 = SendMessage(hwndEdit,SCI_BRACEMATCH,iPos,0);
+ // Try one before
+ else {
+ iPos = SendMessage(hwndEdit,SCI_POSITIONBEFORE,iPos,0);
+ c = (char)SendMessage(hwndEdit,SCI_GETCHARAT,iPos,0);
+ if (StrChrA("()[]{}",c))
+ iBrace2 = SendMessage(hwndEdit,SCI_BRACEMATCH,iPos,0);
+ }
+ if (iBrace2 != -1) {
+ if (iBrace2 > iPos)
+ SendMessage(hwndEdit,SCI_SETSEL,(WPARAM)iPos,(LPARAM)iBrace2+1);
+ else
+ SendMessage(hwndEdit,SCI_SETSEL,(WPARAM)iPos+1,(LPARAM)iBrace2);
+ }
+ }
+ break;
+
+
+ case IDM_EDIT_FIND:
+ if (!IsWindow(hDlgFindReplace))
+ hDlgFindReplace = EditFindReplaceDlg(hwndEdit,&efrData,FALSE);
+ else {
+ if (GetDlgItem(hDlgFindReplace,IDC_REPLACE)) {
+ SendMessage(hDlgFindReplace,WM_COMMAND,MAKELONG(IDMSG_SWITCHTOFIND,1),0);
+ DestroyWindow(hDlgFindReplace);
+ hDlgFindReplace = EditFindReplaceDlg(hwndEdit,&efrData,FALSE);
+ }
+ else {
+ SetForegroundWindow(hDlgFindReplace);
+ PostMessage(hDlgFindReplace,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hDlgFindReplace,IDC_FINDTEXT)),1);
+ }
+ }
+ break;
+
+
+ case IDM_EDIT_FINDNEXT:
+ case IDM_EDIT_FINDPREV:
+ case IDM_EDIT_SELTONEXT:
+ case IDM_EDIT_SELTOPREV:
+ case IDM_EDIT_REPLACENEXT:
+
+ if (SendMessage(hwndEdit,SCI_GETLENGTH,0,0) == 0)
+ break;
+
+ if (!lstrlenA(efrData.szFind)) {
+ if (LOWORD(wParam) != IDM_EDIT_REPLACENEXT)
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_FIND,1),0);
+ else
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_REPLACE,1),0);
+ }
+
+ else {
+
+ UINT cp = SendMessage(hwndEdit,SCI_GETCODEPAGE,0,0);
+ if (cpLastFind != cp) {
+ if (cp != SC_CP_UTF8) {
+
+ WCHAR wch[512];
+
+ MultiByteToWideChar(CP_UTF8,0,efrData.szFindUTF8,-1,wch,COUNTOF(wch));
+ WideCharToMultiByte(cp,0,wch,-1,efrData.szFind,COUNTOF(efrData.szFind),NULL,NULL);
+
+ MultiByteToWideChar(CP_UTF8,0,efrData.szReplaceUTF8,-1,wch,COUNTOF(wch));
+ WideCharToMultiByte(cp,0,wch,-1,efrData.szReplace,COUNTOF(efrData.szReplace),NULL,NULL);
+ }
+ else {
+
+ lstrcpyA(efrData.szFind,efrData.szFindUTF8);
+ lstrcpyA(efrData.szReplace,efrData.szReplaceUTF8);
+ }
+ }
+ cpLastFind = cp;
+ switch (LOWORD(wParam)) {
+
+ case IDM_EDIT_FINDNEXT:
+ EditFindNext(hwndEdit,&efrData,FALSE);
+ break;
+
+ case IDM_EDIT_FINDPREV:
+ EditFindPrev(hwndEdit,&efrData,FALSE);
+ break;
+
+ case IDM_EDIT_SELTONEXT:
+ EditFindNext(hwndEdit,&efrData,TRUE);
+ break;
+
+ case IDM_EDIT_SELTOPREV:
+ EditFindPrev(hwndEdit,&efrData,TRUE);
+ break;
+
+ case IDM_EDIT_REPLACENEXT:
+ if (bReplaceInitialized)
+ EditReplace(hwndEdit,&efrData);
+ else
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_REPLACE,1),0);
+ break;
+ }
+ }
+ break;
+
+
+ case IDM_EDIT_REPLACE:
+ if (!IsWindow(hDlgFindReplace))
+ hDlgFindReplace = EditFindReplaceDlg(hwndEdit,&efrData,TRUE);
+ else {
+ if (!GetDlgItem(hDlgFindReplace,IDC_REPLACE)) {
+ SendMessage(hDlgFindReplace,WM_COMMAND,MAKELONG(IDMSG_SWITCHTOREPLACE,1),0);
+ DestroyWindow(hDlgFindReplace);
+ hDlgFindReplace = EditFindReplaceDlg(hwndEdit,&efrData,TRUE);
+ }
+ else {
+ SetForegroundWindow(hDlgFindReplace);
+ PostMessage(hDlgFindReplace,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hDlgFindReplace,IDC_FINDTEXT)),1);
+ }
+ }
+ break;
+
+
+ case IDM_EDIT_GOTOLINE:
+ EditLinenumDlg(hwndEdit);
+ break;
+
+
+ case IDM_VIEW_SCHEME:
+ Style_SelectLexerDlg(hwndEdit);
+ UpdateStatusbar();
+ UpdateLineNumberWidth();
+ break;
+
+
+ case IDM_VIEW_USE2NDDEFAULT:
+ Style_ToggleUse2ndDefault(hwndEdit);
+ UpdateStatusbar();
+ UpdateLineNumberWidth();
+ break;
+
+
+ case IDM_VIEW_SCHEMECONFIG:
+ Style_ConfigDlg(hwndEdit);
+ UpdateStatusbar();
+ UpdateLineNumberWidth();
+ break;
+
+
+ case IDM_VIEW_FONT:
+ Style_SetDefaultFont(hwndEdit);
+ UpdateStatusbar();
+ UpdateLineNumberWidth();
+ break;
+
+
+ case IDM_VIEW_WORDWRAP:
+ fWordWrap = (fWordWrap) ? FALSE : TRUE;
+ if (!fWordWrap)
+ SendMessage(hwndEdit,SCI_SETWRAPMODE,SC_WRAP_NONE,0);
+ else
+ SendMessage(hwndEdit,SCI_SETWRAPMODE,(iWordWrapMode == 0) ? SC_WRAP_WORD : SC_WRAP_CHAR,0);
+ UpdateToolbar();
+ break;
+
+
+ case IDM_VIEW_WORDWRAPSETTINGS:
+ if (WordWrapSettingsDlg(hwnd,IDD_WORDWRAP,&iWordWrapIndent))
+ {
+ if (fWordWrap)
+ SendMessage(hwndEdit,SCI_SETWRAPMODE,(iWordWrapMode == 0) ? SC_WRAP_WORD : SC_WRAP_CHAR,0);
+ if (iWordWrapIndent == 5)
+ SendMessage(hwndEdit,SCI_SETWRAPINDENTMODE,SC_WRAPINDENT_SAME,0);
+ else if (iWordWrapIndent == 6)
+ SendMessage(hwndEdit,SCI_SETWRAPINDENTMODE,SC_WRAPINDENT_INDENT,0);
+ else {
+ int i = 0;
+ switch (iWordWrapIndent) {
+ case 1: i = 1; break;
+ case 2: i = 2; break;
+ case 3: i = (iIndentWidth) ? 1 * iIndentWidth : 1 * iTabWidth; break;
+ case 4: i = (iIndentWidth) ? 2 * iIndentWidth : 2 * iTabWidth; break;
+ }
+ SendMessage(hwndEdit,SCI_SETWRAPSTARTINDENT,i,0);
+ SendMessage(hwndEdit,SCI_SETWRAPINDENTMODE,SC_WRAPINDENT_FIXED,0);
+ }
+ if (bShowWordWrapSymbols) {
+ int wrapVisualFlags = 0;
+ int wrapVisualFlagsLocation = 0;
+ if (iWordWrapSymbols == 0)
+ iWordWrapSymbols = 22;
+ switch (iWordWrapSymbols%10) {
+ case 1: wrapVisualFlags |= SC_WRAPVISUALFLAG_END; wrapVisualFlagsLocation |= SC_WRAPVISUALFLAGLOC_END_BY_TEXT; break;
+ case 2: wrapVisualFlags |= SC_WRAPVISUALFLAG_END; break;
+ }
+ switch (((iWordWrapSymbols%100)-(iWordWrapSymbols%10))/10) {
+ case 1: wrapVisualFlags |= SC_WRAPVISUALFLAG_START; wrapVisualFlagsLocation |= SC_WRAPVISUALFLAGLOC_START_BY_TEXT; break;
+ case 2: wrapVisualFlags |= SC_WRAPVISUALFLAG_START; break;
+ }
+ SendMessage(hwndEdit,SCI_SETWRAPVISUALFLAGSLOCATION,wrapVisualFlagsLocation,0);
+ SendMessage(hwndEdit,SCI_SETWRAPVISUALFLAGS,wrapVisualFlags,0);
+ }
+ else {
+ SendMessage(hwndEdit,SCI_SETWRAPVISUALFLAGS,0,0);
+ }
+ }
+ break;
+
+
+ case IDM_VIEW_LONGLINEMARKER:
+ bMarkLongLines = (bMarkLongLines) ? FALSE: TRUE;
+ if (bMarkLongLines) {
+ SendMessage(hwndEdit,SCI_SETEDGEMODE,(iLongLineMode == EDGE_LINE)?EDGE_LINE:EDGE_BACKGROUND,0);
+ Style_SetLongLineColors(hwndEdit);
+ }
+ else
+ SendMessage(hwndEdit,SCI_SETEDGEMODE,EDGE_NONE,0);
+ UpdateStatusbar();
+ break;
+
+
+ case IDM_VIEW_LONGLINESETTINGS:
+ if (LongLineSettingsDlg(hwnd,IDD_LONGLINES,&iLongLinesLimit)) {
+ bMarkLongLines = TRUE;
+ SendMessage(hwndEdit,SCI_SETEDGEMODE,(iLongLineMode == EDGE_LINE)?EDGE_LINE:EDGE_BACKGROUND,0);
+ Style_SetLongLineColors(hwndEdit);
+ iLongLinesLimit = max(min(iLongLinesLimit,4096),0);
+ SendMessage(hwndEdit,SCI_SETEDGECOLUMN,iLongLinesLimit,0);
+ UpdateStatusbar();
+ iLongLinesLimitG = iLongLinesLimit;
+ }
+ break;
+
+
+ case IDM_VIEW_TABSASSPACES:
+ bTabsAsSpaces = (bTabsAsSpaces) ? FALSE : TRUE;
+ SendMessage(hwndEdit,SCI_SETUSETABS,!bTabsAsSpaces,0);
+ bTabsAsSpacesG = bTabsAsSpaces;
+ break;
+
+
+ case IDM_VIEW_TABSETTINGS:
+ if (TabSettingsDlg(hwnd,IDD_TABSETTINGS,NULL))
+ {
+ SendMessage(hwndEdit,SCI_SETUSETABS,!bTabsAsSpaces,0);
+ SendMessage(hwndEdit,SCI_SETTABINDENTS,bTabIndents,0);
+ iTabWidth = max(min(iTabWidth,256),1);
+ iIndentWidth = max(min(iIndentWidth,256),0);
+ SendMessage(hwndEdit,SCI_SETTABWIDTH,iTabWidth,0);
+ SendMessage(hwndEdit,SCI_SETINDENT,iIndentWidth,0);
+ bTabsAsSpacesG = bTabsAsSpaces;
+ iTabWidthG = iTabWidth;
+ iIndentWidthG = iIndentWidth;
+ if (SendMessage(hwndEdit,SCI_GETWRAPINDENTMODE,0,0) == SC_WRAPINDENT_FIXED) {
+ int i = 0;
+ switch (iWordWrapIndent) {
+ case 1: i = 1; break;
+ case 2: i = 2; break;
+ case 3: i = (iIndentWidth) ? 1 * iIndentWidth : 1 * iTabWidth; break;
+ case 4: i = (iIndentWidth) ? 2 * iIndentWidth : 2 * iTabWidth; break;
+ }
+ SendMessage(hwndEdit,SCI_SETWRAPSTARTINDENT,i,0);
+ }
+ }
+ break;
+
+
+ case IDM_VIEW_SHOWINDENTGUIDES:
+ bShowIndentGuides = (bShowIndentGuides) ? FALSE : TRUE;
+ Style_SetIndentGuides(hwndEdit,bShowIndentGuides);
+ break;
+
+
+ case IDM_VIEW_AUTOINDENTTEXT:
+ bAutoIndent = (bAutoIndent) ? FALSE : TRUE;
+ break;
+
+
+ case IDM_VIEW_LINENUMBERS:
+ bShowLineNumbers = (bShowLineNumbers) ? FALSE : TRUE;
+ UpdateLineNumberWidth();
+ //SendMessage(hwndEdit,SCI_SETMARGINWIDTHN,0,
+ // (bShowLineNumbers)?SendMessage(hwndEdit,SCI_TEXTWIDTH,STYLE_LINENUMBER,(LPARAM)"_999999_"):0);
+ break;
+
+
+ case IDM_VIEW_MARGIN:
+ bShowSelectionMargin = (bShowSelectionMargin) ? FALSE : TRUE;
+ SendMessage(hwndEdit,SCI_SETMARGINWIDTHN,1,(bShowSelectionMargin)?16:0);
+ break;
+
+
+ case IDM_VIEW_SHOWWHITESPACE:
+ bViewWhiteSpace = (bViewWhiteSpace) ? FALSE : TRUE;
+ SendMessage(hwndEdit,SCI_SETVIEWWS,(bViewWhiteSpace)?SCWS_VISIBLEALWAYS:SCWS_INVISIBLE,0);
+ break;
+
+
+ case IDM_VIEW_SHOWEOLS:
+ bViewEOLs = (bViewEOLs) ? FALSE : TRUE;
+ SendMessage(hwndEdit,SCI_SETVIEWEOL,bViewEOLs,0);
+ break;
+
+
+ case IDM_VIEW_WORDWRAPSYMBOLS:
+ bShowWordWrapSymbols = (bShowWordWrapSymbols) ? 0 : 1;
+ if (bShowWordWrapSymbols) {
+ int wrapVisualFlags = 0;
+ int wrapVisualFlagsLocation = 0;
+ if (iWordWrapSymbols == 0)
+ iWordWrapSymbols = 22;
+ switch (iWordWrapSymbols%10) {
+ case 1: wrapVisualFlags |= SC_WRAPVISUALFLAG_END; wrapVisualFlagsLocation |= SC_WRAPVISUALFLAGLOC_END_BY_TEXT; break;
+ case 2: wrapVisualFlags |= SC_WRAPVISUALFLAG_END; break;
+ }
+ switch (((iWordWrapSymbols%100)-(iWordWrapSymbols%10))/10) {
+ case 1: wrapVisualFlags |= SC_WRAPVISUALFLAG_START; wrapVisualFlagsLocation |= SC_WRAPVISUALFLAGLOC_START_BY_TEXT; break;
+ case 2: wrapVisualFlags |= SC_WRAPVISUALFLAG_START; break;
+ }
+ SendMessage(hwndEdit,SCI_SETWRAPVISUALFLAGSLOCATION,wrapVisualFlagsLocation,0);
+ SendMessage(hwndEdit,SCI_SETWRAPVISUALFLAGS,wrapVisualFlags,0);
+ }
+ else {
+ SendMessage(hwndEdit,SCI_SETWRAPVISUALFLAGS,0,0);
+ }
+ break;
+
+
+ case IDM_VIEW_MATCHBRACES:
+ bMatchBraces = (bMatchBraces) ? FALSE : TRUE;
+ if (bMatchBraces) {
+ NMHDR nmhdr;
+ nmhdr.hwndFrom = hwndEdit;
+ nmhdr.idFrom = IDC_EDIT;
+ nmhdr.code = SCN_UPDATEUI;
+ SendMessage(hwnd,WM_NOTIFY,IDC_EDIT,(LPARAM)&nmhdr);
+ }
+ else
+ SendMessage(hwndEdit,SCI_BRACEHIGHLIGHT,(WPARAM)-1,(LPARAM)-1);
+ break;
+
+
+ case IDM_VIEW_AUTOCLOSETAGS:
+ bAutoCloseTags = (bAutoCloseTags) ? FALSE : TRUE;
+ break;
+
+
+ case IDM_VIEW_HILITECURRENTLINE:
+ bHiliteCurrentLine = (bHiliteCurrentLine) ? FALSE : TRUE;
+ Style_SetCurrentLineBackground(hwndEdit);
+ break;
+
+
+ case IDM_VIEW_ZOOMIN:
+ SendMessage(hwndEdit,SCI_ZOOMIN,0,0);
+ //UpdateLineNumberWidth();
+ break;
+
+
+ case IDM_VIEW_ZOOMOUT:
+ SendMessage(hwndEdit,SCI_ZOOMOUT,0,0);
+ //UpdateLineNumberWidth();
+ break;
+
+
+ case IDM_VIEW_RESETZOOM:
+ SendMessage(hwndEdit,SCI_SETZOOM,0,0);
+ //UpdateLineNumberWidth();
+ break;
+
+
+ case IDM_VIEW_TOOLBAR:
+ if (bShowToolbar) {
+ bShowToolbar = 0;
+ ShowWindow(hwndReBar,SW_HIDE);
+ }
+ else {
+ bShowToolbar = 1;
+ UpdateToolbar();
+ ShowWindow(hwndReBar,SW_SHOW);
+ }
+ SendWMSize(hwnd);
+ break;
+
+
+ case IDM_VIEW_CUSTOMIZETB:
+ SendMessage(hwndToolbar,TB_CUSTOMIZE,0,0);
+ break;
+
+
+ case IDM_VIEW_STATUSBAR:
+ if (bShowStatusbar) {
+ bShowStatusbar = 0;
+ ShowWindow(hwndStatus,SW_HIDE);
+ }
+ else {
+ bShowStatusbar = 1;
+ UpdateStatusbar();
+ ShowWindow(hwndStatus,SW_SHOW);
+ }
+ SendWMSize(hwnd);
+ break;
+
+
+ case IDM_VIEW_STICKYWINPOS:
+ bStickyWinPos = IniGetInt(L"Settings2",L"StickyWindowPosition",bStickyWinPos);
+ if (!bStickyWinPos) {
+ WINDOWPLACEMENT wndpl;
+ WCHAR tchPosX[32], tchPosY[32], tchSizeX[32], tchSizeY[32], tchMaximized[32];
+
+ int ResX = GetSystemMetrics(SM_CXSCREEN);
+ int ResY = GetSystemMetrics(SM_CYSCREEN);
+
+ // GetWindowPlacement
+ wndpl.length = sizeof(WINDOWPLACEMENT);
+ GetWindowPlacement(hwndMain,&wndpl);
+
+ wi.x = wndpl.rcNormalPosition.left;
+ wi.y = wndpl.rcNormalPosition.top;
+ wi.cx = wndpl.rcNormalPosition.right - wndpl.rcNormalPosition.left;
+ wi.cy = wndpl.rcNormalPosition.bottom - wndpl.rcNormalPosition.top;
+ wi.max = (IsZoomed(hwndMain) || (wndpl.flags & WPF_RESTORETOMAXIMIZED));
+
+ wsprintf(tchPosX,L"%ix%i PosX",ResX,ResY);
+ wsprintf(tchPosY,L"%ix%i PosY",ResX,ResY);
+ wsprintf(tchSizeX,L"%ix%i SizeX",ResX,ResY);
+ wsprintf(tchSizeY,L"%ix%i SizeY",ResX,ResY);
+ wsprintf(tchMaximized,L"%ix%i Maximized",ResX,ResY);
+
+ bStickyWinPos = 1;
+ IniSetInt(L"Settings2",L"StickyWindowPosition",1);
+
+ IniSetInt(L"Window",tchPosX,wi.x);
+ IniSetInt(L"Window",tchPosY,wi.y);
+ IniSetInt(L"Window",tchSizeX,wi.cx);
+ IniSetInt(L"Window",tchSizeY,wi.cy);
+ IniSetInt(L"Window",tchMaximized,wi.max);
+
+ InfoBox(0,L"MsgStickyWinPos",IDS_STICKYWINPOS);
+ }
+ else {
+ bStickyWinPos = 0;
+ IniSetInt(L"Settings2",L"StickyWindowPosition",0);
+ }
+ break;
+
+
+ case IDM_VIEW_REUSEWINDOW:
+ if (IniGetInt(L"Settings2",L"ReuseWindow",0))
+ IniSetInt(L"Settings2",L"ReuseWindow",0);
+ else
+ IniSetInt(L"Settings2",L"ReuseWindow",1);
+ break;
+
+
+ case IDM_VIEW_SINGLEFILEINSTANCE:
+ if (IniGetInt(L"Settings2",L"SingleFileInstance",0))
+ IniSetInt(L"Settings2",L"SingleFileInstance",0);
+ else
+ IniSetInt(L"Settings2",L"SingleFileInstance",1);
+ break;
+
+
+ case IDM_VIEW_ALWAYSONTOP:
+ if (bAlwaysOnTop) {
+ bAlwaysOnTop = 0;
+ SetWindowPos(hwnd,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
+ }
+ else {
+ bAlwaysOnTop = 1;
+ SetWindowPos(hwnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
+ }
+ break;
+
+
+ case IDM_VIEW_MINTOTRAY:
+ bMinimizeToTray =(bMinimizeToTray) ? FALSE : TRUE;
+ break;
+
+
+ case IDM_VIEW_TRANSPARENT:
+ bTransparentMode =(bTransparentMode) ? FALSE : TRUE;
+ SetWindowTransparentMode(hwnd,bTransparentMode);
+ break;
+
+
+ case IDM_VIEW_SHOWFILENAMEONLY:
+ iPathNameFormat = 0;
+ lstrcpy(szTitleExcerpt,L"");
+ SetWindowTitle(hwnd,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile,
+ iPathNameFormat,bModified || iEncoding != iOriginalEncoding,
+ IDS_READONLY,bReadOnly,szTitleExcerpt);
+ break;
+
+
+ case IDM_VIEW_SHOWFILENAMEFIRST:
+ iPathNameFormat = 1;
+ lstrcpy(szTitleExcerpt,L"");
+ SetWindowTitle(hwnd,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile,
+ iPathNameFormat,bModified || iEncoding != iOriginalEncoding,
+ IDS_READONLY,bReadOnly,szTitleExcerpt);
+ break;
+
+
+ case IDM_VIEW_SHOWFULLPATH:
+ iPathNameFormat = 2;
+ lstrcpy(szTitleExcerpt,L"");
+ SetWindowTitle(hwnd,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile,
+ iPathNameFormat,bModified || iEncoding != iOriginalEncoding,
+ IDS_READONLY,bReadOnly,szTitleExcerpt);
+ break;
+
+
+ case IDM_VIEW_SHOWEXCERPT:
+ EditGetExcerpt(hwndEdit,szTitleExcerpt,COUNTOF(szTitleExcerpt));
+ SetWindowTitle(hwnd,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile,
+ iPathNameFormat,bModified || iEncoding != iOriginalEncoding,
+ IDS_READONLY,bReadOnly,szTitleExcerpt);
+ break;
+
+
+ case IDM_VIEW_NOSAVERECENT:
+ bSaveRecentFiles = (bSaveRecentFiles) ? FALSE : TRUE;
+ break;
+
+
+ case IDM_VIEW_NOSAVEFINDREPL:
+ bSaveFindReplace = (bSaveFindReplace) ? FALSE : TRUE;
+ break;
+
+
+ case IDM_VIEW_SAVEBEFORERUNNINGTOOLS:
+ bSaveBeforeRunningTools = (bSaveBeforeRunningTools) ? FALSE : TRUE;
+ break;
+
+
+ case IDM_VIEW_CHANGENOTIFY:
+ if (ChangeNotifyDlg(hwnd))
+ InstallFileWatching(szCurFile);
+ break;
+
+
+ case IDM_VIEW_NOESCFUNC:
+ iEscFunction = 0;
+ break;
+
+
+ case IDM_VIEW_ESCMINIMIZE:
+ iEscFunction = 1;
+ break;
+
+
+ case IDM_VIEW_ESCEXIT:
+ iEscFunction = 2;
+ break;
+
+
+ case IDM_VIEW_SAVESETTINGS:
+ bSaveSettings = (bSaveSettings) ? FALSE : TRUE;
+ break;
+
+
+ case IDM_VIEW_SAVESETTINGSNOW:
+ {
+ BOOL bCreateFailure = FALSE;
+
+ if (lstrlen(szIniFile) == 0) {
+
+ if (lstrlen(szIniFile2) > 0) {
+ if (CreateIniFileEx(szIniFile2)) {
+ lstrcpy(szIniFile,szIniFile2);
+ lstrcpy(szIniFile2,L"");
+ }
+ else
+ bCreateFailure = TRUE;
+ }
+
+ else
+ break;
+ }
+
+ if (!bCreateFailure) {
+
+ if (WritePrivateProfileString(L"Settings",L"WriteTest",L"ok",szIniFile)) {
+
+ BeginWaitCursor();
+ StatusSetTextID(hwndStatus,STATUS_HELP,IDS_SAVINGSETTINGS);
+ StatusSetSimple(hwndStatus,TRUE);
+ InvalidateRect(hwndStatus,NULL,TRUE);
+ UpdateWindow(hwndStatus);
+ SaveSettings(TRUE);
+ StatusSetSimple(hwndStatus,FALSE);
+ EndWaitCursor();
+ MsgBox(MBINFO,IDS_SAVEDSETTINGS);
+ }
+ else {
+ dwLastIOError = GetLastError();
+ MsgBox(MBINFO,IDS_WRITEINI_FAIL);
+ }
+ }
+ else
+ MsgBox(MBINFO,IDS_CREATEINI_FAIL);
+ }
+ break;
+
+
+ case IDM_HELP_ABOUT:
+ ThemedDialogBox(g_hInstance,MAKEINTRESOURCE(IDD_ABOUT),
+ hwnd,AboutDlgProc);
+ break;
+
+
+ case CMD_ESCAPE:
+ if (iEscFunction == 1)
+ SendMessage(hwnd,WM_SYSCOMMAND,SC_MINIMIZE,0);
+ else if (iEscFunction == 2)
+ SendMessage(hwnd,WM_CLOSE,0,0);
+ break;
+
+
+ case CMD_SHIFTESC:
+ if (FileSave(TRUE,FALSE,FALSE,FALSE))
+ SendMessage(hwnd,WM_CLOSE,0,0);
+ break;
+
+
+ // Newline with toggled auto indent setting
+ case CMD_CTRLENTER:
+ bAutoIndent = (bAutoIndent) ? 0 : 1;
+ SendMessage(hwndEdit,SCI_NEWLINE,0,0);
+ bAutoIndent = (bAutoIndent) ? 0 : 1;
+ break;
+
+
+ case CMD_CTRLBACK:
+ {
+ int iPos = SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0);
+ int iAnchor = SendMessage(hwndEdit,SCI_GETANCHOR,0,0);
+ int iLine = SendMessage(hwndEdit,SCI_LINEFROMPOSITION,(WPARAM)iPos,0);
+ int iStartPos = SendMessage(hwndEdit,SCI_POSITIONFROMLINE,(WPARAM)iLine,0);
+ int iEndPos = SendMessage(hwndEdit,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0);
+ int iIndentPos = SendMessage(hwndEdit,SCI_GETLINEINDENTPOSITION,(WPARAM)iLine,0);
+
+ if (iPos != iAnchor)
+ SendMessage(hwndEdit,SCI_SETSEL,(WPARAM)iPos,(LPARAM)iPos);
+ else {
+ if (iPos == iStartPos)
+ SendMessage(hwndEdit,SCI_DELETEBACK,0,0);
+ else if (iPos <= iIndentPos)
+ SendMessage(hwndEdit,SCI_DELLINELEFT,0,0);
+ else
+ SendMessage(hwndEdit,SCI_DELWORDLEFT,0,0);
+ }
+ }
+ break;
+
+
+ case CMD_CTRLDEL:
+ {
+ int iPos = SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0);
+ int iAnchor = SendMessage(hwndEdit,SCI_GETANCHOR,0,0);
+ int iLine = SendMessage(hwndEdit,SCI_LINEFROMPOSITION,(WPARAM)iPos,0);
+ int iStartPos = SendMessage(hwndEdit,SCI_POSITIONFROMLINE,(WPARAM)iLine,0);
+ int iEndPos = SendMessage(hwndEdit,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0);
+
+ if (iPos != iAnchor)
+ SendMessage(hwndEdit,SCI_SETSEL,(WPARAM)iPos,(LPARAM)iPos);
+ else {
+ if (iStartPos != iEndPos)
+ SendMessage(hwndEdit,SCI_DELWORDRIGHT,0,0);
+ else // iStartPos == iEndPos
+ SendMessage(hwndEdit,SCI_LINEDELETE,0,0);
+ }
+ }
+ break;
+
+
+ case CMD_CTRLTAB:
+ SendMessage(hwndEdit,SCI_SETTABINDENTS,FALSE,0);
+ SendMessage(hwndEdit,SCI_SETUSETABS,TRUE,0);
+ SendMessage(hwndEdit,SCI_TAB,0,0);
+ SendMessage(hwndEdit,SCI_SETUSETABS,!bTabsAsSpaces,0);
+ SendMessage(hwndEdit,SCI_SETTABINDENTS,bTabIndents,0);
+ break;
+
+
+ case CMD_RELOADANSI:
+ {
+ WCHAR tchCurFile2[MAX_PATH];
+ if (lstrlen(szCurFile)) {
+ iSrcEncoding = CPI_DEFAULT;
+ lstrcpy(tchCurFile2,szCurFile);
+ FileLoad(FALSE,FALSE,TRUE,FALSE,tchCurFile2);
+ }
+ }
+ break;
+
+
+ case CMD_RELOADOEM:
+ {
+ WCHAR tchCurFile2[MAX_PATH];
+ if (lstrlen(szCurFile)) {
+ iSrcEncoding = CPI_OEM;
+ lstrcpy(tchCurFile2,szCurFile);
+ FileLoad(FALSE,FALSE,TRUE,FALSE,tchCurFile2);
+ }
+ }
+ break;
+
+
+ case CMD_RELOADASCIIASUTF8:
+ {
+ WCHAR tchCurFile2[MAX_PATH];
+ BOOL _bLoadASCIIasUTF8 = bLoadASCIIasUTF8;
+ if (lstrlen(szCurFile)) {
+ bLoadASCIIasUTF8 = 1;
+ lstrcpy(tchCurFile2,szCurFile);
+ FileLoad(FALSE,FALSE,TRUE,FALSE,tchCurFile2);
+ bLoadASCIIasUTF8 = _bLoadASCIIasUTF8;
+ }
+ }
+ break;
+
+
+ case CMD_RELOADNOFILEVARS:
+ {
+ WCHAR tchCurFile2[MAX_PATH];
+ if (lstrlen(szCurFile)) {
+ int _fNoFileVariables = fNoFileVariables;
+ BOOL _bNoEncodingTags = bNoEncodingTags;
+ fNoFileVariables = 1;
+ bNoEncodingTags = 1;
+ lstrcpy(tchCurFile2,szCurFile);
+ FileLoad(FALSE,FALSE,TRUE,FALSE,tchCurFile2);
+ fNoFileVariables = _fNoFileVariables;
+ bNoEncodingTags = _bNoEncodingTags;
+ }
+ }
+ break;
+
+
+ case CMD_LEXDEFAULT:
+ Style_SetDefaultLexer(hwndEdit);
+ UpdateStatusbar();
+ UpdateLineNumberWidth();
+ break;
+
+
+ case CMD_LEXHTML:
+ Style_SetHTMLLexer(hwndEdit);
+ UpdateStatusbar();
+ UpdateLineNumberWidth();
+ break;
+
+
+ case CMD_LEXXML:
+ Style_SetXMLLexer(hwndEdit);
+ UpdateStatusbar();
+ UpdateLineNumberWidth();
+ break;
+
+
+ case CMD_TIMESTAMPS:
+ {
+ WCHAR wchFind[256] = {0};
+ WCHAR wchTemplate[256] = {0};
+ WCHAR *pwchSep;
+ WCHAR wchReplace[256];
+
+ SYSTEMTIME st;
+ struct tm sst;
+
+ UINT cp;
+ EDITFINDREPLACE efrTS = { "", "", "", "", SCFIND_REGEXP, 0, 0, 0, 0, 0, hwndEdit };
+
+ IniGetString(L"Settings2",L"TimeStamp",L"\\$Date:[^\\$]+\\$ | $Date: %Y/%m/%d %H:%M:%S $",wchFind,COUNTOF(wchFind));
+
+ if (pwchSep = StrChr(wchFind,L'|')) {
+ lstrcpy(wchTemplate,pwchSep+1);
+ *pwchSep = 0;
+ }
+
+ StrTrim(wchFind,L" ");
+ StrTrim(wchTemplate,L" ");
+
+ if (lstrlen(wchFind) == 0 || lstrlen(wchTemplate) == 0)
+ break;
+
+ GetLocalTime(&st);
+ sst.tm_isdst = -1;
+ sst.tm_sec = (int)st.wSecond;
+ sst.tm_min = (int)st.wMinute;
+ sst.tm_hour = (int)st.wHour;
+ sst.tm_mday = (int)st.wDay;
+ sst.tm_mon = (int)st.wMonth - 1;
+ sst.tm_year = (int)st.wYear - 1900;
+ sst.tm_wday = (int)st.wDayOfWeek;
+ mktime(&sst);
+ wcsftime(wchReplace,COUNTOF(wchReplace),wchTemplate,&sst);
+
+ cp = SendMessage(hwndEdit,SCI_GETCODEPAGE,0,0);
+ WideCharToMultiByte(cp,0,wchFind,-1,efrTS.szFind,COUNTOF(efrTS.szFind),NULL,NULL);
+ WideCharToMultiByte(cp,0,wchReplace,-1,efrTS.szReplace,COUNTOF(efrTS.szReplace),NULL,NULL);
+
+ if (SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0) !=
+ SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0))
+ EditReplaceAllInSelection(hwndEdit,&efrTS,TRUE);
+ else
+ EditReplaceAll(hwndEdit,&efrTS,TRUE);
+ }
+ break;
+
+
+ case CMD_WEBACTION1:
+ case CMD_WEBACTION2:
+ {
+ BOOL bCmdEnabled = FALSE;
+ LPWSTR lpszTemplateName;
+ WCHAR szCmdTemplate[256];
+ char mszSelection[512] = { 0 };
+ DWORD cchSelection;
+ char *lpsz;
+ LPWSTR lpszCommand;
+ LPWSTR lpszArgs;
+ SHELLEXECUTEINFO sei;
+ WCHAR wchDirectory[MAX_PATH] = L"";
+
+ lpszTemplateName = (LOWORD(wParam) == CMD_WEBACTION1) ? L"WebTemplate1" : L"WebTemplate2";
+
+ bCmdEnabled = IniGetString(L"Settings2",lpszTemplateName,L"",szCmdTemplate,COUNTOF(szCmdTemplate));
+
+ if (bCmdEnabled) {
+
+ cchSelection = SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0) -
+ SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0);
+
+ if (cchSelection > 0 && cchSelection <= 500 && SendMessage(hwndEdit,SCI_GETSELTEXT,0,0) < COUNTOF(mszSelection))
+ {
+ SendMessage(hwndEdit,SCI_GETSELTEXT,0,(LPARAM)mszSelection);
+ mszSelection[cchSelection] = 0; // zero terminate
+
+ // Check lpszSelection and truncate bad WCHARs
+ lpsz = StrChrA(mszSelection,13);
+ if (lpsz) *lpsz = '\0';
+
+ lpsz = StrChrA(mszSelection,10);
+ if (lpsz) *lpsz = '\0';
+
+ lpsz = StrChrA(mszSelection,9);
+ if (lpsz) *lpsz = '\0';
+
+ if (lstrlenA(mszSelection)) {
+
+ WCHAR wszSelection[512];
+ UINT uCP = (SendMessage(hwndEdit,SCI_GETCODEPAGE,0,0) == SC_CP_UTF8) ? CP_UTF8 : CP_ACP;
+ MultiByteToWideChar(uCP,0,mszSelection,-1,wszSelection,COUNTOF(wszSelection));
+
+ lpszCommand = GlobalAlloc(GPTR,sizeof(WCHAR)*(512+COUNTOF(szCmdTemplate)+MAX_PATH+32));
+ wsprintf(lpszCommand,szCmdTemplate,wszSelection);
+ ExpandEnvironmentStringsEx(lpszCommand,GlobalSize(lpszCommand)/sizeof(WCHAR));
+
+ lpszArgs = GlobalAlloc(GPTR,GlobalSize(lpszCommand));
+ ExtractFirstArgument(lpszCommand,lpszCommand,lpszArgs);
+
+ if (lstrlen(szCurFile)) {
+ lstrcpy(wchDirectory,szCurFile);
+ PathRemoveFileSpec(wchDirectory);
+ }
+
+ ZeroMemory(&sei,sizeof(SHELLEXECUTEINFO));
+
+ sei.cbSize = sizeof(SHELLEXECUTEINFO);
+ sei.fMask = /*SEE_MASK_NOZONECHECKS*/0x00800000;
+ sei.hwnd = NULL;
+ sei.lpVerb = NULL;
+ sei.lpFile = lpszCommand;
+ sei.lpParameters = lpszArgs;
+ sei.lpDirectory = wchDirectory;
+ sei.nShow = SW_SHOWNORMAL;
+
+ ShellExecuteEx(&sei);
+
+ GlobalFree(lpszCommand);
+ GlobalFree(lpszArgs);
+ }
+ }
+ }
+ }
+ break;
+
+
+ case CMD_FINDNEXTSEL:
+ case CMD_FINDPREVSEL:
+ case IDM_EDIT_SAVEFIND:
+ {
+ int cchSelection = SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0) -
+ SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0);
+
+ if (cchSelection == 0)
+ {
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_SELECTWORD,1),0);
+ cchSelection = SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0) -
+ SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0);
+ }
+
+ if (cchSelection > 0 && cchSelection <= 500 && SendMessage(hwndEdit,SCI_GETSELTEXT,0,0) < 512)
+ {
+ char mszSelection[512];
+ char *lpsz;
+
+ SendMessage(hwndEdit,SCI_GETSELTEXT,0,(LPARAM)mszSelection);
+ mszSelection[cchSelection] = 0; // zero terminate
+
+ // Check lpszSelection and truncate newlines
+ lpsz = StrChrA(mszSelection,'\n');
+ if (lpsz) *lpsz = '\0';
+
+ lpsz = StrChrA(mszSelection,'\r');
+ if (lpsz) *lpsz = '\0';
+
+ cpLastFind = SendMessage(hwndEdit,SCI_GETCODEPAGE,0,0);
+ lstrcpyA(efrData.szFind,mszSelection);
+
+ if (cpLastFind != SC_CP_UTF8)
+ {
+ WCHAR wszBuf[512];
+
+ MultiByteToWideChar(cpLastFind,0,mszSelection,-1,wszBuf,COUNTOF(wszBuf));
+ WideCharToMultiByte(CP_UTF8,0,wszBuf,-1,efrData.szFindUTF8,COUNTOF(efrData.szFindUTF8),NULL,NULL);
+ }
+ else
+ lstrcpyA(efrData.szFindUTF8,mszSelection);
+
+ efrData.fuFlags &= (~SCFIND_REGEXP);
+ efrData.bTransformBS = FALSE;
+
+ switch (LOWORD(wParam)) {
+
+ case IDM_EDIT_SAVEFIND:
+ break;
+
+ case CMD_FINDNEXTSEL:
+ EditFindNext(hwndEdit,&efrData,FALSE);
+ break;
+
+ case CMD_FINDPREVSEL:
+ EditFindPrev(hwndEdit,&efrData,FALSE);
+ break;
+ }
+ }
+ }
+ break;
+
+
+ case CMD_INCLINELIMIT:
+ case CMD_DECLINELIMIT:
+ if (!bMarkLongLines)
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_VIEW_LONGLINEMARKER,1),0);
+ else {
+ if (LOWORD(wParam) == CMD_INCLINELIMIT)
+ iLongLinesLimit++;
+ else
+ iLongLinesLimit--;
+ iLongLinesLimit = max(min(iLongLinesLimit,4096),0);
+ SendMessage(hwndEdit,SCI_SETEDGECOLUMN,iLongLinesLimit,0);
+ UpdateStatusbar();
+ iLongLinesLimitG = iLongLinesLimit;
+ }
+ break;
+
+
+ case CMD_STRINGIFY:
+ EditEncloseSelection(hwndEdit,L"'",L"'");
+ break;
+
+
+ case CMD_STRINGIFY2:
+ EditEncloseSelection(hwndEdit,L"\"",L"\"");
+ break;
+
+
+ case CMD_EMBRACE:
+ EditEncloseSelection(hwndEdit,L"(",L")");
+ break;
+
+
+ case CMD_EMBRACE2:
+ EditEncloseSelection(hwndEdit,L"[",L"]");
+ break;
+
+
+ case CMD_EMBRACE3:
+ EditEncloseSelection(hwndEdit,L"{",L"}");
+ break;
+
+
+ case CMD_EMBRACE4:
+ EditEncloseSelection(hwndEdit,L"`",L"`");
+ break;
+
+
+ case CMD_INCREASENUM:
+ EditModifyNumber(hwndEdit,TRUE);
+ break;
+
+
+ case CMD_DECREASENUM:
+ EditModifyNumber(hwndEdit,FALSE);
+ break;
+
+
+ case CMD_TOGGLETITLE:
+ EditGetExcerpt(hwndEdit,szTitleExcerpt,COUNTOF(szTitleExcerpt));
+ SetWindowTitle(hwnd,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile,
+ iPathNameFormat,bModified || iEncoding != iOriginalEncoding,
+ IDS_READONLY,bReadOnly,szTitleExcerpt);
+ break;
+
+
+ case CMD_JUMP2SELSTART:
+ if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) {
+ int iAnchorPos = SendMessage(hwndEdit,SCI_GETANCHOR,0,0);
+ int iCursorPos = SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0);
+ if (iCursorPos > iAnchorPos) {
+ SendMessage(hwndEdit,SCI_SETSEL,iCursorPos,iAnchorPos);
+ SendMessage(hwndEdit,SCI_CHOOSECARETX,0,0);
+ }
+ }
+ break;
+
+
+ case CMD_JUMP2SELEND:
+ if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) {
+ int iAnchorPos = SendMessage(hwndEdit,SCI_GETANCHOR,0,0);
+ int iCursorPos = SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0);
+ if (iCursorPos < iAnchorPos) {
+ SendMessage(hwndEdit,SCI_SETSEL,iCursorPos,iAnchorPos);
+ SendMessage(hwndEdit,SCI_CHOOSECARETX,0,0);
+ }
+ }
+ break;
+
+
+ case CMD_COPYPATHNAME: {
+
+ WCHAR *pszCopy;
+ WCHAR tchUntitled[32];
+ if (lstrlen(szCurFile))
+ pszCopy = szCurFile;
+ else {
+ GetString(IDS_UNTITLED,tchUntitled,COUNTOF(tchUntitled));
+ pszCopy = tchUntitled;
+ }
+
+ if (OpenClipboard(hwnd)) {
+ HANDLE hData;
+ WCHAR *pData;
+ EmptyClipboard();
+ hData = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,sizeof(WCHAR) * (lstrlen(pszCopy) + 1));
+ pData = GlobalLock(hData);
+ StrCpyN(pData,pszCopy,GlobalSize(hData) / sizeof(WCHAR));
+ GlobalUnlock(hData);
+ SetClipboardData(CF_UNICODETEXT,hData);
+ CloseClipboard();
+ }
+ }
+ break;
+
+
+ case CMD_OPENINIFILE:
+ if (lstrlen(szIniFile)) {
+ CreateIniFile();
+ FileLoad(FALSE,FALSE,FALSE,FALSE,szIniFile);
+ }
+ break;
+
+
+ case IDT_FILE_NEW:
+ if (IsCmdEnabled(hwnd,IDM_FILE_NEW))
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_NEW,1),0);
+ else
+ MessageBeep(0);
+ break;
+
+
+ case IDT_FILE_OPEN:
+ if (IsCmdEnabled(hwnd,IDM_FILE_OPEN))
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_OPEN,1),0);
+ else
+ MessageBeep(0);
+ break;
+
+
+ case IDT_FILE_BROWSE:
+ if (IsCmdEnabled(hwnd,IDM_FILE_BROWSE))
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_BROWSE,1),0);
+ else
+ MessageBeep(0);
+ break;
+
+
+ case IDT_FILE_SAVE:
+ if (IsCmdEnabled(hwnd,IDM_FILE_SAVE))
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_SAVE,1),0);
+ else
+ MessageBeep(0);
+ break;
+
+
+ case IDT_EDIT_UNDO:
+ if (IsCmdEnabled(hwnd,IDM_EDIT_UNDO))
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_UNDO,1),0);
+ else
+ MessageBeep(0);
+ break;
+
+
+ case IDT_EDIT_REDO:
+ if (IsCmdEnabled(hwnd,IDM_EDIT_REDO))
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_REDO,1),0);
+ else
+ MessageBeep(0);
+ break;
+
+
+ case IDT_EDIT_CUT:
+ if (IsCmdEnabled(hwnd,IDM_EDIT_CUT))
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_CUT,1),0);
+ else
+ MessageBeep(0);
+ break;
+
+
+ case IDT_EDIT_COPY:
+ if (IsCmdEnabled(hwnd,IDM_EDIT_COPY))
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_COPY,1),0);
+ else
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_COPYALL,1),0);
+ break;
+
+
+ case IDT_EDIT_PASTE:
+ if (IsCmdEnabled(hwnd,IDM_EDIT_PASTE))
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_PASTE,1),0);
+ else
+ MessageBeep(0);
+ break;
+
+
+ case IDT_EDIT_FIND:
+ if (IsCmdEnabled(hwnd,IDM_EDIT_FIND))
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_FIND,1),0);
+ else
+ MessageBeep(0);
+ break;
+
+
+ case IDT_EDIT_REPLACE:
+ if (IsCmdEnabled(hwnd,IDM_EDIT_REPLACE))
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_REPLACE,1),0);
+ else
+ MessageBeep(0);
+ break;
+
+
+ case IDT_VIEW_WORDWRAP:
+ if (IsCmdEnabled(hwnd,IDM_VIEW_WORDWRAP))
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_VIEW_WORDWRAP,1),0);
+ else
+ MessageBeep(0);
+ break;
+
+
+ case IDT_VIEW_ZOOMIN:
+ if (IsCmdEnabled(hwnd,IDM_VIEW_ZOOMIN))
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_VIEW_ZOOMIN,1),0);
+ else
+ MessageBeep(0);
+ break;
+
+
+ case IDT_VIEW_ZOOMOUT:
+ if (IsCmdEnabled(hwnd,IDM_VIEW_ZOOMOUT))
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_VIEW_ZOOMOUT,1),0);
+ else
+ MessageBeep(0);
+ break;
+
+
+ case IDT_VIEW_SCHEME:
+ if (IsCmdEnabled(hwnd,IDM_VIEW_SCHEME))
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_VIEW_SCHEME,1),0);
+ else
+ MessageBeep(0);
+ break;
+
+
+ case IDT_VIEW_SCHEMECONFIG:
+ if (IsCmdEnabled(hwnd,IDM_VIEW_SCHEMECONFIG))
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_VIEW_SCHEMECONFIG,1),0);
+ else
+ MessageBeep(0);
+ break;
+
+
+ case IDT_FILE_EXIT:
+ SendMessage(hwnd,WM_CLOSE,0,0);
+ break;
+
+
+ case IDT_FILE_SAVEAS:
+ if (IsCmdEnabled(hwnd,IDM_FILE_SAVEAS))
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_SAVEAS,1),0);
+ else
+ MessageBeep(0);
+ break;
+
+
+ case IDT_FILE_SAVECOPY:
+ if (IsCmdEnabled(hwnd,IDM_FILE_SAVECOPY))
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_SAVECOPY,1),0);
+ else
+ MessageBeep(0);
+ break;
+
+
+ case IDT_EDIT_CLEAR:
+ if (IsCmdEnabled(hwnd,IDM_EDIT_CLEAR))
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_CLEAR,1),0);
+ else
+ SendMessage(hwndEdit,SCI_CLEARALL,0,0);
+ break;
+
+
+ case IDT_FILE_PRINT:
+ if (IsCmdEnabled(hwnd,IDM_FILE_PRINT))
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_PRINT,1),0);
+ else
+ MessageBeep(0);
+ break;
+
+
+ case IDT_FILE_OPENFAV:
+ if (IsCmdEnabled(hwnd,IDM_FILE_OPENFAV))
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_OPENFAV,1),0);
+ else
+ MessageBeep(0);
+ break;
+
+
+ case IDT_FILE_ADDTOFAV:
+ if (IsCmdEnabled(hwnd,IDM_FILE_ADDTOFAV))
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_ADDTOFAV,1),0);
+ else
+ MessageBeep(0);
+ break;
+
+ }
+
+ return(0);
+
+}
+
+
+//=============================================================================
+//
+// MsgNotify() - Handles WM_NOTIFY
+//
+//
+LRESULT MsgNotify(HWND hwnd,WPARAM wParam,LPARAM lParam)
+{
+
+ LPNMHDR pnmh = (LPNMHDR)lParam;
+ struct SCNotification* scn = (struct SCNotification*)lParam;
+
+ switch(pnmh->idFrom)
+ {
+
+ case IDC_EDIT:
+
+ switch(pnmh->code)
+ {
+ case SCN_UPDATEUI:
+ UpdateToolbar();
+ UpdateStatusbar();
+
+ // Invalidate invalid selections
+ #pragma message("TODO: Remove check for invalid selections once fixed in Scintilla")
+ if (SendMessage(hwndEdit,SCI_GETSELECTIONS,0,0) > 1 &&
+ SendMessage(hwndEdit,SCI_GETSELECTIONMODE,0,0) != SC_SEL_RECTANGLE) {
+ int iCurPos = SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0);
+ SendMessage(hwndEdit,WM_CANCELMODE,0,0);
+ SendMessage(hwndEdit,SCI_CLEARSELECTIONS,0,0);
+ SendMessage(hwndEdit,SCI_SETSELECTION,(WPARAM)iCurPos,(LPARAM)iCurPos);
+ }
+
+ // Brace Match
+ if (bMatchBraces)
+ {
+ int iPos;
+ char c;
+
+ int iEndStyled = SendMessage(hwndEdit,SCI_GETENDSTYLED,0,0);
+ if (iEndStyled < SendMessage(hwndEdit,SCI_GETLENGTH,0,0)) {
+ int iLine = SendMessage(hwndEdit,SCI_LINEFROMPOSITION,iEndStyled,0);
+ int iEndStyled = SendMessage(hwndEdit,SCI_POSITIONFROMLINE,iLine,0);
+ SendMessage(hwndEdit,SCI_COLOURISE,iEndStyled,-1);
+ }
+
+ iPos = SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0);
+ c = (char)SendMessage(hwndEdit,SCI_GETCHARAT,iPos,0);
+ if (StrChrA("()[]{}",c)) {
+ int iBrace2 = SendMessage(hwndEdit,SCI_BRACEMATCH,iPos,0);
+ if (iBrace2 != -1) {
+ int col1 = SendMessage(hwndEdit,SCI_GETCOLUMN,iPos,0);
+ int col2 = SendMessage(hwndEdit,SCI_GETCOLUMN,iBrace2,0);
+ SendMessage(hwndEdit,SCI_BRACEHIGHLIGHT,iPos,iBrace2);
+ SendMessage(hwndEdit,SCI_SETHIGHLIGHTGUIDE,min(col1,col2),0);
+ }
+ else {
+ SendMessage(hwndEdit,SCI_BRACEBADLIGHT,iPos,0);
+ SendMessage(hwndEdit,SCI_SETHIGHLIGHTGUIDE,0,0);
+ }
+ }
+ // Try one before
+ else
+ {
+ iPos = SendMessage(hwndEdit,SCI_POSITIONBEFORE,iPos,0);
+ c = (char)SendMessage(hwndEdit,SCI_GETCHARAT,iPos,0);
+ if (StrChrA("()[]{}",c)) {
+ int iBrace2 = SendMessage(hwndEdit,SCI_BRACEMATCH,iPos,0);
+ if (iBrace2 != -1) {
+ int col1 = SendMessage(hwndEdit,SCI_GETCOLUMN,iPos,0);
+ int col2 = SendMessage(hwndEdit,SCI_GETCOLUMN,iBrace2,0);
+ SendMessage(hwndEdit,SCI_BRACEHIGHLIGHT,iPos,iBrace2);
+ SendMessage(hwndEdit,SCI_SETHIGHLIGHTGUIDE,min(col1,col2),0);
+ }
+ else {
+ SendMessage(hwndEdit,SCI_BRACEBADLIGHT,iPos,0);
+ SendMessage(hwndEdit,SCI_SETHIGHLIGHTGUIDE,0,0);
+ }
+ }
+ else {
+ SendMessage(hwndEdit,SCI_BRACEHIGHLIGHT,(WPARAM)-1,(LPARAM)-1);
+ SendMessage(hwndEdit,SCI_SETHIGHLIGHTGUIDE,0,0);
+ }
+ }
+ }
+ break;
+
+ case SCN_CHARADDED:
+ // Auto indent
+ if (bAutoIndent && (scn->ch == '\x0D' || scn->ch == '\x0A'))
+ {
+ // in CRLF mode handle LF only...
+ if ((SC_EOL_CRLF == iEOLMode && scn->ch != '\x0A') || SC_EOL_CRLF != iEOLMode)
+ {
+ char *pLineBuf;
+ char *pPos;
+ //int iIndentLen;
+
+ int iCurPos = SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0);
+ //int iAnchorPos = SendMessage(hwndEdit,SCI_GETANCHOR,0,0);
+ int iCurLine = SendMessage(hwndEdit,SCI_LINEFROMPOSITION,(WPARAM)iCurPos,0);
+ int iLineLength = SendMessage(hwndEdit,SCI_LINELENGTH,iCurLine,0);
+ //int iIndentBefore = SendMessage(hwndEdit,SCI_GETLINEINDENTATION,(WPARAM)iCurLine-1,0);
+
+ if (iCurLine > 0/* && iLineLength <= 2*/)
+ {
+ int iPrevLineLength = SendMessage(hwndEdit,SCI_LINELENGTH,iCurLine-1,0);
+ if (pLineBuf = GlobalAlloc(GPTR,iPrevLineLength+1))
+ {
+ SendMessage(hwndEdit,SCI_GETLINE,iCurLine-1,(LPARAM)pLineBuf);
+ *(pLineBuf+iPrevLineLength) = '\0';
+ for (pPos = pLineBuf; *pPos; pPos++) {
+ if (*pPos != ' ' && *pPos != '\t')
+ *pPos = '\0';
+ }
+ if (*pLineBuf) {
+ //int iPrevLineStartPos;
+ //int iPrevLineEndPos;
+ //int iPrevLineIndentPos;
+
+ SendMessage(hwndEdit,SCI_BEGINUNDOACTION,0,0);
+ SendMessage(hwndEdit,SCI_ADDTEXT,lstrlenA(pLineBuf),(LPARAM)pLineBuf);
+ SendMessage(hwndEdit,SCI_ENDUNDOACTION,0,0);
+
+ //iPrevLineStartPos = SendMessage(hwndEdit,SCI_POSITIONFROMLINE,(WPARAM)iCurLine-1,0);
+ //iPrevLineEndPos = SendMessage(hwndEdit,SCI_GETLINEENDPOSITION,(WPARAM)iCurLine-1,0);
+ //iPrevLineIndentPos = SendMessage(hwndEdit,SCI_GETLINEINDENTPOSITION,(WPARAM)iCurLine-1,0);
+
+ //if (iPrevLineEndPos == iPrevLineIndentPos) {
+ // SendMessage(hwndEdit,SCI_BEGINUNDOACTION,0,0);
+ // SendMessage(hwndEdit,SCI_SETTARGETSTART,(WPARAM)iPrevLineStartPos,0);
+ // SendMessage(hwndEdit,SCI_SETTARGETEND,(WPARAM)iPrevLineEndPos,0);
+ // SendMessage(hwndEdit,SCI_REPLACETARGET,0,(LPARAM)"");
+ // SendMessage(hwndEdit,SCI_ENDUNDOACTION,0,0);
+ //}
+ }
+ GlobalFree(pLineBuf);
+ //int iIndent = SendMessage(hwndEdit,SCI_GETLINEINDENTATION,(WPARAM)iCurLine,0);
+ //SendMessage(hwndEdit,SCI_SETLINEINDENTATION,(WPARAM)iCurLine,(LPARAM)iIndentBefore);
+ //iIndentLen = /*- iIndent +*/ SendMessage(hwndEdit,SCI_GETLINEINDENTATION,(WPARAM)iCurLine,0);
+ //if (iIndentLen > 0)
+ // SendMessage(hwndEdit,SCI_SETSEL,(WPARAM)iAnchorPos+iIndentLen,(LPARAM)iCurPos+iIndentLen);
+ }
+ }
+ }
+ }
+ // Auto close tags
+ else if (bAutoCloseTags && scn->ch == '>')
+ {
+ int iLexer = SendMessage(hwndEdit,SCI_GETLEXER,0,0);
+ if (/*iLexer == SCLEX_HTML || iLexer == SCLEX_XML*/ 1)
+ {
+ char tchBuf[512];
+ char tchIns[516] = "</";
+ int cchIns = 2;
+ int iCurPos = SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0);
+ int iHelper = iCurPos - (COUNTOF(tchBuf) - 1);
+ int iStartPos = max(0,iHelper);
+ int iSize = iCurPos - iStartPos;
+
+ if (iSize >= 3) {
+
+ struct TextRange tr = { { iStartPos, iCurPos }, tchBuf };
+ SendMessage(hwndEdit,SCI_GETTEXTRANGE,0,(LPARAM)&tr);
+
+ if (tchBuf[iSize - 2] != '/') {
+
+ const char* pBegin = &tchBuf[0];
+ const char* pCur = &tchBuf[iSize - 2];
+
+ while (pCur > pBegin && *pCur != '<' && *pCur != '>')
+ --pCur;
+
+ if (*pCur == '<') {
+ pCur++;
+ while (StrChrA(":_-.", *pCur) || IsCharAlphaNumericA(*pCur)) {
+ tchIns[cchIns++] = *pCur;
+ pCur++;
+ }
+ }
+
+ tchIns[cchIns++] = '>';
+ tchIns[cchIns] = 0;
+
+ if (cchIns > 3 &&
+ lstrcmpiA(tchIns,"</base>") &&
+ lstrcmpiA(tchIns,"</bgsound>") &&
+ lstrcmpiA(tchIns,"</br>") &&
+ lstrcmpiA(tchIns,"</embed>") &&
+ lstrcmpiA(tchIns,"</hr>") &&
+ lstrcmpiA(tchIns,"</img>") &&
+ lstrcmpiA(tchIns,"</input>") &&
+ lstrcmpiA(tchIns,"</link>") &&
+ lstrcmpiA(tchIns,"</meta>"))
+ {
+ SendMessage(hwndEdit,SCI_BEGINUNDOACTION,0,0);
+ SendMessage(hwndEdit,SCI_REPLACESEL,0,(LPARAM)tchIns);
+ SendMessage(hwndEdit,SCI_SETSEL,iCurPos,iCurPos);
+ SendMessage(hwndEdit,SCI_ENDUNDOACTION,0,0);
+ }
+ }
+ }
+ }
+ }
+ break;
+
+ case SCN_MODIFIED:
+ case SCN_ZOOM:
+ UpdateLineNumberWidth();
+ break;
+
+ case SCN_SAVEPOINTREACHED:
+ bModified = FALSE;
+ SetWindowTitle(hwnd,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile,
+ iPathNameFormat,bModified || iEncoding != iOriginalEncoding,
+ IDS_READONLY,bReadOnly,szTitleExcerpt);
+ break;
+
+ case SCN_SAVEPOINTLEFT:
+ bModified = TRUE;
+ SetWindowTitle(hwnd,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile,
+ iPathNameFormat,bModified || iEncoding != iOriginalEncoding,
+ IDS_READONLY,bReadOnly,szTitleExcerpt);
+ break;
+ }
+ break;
+
+
+ case IDC_TOOLBAR:
+
+ switch(pnmh->code)
+ {
+
+ case TBN_ENDADJUST:
+ UpdateToolbar();
+ break;
+
+ case TBN_QUERYDELETE:
+ case TBN_QUERYINSERT:
+ return TRUE;
+
+ case TBN_GETBUTTONINFO:
+ {
+ if (((LPTBNOTIFY)lParam)->iItem < COUNTOF(tbbMainWnd))
+ {
+ WCHAR tch[256];
+ GetString(tbbMainWnd[((LPTBNOTIFY)lParam)->iItem].idCommand,tch,COUNTOF(tch));
+ lstrcpyn(((LPTBNOTIFY)lParam)->pszText,/*StrChr(tch,L'\n')+1*/tch,((LPTBNOTIFY)lParam)->cchText);
+ CopyMemory(&((LPTBNOTIFY)lParam)->tbButton,&tbbMainWnd[((LPTBNOTIFY)lParam)->iItem],sizeof(TBBUTTON));
+ return TRUE;
+ }
+ }
+ return FALSE;
+
+ case TBN_RESET:
+ {
+ int i; int c = SendMessage(hwndToolbar,TB_BUTTONCOUNT,0,0);
+ for (i = 0; i < c; i++)
+ SendMessage(hwndToolbar,TB_DELETEBUTTON,0,0);
+ SendMessage(hwndToolbar,TB_ADDBUTTONS,NUMINITIALTOOLS,(LPARAM)tbbMainWnd);
+ return(0);
+ }
+
+ }
+ break;
+
+
+ case IDC_STATUSBAR:
+
+ switch(pnmh->code)
+ {
+
+ case NM_CLICK:
+ {
+ LPNMMOUSE pnmm = (LPNMMOUSE)lParam;
+
+ switch (pnmm->dwItemSpec)
+ {
+ case STATUS_EOLMODE:
+ SendMessage(hwndEdit,SCI_CONVERTEOLS,SendMessage(hwndEdit,SCI_GETEOLMODE,0,0),0);
+ return TRUE;
+
+ default:
+ return FALSE;
+ }
+ }
+
+ case NM_DBLCLK:
+ {
+ int i;
+ LPNMMOUSE pnmm = (LPNMMOUSE)lParam;
+
+ switch (pnmm->dwItemSpec)
+ {
+ case STATUS_CODEPAGE:
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_ENCODING_SELECT,1),0);
+ return TRUE;
+
+ case STATUS_EOLMODE:
+ if (iEOLMode == SC_EOL_CRLF)
+ i = IDM_LINEENDINGS_CRLF;
+ else if (iEOLMode == SC_EOL_LF)
+ i = IDM_LINEENDINGS_LF;
+ else
+ i = IDM_LINEENDINGS_CR;
+ i++;
+ if (i > IDM_LINEENDINGS_CR)
+ i = IDM_LINEENDINGS_CRLF;
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(i,1),0);
+ return TRUE;
+
+ case STATUS_LEXER:
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_VIEW_SCHEME,1),0);
+ return TRUE;
+
+ case STATUS_OVRMODE:
+ SendMessage(hwndEdit,SCI_EDITTOGGLEOVERTYPE,0,0);
+ return TRUE;
+
+ default:
+ return FALSE;
+ }
+ }
+ break;
+
+ }
+ break;
+
+
+ default:
+
+ switch(pnmh->code)
+ {
+
+ case TTN_NEEDTEXT:
+ {
+ WCHAR tch[256];
+
+ if (((LPTOOLTIPTEXT)lParam)->uFlags & TTF_IDISHWND)
+ {
+ ;
+ }
+
+ else
+ {
+ GetString(pnmh->idFrom,tch,COUNTOF(tch));
+ lstrcpyn(((LPTOOLTIPTEXT)lParam)->szText,/*StrChr(tch,L'\n')+1*/tch,80);
+ }
+ }
+ break;
+
+ }
+ break;
+
+ }
+
+
+ return(0);
+
+}
+
+
+//=============================================================================
+//
+// LoadSettings()
+//
+//
+void LoadSettings()
+{
+ WCHAR *pIniSection = LocalAlloc(LPTR,sizeof(WCHAR)*32*1024);
+ int cchIniSection = LocalSize(pIniSection)/sizeof(WCHAR);
+
+ LoadIniSection(L"Settings",pIniSection,cchIniSection);
+
+ bSaveSettings =
+ IniSectionGetInt(pIniSection,L"SaveSettings",1);
+ if (bSaveSettings) bSaveSettings = 1;
+
+ bSaveRecentFiles =
+ IniSectionGetInt(pIniSection,L"SaveRecentFiles",0);
+ if (bSaveRecentFiles) bSaveRecentFiles = 1;
+
+ bSaveFindReplace =
+ IniSectionGetInt(pIniSection,L"SaveFindReplace",0);
+ if (bSaveFindReplace) bSaveFindReplace = 1;
+
+ efrData.bFindClose = IniSectionGetInt(pIniSection,L"CloseFind",0);
+ if (efrData.bFindClose) efrData.bReplaceClose = TRUE;
+
+ efrData.bReplaceClose = IniSectionGetInt(pIniSection,L"CloseReplace",0);
+ if (efrData.bReplaceClose) efrData.bReplaceClose = TRUE;
+
+ efrData.bNoFindWrap = IniSectionGetInt(pIniSection,L"NoFindWrap",0);
+ if (efrData.bNoFindWrap) efrData.bNoFindWrap = TRUE;
+
+ if (!IniSectionGetString(pIniSection,L"OpenWithDir",L"",
+ tchOpenWithDir,COUNTOF(tchOpenWithDir)))
+ SHGetSpecialFolderPath(NULL,tchOpenWithDir,CSIDL_DESKTOP,TRUE);
+ else
+ PathAbsoluteFromApp(tchOpenWithDir,NULL,COUNTOF(tchOpenWithDir),TRUE);
+
+ if (!IniSectionGetString(pIniSection,L"Favorites",L"",
+ tchFavoritesDir,COUNTOF(tchFavoritesDir)))
+ SHGetFolderPath(NULL,CSIDL_PERSONAL,NULL,SHGFP_TYPE_CURRENT,tchFavoritesDir);
+ else
+ PathAbsoluteFromApp(tchFavoritesDir,NULL,COUNTOF(tchFavoritesDir),TRUE);
+
+ iPathNameFormat = IniSectionGetInt(pIniSection,L"PathNameFormat",0);
+ iPathNameFormat = max(min(iPathNameFormat,2),0);
+
+ fWordWrap = IniSectionGetInt(pIniSection,L"WordWrap",0);
+ if (fWordWrap) fWordWrap = 1;
+
+ iWordWrapMode = IniSectionGetInt(pIniSection,L"WordWrapMode",0);
+ iWordWrapMode = max(min(iWordWrapMode,1),0);
+
+ iWordWrapIndent = IniSectionGetInt(pIniSection,L"WordWrapIndent",0);
+ iWordWrapIndent = max(min(iWordWrapIndent,6),0);
+
+ iWordWrapSymbols = IniSectionGetInt(pIniSection,L"WordWrapSymbols",22);
+ iWordWrapSymbols = max(min(iWordWrapSymbols%10,2),0)+max(min((iWordWrapSymbols%100-iWordWrapSymbols%10)/10,2),0)*10;
+
+ bShowWordWrapSymbols = IniSectionGetInt(pIniSection,L"ShowWordWrapSymbols",0);
+ if (bShowWordWrapSymbols) bShowWordWrapSymbols = 1;
+
+ bMatchBraces = IniSectionGetInt(pIniSection,L"MatchBraces",1);
+ if (bMatchBraces) bMatchBraces = 1;
+
+ bAutoCloseTags = IniSectionGetInt(pIniSection,L"AutoCloseTags",0);
+ if (bAutoCloseTags) bAutoCloseTags = 1;
+
+ bHiliteCurrentLine = IniSectionGetInt(pIniSection,L"HighlightCurrentLine",0);
+ if (bHiliteCurrentLine) bHiliteCurrentLine = 1;
+
+ bAutoIndent = IniSectionGetInt(pIniSection,L"AutoIndent",1);
+ if (bAutoIndent) bAutoIndent = 1;
+
+ bShowIndentGuides = IniSectionGetInt(pIniSection,L"ShowIndentGuides",0);
+ if (bShowIndentGuides) bShowIndentGuides = 1;
+
+ bTabsAsSpaces = IniSectionGetInt(pIniSection,L"TabsAsSpaces",1);
+ if (bTabsAsSpaces) bTabsAsSpaces = 1;
+ bTabsAsSpacesG = bTabsAsSpaces;
+
+ bTabIndents = IniSectionGetInt(pIniSection,L"TabIndents",1);
+ if (bTabIndents) bTabIndents = 1;
+
+ iTabWidth = IniSectionGetInt(pIniSection,L"TabWidth",2);
+ iTabWidth = max(min(iTabWidth,256),1);
+ iTabWidthG = iTabWidth;
+
+ iIndentWidth = IniSectionGetInt(pIniSection,L"IndentWidth",0);
+ iIndentWidth = max(min(iIndentWidth,256),0);
+ iIndentWidthG = iIndentWidth;
+
+ bMarkLongLines = IniSectionGetInt(pIniSection,L"MarkLongLines",0);
+ if (bMarkLongLines) bMarkLongLines = 1;
+
+ iLongLinesLimit = IniSectionGetInt(pIniSection,L"LongLinesLimit",72);
+ iLongLinesLimit = max(min(iLongLinesLimit,4096),0);
+ iLongLinesLimitG = iLongLinesLimit;
+
+ iLongLineMode = IniSectionGetInt(pIniSection,L"LongLineMode",EDGE_LINE);
+ iLongLineMode = max(min(iLongLineMode,EDGE_BACKGROUND),EDGE_LINE);
+
+ bShowSelectionMargin = IniSectionGetInt(pIniSection,L"ShowSelectionMargin",0);
+ if (bShowSelectionMargin) bShowSelectionMargin = 1;
+
+ bShowLineNumbers = IniSectionGetInt(pIniSection,L"ShowLineNumbers",1);
+ if (bShowLineNumbers) bShowLineNumbers = 1;
+
+ bViewWhiteSpace = IniSectionGetInt(pIniSection,L"ViewWhiteSpace",0);
+ if (bViewWhiteSpace) bViewWhiteSpace = 1;
+
+ bViewEOLs = IniSectionGetInt(pIniSection,L"ViewEOLs",0);
+ if (bViewEOLs) bViewEOLs = 1;
+
+ iDefaultEncoding = IniSectionGetInt(pIniSection,L"DefaultEncoding",0);
+ iDefaultEncoding = Encoding_MapIniSetting(TRUE,iDefaultEncoding);
+ if (!Encoding_IsValid(iDefaultEncoding)) iDefaultEncoding = CPI_DEFAULT;
+
+ bSkipUnicodeDetection = IniSectionGetInt(pIniSection,L"SkipUnicodeDetection",0);
+ if (bSkipUnicodeDetection) bSkipUnicodeDetection = 1;
+
+ bLoadASCIIasUTF8 = IniSectionGetInt(pIniSection,L"LoadASCIIasUTF8",0);
+ if (bLoadASCIIasUTF8) bLoadASCIIasUTF8 = 1;
+
+ bNoEncodingTags = IniSectionGetInt(pIniSection,L"NoEncodingTags",0);
+ if (bNoEncodingTags) bNoEncodingTags = 1;
+
+ iDefaultEOLMode = IniSectionGetInt(pIniSection,L"DefaultEOLMode",0);
+ iDefaultEOLMode = max(min(iDefaultEOLMode,2),0);
+
+ bFixLineEndings = IniSectionGetInt(pIniSection,L"FixLineEndings",1);
+ if (bFixLineEndings) bFixLineEndings = 1;
+
+ bAutoStripBlanks = IniSectionGetInt(pIniSection,L"FixTrailingBlanks",0);
+ if (bAutoStripBlanks) bAutoStripBlanks = 1;
+
+ iPrintHeader = IniSectionGetInt(pIniSection,L"PrintHeader",1);
+ iPrintHeader = max(min(iPrintHeader,3),0);
+
+ iPrintFooter = IniSectionGetInt(pIniSection,L"PrintFooter",0);
+ iPrintFooter = max(min(iPrintFooter,1),0);
+
+ iPrintColor = IniSectionGetInt(pIniSection,L"PrintColorMode",3);
+ iPrintColor = max(min(iPrintColor,4),0);
+
+ iPrintZoom = IniSectionGetInt(pIniSection,L"PrintZoom",10)-10;
+ iPrintZoom = max(min(iPrintZoom,20),-10);
+
+ pagesetupMargin.left = IniSectionGetInt(pIniSection,L"PrintMarginLeft",-1);
+ pagesetupMargin.left = max(pagesetupMargin.left,-1);
+
+ pagesetupMargin.top = IniSectionGetInt(pIniSection,L"PrintMarginTop",-1);
+ pagesetupMargin.top = max(pagesetupMargin.top,-1);
+
+ pagesetupMargin.right = IniSectionGetInt(pIniSection,L"PrintMarginRight",-1);
+ pagesetupMargin.right = max(pagesetupMargin.right,-1);
+
+ pagesetupMargin.bottom = IniSectionGetInt(pIniSection,L"PrintMarginBottom",-1);
+ pagesetupMargin.bottom = max(pagesetupMargin.bottom,-1);
+
+ bSaveBeforeRunningTools = IniSectionGetInt(pIniSection,L"SaveBeforeRunningTools",0);
+ if (bSaveBeforeRunningTools) bSaveBeforeRunningTools = 1;
+
+ iFileWatchingMode = IniSectionGetInt(pIniSection,L"FileWatchingMode",0);
+ iFileWatchingMode = max(min(iFileWatchingMode,2),0);
+
+ bResetFileWatching = IniSectionGetInt(pIniSection,L"ResetFileWatching",1);
+ if (bResetFileWatching) bResetFileWatching = 1;
+
+ iEscFunction = IniSectionGetInt(pIniSection,L"EscFunction",0);
+ iEscFunction = max(min(iEscFunction,2),0);
+
+ bAlwaysOnTop = IniSectionGetInt(pIniSection,L"AlwaysOnTop",0);
+ if (bAlwaysOnTop) bAlwaysOnTop = 1;
+
+ bMinimizeToTray = IniSectionGetInt(pIniSection,L"MinimizeToTray",0);
+ if (bMinimizeToTray) bMinimizeToTray = 1;
+
+ bTransparentMode = IniSectionGetInt(pIniSection,L"TransparentMode",0);
+ if (bTransparentMode) bTransparentMode = 1;
+
+ // Check if SetLayeredWindowAttributes() is available
+ bTransparentModeAvailable =
+ (GetProcAddress(GetModuleHandle(L"User32"),"SetLayeredWindowAttributes") != NULL);
+
+ IniSectionGetString(pIniSection,L"ToolbarButtons",L"",
+ tchToolbarButtons,COUNTOF(tchToolbarButtons));
+
+ bShowToolbar = IniSectionGetInt(pIniSection,L"ShowToolbar",1);
+ if (bShowToolbar) bShowToolbar = 1;
+
+ bShowStatusbar = IniSectionGetInt(pIniSection,L"ShowStatusbar",1);
+ if (bShowStatusbar) bShowStatusbar = 1;
+
+ cxEncodingDlg = IniSectionGetInt(pIniSection,L"EncodingDlgSizeX",256);
+ cxEncodingDlg = max(cxEncodingDlg,0);
+
+ cyEncodingDlg = IniSectionGetInt(pIniSection,L"EncodingDlgSizeY",262);
+ cyEncodingDlg = max(cyEncodingDlg,0);
+
+ cxRecodeDlg = IniSectionGetInt(pIniSection,L"RecodeDlgSizeX",256);
+ cxRecodeDlg = max(cxRecodeDlg,0);
+
+ cyRecodeDlg = IniSectionGetInt(pIniSection,L"RecodeDlgSizeY",262);
+ cyRecodeDlg = max(cyRecodeDlg,0);
+
+ cxFileMRUDlg = IniSectionGetInt(pIniSection,L"FileMRUDlgSizeX",412);
+ cxFileMRUDlg = max(cxFileMRUDlg,0);
+
+ cyFileMRUDlg = IniSectionGetInt(pIniSection,L"FileMRUDlgSizeY",376);
+ cyFileMRUDlg = max(cyFileMRUDlg,0);
+
+ cxOpenWithDlg = IniSectionGetInt(pIniSection,L"OpenWithDlgSizeX",384);
+ cxOpenWithDlg = max(cxOpenWithDlg,0);
+
+ cyOpenWithDlg = IniSectionGetInt(pIniSection,L"OpenWithDlgSizeY",386);
+ cyOpenWithDlg = max(cyOpenWithDlg,0);
+
+ cxFavoritesDlg = IniSectionGetInt(pIniSection,L"FavoritesDlgSizeX",334);
+ cxFavoritesDlg = max(cxFavoritesDlg,0);
+
+ cyFavoritesDlg = IniSectionGetInt(pIniSection,L"FavoritesDlgSizeY",316);
+ cyFavoritesDlg = max(cyFavoritesDlg,0);
+
+ xFindReplaceDlg = IniSectionGetInt(pIniSection,L"FindReplaceDlgPosX",0);
+ yFindReplaceDlg = IniSectionGetInt(pIniSection,L"FindReplaceDlgPosY",0);
+
+ LoadIniSection(L"Settings2",pIniSection,cchIniSection);
+
+ bStickyWinPos = IniSectionGetInt(pIniSection,L"StickyWindowPosition",0);
+ if (bStickyWinPos) bStickyWinPos = 1;
+
+ IniSectionGetString(pIniSection,L"DefaultExtension",L"txt",
+ tchDefaultExtension,COUNTOF(tchDefaultExtension));
+ StrTrim(tchDefaultExtension,L" \t.\"");
+
+ IniSectionGetString(pIniSection,L"DefaultDirectory",L"",
+ tchDefaultDir,COUNTOF(tchDefaultDir));
+
+ ZeroMemory(tchFileDlgFilters,sizeof(WCHAR)*COUNTOF(tchFileDlgFilters));
+ IniSectionGetString(pIniSection,L"FileDlgFilters",L"",
+ tchFileDlgFilters,COUNTOF(tchFileDlgFilters)-2);
+
+ iFileCheckInverval = IniSectionGetInt(pIniSection,L"FileCheckInverval",2000);
+
+ LoadIniSection(L"Toolbar Images",pIniSection,cchIniSection);
+ IniSectionGetString(pIniSection,L"BitmapDefault",L"",
+ tchToolbarBitmap,COUNTOF(tchToolbarBitmap));
+ IniSectionGetString(pIniSection,L"BitmapHot",L"",
+ tchToolbarBitmapHot,COUNTOF(tchToolbarBitmap));
+ IniSectionGetString(pIniSection,L"BitmapDisabled",L"",
+ tchToolbarBitmapDisabled,COUNTOF(tchToolbarBitmap));
+
+ if (!flagPosParam /*|| bStickyWinPos*/) { // ignore window position if /p was specified
+
+ WCHAR tchPosX[32], tchPosY[32], tchSizeX[32], tchSizeY[32], tchMaximized[32];
+
+ int ResX = GetSystemMetrics(SM_CXSCREEN);
+ int ResY = GetSystemMetrics(SM_CYSCREEN);
+
+ wsprintf(tchPosX,L"%ix%i PosX",ResX,ResY);
+ wsprintf(tchPosY,L"%ix%i PosY",ResX,ResY);
+ wsprintf(tchSizeX,L"%ix%i SizeX",ResX,ResY);
+ wsprintf(tchSizeY,L"%ix%i SizeY",ResX,ResY);
+ wsprintf(tchMaximized,L"%ix%i Maximized",ResX,ResY);
+
+ LoadIniSection(L"Window",pIniSection,cchIniSection);
+
+ wi.x = IniSectionGetInt(pIniSection,tchPosX,CW_USEDEFAULT);
+ wi.y = IniSectionGetInt(pIniSection,tchPosY,CW_USEDEFAULT);
+ wi.cx = IniSectionGetInt(pIniSection,tchSizeX,CW_USEDEFAULT);
+ wi.cy = IniSectionGetInt(pIniSection,tchSizeY,CW_USEDEFAULT);
+ wi.max = IniSectionGetInt(pIniSection,tchMaximized,0);
+ if (wi.max) wi.max = 1;
+ }
+
+ LocalFree(pIniSection);
+
+ iDefaultCodePage = 0; {
+ int acp = GetACP();
+ if (acp == 932 || acp == 936 || acp == 949 || acp == 950 || acp == 1361)
+ iDefaultCodePage = acp;
+ }
+
+ {
+ CHARSETINFO ci;
+ if (TranslateCharsetInfo((DWORD*)iDefaultCodePage,&ci,TCI_SRCCODEPAGE))
+ iDefaultCharSet = ci.ciCharset;
+ else
+ iDefaultCharSet = ANSI_CHARSET;
+ }
+
+ // Scintilla Styles
+ Style_Load();
+
+}
+
+
+//=============================================================================
+//
+// SaveSettings()
+//
+//
+void SaveSettings(BOOL bSaveSettingsNow)
+{
+ WCHAR *pIniSection = NULL;
+ int cchIniSection = 0;
+
+ WCHAR wchTmp[MAX_PATH];
+
+ if (lstrlen(szIniFile) == 0)
+ return;
+
+ CreateIniFile();
+
+ if (!bSaveSettings && !bSaveSettingsNow) {
+ IniSetInt(L"Settings",L"SaveSettings",bSaveSettings);
+ return;
+ }
+
+ pIniSection = LocalAlloc(LPTR,sizeof(WCHAR)*32*1024);
+ cchIniSection = LocalSize(pIniSection)/sizeof(WCHAR);
+
+ IniSectionSetInt(pIniSection,L"SaveSettings",bSaveSettings);
+ IniSectionSetInt(pIniSection,L"SaveRecentFiles",bSaveRecentFiles);
+ IniSectionSetInt(pIniSection,L"SaveFindReplace",bSaveFindReplace);
+ IniSectionSetInt(pIniSection,L"CloseFind",efrData.bFindClose);
+ IniSectionSetInt(pIniSection,L"CloseReplace",efrData.bReplaceClose);
+ IniSectionSetInt(pIniSection,L"NoFindWrap",efrData.bNoFindWrap);
+ PathRelativeToApp(tchOpenWithDir,wchTmp,COUNTOF(wchTmp),FALSE,TRUE,flagPortableMyDocs);
+ IniSectionSetString(pIniSection,L"OpenWithDir",wchTmp);
+ PathRelativeToApp(tchFavoritesDir,wchTmp,COUNTOF(wchTmp),FALSE,TRUE,flagPortableMyDocs);
+ IniSectionSetString(pIniSection,L"Favorites",wchTmp);
+ IniSectionSetInt(pIniSection,L"PathNameFormat",iPathNameFormat);
+ IniSectionSetInt(pIniSection,L"WordWrap",fWordWrap);
+ IniSectionSetInt(pIniSection,L"WordWrapMode",iWordWrapMode);
+ IniSectionSetInt(pIniSection,L"WordWrapIndent",iWordWrapIndent);
+ IniSectionSetInt(pIniSection,L"WordWrapSymbols",iWordWrapSymbols);
+ IniSectionSetInt(pIniSection,L"ShowWordWrapSymbols",bShowWordWrapSymbols);
+ IniSectionSetInt(pIniSection,L"MatchBraces",bMatchBraces);
+ IniSectionSetInt(pIniSection,L"AutoCloseTags",bAutoCloseTags);
+ IniSectionSetInt(pIniSection,L"HighlightCurrentLine",bHiliteCurrentLine);
+ IniSectionSetInt(pIniSection,L"AutoIndent",bAutoIndent);
+ IniSectionSetInt(pIniSection,L"ShowIndentGuides",bShowIndentGuides);
+ IniSectionSetInt(pIniSection,L"TabsAsSpaces",bTabsAsSpacesG);
+ IniSectionSetInt(pIniSection,L"TabIndents",bTabIndents);
+ IniSectionSetInt(pIniSection,L"TabWidth",iTabWidthG);
+ IniSectionSetInt(pIniSection,L"IndentWidth",iIndentWidthG);
+ IniSectionSetInt(pIniSection,L"MarkLongLines",bMarkLongLines);
+ IniSectionSetInt(pIniSection,L"LongLinesLimit",iLongLinesLimitG);
+ IniSectionSetInt(pIniSection,L"LongLineMode",iLongLineMode);
+ IniSectionSetInt(pIniSection,L"ShowSelectionMargin",bShowSelectionMargin);
+ IniSectionSetInt(pIniSection,L"ShowLineNumbers",bShowLineNumbers);
+ IniSectionSetInt(pIniSection,L"ViewWhiteSpace",bViewWhiteSpace);
+ IniSectionSetInt(pIniSection,L"ViewEOLs",bViewEOLs);
+ IniSectionSetInt(pIniSection,L"DefaultEncoding",Encoding_MapIniSetting(FALSE,iDefaultEncoding));
+ IniSectionSetInt(pIniSection,L"SkipUnicodeDetection",bSkipUnicodeDetection);
+ IniSectionSetInt(pIniSection,L"LoadASCIIasUTF8",bLoadASCIIasUTF8);
+ IniSectionSetInt(pIniSection,L"NoEncodingTags",bNoEncodingTags);
+ IniSectionSetInt(pIniSection,L"DefaultEOLMode",iDefaultEOLMode);
+ IniSectionSetInt(pIniSection,L"FixLineEndings",bFixLineEndings);
+ IniSectionSetInt(pIniSection,L"FixTrailingBlanks",bAutoStripBlanks);
+ IniSectionSetInt(pIniSection,L"PrintHeader",iPrintHeader);
+ IniSectionSetInt(pIniSection,L"PrintFooter",iPrintFooter);
+ IniSectionSetInt(pIniSection,L"PrintColorMode",iPrintColor);
+ IniSectionSetInt(pIniSection,L"PrintZoom",iPrintZoom+10);
+ IniSectionSetInt(pIniSection,L"PrintMarginLeft",pagesetupMargin.left);
+ IniSectionSetInt(pIniSection,L"PrintMarginTop",pagesetupMargin.top);
+ IniSectionSetInt(pIniSection,L"PrintMarginRight",pagesetupMargin.right);
+ IniSectionSetInt(pIniSection,L"PrintMarginBottom",pagesetupMargin.bottom);
+ IniSectionSetInt(pIniSection,L"SaveBeforeRunningTools",bSaveBeforeRunningTools);
+ IniSectionSetInt(pIniSection,L"FileWatchingMode",iFileWatchingMode);
+ IniSectionSetInt(pIniSection,L"ResetFileWatching",bResetFileWatching);
+ IniSectionSetInt(pIniSection,L"EscFunction",iEscFunction);
+ IniSectionSetInt(pIniSection,L"AlwaysOnTop",bAlwaysOnTop);
+ IniSectionSetInt(pIniSection,L"MinimizeToTray",bMinimizeToTray);
+ IniSectionSetInt(pIniSection,L"TransparentMode",bTransparentMode);
+ Toolbar_GetButtons(hwndToolbar,IDT_FILE_NEW,tchToolbarButtons,COUNTOF(tchToolbarButtons));
+ IniSectionSetString(pIniSection,L"ToolbarButtons",tchToolbarButtons);
+ IniSectionSetInt(pIniSection,L"ShowToolbar",bShowToolbar);
+ IniSectionSetInt(pIniSection,L"ShowStatusbar",bShowStatusbar);
+ IniSectionSetInt(pIniSection,L"EncodingDlgSizeX",cxEncodingDlg);
+ IniSectionSetInt(pIniSection,L"EncodingDlgSizeY",cyEncodingDlg);
+ IniSectionSetInt(pIniSection,L"RecodeDlgSizeX",cxRecodeDlg);
+ IniSectionSetInt(pIniSection,L"RecodeDlgSizeY",cyRecodeDlg);
+ IniSectionSetInt(pIniSection,L"FileMRUDlgSizeX",cxFileMRUDlg);
+ IniSectionSetInt(pIniSection,L"FileMRUDlgSizeY",cyFileMRUDlg);
+ IniSectionSetInt(pIniSection,L"OpenWithDlgSizeX",cxOpenWithDlg);
+ IniSectionSetInt(pIniSection,L"OpenWithDlgSizeY",cyOpenWithDlg);
+ IniSectionSetInt(pIniSection,L"FavoritesDlgSizeX",cxFavoritesDlg);
+ IniSectionSetInt(pIniSection,L"FavoritesDlgSizeY",cyFavoritesDlg);
+ IniSectionSetInt(pIniSection,L"FindReplaceDlgPosX",xFindReplaceDlg);
+ IniSectionSetInt(pIniSection,L"FindReplaceDlgPosY",yFindReplaceDlg);
+
+ SaveIniSection(L"Settings",pIniSection);
+ LocalFree(pIniSection);
+
+ /*
+ SaveSettingsNow(): query Window Dimensions
+ */
+
+ if (bSaveSettingsNow)
+ {
+ WINDOWPLACEMENT wndpl;
+
+ // GetWindowPlacement
+ wndpl.length = sizeof(WINDOWPLACEMENT);
+ GetWindowPlacement(hwndMain,&wndpl);
+
+ wi.x = wndpl.rcNormalPosition.left;
+ wi.y = wndpl.rcNormalPosition.top;
+ wi.cx = wndpl.rcNormalPosition.right - wndpl.rcNormalPosition.left;
+ wi.cy = wndpl.rcNormalPosition.bottom - wndpl.rcNormalPosition.top;
+ wi.max = (IsZoomed(hwndMain) || (wndpl.flags & WPF_RESTORETOMAXIMIZED));
+ }
+
+ if (!IniGetInt(L"Settings2",L"StickyWindowPosition",0)) {
+
+ WCHAR tchPosX[32], tchPosY[32], tchSizeX[32], tchSizeY[32], tchMaximized[32];
+
+ int ResX = GetSystemMetrics(SM_CXSCREEN);
+ int ResY = GetSystemMetrics(SM_CYSCREEN);
+
+ wsprintf(tchPosX,L"%ix%i PosX",ResX,ResY);
+ wsprintf(tchPosY,L"%ix%i PosY",ResX,ResY);
+ wsprintf(tchSizeX,L"%ix%i SizeX",ResX,ResY);
+ wsprintf(tchSizeY,L"%ix%i SizeY",ResX,ResY);
+ wsprintf(tchMaximized,L"%ix%i Maximized",ResX,ResY);
+
+ IniSetInt(L"Window",tchPosX,wi.x);
+ IniSetInt(L"Window",tchPosY,wi.y);
+ IniSetInt(L"Window",tchSizeX,wi.cx);
+ IniSetInt(L"Window",tchSizeY,wi.cy);
+ IniSetInt(L"Window",tchMaximized,wi.max);
+ }
+
+ // Scintilla Styles
+ Style_Save();
+
+}
+
+
+//=============================================================================
+//
+// ParseCommandLine()
+//
+//
+void ParseCommandLine()
+{
+
+ LPWSTR lp1,lp2,lp3;
+ BOOL bContinue = TRUE;
+ BOOL bIsNotepadReplacement = FALSE;
+
+ LPWSTR lpCmdLine = GetCommandLine();
+
+ if (lstrlen(lpCmdLine) == 0)
+ return;
+
+ // Good old console can also send args separated by Tabs
+ StrTab2Space(lpCmdLine);
+
+ lp1 = LocalAlloc(LPTR,sizeof(WCHAR)*(lstrlen(lpCmdLine) + 1));
+ lp2 = LocalAlloc(LPTR,sizeof(WCHAR)*(lstrlen(lpCmdLine) + 1));
+ lp3 = LocalAlloc(LPTR,sizeof(WCHAR)*(lstrlen(lpCmdLine) + 1));
+
+ // Start with 2nd argument
+ ExtractFirstArgument(lpCmdLine,lp1,lp3);
+
+ while (bContinue && ExtractFirstArgument(lp3,lp1,lp2))
+ {
+
+ // options
+ if (lstrcmp(lp1,L"+") == 0)
+ flagMultiFileArg = 2;
+
+ else if (lstrcmp(lp1,L"-") == 0)
+ flagMultiFileArg = 1;
+
+ else if ((*lp1 == L'/') || (*lp1 == L'-'))
+ {
+
+ StrTrim(lp1,L"-/");
+
+ // Encoding
+ if (lstrcmpi(lp1,L"ANSI") == 0 || lstrcmpi(lp1,L"A") == 0 || lstrcmpi(lp1,L"MBCS") == 0)
+ flagSetEncoding = IDM_ENCODING_ANSI-IDM_ENCODING_ANSI + 1;
+ else if (lstrcmpi(lp1,L"UNICODE") == 0 || lstrcmpi(lp1,L"W") == 0)
+ flagSetEncoding = IDM_ENCODING_UNICODE-IDM_ENCODING_ANSI + 1;
+ else if (lstrcmpi(lp1,L"UNICODEBE") == 0 || lstrcmpi(lp1,L"UNICODE-BE") == 0)
+ flagSetEncoding = IDM_ENCODING_UNICODEREV-IDM_ENCODING_ANSI + 1;
+ else if (lstrcmpi(lp1,L"UTF8") == 0 || lstrcmpi(lp1,L"UTF-8") == 0)
+ flagSetEncoding = IDM_ENCODING_UTF8-IDM_ENCODING_ANSI + 1;
+ else if (lstrcmpi(lp1,L"UTF8SIG") == 0 || lstrcmpi(lp1,L"UTF-8SIG") == 0 ||
+ lstrcmpi(lp1,L"UTF8SIGNATURE") == 0 || lstrcmpi(lp1,L"UTF-8SIGNATURE") == 0 ||
+ lstrcmpi(lp1,L"UTF8-SIGNATURE") == 0 || lstrcmpi(lp1,L"UTF-8-SIGNATURE") == 0)
+ flagSetEncoding = IDM_ENCODING_UTF8SIGN-IDM_ENCODING_ANSI + 1;
+
+ // EOL Mode
+ else if (lstrcmpi(lp1,L"CRLF") == 0 || lstrcmpi(lp1,L"CR+LF") == 0)
+ flagSetEOLMode = IDM_LINEENDINGS_CRLF-IDM_LINEENDINGS_CRLF + 1;
+ else if (lstrcmpi(lp1,L"LF") == 0)
+ flagSetEOLMode = IDM_LINEENDINGS_LF-IDM_LINEENDINGS_CRLF + 1;
+ else if (lstrcmpi(lp1,L"CR") == 0)
+ flagSetEOLMode = IDM_LINEENDINGS_CR-IDM_LINEENDINGS_CRLF + 1;
+
+ else switch (*CharUpper(lp1))
+ {
+
+ case L'N':
+ flagReuseWindow = 0;
+ flagNoReuseWindow = 1;
+ if (*CharUpper(lp1+1) == L'S')
+ flagSingleFileInstance = 1;
+ else
+ flagSingleFileInstance = 0;
+ break;
+
+ case L'R':
+ flagReuseWindow = 1;
+ flagNoReuseWindow = 0;
+ if (*CharUpper(lp1+1) == L'S')
+ flagSingleFileInstance = 1;
+ else
+ flagSingleFileInstance = 0;
+ break;
+
+ case L'F':
+ if (*(lp1+1) == L'0' || *CharUpper(lp1+1) == L'O')
+ lstrcpy(szIniFile,L"*?");
+ else if (ExtractFirstArgument(lp2,lp1,lp2)) {
+ StrCpyN(szIniFile,lp1,COUNTOF(szIniFile));
+ TrimString(szIniFile);
+ PathUnquoteSpaces(szIniFile);
+ }
+ break;
+
+ case L'I':
+ flagStartAsTrayIcon = 1;
+ break;
+
+ case L'P':
+ if (StrCmpNI(lp1,L"POS:",4) == 0)
+ lp1 += 3;
+ else if (StrCmpNI(lp1,L"POS",3) == 0)
+ lp1 += 2;
+ else if (*(lp1+1) == L':')
+ lp1 += 1;
+ else if (bIsNotepadReplacement) {
+ if (*(lp1+1) == L'T')
+ ExtractFirstArgument(lp2,lp1,lp2);
+ break;
+ }
+ if (*(lp1+1) == L'0' || *CharUpper(lp1+1) == L'O') {
+ flagPosParam = 1;
+ flagDefaultPos = 1;
+ }
+ else if (*CharUpper(lp1+1) == L'D' || *CharUpper(lp1+1) == L'S') {
+ flagPosParam = 1;
+ flagDefaultPos = (StrChrI((lp1+1),L'L')) ? 3 : 2;
+ }
+ else if (StrChrI(L"FLTRBM",*(lp1+1))) {
+ WCHAR *p = (lp1+1);
+ flagPosParam = 1;
+ flagDefaultPos = 0;
+ while (*p) {
+ switch (*CharUpper(p)) {
+ case L'F':
+ flagDefaultPos &= ~(4|8|16|32);
+ flagDefaultPos |= 64;
+ break;
+ case L'L':
+ flagDefaultPos &= ~(8|64);
+ flagDefaultPos |= 4;
+ break;
+ case L'R':
+ flagDefaultPos &= ~(4|64);
+ flagDefaultPos |= 8;
+ break;
+ case L'T':
+ flagDefaultPos &= ~(32|64);
+ flagDefaultPos |= 16;
+ break;
+ case L'B':
+ flagDefaultPos &= ~(16|64);
+ flagDefaultPos |= 32;
+ break;
+ case L'M':
+ if (flagDefaultPos == 0)
+ flagDefaultPos |= 64;
+ flagDefaultPos |= 128;
+ break;
+ }
+ p = CharNext(p);
+ }
+ }
+ else if (ExtractFirstArgument(lp2,lp1,lp2)) {
+ int itok =
+ swscanf(lp1,L"%i,%i,%i,%i,%i",&wi.x,&wi.y,&wi.cx,&wi.cy,&wi.max);
+ if (itok == 4 || itok == 5) { // scan successful
+ flagPosParam = 1;
+ if (wi.cx < 1) wi.cx = CW_USEDEFAULT;
+ if (wi.cy < 1) wi.cy = CW_USEDEFAULT;
+ if (wi.max) wi.max = 1;
+ if (itok == 4) wi.max = 0;
+ }
+ }
+ break;
+
+ case L'T':
+ if (ExtractFirstArgument(lp2,lp1,lp2)) {
+ StrCpyN(szTitleExcerpt,lp1,COUNTOF(szTitleExcerpt));
+ fKeepTitleExcerpt = 1;
+ }
+ break;
+
+ case L'C':
+ flagNewFromClipboard = 1;
+ break;
+
+ case L'B':
+ flagPasteBoard = 1;
+ break;
+
+ case L'E':
+ if (ExtractFirstArgument(lp2,lp1,lp2)) {
+ if (lpEncodingArg)
+ LocalFree(lpEncodingArg);
+ lpEncodingArg = StrDup(lp1);
+ }
+ break;
+
+ case L'G':
+ if (ExtractFirstArgument(lp2,lp1,lp2)) {
+ int itok =
+ swscanf(lp1,L"%i,%i",&iInitialLine,&iInitialColumn);
+ if (itok == 1 || itok == 2) { // scan successful
+ flagJumpTo = 1;
+ }
+ }
+ break;
+
+ case L'M':
+ {
+ BOOL bFindUp = FALSE;
+ BOOL bRegex = FALSE;
+ BOOL bTransBS = FALSE;
+
+ if (StrChr(lp1,L'-'))
+ bFindUp = TRUE;
+ if (StrChr(lp1,L'R'))
+ bRegex = TRUE;
+ if (StrChr(lp1,L'B'))
+ bTransBS = TRUE;
+
+ if (ExtractFirstArgument(lp2,lp1,lp2)) {
+ if (lpMatchArg)
+ GlobalFree(lpMatchArg);
+ lpMatchArg = StrDup(lp1);
+ flagMatchText = 1;
+
+ if (bFindUp)
+ flagMatchText |= 2;
+
+ if (bRegex) {
+ flagMatchText &= ~8;
+ flagMatchText |= 4;
+ }
+
+ if (bTransBS) {
+ flagMatchText &= ~4;
+ flagMatchText |= 8;
+ }
+ }
+ }
+ break;
+
+ case L'Q':
+ flagQuietCreate = 1;
+ break;
+
+ case L'S':
+ if (ExtractFirstArgument(lp2,lp1,lp2)) {
+ if (lpSchemeArg)
+ LocalFree(lpSchemeArg);
+ lpSchemeArg = StrDup(lp1);
+ flagLexerSpecified = 1;
+ }
+ break;
+
+ case L'D':
+ if (lpSchemeArg) {
+ LocalFree(lpSchemeArg);
+ lpSchemeArg = NULL;
+ }
+ iInitialLexer = 0;
+ flagLexerSpecified = 1;
+ break;
+
+ case L'H':
+ if (lpSchemeArg) {
+ LocalFree(lpSchemeArg);
+ lpSchemeArg = NULL;
+ }
+ iInitialLexer = 1;
+ flagLexerSpecified = 1;
+ break;
+
+ case L'X':
+ if (lpSchemeArg) {
+ LocalFree(lpSchemeArg);
+ lpSchemeArg = NULL;
+ }
+ iInitialLexer = 2;
+ flagLexerSpecified = 1;
+ break;
+
+ case L'U':
+ flagRelaunchElevated = 1;
+ break;
+
+ case L'Z':
+ ExtractFirstArgument(lp2,lp1,lp2);
+ flagMultiFileArg = 1;
+ bIsNotepadReplacement = TRUE;
+ break;
+
+ case L'?':
+ flagDisplayHelp = 1;
+ break;
+
+ default:
+ break;
+
+ }
+
+ }
+
+ // pathname
+ else
+ {
+ LPWSTR lpFileBuf = LocalAlloc(LPTR,sizeof(WCHAR)*(lstrlen(lpCmdLine) + 1));
+
+ cchiFileList = lstrlen(lpCmdLine) - lstrlen(lp3);
+
+ if (lpFileArg)
+ GlobalFree(lpFileArg);
+
+ lpFileArg = GlobalAlloc(GPTR,sizeof(WCHAR)*(MAX_PATH+2)); // changed for ActivatePrevInst() needs
+ StrCpyN(lpFileArg,lp3,MAX_PATH);
+ StrTrim(lpFileArg,L" \"");
+
+ while (cFileList < 32 && ExtractFirstArgument(lp3,lpFileBuf,lp3)) {
+ PathQuoteSpaces(lpFileBuf);
+ lpFileList[cFileList++] = StrDup(lpFileBuf);
+ }
+
+ bContinue = FALSE;
+ LocalFree(lpFileBuf);
+ }
+
+ // Continue with next argument
+ if (bContinue)
+ lstrcpy(lp3,lp2);
+
+ }
+
+ LocalFree(lp1);
+ LocalFree(lp2);
+ LocalFree(lp3);
+
+}
+
+
+//=============================================================================
+//
+// LoadFlags()
+//
+//
+void LoadFlags()
+{
+ WCHAR *pIniSection = LocalAlloc(LPTR,sizeof(WCHAR)*32*1024);
+ int cchIniSection = LocalSize(pIniSection)/sizeof(WCHAR);
+
+ LoadIniSection(L"Settings2",pIniSection,cchIniSection);
+
+ if (!flagReuseWindow && !flagNoReuseWindow) {
+
+ if (!IniSectionGetInt(pIniSection,L"ReuseWindow",0))
+ flagNoReuseWindow = 1;
+
+ if (IniSectionGetInt(pIniSection,L"SingleFileInstance",0))
+ flagSingleFileInstance = 1;
+ }
+
+ if (flagMultiFileArg == 0) {
+ if (IniSectionGetInt(pIniSection,L"MultiFileArg",0))
+ flagMultiFileArg = 2;
+ }
+
+ if (IniSectionGetInt(pIniSection,L"RelativeFileMRU",1))
+ flagRelativeFileMRU = 1;
+
+ if (IniSectionGetInt(pIniSection,L"PortableMyDocs",flagRelativeFileMRU))
+ flagPortableMyDocs = 1;
+
+ if (IniSectionGetInt(pIniSection,L"NoFadeHidden",0))
+ flagNoFadeHidden = 1;
+
+ if (IniSectionGetInt(pIniSection,L"SimpleIndentGuides",0))
+ flagSimpleIndentGuides = 1;
+
+ if (IniSectionGetInt(pIniSection,L"NoHTMLGuess",0))
+ fNoHTMLGuess = 1;
+
+ if (IniSectionGetInt(pIniSection,L"NoCGIGuess",0))
+ fNoCGIGuess = 1;
+
+ if (IniSectionGetInt(pIniSection,L"NoFileVariables",0))
+ fNoFileVariables = 1;
+
+ IniSectionGetString(pIniSection,L"ShellAppUserModelID",L"(default)",
+ g_wchAppUserModelID,COUNTOF(g_wchAppUserModelID));
+
+ if (IniSectionGetInt(pIniSection,L"ShellUseSystemMRU",0))
+ flagUseSystemMRU = 1;
+
+ LocalFree(pIniSection);
+}
+
+
+//=============================================================================
+//
+// FindIniFile()
+//
+//
+int CheckIniFile(LPWSTR lpszFile,LPCWSTR lpszModule)
+{
+ WCHAR tchFileExpanded[MAX_PATH];
+ WCHAR tchBuild[MAX_PATH];
+ ExpandEnvironmentStrings(lpszFile,tchFileExpanded,COUNTOF(tchFileExpanded));
+
+ if (PathIsRelative(tchFileExpanded)) {
+ // program directory
+ lstrcpy(tchBuild,lpszModule);
+ lstrcpy(PathFindFileName(tchBuild),tchFileExpanded);
+ if (PathFileExists(tchBuild)) {
+ lstrcpy(lpszFile,tchBuild);
+ return(1);
+ }
+ // %appdata%
+ if (S_OK == SHGetFolderPath(NULL,CSIDL_APPDATA,NULL,SHGFP_TYPE_CURRENT,tchBuild)) {
+ PathAppend(tchBuild,tchFileExpanded);
+ if (PathFileExists(tchBuild)) {
+ lstrcpy(lpszFile,tchBuild);
+ return(1);
+ }
+ }
+ // general
+ if (SearchPath(NULL,tchFileExpanded,NULL,COUNTOF(tchBuild),tchBuild,NULL)) {
+ lstrcpy(lpszFile,tchBuild);
+ return(1);
+ }
+ }
+
+ else if (PathFileExists(tchFileExpanded)) {
+ lstrcpy(lpszFile,tchFileExpanded);
+ return(1);
+ }
+
+ return(0);
+}
+
+int CheckIniFileRedirect(LPWSTR lpszFile,LPCWSTR lpszModule)
+{
+ WCHAR tch[MAX_PATH];
+ if (GetPrivateProfileString(L"Notepad2",L"Notepad2.ini",L"",tch,COUNTOF(tch),lpszFile)) {
+ if (CheckIniFile(tch,lpszModule)) {
+ lstrcpy(lpszFile,tch);
+ return(1);
+ }
+ else {
+ WCHAR tchFileExpanded[MAX_PATH];
+ ExpandEnvironmentStrings(tch,tchFileExpanded,COUNTOF(tchFileExpanded));
+ if (PathIsRelative(tchFileExpanded)) {
+ lstrcpy(lpszFile,lpszModule);
+ lstrcpy(PathFindFileName(lpszFile),tchFileExpanded);
+ return(1);
+ }
+ else {
+ lstrcpy(lpszFile,tchFileExpanded);
+ return(1);
+ }
+ }
+ }
+ return(0);
+}
+
+int FindIniFile() {
+
+ int bFound = 0;
+ WCHAR tchTest[MAX_PATH];
+ WCHAR tchModule[MAX_PATH];
+ GetModuleFileName(NULL,tchModule,COUNTOF(tchModule));
+
+ if (lstrlen(szIniFile)) {
+ if (lstrcmpi(szIniFile,L"*?") == 0)
+ return(0);
+ else {
+ if (!CheckIniFile(szIniFile,tchModule)) {
+ ExpandEnvironmentStringsEx(szIniFile,COUNTOF(szIniFile));
+ if (PathIsRelative(szIniFile)) {
+ lstrcpy(tchTest,tchModule);
+ PathRemoveFileSpec(tchTest);
+ PathAppend(tchTest,szIniFile);
+ lstrcpy(szIniFile,tchTest);
+ }
+ }
+ }
+ return(1);
+ }
+
+ lstrcpy(tchTest,PathFindFileName(tchModule));
+ PathRenameExtension(tchTest,L".ini");
+ bFound = CheckIniFile(tchTest,tchModule);
+
+ if (!bFound) {
+ lstrcpy(tchTest,L"Notepad2.ini");
+ bFound = CheckIniFile(tchTest,tchModule);
+ }
+
+ if (bFound) {
+ // allow two redirections: administrator -> user -> custom
+ if (CheckIniFileRedirect(tchTest,tchModule))
+ CheckIniFileRedirect(tchTest,tchModule);
+ lstrcpy(szIniFile,tchTest);
+ }
+
+ else {
+ lstrcpy(szIniFile,tchModule);
+ PathRenameExtension(szIniFile,L".ini");
+ }
+
+ return(1);
+}
+
+
+int TestIniFile() {
+
+ if (lstrcmpi(szIniFile,L"*?") == 0) {
+ lstrcpy(szIniFile2,L"");
+ lstrcpy(szIniFile,L"");
+ return(0);
+ }
+
+ if (PathIsDirectory(szIniFile) || *CharPrev(szIniFile,StrEnd(szIniFile)) == L'\\') {
+ WCHAR wchModule[MAX_PATH];
+ GetModuleFileName(NULL,wchModule,COUNTOF(wchModule));
+ PathAppend(szIniFile,PathFindFileName(wchModule));
+ PathRenameExtension(szIniFile,L".ini");
+ if (!PathFileExists(szIniFile)) {
+ lstrcpy(PathFindFileName(szIniFile),L"Notepad2.ini");
+ if (!PathFileExists(szIniFile)) {
+ lstrcpy(PathFindFileName(szIniFile),PathFindFileName(wchModule));
+ PathRenameExtension(szIniFile,L".ini");
+ }
+ }
+ }
+
+ if (!PathFileExists(szIniFile) || PathIsDirectory(szIniFile)) {
+ lstrcpy(szIniFile2,szIniFile);
+ lstrcpy(szIniFile,L"");
+ return(0);
+ }
+ else
+ return(1);
+}
+
+
+int CreateIniFile() {
+
+ return(CreateIniFileEx(szIniFile));
+}
+
+
+int CreateIniFileEx(LPCWSTR lpszIniFile) {
+
+ if (*lpszIniFile) {
+
+ HANDLE hFile;
+ WCHAR *pwchTail;
+
+ if (pwchTail = StrRChrW(lpszIniFile,NULL,L'\\')) {
+ *pwchTail = 0;
+ SHCreateDirectoryEx(NULL,lpszIniFile,NULL);
+ *pwchTail = L'\\';
+ }
+
+ hFile = CreateFile(lpszIniFile,
+ GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,
+ NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
+ dwLastIOError = GetLastError();
+ if (hFile != INVALID_HANDLE_VALUE) {
+ if (GetFileSize(hFile,NULL) == 0) {
+ DWORD dw;
+ WriteFile(hFile,(LPCVOID)L"\xFEFF[Notepad2]\r\n",26,&dw,NULL);
+ }
+ CloseHandle(hFile);
+ return(1);
+ }
+ else
+ return(0);
+ }
+
+ else
+ return(0);
+}
+
+
+//=============================================================================
+//
+// UpdateToolbar()
+//
+//
+#define EnableTool(id,b) SendMessage(hwndToolbar,TB_ENABLEBUTTON,id, \
+ MAKELONG(((b) ? 1 : 0), 0))
+
+#define CheckTool(id,b) SendMessage(hwndToolbar,TB_CHECKBUTTON,id, \
+ MAKELONG(b,0))
+
+void UpdateToolbar()
+{
+
+ int i;
+
+ if (!bShowToolbar)
+ return;
+
+ EnableTool(IDT_FILE_ADDTOFAV,lstrlen(szCurFile));
+
+ EnableTool(IDT_EDIT_UNDO,SendMessage(hwndEdit,SCI_CANUNDO,0,0) /*&& !bReadOnly*/);
+ EnableTool(IDT_EDIT_REDO,SendMessage(hwndEdit,SCI_CANREDO,0,0) /*&& !bReadOnly*/);
+
+ i = SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0) - SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0);
+ EnableTool(IDT_EDIT_CUT,i /*&& !bReadOnly*/);
+ EnableTool(IDT_EDIT_COPY,SendMessage(hwndEdit,SCI_GETLENGTH,0,0));
+ EnableTool(IDT_EDIT_PASTE,SendMessage(hwndEdit,SCI_CANPASTE,0,0) /*&& !bReadOnly*/);
+
+ i = SendMessage(hwndEdit,SCI_GETLENGTH,0,0);
+ EnableTool(IDT_EDIT_FIND,i);
+ //EnableTool(IDT_EDIT_FINDNEXT,i);
+ //EnableTool(IDT_EDIT_FINDPREV,i && lstrlen(efrData.szFind));
+ EnableTool(IDT_EDIT_REPLACE,i /*&& !bReadOnly*/);
+ EnableTool(IDT_EDIT_CLEAR,i /*&& !bReadOnly*/);
+
+ CheckTool(IDT_VIEW_WORDWRAP,fWordWrap);
+
+}
+
+
+//=============================================================================
+//
+// UpdateStatusbar()
+//
+//
+void UpdateStatusbar()
+{
+
+ int iPos;
+ int iLn;
+ int iLines;
+ int iCol;
+ int iSel;
+ WCHAR tchLn[32];
+ WCHAR tchLines[32];
+ WCHAR tchCol[32];
+ WCHAR tchCols[32];
+ WCHAR tchSel[32];
+ WCHAR tchDocPos[256];
+
+ int iBytes;
+ WCHAR tchBytes[64];
+ WCHAR tchDocSize[256];
+
+ WCHAR tchEOLMode[32];
+ WCHAR tchOvrMode[32];
+ WCHAR tchLexerName[128];
+
+ if (!bShowStatusbar)
+ return;
+
+ iPos = SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0);
+
+ iLn = SendMessage(hwndEdit,SCI_LINEFROMPOSITION,iPos,0) + 1;
+ wsprintf(tchLn,L"%i",iLn);
+ FormatNumberStr(tchLn);
+
+ iLines = SendMessage(hwndEdit,SCI_GETLINECOUNT,0,0);
+ wsprintf(tchLines,L"%i",iLines);
+ FormatNumberStr(tchLines);
+
+ iCol = SendMessage(hwndEdit,SCI_GETCOLUMN,iPos,0) + 1;
+ wsprintf(tchCol,L"%i",iCol);
+ FormatNumberStr(tchCol);
+
+ if (bMarkLongLines) {
+ wsprintf(tchCols,L"%i",iLongLinesLimit);
+ FormatNumberStr(tchCols);
+ }
+
+ if (SC_SEL_RECTANGLE != SendMessage(hwndEdit,SCI_GETSELECTIONMODE,0,0))
+ {
+ iSel = SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0) - SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0);
+ wsprintf(tchSel,L"%i",iSel);
+ FormatNumberStr(tchSel);
+ }
+ else
+ lstrcpy(tchSel,L"--");
+
+ if (!bMarkLongLines)
+ FormatString(tchDocPos,COUNTOF(tchDocPos),IDS_DOCPOS,tchLn,tchLines,tchCol,tchSel);
+ else
+ FormatString(tchDocPos,COUNTOF(tchDocPos),IDS_DOCPOS2,tchLn,tchLines,tchCol,tchCols,tchSel);
+
+ iBytes = SendMessage(hwndEdit,SCI_GETLENGTH,0,0);
+ StrFormatByteSize(iBytes,tchBytes,COUNTOF(tchBytes));
+
+ FormatString(tchDocSize,COUNTOF(tchDocSize),IDS_DOCSIZE,tchBytes);
+
+ Encoding_GetLabel(iEncoding);
+
+ if (iEOLMode == SC_EOL_CR)
+ lstrcpy(tchEOLMode,L"CR");
+ else if (iEOLMode == SC_EOL_LF)
+ lstrcpy(tchEOLMode,L"LF");
+ else
+ lstrcpy(tchEOLMode,L"CR+LF");
+
+ if (SendMessage(hwndEdit,SCI_GETOVERTYPE,0,0))
+ lstrcpy(tchOvrMode,L"OVR");
+ else
+ lstrcpy(tchOvrMode,L"INS");
+
+ Style_GetCurrentLexerName(tchLexerName,COUNTOF(tchLexerName));
+
+ StatusSetText(hwndStatus,STATUS_DOCPOS,tchDocPos);
+ StatusSetText(hwndStatus,STATUS_DOCSIZE,tchDocSize);
+ StatusSetText(hwndStatus,STATUS_CODEPAGE,mEncoding[iEncoding].wchLabel);
+ StatusSetText(hwndStatus,STATUS_EOLMODE,tchEOLMode);
+ StatusSetText(hwndStatus,STATUS_OVRMODE,tchOvrMode);
+ StatusSetText(hwndStatus,STATUS_LEXER,tchLexerName);
+
+ //InvalidateRect(hwndStatus,NULL,TRUE);
+
+}
+
+
+//=============================================================================
+//
+// UpdateLineNumberWidth()
+//
+//
+void UpdateLineNumberWidth()
+{
+ char tchLines[32];
+ int iLineMarginWidthNow;
+ int iLineMarginWidthFit;
+
+ if (bShowLineNumbers) {
+
+ wsprintfA(tchLines,"_%i_",SendMessage(hwndEdit,SCI_GETLINECOUNT,0,0));
+
+ iLineMarginWidthNow = SendMessage(hwndEdit,SCI_GETMARGINWIDTHN,0,0);
+ iLineMarginWidthFit = SendMessage(hwndEdit,SCI_TEXTWIDTH,STYLE_LINENUMBER,(LPARAM)tchLines);
+
+ if (iLineMarginWidthNow != iLineMarginWidthFit) {
+ //SendMessage(hwndEdit,SCI_SETMARGINWIDTHN,0,0);
+ SendMessage(hwndEdit,SCI_SETMARGINWIDTHN,0,iLineMarginWidthFit);
+ }
+ }
+
+ else
+ SendMessage(hwndEdit,SCI_SETMARGINWIDTHN,0,0);
+}
+
+
+//=============================================================================
+//
+// FileIO()
+//
+//
+BOOL FileIO(BOOL fLoad,LPCWSTR psz,BOOL bNoEncDetect,int *ienc,int *ieol,
+ BOOL *pbUnicodeErr,BOOL *pbFileTooBig,
+ BOOL *pbCancelDataLoss,BOOL bSaveCopy)
+{
+ SHFILEINFO shfi;
+ WCHAR tch[MAX_PATH+40];
+ BOOL fSuccess;
+ DWORD dwFileAttributes;
+
+ BeginWaitCursor();
+
+ SHGetFileInfo2(psz,0,&shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME);
+ FormatString(tch,COUNTOF(tch),(fLoad) ? IDS_LOADFILE : IDS_SAVEFILE,shfi.szDisplayName);
+
+ StatusSetText(hwndStatus,STATUS_HELP,tch);
+ StatusSetSimple(hwndStatus,TRUE);
+
+ InvalidateRect(hwndStatus,NULL,TRUE);
+ UpdateWindow(hwndStatus);
+
+ if (fLoad)
+ fSuccess = EditLoadFile(hwndEdit,psz,bNoEncDetect,ienc,ieol,pbUnicodeErr,pbFileTooBig);
+ else
+ fSuccess = EditSaveFile(hwndEdit,psz,*ienc,pbCancelDataLoss,bSaveCopy);
+
+ dwFileAttributes = GetFileAttributes(psz);
+ bReadOnly = (dwFileAttributes != INVALID_FILE_ATTRIBUTES && dwFileAttributes & FILE_ATTRIBUTE_READONLY);
+
+ StatusSetSimple(hwndStatus,FALSE);
+
+ EndWaitCursor();
+
+ return(fSuccess);
+}
+
+
+//=============================================================================
+//
+// FileLoad()
+//
+//
+BOOL FileLoad(BOOL bDontSave,BOOL bNew,BOOL bReload,BOOL bNoEncDetect,LPCWSTR lpszFile)
+{
+ WCHAR tch[MAX_PATH] = L"";
+ WCHAR szFileName[MAX_PATH] = L"";
+ BOOL fSuccess;
+ BOOL bUnicodeErr = FALSE;
+ BOOL bFileTooBig = FALSE;
+
+ if (!bDontSave)
+ {
+ if (!FileSave(FALSE,TRUE,FALSE,FALSE))
+ return FALSE;
+ }
+
+ if (bNew) {
+ lstrcpy(szCurFile,L"");
+ SetDlgItemText(hwndMain,IDC_FILENAME,szCurFile);
+ SetDlgItemInt(hwndMain,IDC_REUSELOCK,GetTickCount(),FALSE);
+ if (!fKeepTitleExcerpt)
+ lstrcpy(szTitleExcerpt,L"");
+ FileVars_Init(NULL,0,&fvCurFile);
+ EditSetNewText(hwndEdit,"",0);
+ Style_SetLexer(hwndEdit,NULL);
+ UpdateLineNumberWidth();
+ bModified = FALSE;
+ bReadOnly = FALSE;
+ iEOLMode = iLineEndings[iDefaultEOLMode];
+ SendMessage(hwndEdit,SCI_SETEOLMODE,iLineEndings[iDefaultEOLMode],0);
+ iEncoding = iDefaultEncoding;
+ iOriginalEncoding = iDefaultEncoding;
+ SendMessage(hwndEdit,SCI_SETCODEPAGE,(iDefaultEncoding == CPI_DEFAULT) ? iDefaultCodePage : SC_CP_UTF8,0);
+ EditSetNewText(hwndEdit,"",0);
+ SetWindowTitle(hwndMain,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile,
+ iPathNameFormat,bModified || iEncoding != iOriginalEncoding,
+ IDS_READONLY,bReadOnly,szTitleExcerpt);
+
+ // Terminate file watching
+ if (bResetFileWatching)
+ iFileWatchingMode = 0;
+ InstallFileWatching(NULL);
+
+ return TRUE;
+ }
+
+ if (!lpszFile || lstrlen(lpszFile) == 0) {
+ if (!OpenFileDlg(hwndMain,tch,COUNTOF(tch),NULL))
+ return FALSE;
+ }
+
+ else
+ lstrcpy(tch,lpszFile);
+
+ ExpandEnvironmentStringsEx(tch,COUNTOF(tch));
+
+ if (PathIsRelative(tch)) {
+ GetCurrentDirectory(COUNTOF(szFileName),szFileName);
+ PathAppend(szFileName,tch);
+ if (!PathFileExists(szFileName)) {
+ WCHAR wchFullPath[MAX_PATH];
+ if (SearchPath(NULL,tch,NULL,COUNTOF(wchFullPath),wchFullPath,NULL)) {
+ lstrcpy(szFileName,wchFullPath);
+ }
+ }
+ }
+
+ else
+ lstrcpy(szFileName,tch);
+
+ PathCanonicalizeEx(szFileName);
+ GetLongPathNameEx(szFileName,szFileName,COUNTOF(szFileName));
+
+ if (PathIsLnkFile(szFileName))
+ PathGetLnkPath(szFileName,szFileName,COUNTOF(szFileName));
+
+ // Ask to create a new file...
+ if (!bReload && !PathFileExists(szFileName))
+ {
+ if (flagQuietCreate || MsgBox(MBYESNO,IDS_ASK_CREATE,szFileName) == IDYES) {
+ HANDLE hFile = CreateFile(szFileName,
+ GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,
+ NULL,CREATE_NEW,FILE_ATTRIBUTE_NORMAL,NULL);
+ dwLastIOError = GetLastError();
+ if (fSuccess = (hFile != INVALID_HANDLE_VALUE)) {
+ CloseHandle(hFile);
+ FileVars_Init(NULL,0,&fvCurFile);
+ EditSetNewText(hwndEdit,"",0);
+ Style_SetLexer(hwndEdit,NULL);
+ iEOLMode = iLineEndings[iDefaultEOLMode];
+ SendMessage(hwndEdit,SCI_SETEOLMODE,iLineEndings[iDefaultEOLMode],0);
+ if (iSrcEncoding != -1) {
+ iEncoding = iSrcEncoding;
+ iOriginalEncoding = iSrcEncoding;
+ }
+ else {
+ iEncoding = iDefaultEncoding;
+ iOriginalEncoding = iDefaultEncoding;
+ }
+ SendMessage(hwndEdit,SCI_SETCODEPAGE,(iEncoding == CPI_DEFAULT) ? iDefaultCodePage : SC_CP_UTF8,0);
+ bReadOnly = FALSE;
+ EditSetNewText(hwndEdit,"",0);
+ }
+ }
+ else
+ return FALSE;
+ }
+
+ else
+ fSuccess = FileIO(TRUE,szFileName,bNoEncDetect,&iEncoding,&iEOLMode,&bUnicodeErr,&bFileTooBig,NULL,FALSE);
+
+ if (fSuccess) {
+ lstrcpy(szCurFile,szFileName);
+ SetDlgItemText(hwndMain,IDC_FILENAME,szCurFile);
+ SetDlgItemInt(hwndMain,IDC_REUSELOCK,GetTickCount(),FALSE);
+ if (!fKeepTitleExcerpt)
+ lstrcpy(szTitleExcerpt,L"");
+ if (!flagLexerSpecified) // flag will be cleared
+ Style_SetLexerFromFile(hwndEdit,szCurFile);
+ UpdateLineNumberWidth();
+ iOriginalEncoding = iEncoding;
+ bModified = FALSE;
+ //bReadOnly = FALSE;
+ SendMessage(hwndEdit,SCI_SETEOLMODE,iEOLMode,0);
+ MRU_AddFile(pFileMRU,szFileName,flagRelativeFileMRU,flagPortableMyDocs);
+ if (flagUseSystemMRU)
+ SHAddToRecentDocs(SHARD_PATHW,szFileName);
+ SetWindowTitle(hwndMain,uidsAppTitle,fIsElevated,IDS_UNTITLED,szFileName,
+ iPathNameFormat,bModified || iEncoding != iOriginalEncoding,
+ IDS_READONLY,bReadOnly,szTitleExcerpt);
+
+ // Install watching of the current file
+ if (!bReload && bResetFileWatching)
+ iFileWatchingMode = 0;
+ InstallFileWatching(szCurFile);
+
+ // the .LOG feature ...
+ if (SendMessage(hwndEdit,SCI_GETLENGTH,0,0) >= 4) {
+ char tchLog[5] = "";
+ SendMessage(hwndEdit,SCI_GETTEXT,5,(LPARAM)tchLog);
+ if (lstrcmpiA(tchLog,".LOG") == 0) {
+ EditJumpTo(hwndEdit,-1,0);
+ SendMessage(hwndEdit,SCI_BEGINUNDOACTION,0,0);
+ SendMessage(hwndEdit,SCI_NEWLINE,0,0);
+ SendMessage(hwndMain,WM_COMMAND,MAKELONG(IDM_EDIT_INSERT_SHORTDATE,1),0);
+ SendMessage(hwndEdit,SCI_NEWLINE,0,0);
+ SendMessage(hwndEdit,SCI_ENDUNDOACTION,0,0);
+ EditJumpTo(hwndEdit,-1,0);
+ }
+ }
+
+ // Show warning: Unicode file loaded as ANSI
+ if (bUnicodeErr)
+ MsgBox(MBWARN,IDS_ERR_UNICODE);
+ }
+
+ else if (!bFileTooBig)
+ MsgBox(MBWARN,IDS_ERR_LOADFILE,szFileName);
+
+ return(fSuccess);
+}
+
+
+//=============================================================================
+//
+// FileSave()
+//
+//
+BOOL FileSave(BOOL bSaveAlways,BOOL bAsk,BOOL bSaveAs,BOOL bSaveCopy)
+{
+ WCHAR tchFile[MAX_PATH];
+ BOOL fSuccess = FALSE;
+ BOOL bCancelDataLoss = FALSE;
+
+ BOOL bIsEmptyNewFile = FALSE;
+ if (lstrlen(szCurFile) == 0) {
+ int cchText = SendMessage(hwndEdit,SCI_GETLENGTH,0,0);
+ if (cchText == 0)
+ bIsEmptyNewFile = TRUE;
+ else if (cchText < 1023) {
+ char tchText[2048];
+ SendMessage(hwndEdit,SCI_GETTEXT,(WPARAM)2047,(LPARAM)tchText);
+ StrTrimA(tchText," \t\n\r");
+ if (lstrlenA(tchText) == 0)
+ bIsEmptyNewFile = TRUE;
+ }
+ }
+
+ if (!bSaveAlways && (!bModified && iEncoding == iOriginalEncoding || bIsEmptyNewFile) && !bSaveAs)
+ return TRUE;
+
+ if (bAsk)
+ {
+ // File or "Untitled" ...
+ WCHAR tch[MAX_PATH];
+ if (lstrlen(szCurFile))
+ lstrcpy(tch,szCurFile);
+ else
+ GetString(IDS_UNTITLED,tch,COUNTOF(tch));
+
+ switch (MsgBox(MBYESNOCANCEL,IDS_ASK_SAVE,tch)) {
+ case IDCANCEL:
+ return FALSE;
+ case IDNO:
+ return TRUE;
+ }
+ }
+
+ // Read only...
+ if (!bSaveAs && !bSaveCopy && lstrlen(szCurFile))
+ {
+ DWORD dwFileAttributes = GetFileAttributes(szCurFile);
+ if (dwFileAttributes != INVALID_FILE_ATTRIBUTES)
+ bReadOnly = (dwFileAttributes & FILE_ATTRIBUTE_READONLY);
+ if (bReadOnly) {
+ SetWindowTitle(hwndMain,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile,
+ iPathNameFormat,bModified || iEncoding != iOriginalEncoding,
+ IDS_READONLY,bReadOnly,szTitleExcerpt);
+ if (MsgBox(MBYESNOWARN,IDS_READONLY_SAVE,szCurFile) == IDYES)
+ bSaveAs = TRUE;
+ else
+ return FALSE;
+ }
+ }
+
+ // Save As...
+ if (bSaveAs || bSaveCopy || lstrlen(szCurFile) == 0)
+ {
+ WCHAR tchInitialDir[MAX_PATH] = L"";
+ if (bSaveCopy && lstrlen(tchLastSaveCopyDir)) {
+ lstrcpy(tchInitialDir,tchLastSaveCopyDir);
+ lstrcpy(tchFile,tchLastSaveCopyDir);
+ PathAppend(tchFile,PathFindFileName(szCurFile));
+ }
+ else
+ lstrcpy(tchFile,szCurFile);
+
+ if (SaveFileDlg(hwndMain,tchFile,COUNTOF(tchFile),tchInitialDir))
+ {
+ if (fSuccess = FileIO(FALSE,tchFile,FALSE,&iEncoding,&iEOLMode,NULL,NULL,&bCancelDataLoss,bSaveCopy))
+ {
+ if (!bSaveCopy)
+ {
+ lstrcpy(szCurFile,tchFile);
+ SetDlgItemText(hwndMain,IDC_FILENAME,szCurFile);
+ SetDlgItemInt(hwndMain,IDC_REUSELOCK,GetTickCount(),FALSE);
+ if (!fKeepTitleExcerpt)
+ lstrcpy(szTitleExcerpt,L"");
+ Style_SetLexerFromFile(hwndEdit,szCurFile);
+ UpdateStatusbar();
+ UpdateLineNumberWidth();
+ }
+ else {
+ lstrcpy(tchLastSaveCopyDir,tchFile);
+ PathRemoveFileSpec(tchLastSaveCopyDir);
+ }
+ }
+ }
+ else
+ return FALSE;
+ }
+
+ else
+ fSuccess = FileIO(FALSE,szCurFile,FALSE,&iEncoding,&iEOLMode,NULL,NULL,&bCancelDataLoss,FALSE);
+
+ if (fSuccess)
+ {
+ if (!bSaveCopy)
+ {
+ bModified = FALSE;
+ iOriginalEncoding = iEncoding;
+ MRU_AddFile(pFileMRU,szCurFile,flagRelativeFileMRU,flagPortableMyDocs);
+ if (flagUseSystemMRU)
+ SHAddToRecentDocs(SHARD_PATHW,szCurFile);
+ SetWindowTitle(hwndMain,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile,
+ iPathNameFormat,bModified || iEncoding != iOriginalEncoding,
+ IDS_READONLY,bReadOnly,szTitleExcerpt);
+
+ // Install watching of the current file
+ if (bSaveAs && bResetFileWatching)
+ iFileWatchingMode = 0;
+ InstallFileWatching(szCurFile);
+ }
+ }
+
+ else if (!bCancelDataLoss)
+ {
+ if (lstrlen(szCurFile) != 0)
+ lstrcpy(tchFile,szCurFile);
+
+ SetWindowTitle(hwndMain,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile,
+ iPathNameFormat,bModified || iEncoding != iOriginalEncoding,
+ IDS_READONLY,bReadOnly,szTitleExcerpt);
+
+ MsgBox(MBWARN,IDS_ERR_SAVEFILE,tchFile);
+ }
+
+ return(fSuccess);
+}
+
+
+//=============================================================================
+//
+// OpenFileDlg()
+//
+//
+BOOL OpenFileDlg(HWND hwnd,LPWSTR lpstrFile,int cchFile,LPCWSTR lpstrInitialDir)
+{
+ OPENFILENAME ofn;
+ WCHAR szFile[MAX_PATH];
+ WCHAR szFilter[NUMLEXERS*1024];
+ WCHAR tchInitialDir[MAX_PATH];
+
+ lstrcpy(szFile,L"");
+ Style_GetOpenDlgFilterStr(szFilter,COUNTOF(szFilter));
+
+ if (!lpstrInitialDir) {
+ if (lstrlen(szCurFile)) {
+ lstrcpy(tchInitialDir,szCurFile);
+ PathRemoveFileSpec(tchInitialDir);
+ }
+ else if (lstrlen(tchDefaultDir)) {
+ ExpandEnvironmentStrings(tchDefaultDir,tchInitialDir,COUNTOF(tchInitialDir));
+ if (PathIsRelative(tchInitialDir)) {
+ WCHAR tchModule[MAX_PATH];
+ GetModuleFileName(NULL,tchModule,COUNTOF(tchModule));
+ PathRemoveFileSpec(tchModule);
+ PathAppend(tchModule,tchInitialDir);
+ PathCanonicalize(tchInitialDir,tchModule);
+ }
+ }
+ }
+
+ ZeroMemory(&ofn,sizeof(OPENFILENAME));
+ ofn.lStructSize = sizeof(OPENFILENAME);
+ ofn.hwndOwner = hwnd;
+ ofn.lpstrFilter = szFilter;
+ ofn.lpstrFile = szFile;
+ ofn.lpstrInitialDir = (lpstrInitialDir) ? lpstrInitialDir : tchInitialDir;
+ ofn.nMaxFile = COUNTOF(szFile);
+ ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | /* OFN_NOCHANGEDIR |*/
+ OFN_DONTADDTORECENT | OFN_PATHMUSTEXIST |
+ OFN_SHAREAWARE /*| OFN_NODEREFERENCELINKS*/;
+ ofn.lpstrDefExt = (lstrlen(tchDefaultExtension)) ? tchDefaultExtension : NULL;
+
+ if (GetOpenFileName(&ofn)) {
+ lstrcpyn(lpstrFile,szFile,cchFile);
+ return TRUE;
+ }
+
+ else
+ return FALSE;
+}
+
+
+//=============================================================================
+//
+// SaveFileDlg()
+//
+//
+BOOL SaveFileDlg(HWND hwnd,LPWSTR lpstrFile,int cchFile,LPCWSTR lpstrInitialDir)
+{
+ OPENFILENAME ofn;
+ WCHAR szNewFile[MAX_PATH];
+ WCHAR szFilter[NUMLEXERS*1024];
+ WCHAR tchInitialDir[MAX_PATH];
+
+ lstrcpy(szNewFile,lpstrFile);
+ Style_GetOpenDlgFilterStr(szFilter,COUNTOF(szFilter));
+
+ if (lstrlen(lpstrInitialDir))
+ lstrcpy(tchInitialDir,lpstrInitialDir);
+
+ else if (lstrlen(szCurFile)) {
+ lstrcpy(tchInitialDir,szCurFile);
+ PathRemoveFileSpec(tchInitialDir);
+ }
+ else if (lstrlen(tchDefaultDir)) {
+ ExpandEnvironmentStrings(tchDefaultDir,tchInitialDir,COUNTOF(tchInitialDir));
+ if (PathIsRelative(tchInitialDir)) {
+ WCHAR tchModule[MAX_PATH];
+ GetModuleFileName(NULL,tchModule,COUNTOF(tchModule));
+ PathRemoveFileSpec(tchModule);
+ PathAppend(tchModule,tchInitialDir);
+ PathCanonicalize(tchInitialDir,tchModule);
+ }
+ }
+
+ ZeroMemory(&ofn,sizeof(OPENFILENAME));
+ ofn.lStructSize = sizeof(OPENFILENAME);
+ ofn.hwndOwner = hwnd;
+ ofn.lpstrFilter = szFilter;
+ ofn.lpstrFile = szNewFile;
+ ofn.lpstrInitialDir = tchInitialDir;
+ ofn.nMaxFile = MAX_PATH;
+ ofn.Flags = OFN_HIDEREADONLY /*| OFN_NOCHANGEDIR*/ |
+ /*OFN_NODEREFERENCELINKS |*/ OFN_OVERWRITEPROMPT |
+ OFN_DONTADDTORECENT | OFN_PATHMUSTEXIST;
+ ofn.lpstrDefExt = (lstrlen(tchDefaultExtension)) ? tchDefaultExtension : NULL;
+
+ if (GetSaveFileName(&ofn)) {
+ lstrcpyn(lpstrFile,szNewFile,cchFile);
+ return TRUE;
+ }
+
+ else
+ return FALSE;
+}
+
+
+/******************************************************************************
+*
+* ActivatePrevInst()
+*
+* Tries to find and activate an already open Notepad2 Window
+*
+*
+******************************************************************************/
+BOOL CALLBACK EnumWndProc(HWND hwnd,LPARAM lParam)
+{
+ BOOL bContinue = TRUE;
+ WCHAR szClassName[64];
+
+ if (GetClassName(hwnd,szClassName,COUNTOF(szClassName)))
+
+ if (lstrcmpi(szClassName,wchWndClass) == 0) {
+
+ DWORD dwReuseLock = GetDlgItemInt(hwnd,IDC_REUSELOCK,NULL,FALSE);
+ if (GetTickCount() - dwReuseLock >= REUSEWINDOWLOCKTIMEOUT) {
+
+ *(HWND*)lParam = hwnd;
+
+ if (IsWindowEnabled(hwnd))
+ bContinue = FALSE;
+ }
+ }
+ return(bContinue);
+}
+
+BOOL CALLBACK EnumWndProc2(HWND hwnd,LPARAM lParam)
+{
+ BOOL bContinue = TRUE;
+ WCHAR szClassName[64];
+
+ if (GetClassName(hwnd,szClassName,COUNTOF(szClassName)))
+
+ if (lstrcmpi(szClassName,wchWndClass) == 0) {
+
+ DWORD dwReuseLock = GetDlgItemInt(hwnd,IDC_REUSELOCK,NULL,FALSE);
+ if (GetTickCount() - dwReuseLock >= REUSEWINDOWLOCKTIMEOUT) {
+
+ WCHAR tchFileName[MAX_PATH] = L"";
+
+ if (IsWindowEnabled(hwnd))
+ bContinue = FALSE;
+
+ GetDlgItemText(hwnd,IDC_FILENAME,tchFileName,COUNTOF(tchFileName));
+ if (lstrcmpi(tchFileName,lpFileArg) == 0)
+ *(HWND*)lParam = hwnd;
+ else
+ bContinue = TRUE;
+ }
+ }
+ return(bContinue);
+}
+
+BOOL ActivatePrevInst()
+{
+ HWND hwnd = NULL;
+ COPYDATASTRUCT cds;
+
+ if ((flagNoReuseWindow && !flagSingleFileInstance) || flagStartAsTrayIcon || flagNewFromClipboard || flagPasteBoard)
+ return(FALSE);
+
+ if (flagSingleFileInstance && lpFileArg) {
+
+ // Search working directory from second instance, first!
+ // lpFileArg is at least MAX_PATH+2 bytes
+ WCHAR tchTmp[MAX_PATH];
+
+ ExpandEnvironmentStringsEx(lpFileArg,GlobalSize(lpFileArg)/sizeof(WCHAR));
+
+ if (PathIsRelative(lpFileArg)) {
+ GetCurrentDirectory(COUNTOF(tchTmp),tchTmp);
+ PathAppend(tchTmp,lpFileArg);
+ if (PathFileExists(tchTmp))
+ lstrcpy(lpFileArg,tchTmp);
+ else {
+ if (SearchPath(NULL,lpFileArg,NULL,COUNTOF(tchTmp),tchTmp,NULL))
+ lstrcpy(lpFileArg,tchTmp);
+ else {
+ GetCurrentDirectory(COUNTOF(tchTmp),tchTmp);
+ PathAppend(tchTmp,lpFileArg);
+ lstrcpy(lpFileArg,tchTmp);
+ }
+ }
+ }
+
+ else if (SearchPath(NULL,lpFileArg,NULL,COUNTOF(tchTmp),tchTmp,NULL))
+ lstrcpy(lpFileArg,tchTmp);
+
+ GetLongPathName(lpFileArg,lpFileArg,MAX_PATH);
+
+ EnumWindows(EnumWndProc2,(LPARAM)&hwnd);
+
+ if (hwnd != NULL)
+ {
+ // Enabled
+ if (IsWindowEnabled(hwnd))
+ {
+ LPNP2PARAMS params;
+ DWORD cb = sizeof(NP2PARAMS);
+
+ // Make sure the previous window won't pop up a change notification message
+ //SendMessage(hwnd,WM_CHANGENOTIFYCLEAR,0,0);
+
+ if (IsIconic(hwnd))
+ ShowWindowAsync(hwnd,SW_RESTORE);
+
+ if (!IsWindowVisible(hwnd)) {
+ SendMessage(hwnd,WM_TRAYMESSAGE,0,WM_LBUTTONDBLCLK);
+ SendMessage(hwnd,WM_TRAYMESSAGE,0,WM_LBUTTONUP);
+ }
+
+ SetForegroundWindow(hwnd);
+
+ if (lpSchemeArg)
+ cb += (lstrlen(lpSchemeArg) + 1) * sizeof(WCHAR);
+
+ params = GlobalAlloc(GPTR,cb);
+ params->flagFileSpecified = FALSE;
+ params->flagQuietCreate = FALSE;
+ params->flagLexerSpecified = flagLexerSpecified;
+ if (flagLexerSpecified && lpSchemeArg) {
+ lstrcpy(StrEnd(¶ms->wchData)+1,lpSchemeArg);
+ params->iInitialLexer = -1;
+ }
+ else
+ params->iInitialLexer = iInitialLexer;
+ params->flagJumpTo = flagJumpTo;
+ params->iInitialLine = iInitialLine;
+ params->iInitialColumn = iInitialColumn;
+
+ params->iSrcEncoding = (lpEncodingArg) ? Encoding_MatchW(lpEncodingArg) : -1;
+ params->flagSetEncoding = flagSetEncoding;
+ params->flagSetEOLMode = flagSetEOLMode;
+ params->flagTitleExcerpt = 0;
+
+ cds.dwData = DATA_NOTEPAD2_PARAMS;
+ cds.cbData = GlobalSize(params);
+ cds.lpData = params;
+
+ SendMessage(hwnd,WM_COPYDATA,(WPARAM)NULL,(LPARAM)&cds);
+ GlobalFree(params);
+
+ return(TRUE);
+ }
+
+ else // IsWindowEnabled()
+ {
+ // Ask...
+ if (IDYES == MsgBox(MBYESNO,IDS_ERR_PREVWINDISABLED))
+ return(FALSE);
+ else
+ return(TRUE);
+ }
+ }
+ }
+
+ if (flagNoReuseWindow)
+ return(FALSE);
+
+ hwnd = NULL;
+ EnumWindows(EnumWndProc,(LPARAM)&hwnd);
+
+ // Found a window
+ if (hwnd != NULL)
+ {
+ // Enabled
+ if (IsWindowEnabled(hwnd))
+ {
+ // Make sure the previous window won't pop up a change notification message
+ //SendMessage(hwnd,WM_CHANGENOTIFYCLEAR,0,0);
+
+ if (IsIconic(hwnd))
+ ShowWindowAsync(hwnd,SW_RESTORE);
+
+ if (!IsWindowVisible(hwnd)) {
+ SendMessage(hwnd,WM_TRAYMESSAGE,0,WM_LBUTTONDBLCLK);
+ SendMessage(hwnd,WM_TRAYMESSAGE,0,WM_LBUTTONUP);
+ }
+
+ SetForegroundWindow(hwnd);
+
+ if (lpFileArg)
+ {
+ // Search working directory from second instance, first!
+ // lpFileArg is at least MAX_PATH+2 bytes
+ WCHAR tchTmp[MAX_PATH];
+ LPNP2PARAMS params;
+ DWORD cb = sizeof(NP2PARAMS);
+ int cchTitleExcerpt;
+
+ ExpandEnvironmentStringsEx(lpFileArg,GlobalSize(lpFileArg)/sizeof(WCHAR));
+
+ if (PathIsRelative(lpFileArg)) {
+ GetCurrentDirectory(COUNTOF(tchTmp),tchTmp);
+ PathAppend(tchTmp,lpFileArg);
+ if (PathFileExists(tchTmp))
+ lstrcpy(lpFileArg,tchTmp);
+ else {
+ if (SearchPath(NULL,lpFileArg,NULL,COUNTOF(tchTmp),tchTmp,NULL))
+ lstrcpy(lpFileArg,tchTmp);
+ }
+ }
+
+ else if (SearchPath(NULL,lpFileArg,NULL,COUNTOF(tchTmp),tchTmp,NULL))
+ lstrcpy(lpFileArg,tchTmp);
+
+ cb += (lstrlen(lpFileArg) + 1) * sizeof(WCHAR);
+
+ if (lpSchemeArg)
+ cb += (lstrlen(lpSchemeArg) + 1) * sizeof(WCHAR);
+
+ cchTitleExcerpt = lstrlen(szTitleExcerpt);
+ if (cchTitleExcerpt)
+ cb += (cchTitleExcerpt + 1) * sizeof(WCHAR);
+
+ params = GlobalAlloc(GPTR,cb);
+ params->flagFileSpecified = TRUE;
+ lstrcpy(¶ms->wchData,lpFileArg);
+ params->flagQuietCreate = flagQuietCreate;
+ params->flagLexerSpecified = flagLexerSpecified;
+ if (flagLexerSpecified && lpSchemeArg) {
+ lstrcpy(StrEnd(¶ms->wchData)+1,lpSchemeArg);
+ params->iInitialLexer = -1;
+ }
+ else
+ params->iInitialLexer = iInitialLexer;
+ params->flagJumpTo = flagJumpTo;
+ params->iInitialLine = iInitialLine;
+ params->iInitialColumn = iInitialColumn;
+
+ params->iSrcEncoding = (lpEncodingArg) ? Encoding_MatchW(lpEncodingArg) : -1;
+ params->flagSetEncoding = flagSetEncoding;
+ params->flagSetEOLMode = flagSetEOLMode;
+
+ if (cchTitleExcerpt) {
+ lstrcpy(StrEnd(¶ms->wchData)+1,szTitleExcerpt);
+ params->flagTitleExcerpt = 1;
+ }
+ else
+ params->flagTitleExcerpt = 0;
+
+ cds.dwData = DATA_NOTEPAD2_PARAMS;
+ cds.cbData = GlobalSize(params);
+ cds.lpData = params;
+
+ SendMessage(hwnd,WM_COPYDATA,(WPARAM)NULL,(LPARAM)&cds);
+ GlobalFree(params);
+ GlobalFree(lpFileArg);
+ }
+ return(TRUE);
+ }
+ else // IsWindowEnabled()
+ {
+ // Ask...
+ if (IDYES == MsgBox(MBYESNO,IDS_ERR_PREVWINDISABLED))
+ return(FALSE);
+ else
+ return(TRUE);
+ }
+ }
+ else
+ return(FALSE);
+}
+
+
+//=============================================================================
+//
+// RelaunchMultiInst()
+//
+//
+BOOL RelaunchMultiInst() {
+
+ if (flagMultiFileArg == 2 && cFileList > 1) {
+
+ int i;
+ STARTUPINFO si;
+ PROCESS_INFORMATION pi;
+
+ LPWSTR lpCmdLineNew = StrDup(GetCommandLine());
+ LPWSTR lp1 = LocalAlloc(LPTR,sizeof(WCHAR)*(lstrlen(lpCmdLineNew) + 1));
+ LPWSTR lp2 = LocalAlloc(LPTR,sizeof(WCHAR)*(lstrlen(lpCmdLineNew) + 1));
+
+ StrTab2Space(lpCmdLineNew);
+
+ for (i = 0; i < cFileList; i++) {
+
+ lstrcpy(lpCmdLineNew + cchiFileList,L" /n ");
+ lstrcat(lpCmdLineNew,lpFileList[i]);
+ LocalFree(lpFileList[i]);
+
+ ZeroMemory(&si,sizeof(STARTUPINFO));
+ si.cb = sizeof(STARTUPINFO);
+ ZeroMemory(&pi,sizeof(PROCESS_INFORMATION));
+
+ CreateProcess(NULL,lpCmdLineNew,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi);
+ }
+ LocalFree(lpCmdLineNew);
+ LocalFree(lp1);
+ LocalFree(lp2);
+ GlobalFree(lpFileArg);
+
+ return TRUE;
+ }
+
+ else {
+ int i;
+ for (i = 0; i < cFileList; i++)
+ LocalFree(lpFileList[i]);
+ return FALSE;
+ }
+}
+
+
+//=============================================================================
+//
+// RelaunchElevated()
+//
+//
+BOOL RelaunchElevated() {
+
+ if (!IsVista() || fIsElevated || !flagRelaunchElevated || flagDisplayHelp)
+ return(FALSE);
+
+ else {
+
+ LPWSTR lpCmdLine;
+ LPWSTR lpArg1, lpArg2;
+ STARTUPINFO si;
+ SHELLEXECUTEINFO sei;
+
+ si.cb = sizeof(STARTUPINFO);
+ GetStartupInfo(&si);
+
+ lpCmdLine = GetCommandLine();
+ lpArg1 = LocalAlloc(LPTR,sizeof(WCHAR)*(lstrlen(lpCmdLine) + 1));
+ lpArg2 = LocalAlloc(LPTR,sizeof(WCHAR)*(lstrlen(lpCmdLine) + 1));
+ ExtractFirstArgument(lpCmdLine,lpArg1,lpArg2);
+
+ if (lstrlen(lpArg1)) {
+
+ ZeroMemory(&sei,sizeof(SHELLEXECUTEINFO));
+ sei.cbSize = sizeof(SHELLEXECUTEINFO);
+ sei.fMask = SEE_MASK_FLAG_NO_UI | /*SEE_MASK_NOZONECHECKS*/0x00800000;
+ sei.hwnd = NULL;
+ sei.lpVerb = L"runas";
+ sei.lpFile = lpArg1;
+ sei.lpParameters = lpArg2;
+ sei.lpDirectory = NULL;
+ sei.nShow = si.wShowWindow;
+
+ ShellExecuteEx(&sei);
+ }
+
+ LocalFree(lpArg1);
+ LocalFree(lpArg2);
+
+ return(TRUE);
+ }
+}
+
+
+//=============================================================================
+//
+// ShowNotifyIcon()
+//
+//
+void ShowNotifyIcon(HWND hwnd,BOOL bAdd)
+{
+
+ static HICON hIcon;
+ NOTIFYICONDATA nid;
+
+ if (!hIcon)
+ hIcon = LoadImage(g_hInstance,MAKEINTRESOURCE(IDR_MAINWND),
+ IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
+
+ ZeroMemory(&nid,sizeof(NOTIFYICONDATA));
+ nid.cbSize = sizeof(NOTIFYICONDATA);
+ nid.hWnd = hwnd;
+ nid.uID = 0;
+ nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
+ nid.uCallbackMessage = WM_TRAYMESSAGE;
+ nid.hIcon = hIcon;
+ lstrcpy(nid.szTip,L"Notepad2");
+
+ if(bAdd)
+ Shell_NotifyIcon(NIM_ADD,&nid);
+ else
+ Shell_NotifyIcon(NIM_DELETE,&nid);
+
+}
+
+
+//=============================================================================
+//
+// SetNotifyIconTitle()
+//
+//
+void SetNotifyIconTitle(HWND hwnd)
+{
+
+ NOTIFYICONDATA nid;
+ SHFILEINFO shfi;
+ WCHAR tchTitle[128];
+ WCHAR tchFormat[32];
+
+ ZeroMemory(&nid,sizeof(NOTIFYICONDATA));
+ nid.cbSize = sizeof(NOTIFYICONDATA);
+ nid.hWnd = hwnd;
+ nid.uID = 0;
+ nid.uFlags = NIF_TIP;
+
+ if (lstrlen(szTitleExcerpt)) {
+ GetString(IDS_TITLEEXCERPT,tchFormat,COUNTOF(tchFormat));
+ wsprintf(tchTitle,tchFormat,szTitleExcerpt);
+ }
+
+ else if (lstrlen(szCurFile)) {
+ SHGetFileInfo2(szCurFile,0,&shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME);
+ PathCompactPathEx(tchTitle,shfi.szDisplayName,COUNTOF(tchTitle)-4,0);
+ }
+ else
+ GetString(IDS_UNTITLED,tchTitle,COUNTOF(tchTitle)-4);
+
+ if (bModified || iEncoding != iOriginalEncoding)
+ lstrcpy(nid.szTip,L"* ");
+ else
+ lstrcpy(nid.szTip,L"");
+ lstrcat(nid.szTip,tchTitle);
+
+ Shell_NotifyIcon(NIM_MODIFY,&nid);
+
+}
+
+
+//=============================================================================
+//
+// InstallFileWatching()
+//
+//
+void InstallFileWatching(LPCWSTR lpszFile)
+{
+
+ WCHAR tchDirectory[MAX_PATH];
+ HANDLE hFind;
+
+ // Terminate
+ if (!iFileWatchingMode || !lpszFile || lstrlen(lpszFile) == 0)
+ {
+ if (bRunningWatch)
+ {
+ FindCloseChangeNotification(hChangeHandle);
+ KillTimer(NULL,ID_WATCHTIMER);
+ bRunningWatch = FALSE;
+ //bPendingChangeNotify = FALSE;
+ }
+ return;
+ }
+
+ // Install
+ else
+ {
+ // Terminate previous watching
+ if (bRunningWatch) {
+ FindCloseChangeNotification(hChangeHandle);
+ //bPendingChangeNotify = FALSE;
+ }
+
+ // No previous watching installed, so launch the timer first
+ else
+ SetTimer(NULL,ID_WATCHTIMER,iFileCheckInverval,WatchTimerProc);
+
+ lstrcpy(tchDirectory,lpszFile);
+ PathRemoveFileSpec(tchDirectory);
+
+ // Save data of current file
+ hFind = FindFirstFile(szCurFile,&fdCurFile);
+ if (hFind != INVALID_HANDLE_VALUE)
+ FindClose(hFind);
+ else
+ ZeroMemory(&fdCurFile,sizeof(WIN32_FIND_DATA));
+
+ hChangeHandle = FindFirstChangeNotification(tchDirectory,FALSE,
+ FILE_NOTIFY_CHANGE_FILE_NAME | \
+ FILE_NOTIFY_CHANGE_DIR_NAME | \
+ FILE_NOTIFY_CHANGE_ATTRIBUTES | \
+ FILE_NOTIFY_CHANGE_SIZE | \
+ FILE_NOTIFY_CHANGE_LAST_WRITE);
+
+ bRunningWatch = TRUE;
+ //bPendingChangeNotify = FALSE;
+ }
+}
+
+
+//=============================================================================
+//
+// WatchTimerProc()
+//
+//
+void CALLBACK WatchTimerProc(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime)
+{
+ // Check Change Notification Handle
+ if (bRunningWatch && WAIT_OBJECT_0 == WaitForSingleObject(hChangeHandle,0))
+ {
+ // Check if the changes affect the current file
+ WIN32_FIND_DATA fdUpdated;
+ HANDLE hFind = FindFirstFile(szCurFile,&fdUpdated);
+ if (INVALID_HANDLE_VALUE != hFind)
+ FindClose(hFind);
+ else
+ // The current file has been removed
+ ZeroMemory(&fdUpdated,sizeof(WIN32_FIND_DATA));
+
+ // Check if the file has been changed
+ if (CompareFileTime(&fdCurFile.ftLastWriteTime,&fdUpdated.ftLastWriteTime) != 0 ||
+ fdCurFile.nFileSizeLow != fdUpdated.nFileSizeLow ||
+ fdCurFile.nFileSizeHigh != fdUpdated.nFileSizeHigh)
+ {
+ // Shutdown current watching and give control to main window
+ bRunningWatch = FALSE;
+ //bPendingChangeNotify = TRUE;
+ FindCloseChangeNotification(hChangeHandle);
+ KillTimer(NULL,ID_WATCHTIMER);
+ SendMessage(hwndMain,WM_CHANGENOTIFY,0,0);
+ }
+
+ else
+ FindNextChangeNotification(hChangeHandle);
+ }
+}
+
+
+//=============================================================================
+//
+// PasteBoardTimer()
+//
+//
+void CALLBACK PasteBoardTimer(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime)
+{
+ if (dwLastCopyTime > 0 && GetTickCount() - dwLastCopyTime > 200) {
+
+ if (SendMessage(hwndEdit,SCI_CANPASTE,0,0)) {
+
+ BOOL bAutoIndent2 = bAutoIndent;
+ bAutoIndent = 0;
+ EditJumpTo(hwndEdit,-1,0);
+ SendMessage(hwndEdit,SCI_BEGINUNDOACTION,0,0);
+ if (SendMessage(hwndEdit,SCI_GETLENGTH,0,0) > 0)
+ SendMessage(hwndEdit,SCI_NEWLINE,0,0);
+ SendMessage(hwndEdit,SCI_PASTE,0,0);
+ SendMessage(hwndEdit,SCI_NEWLINE,0,0);
+ SendMessage(hwndEdit,SCI_ENDUNDOACTION,0,0);
+ bAutoIndent = bAutoIndent2;
+ }
+
+ dwLastCopyTime = 0;
+ }
+}
+
+
+
+/// End of Notepad2.c \\\
diff --git a/src/Notepad2.h b/src/Notepad2.h new file mode 100644 index 0000000..e3f52c9 --- /dev/null +++ b/src/Notepad2.h @@ -0,0 +1,145 @@ +/******************************************************************************
+*
+*
+* Notepad2
+*
+* Notepad2.h
+* Global definitions and declarations
+*
+* See Readme.txt for more information about this source code.
+* Please send me your comments to this work.
+*
+* See License.txt for details about distribution and modification.
+*
+* (c) Florian Balmer 1996-2010
+* florian.balmer@gmail.com
+* http://www.flos-freeware.ch
+*
+*
+******************************************************************************/
+
+
+
+//==== Main Window ============================================================
+#define WC_NOTEPAD2 L"Notepad2"
+
+
+//==== Data Type for WM_COPYDATA ==============================================
+#define DATA_NOTEPAD2_PARAMS 0xFB09
+typedef struct np2params {
+
+ int flagFileSpecified;
+ int flagLexerSpecified;
+ int iInitialLexer;
+ int flagQuietCreate;
+ int flagJumpTo;
+ int iInitialLine;
+ int iInitialColumn;
+ int iSrcEncoding;
+ int flagSetEncoding;
+ int flagSetEOLMode;
+ int flagTitleExcerpt;
+ WCHAR wchData;
+
+} NP2PARAMS, *LPNP2PARAMS;
+
+
+//==== Toolbar Style ==========================================================
+#define WS_TOOLBAR (WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | \
+ TBSTYLE_TOOLTIPS | TBSTYLE_FLAT | TBSTYLE_ALTDRAG | \
+ TBSTYLE_LIST | CCS_NODIVIDER | CCS_NOPARENTALIGN | \
+ CCS_ADJUSTABLE)
+
+
+//==== ReBar Style ============================================================
+#define WS_REBAR (WS_CHILD | WS_CLIPCHILDREN | WS_BORDER | RBS_VARHEIGHT | \
+ RBS_BANDBORDERS | CCS_NODIVIDER | CCS_NOPARENTALIGN)
+
+
+//==== Ids ====================================================================
+#define IDC_STATUSBAR 0xFB00
+#define IDC_TOOLBAR 0xFB01
+#define IDC_REBAR 0xFB02
+#define IDC_EDIT 0xFB03
+#define IDC_EDITFRAME 0xFB04
+#define IDC_FILENAME 0xFB05
+#define IDC_REUSELOCK 0xFB06
+
+
+//==== Statusbar ==============================================================
+#define STATUS_DOCPOS 0
+#define STATUS_DOCSIZE 1
+#define STATUS_CODEPAGE 2
+#define STATUS_EOLMODE 3
+#define STATUS_OVRMODE 4
+#define STATUS_LEXER 5
+#define STATUS_HELP 255
+
+
+//==== Change Notifications ===================================================
+#define ID_WATCHTIMER 0xA000
+#define WM_CHANGENOTIFY WM_USER+1
+//#define WM_CHANGENOTIFYCLEAR WM_USER+2
+
+
+//==== Callback Message from System Tray ======================================
+#define WM_TRAYMESSAGE WM_USER
+
+
+//==== Paste Board Timer ======================================================
+#define ID_PASTEBOARDTIMER 0xA001
+
+
+//==== Reuse Window Lock Timeout ==============================================
+#define REUSEWINDOWLOCKTIMEOUT 1000
+
+
+//==== Function Declarations ==================================================
+BOOL InitApplication(HINSTANCE);
+HWND InitInstance(HINSTANCE,LPSTR,int);
+BOOL ActivatePrevInst();
+BOOL RelaunchMultiInst();
+BOOL RelaunchElevated();
+void ShowNotifyIcon(HWND,BOOL);
+void SetNotifyIconTitle(HWND);
+void InstallFileWatching(LPCWSTR);
+void CALLBACK WatchTimerProc(HWND,UINT,UINT_PTR,DWORD);
+void CALLBACK PasteBoardTimer(HWND,UINT,UINT_PTR,DWORD);
+
+
+void LoadSettings();
+void SaveSettings(BOOL);
+void ParseCommandLine();
+void LoadFlags();
+int CheckIniFile(LPWSTR,LPCWSTR);
+int CheckIniFileRedirect(LPWSTR,LPCWSTR);
+int FindIniFile();
+int TestIniFile();
+int CreateIniFile();
+int CreateIniFileEx(LPCWSTR);
+
+
+void UpdateStatusbar();
+void UpdateToolbar();
+void UpdateLineNumberWidth();
+
+
+BOOL FileIO(BOOL,LPCWSTR,BOOL,int*,int*,BOOL*,BOOL*,BOOL*,BOOL);
+BOOL FileLoad(BOOL,BOOL,BOOL,BOOL,LPCWSTR);
+BOOL FileSave(BOOL,BOOL,BOOL,BOOL);
+BOOL OpenFileDlg(HWND,LPWSTR,int,LPCWSTR);
+BOOL SaveFileDlg(HWND,LPWSTR,int,LPCWSTR);
+
+
+LRESULT CALLBACK MainWndProc(HWND,UINT,WPARAM,LPARAM);
+LRESULT MsgCreate(HWND,WPARAM,LPARAM);
+void CreateBars(HWND,HINSTANCE);
+void MsgThemeChanged(HWND,WPARAM,LPARAM);
+void MsgSize(HWND,WPARAM,LPARAM);
+void MsgInitMenu(HWND,WPARAM,LPARAM);
+LRESULT MsgCommand(HWND,WPARAM,LPARAM);
+LRESULT MsgNotify(HWND,WPARAM,LPARAM);
+
+
+
+/// End of Notepad2.h \\\
diff --git a/src/Notepad2.rc b/src/Notepad2.rc new file mode 100644 index 0000000..d57bfba --- /dev/null +++ b/src/Notepad2.rc @@ -0,0 +1,1896 @@ +// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "winres.h"
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDR_MAINWND ICON "..\\res\\Notepad2.ico"
+IDI_RUN ICON "..\\res\\Run.ico"
+IDI_STYLES ICON "..\\res\\Styles.ico"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Bitmap
+//
+
+IDR_MAINWND BITMAP "..\\res\\Toolbar.bmp"
+IDB_OPEN BITMAP "..\\res\\Open.bmp"
+IDB_NEXT BITMAP "..\\res\\Next.bmp"
+IDB_PREV BITMAP "..\\res\\Prev.bmp"
+IDB_PICK BITMAP "..\\res\\Pick.bmp"
+IDB_ENCODING BITMAP "..\\res\\Encoding.bmp"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Cursor
+//
+
+400 CURSOR "..\\Scintilla\\win32\\Margin.cur"
+IDC_COPY CURSOR "..\\res\\Copy.cur"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// RT_MANIFEST
+//
+
+IDR_RT_MANIFEST RT_MANIFEST "..\\res\\Notepad2.exe.manifest"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Menu
+//
+
+IDR_MAINWND MENU
+BEGIN
+ POPUP "&File"
+ BEGIN
+ MENUITEM "&New\tCtrl+N", IDM_FILE_NEW
+ MENUITEM "&Open...\tCtrl+O", IDM_FILE_OPEN
+ MENUITEM "Re&vert\tF5", IDM_FILE_REVERT
+ MENUITEM "&Save\tCtrl+S", IDM_FILE_SAVE
+ MENUITEM "Save &As...\tF6", IDM_FILE_SAVEAS
+ MENUITEM "Save &Copy...\tCtrl+F6", IDM_FILE_SAVECOPY
+ MENUITEM "&Read Only", IDM_FILE_READONLY
+ MENUITEM SEPARATOR
+ POPUP "&Launch"
+ BEGIN
+ MENUITEM "&New Window\tAlt+N", IDM_FILE_NEWWINDOW
+ MENUITEM "&Empty Window\tAlt+0", IDM_FILE_NEWWINDOW2
+ MENUITEM SEPARATOR
+ MENUITEM "Execute &Document\tCtrl+L", IDM_FILE_LAUNCH
+ MENUITEM "&Open with...\tAlt+L", IDM_FILE_OPENWITH
+ MENUITEM "&Command...\tCtrl+R", IDM_FILE_RUN
+ END
+ MENUITEM SEPARATOR
+ POPUP "&Encoding"
+ BEGIN
+ MENUITEM "&ANSI", IDM_ENCODING_ANSI
+ MENUITEM "&Unicode", IDM_ENCODING_UNICODE
+ MENUITEM "Unicode &Big Endian", IDM_ENCODING_UNICODEREV
+ MENUITEM "UTF-&8", IDM_ENCODING_UTF8
+ MENUITEM "UTF-8 with &Signature", IDM_ENCODING_UTF8SIGN
+ MENUITEM "&More...\tF9", IDM_ENCODING_SELECT
+ MENUITEM SEPARATOR
+ MENUITEM "&Recode...\tF8", IDM_ENCODING_RECODE
+ MENUITEM SEPARATOR
+ MENUITEM "&Default...", IDM_ENCODING_SETDEFAULT
+ END
+ POPUP "Line Endin&gs"
+ BEGIN
+ MENUITEM "&Windows (CR+LF)", IDM_LINEENDINGS_CRLF
+ MENUITEM "&Unix (LF)", IDM_LINEENDINGS_LF
+ MENUITEM "&Mac (CR)", IDM_LINEENDINGS_CR
+ MENUITEM SEPARATOR
+ MENUITEM "&Default...", IDM_LINEENDINGS_SETDEFAULT
+
+ END
+ MENUITEM SEPARATOR
+ MENUITEM "Page Se&tup...", IDM_FILE_PAGESETUP
+ MENUITEM "&Print...\tCtrl+P", IDM_FILE_PRINT
+ MENUITEM SEPARATOR
+ MENUITEM "Propert&ies...", IDM_FILE_PROPERTIES
+ MENUITEM "Create &Desktop Link", IDM_FILE_CREATELINK
+ MENUITEM SEPARATOR
+ POPUP "&Favorites"
+ BEGIN
+ MENUITEM "&Open Favorites...\tAlt+I", IDM_FILE_OPENFAV
+ MENUITEM "&Add Current File...\tAlt+K", IDM_FILE_ADDTOFAV
+ MENUITEM "&Manage...\tAlt+F9", IDM_FILE_MANAGEFAV
+ END
+ MENUITEM "Recent (&History)...\tAlt+H", IDM_FILE_RECENT
+ MENUITEM SEPARATOR
+ MENUITEM "E&xit\tAlt+F4", IDM_FILE_EXIT
+ END
+ POPUP "&Edit"
+ BEGIN
+ MENUITEM "&Undo\tCtrl+Z", IDM_EDIT_UNDO
+ MENUITEM "&Redo\tCtrl+Y", IDM_EDIT_REDO
+ MENUITEM SEPARATOR
+ MENUITEM "Cu&t\tCtrl+X", IDM_EDIT_CUT
+ MENUITEM "&Copy\tCtrl+C", IDM_EDIT_COPY
+ MENUITEM "Copy A&ll\tAlt+C", IDM_EDIT_COPYALL
+ MENUITEM "Copy &Add\tCtrl+E", IDM_EDIT_COPYADD
+ MENUITEM "&Paste\tCtrl+V", IDM_EDIT_PASTE
+ MENUITEM "S&wap\tCtrl+K", IDM_EDIT_SWAP
+ MENUITEM "Clear\tDel", IDM_EDIT_CLEAR
+ MENUITEM "Clear Clipboar&d", IDM_EDIT_CLEARCLIPBOARD
+ MENUITEM "&Select All\tCtrl+A", IDM_EDIT_SELECTALL
+ MENUITEM SEPARATOR
+ POPUP "L&ines"
+ BEGIN
+ MENUITEM "Move &Up\tCtrl+Shift+Up", IDM_EDIT_MOVELINEUP
+ MENUITEM "&Move Down\tCtrl+Shift+Down", IDM_EDIT_MOVELINEDOWN
+ MENUITEM SEPARATOR
+ MENUITEM "&Duplicate Line\tCtrl+D", IDM_EDIT_DUPLICATELINE
+ MENUITEM "&Cut Line\tCtrl+Shift+X", IDM_EDIT_CUTLINE
+ MENUITEM "C&opy Line\tCtrl+Shift+C", IDM_EDIT_COPYLINE
+ MENUITEM "D&elete Line\tCtrl+Shift+D", IDM_EDIT_DELETELINE
+ MENUITEM SEPARATOR
+ MENUITEM "Column &Wrap...\tCtrl+Shift+W", IDM_EDIT_COLUMNWRAP
+ MENUITEM "&Split Lines\tCtrl+I", IDM_EDIT_SPLITLINES
+ MENUITEM "&Join Lines\tCtrl+J", IDM_EDIT_JOINLINES
+ MENUITEM "Join &Paragraphs\tCtrl+Shift+J", IDM_EDIT_JOINLINESEX
+ END
+ POPUP "&Block"
+ BEGIN
+ MENUITEM "&Indent\tTab", IDM_EDIT_INDENT
+ MENUITEM "&Unindent\tShift+Tab", IDM_EDIT_UNINDENT
+ MENUITEM SEPARATOR
+ MENUITEM "&Enclose Selection...\tAlt+Q",
+ IDM_EDIT_ENCLOSESELECTION
+
+ MENUITEM "&Duplicate Selection\tAlt+D", IDM_EDIT_SELECTIONDUPLICATE
+
+ MENUITEM SEPARATOR
+ MENUITEM "&Pad With Spaces\tAlt+B", IDM_EDIT_PADWITHSPACES
+ MENUITEM "Strip &First Character\tAlt+Z", IDM_EDIT_STRIP1STCHAR
+ MENUITEM "Strip &Last Character\tAlt+U", IDM_EDIT_STRIPLASTCHAR
+ MENUITEM "Strip &Trailing Blanks\tAlt+W", IDM_EDIT_TRIMLINES
+ MENUITEM "Compress &Whitespace\tAlt+P", IDM_EDIT_COMPRESSWS
+ MENUITEM "&Remove Blank Lines\tAlt+R", IDM_EDIT_REMOVEBLANKLINES
+
+ MENUITEM SEPARATOR
+ MENUITEM "&Modify Lines...\tAlt+M", IDM_EDIT_MODIFYLINES
+ MENUITEM "S&ort Lines...\tAlt+O", IDM_EDIT_SORTLINES
+ END
+ POPUP "C&onvert"
+ BEGIN
+ MENUITEM "&Uppercase\tCtrl+Shift+U", IDM_EDIT_CONVERTUPPERCASE
+
+ MENUITEM "&Lowercase\tCtrl+U", IDM_EDIT_CONVERTLOWERCASE
+
+ MENUITEM SEPARATOR
+ MENUITEM "&Invert Case\tCtrl+Alt+U", IDM_EDIT_INVERTCASE
+ MENUITEM "Title &Case\tCtrl+Alt+I", IDM_EDIT_TITLECASE
+ MENUITEM "&Sentence Case\tCtrl+Alt+O", IDM_EDIT_SENTENCECASE
+ MENUITEM SEPARATOR
+ MENUITEM "&Tabify Selection\tCtrl+Shift+T",
+ IDM_EDIT_CONVERTSPACES
+ MENUITEM "U&ntabify Selection\tCtrl+Shift+S",
+ IDM_EDIT_CONVERTTABS
+ MENUITEM SEPARATOR
+ MENUITEM "Ta&bify Indent\tCtrl+Alt+T", IDM_EDIT_CONVERTSPACES2
+ MENUITEM "Untabi&fy Indent\tCtrl+Alt+S", IDM_EDIT_CONVERTTABS2
+ END
+ POPUP "I&nsert"
+ BEGIN
+ MENUITEM "&HTML/XML Tag...\tAlt+X", IDM_EDIT_INSERT_TAG
+ MENUITEM SEPARATOR
+ MENUITEM "&Encoding Identifier\tCtrl+F8",
+ IDM_EDIT_INSERT_ENCODING
+ MENUITEM SEPARATOR
+ MENUITEM "Time/Date (&Short Form)\tCtrl+F5",
+ IDM_EDIT_INSERT_SHORTDATE
+
+ MENUITEM "Time/Date (&Long Form)\tCtrl+Shift+F5",
+ IDM_EDIT_INSERT_LONGDATE
+ MENUITEM SEPARATOR
+ MENUITEM "&Filename\tCtrl+F9", IDM_EDIT_INSERT_FILENAME
+ MENUITEM "&Path and Filename\tCtrl+Shift+F9",
+ IDM_EDIT_INSERT_PATHNAME
+ END
+ POPUP "Spec&ial"
+ BEGIN
+ MENUITEM "Line Comment (&Toggle)\tCtrl+Q", IDM_EDIT_LINECOMMENT
+ MENUITEM "Stream &Comment\tCtrl+Shift+Q", IDM_EDIT_STREAMCOMMENT
+ MENUITEM SEPARATOR
+ MENUITEM "URL &Encode\tCtrl+Shift+E", IDM_EDIT_URLENCODE
+ MENUITEM "URL &Decode\tCtrl+Shift+R", IDM_EDIT_URLDECODE
+ MENUITEM SEPARATOR
+ MENUITEM "Esca&pe C Chars\tCtrl+Alt+E", IDM_EDIT_ESCAPECCHARS
+ MENUITEM "&Unescape C Chars\tCtrl+Alt+U",
+ IDM_EDIT_UNESCAPECCHARS
+ MENUITEM SEPARATOR
+ MENUITEM "&Find Matching Brace\tCtrl+B",
+ IDM_EDIT_FINDMATCHINGBRACE
+
+ MENUITEM "&Select To Matching Brace\tCtrl+Shift+B",
+ IDM_EDIT_SELTOMATCHINGBRACE
+
+ END
+ MENUITEM SEPARATOR
+ MENUITEM "&Find...\tCtrl+F", IDM_EDIT_FIND
+ MENUITEM "Sa&ve Find Text\tAlt+F3", IDM_EDIT_SAVEFIND
+ MENUITEM "Find Ne&xt\tF3", IDM_EDIT_FINDNEXT
+ MENUITEM "Find Pre&vious\tShift+F3", IDM_EDIT_FINDPREV
+ MENUITEM "Select To Ne&xt\tF2", IDM_EDIT_SELTONEXT
+ MENUITEM "R&eplace...\tCtrl+H", IDM_EDIT_REPLACE
+ MENUITEM "&Goto...\tCtrl+G", IDM_EDIT_GOTOLINE
+ END
+ POPUP "&View"
+ BEGIN
+ MENUITEM "&Syntax Scheme...\tF12", IDM_VIEW_SCHEME
+ MENUITEM "&2nd Default Scheme\tShift+F12", IDM_VIEW_USE2NDDEFAULT
+ MENUITEM "&Customize Schemes...\tCtrl+F12", IDM_VIEW_SCHEMECONFIG
+ MENUITEM "&Default Font...\tAlt+F12", IDM_VIEW_FONT
+ MENUITEM SEPARATOR
+ MENUITEM "Word W&rap\tCtrl+W", IDM_VIEW_WORDWRAP
+ MENUITEM "&Long Line Marker\tCtrl+Shift+L", IDM_VIEW_LONGLINEMARKER
+ MENUITEM "Indentation &Guides\tCtrl+Shift+G",
+ IDM_VIEW_SHOWINDENTGUIDES
+ MENUITEM SEPARATOR
+ MENUITEM "Show &Whitespace\tCtrl+Shift+8", IDM_VIEW_SHOWWHITESPACE
+ MENUITEM "Show Line &Endings\tCtrl+Shift+9", IDM_VIEW_SHOWEOLS
+ MENUITEM "Show Wrap S&ymbols\tCtrl+Shift+0",
+ IDM_VIEW_WORDWRAPSYMBOLS
+ MENUITEM SEPARATOR
+ MENUITEM "Visual &Brace Matching\tCtrl+Shift+V",
+ IDM_VIEW_MATCHBRACES
+ MENUITEM "Highlight C&urrent Line\tCtrl+Shift+I",
+ IDM_VIEW_HILITECURRENTLINE
+ MENUITEM SEPARATOR
+ MENUITEM "Line &Numbers\tCtrl+Shift+N", IDM_VIEW_LINENUMBERS
+ MENUITEM "Selection &Margin\tCtrl+Shift+M", IDM_VIEW_MARGIN
+ MENUITEM SEPARATOR
+ MENUITEM "Zoom &In\tCtrl++", IDM_VIEW_ZOOMIN
+ MENUITEM "Zoom &Out\tCtrl+-", IDM_VIEW_ZOOMOUT
+ MENUITEM "Reset &Zoom\tCtrl+/", IDM_VIEW_RESETZOOM
+ END
+ POPUP "&Settings"
+ BEGIN
+ MENUITEM "Insert Tabs as &Spaces", IDM_VIEW_TABSASSPACES
+ MENUITEM "&Tab Settings...\tCtrl+T", IDM_VIEW_TABSETTINGS
+ MENUITEM "&Word Wrap Settings...", IDM_VIEW_WORDWRAPSETTINGS
+ MENUITEM "&Long Line Settings...", IDM_VIEW_LONGLINESETTINGS
+ MENUITEM "Auto In&dent Text", IDM_VIEW_AUTOINDENTTEXT
+ MENUITEM "Auto Close &HTML/XML\tCtrl+Shift+H",
+ IDM_VIEW_AUTOCLOSETAGS
+ MENUITEM SEPARATOR
+ MENUITEM "&Reuse Window", IDM_VIEW_REUSEWINDOW
+ MENUITEM "Sticky Window &Position", IDM_VIEW_STICKYWINPOS
+ MENUITEM "&Always On Top\tAlt+T", IDM_VIEW_ALWAYSONTOP
+ MENUITEM "Minimi&ze To Tray", IDM_VIEW_MINTOTRAY
+ MENUITEM "Transparent &Mode\tCtrl+0", IDM_VIEW_TRANSPARENT
+ MENUITEM SEPARATOR
+ MENUITEM "Single &File Instance", IDM_VIEW_SINGLEFILEINSTANCE
+ MENUITEM "File &Change Notification...\tAlt+F5",
+ IDM_VIEW_CHANGENOTIFY
+ POPUP "Window Title Displa&y"
+ BEGIN
+ MENUITEM "Filename &Only", IDM_VIEW_SHOWFILENAMEONLY
+
+ MENUITEM "Filename and &Directory", IDM_VIEW_SHOWFILENAMEFIRST
+
+ MENUITEM "Full &Pathname", IDM_VIEW_SHOWFULLPATH
+ MENUITEM "&Text Excerpt\tCtrl+9", IDM_VIEW_SHOWEXCERPT
+ END
+ POPUP "Esc &Key Function"
+ BEGIN
+ MENUITEM "&None", IDM_VIEW_NOESCFUNC
+ MENUITEM "&Minimize Notepad2", IDM_VIEW_ESCMINIMIZE
+ MENUITEM "E&xit Notepad2", IDM_VIEW_ESCEXIT
+ END
+ MENUITEM "Sa&ve Before Running Tools", IDM_VIEW_SAVEBEFORERUNNINGTOOLS
+
+ MENUITEM "Remember Recent F&iles", IDM_VIEW_NOSAVERECENT
+ MENUITEM "Remember S&earch Strings", IDM_VIEW_NOSAVEFINDREPL
+ MENUITEM SEPARATOR
+ MENUITEM "Sh&ow Toolbar", IDM_VIEW_TOOLBAR
+ MENUITEM "C&ustomize Toolbar...", IDM_VIEW_CUSTOMIZETB
+ MENUITEM "Sh&ow Statusbar", IDM_VIEW_STATUSBAR
+ MENUITEM SEPARATOR
+ MENUITEM "Save Settings On E&xit", IDM_VIEW_SAVESETTINGS
+ MENUITEM "Save Settings &Now\tF7", IDM_VIEW_SAVESETTINGSNOW
+ END
+ POPUP "&?"
+ BEGIN
+ MENUITEM "&About...\tF1", IDM_HELP_ABOUT
+ END
+END
+
+IDR_POPUPMENU MENU
+BEGIN
+ POPUP "+"
+ BEGIN
+ MENUITEM "&Undo", IDM_EDIT_UNDO
+ MENUITEM "&Redo", IDM_EDIT_REDO
+ MENUITEM SEPARATOR
+ MENUITEM "Cu&t", IDM_EDIT_CUT
+ MENUITEM "&Copy", IDM_EDIT_COPY
+ MENUITEM "&Paste", IDM_EDIT_PASTE
+ MENUITEM "Cl&ear", IDM_EDIT_CLEAR
+ MENUITEM SEPARATOR
+ MENUITEM "&Select All", IDM_EDIT_SELECTALL
+ END
+ POPUP "+"
+ BEGIN
+ MENUITEM "Show &Toolbar", IDM_VIEW_TOOLBAR
+ MENUITEM "&Customize Toolbar...", IDM_VIEW_CUSTOMIZETB
+ MENUITEM "Show &Statusbar", IDM_VIEW_STATUSBAR
+ END
+ POPUP "+"
+ BEGIN
+ MENUITEM "Open Notepad2", IDM_TRAY_RESTORE
+ MENUITEM "Exit Notepad2", IDM_TRAY_EXIT
+ END
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Accelerator
+//
+
+IDR_MAINWND ACCELERATORS
+BEGIN
+ "0", IDM_VIEW_TRANSPARENT, VIRTKEY, CONTROL, NOINVERT
+ "0", IDM_FILE_NEWWINDOW2, VIRTKEY, ALT, NOINVERT
+ "0", IDM_VIEW_WORDWRAPSYMBOLS, VIRTKEY, SHIFT, CONTROL,
+ NOINVERT
+ "1", CMD_STRINGIFY, VIRTKEY, CONTROL, NOINVERT
+ "1", CMD_WEBACTION1, VIRTKEY, SHIFT, CONTROL,
+ NOINVERT
+ "2", CMD_STRINGIFY2, VIRTKEY, CONTROL, NOINVERT
+ "2", CMD_WEBACTION2, VIRTKEY, SHIFT, CONTROL,
+ NOINVERT
+ "3", CMD_EMBRACE, VIRTKEY, CONTROL, NOINVERT
+ "4", CMD_EMBRACE2, VIRTKEY, CONTROL, NOINVERT
+ "5", CMD_EMBRACE3, VIRTKEY, CONTROL, NOINVERT
+ "6", CMD_EMBRACE4, VIRTKEY, CONTROL, NOINVERT
+ "8", IDM_VIEW_SHOWWHITESPACE, VIRTKEY, SHIFT, CONTROL,
+ NOINVERT
+ "9", CMD_TOGGLETITLE, VIRTKEY, CONTROL, NOINVERT
+ "9", IDM_VIEW_SHOWEOLS, VIRTKEY, SHIFT, CONTROL,
+ NOINVERT
+ "A", IDM_EDIT_SELECTALL, VIRTKEY, CONTROL, NOINVERT
+ "A", CMD_RELOADANSI, VIRTKEY, SHIFT, CONTROL,
+ NOINVERT
+ "B", IDM_EDIT_FINDMATCHINGBRACE, VIRTKEY, CONTROL, NOINVERT
+ "B", IDM_EDIT_PADWITHSPACES, VIRTKEY, ALT, NOINVERT
+ "B", IDM_EDIT_SELTOMATCHINGBRACE, VIRTKEY, SHIFT, CONTROL,
+ NOINVERT
+ "C", IDM_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT
+ "C", IDM_EDIT_COPYALL, VIRTKEY, ALT, NOINVERT
+ "C", IDM_EDIT_COPYLINE, VIRTKEY, SHIFT, CONTROL,
+ NOINVERT
+ "D", IDM_EDIT_DUPLICATELINE, VIRTKEY, CONTROL, NOINVERT
+ "D", IDM_EDIT_SELECTIONDUPLICATE, VIRTKEY, ALT, NOINVERT
+ "D", IDM_EDIT_DELETELINE, VIRTKEY, SHIFT, CONTROL,
+ NOINVERT
+ "E", IDM_EDIT_COPYADD, VIRTKEY, CONTROL, NOINVERT
+ "E", IDM_EDIT_ESCAPECCHARS, VIRTKEY, CONTROL, ALT, NOINVERT
+ "E", IDM_EDIT_URLENCODE, VIRTKEY, SHIFT, CONTROL,
+ NOINVERT
+ "F", IDM_EDIT_FIND, VIRTKEY, CONTROL, NOINVERT
+ "G", IDM_EDIT_GOTOLINE, VIRTKEY, CONTROL, NOINVERT
+ "G", IDM_VIEW_SHOWINDENTGUIDES, VIRTKEY, SHIFT, CONTROL,
+ NOINVERT
+ "H", IDM_EDIT_REPLACE, VIRTKEY, CONTROL, NOINVERT
+ "H", IDM_FILE_RECENT, VIRTKEY, ALT, NOINVERT
+ "H", IDM_VIEW_AUTOCLOSETAGS, VIRTKEY, SHIFT, CONTROL,
+ NOINVERT
+ "I", IDM_EDIT_SPLITLINES, VIRTKEY, CONTROL, NOINVERT
+ "I", IDM_FILE_OPENFAV, VIRTKEY, ALT, NOINVERT
+ "I", IDM_EDIT_TITLECASE, VIRTKEY, CONTROL, ALT, NOINVERT
+ "I", IDM_VIEW_HILITECURRENTLINE, VIRTKEY, SHIFT, CONTROL,
+ NOINVERT
+ "J", IDM_EDIT_JOINLINES, VIRTKEY, CONTROL, NOINVERT
+ "J", IDM_EDIT_JOINLINESEX, VIRTKEY, SHIFT, CONTROL,
+ NOINVERT
+ "K", IDM_EDIT_SWAP, VIRTKEY, CONTROL, NOINVERT
+ "K", IDM_FILE_ADDTOFAV, VIRTKEY, ALT, NOINVERT
+ "L", IDM_FILE_LAUNCH, VIRTKEY, CONTROL, NOINVERT
+ "L", IDM_FILE_OPENWITH, VIRTKEY, ALT, NOINVERT
+ "L", IDM_VIEW_LONGLINEMARKER, VIRTKEY, SHIFT, CONTROL,
+ NOINVERT
+ "M", IDM_FILE_BROWSE, VIRTKEY, CONTROL, NOINVERT
+ "M", IDM_EDIT_MODIFYLINES, VIRTKEY, ALT, NOINVERT
+ "M", IDM_VIEW_MARGIN, VIRTKEY, SHIFT, CONTROL,
+ NOINVERT
+ "N", IDM_FILE_NEW, VIRTKEY, CONTROL, NOINVERT
+ "N", IDM_FILE_NEWWINDOW, VIRTKEY, ALT, NOINVERT
+ "N", IDM_VIEW_LINENUMBERS, VIRTKEY, SHIFT, CONTROL,
+ NOINVERT
+ "O", IDM_FILE_OPEN, VIRTKEY, CONTROL, NOINVERT
+ "O", IDM_EDIT_SORTLINES, VIRTKEY, ALT, NOINVERT
+ "O", IDM_EDIT_SENTENCECASE, VIRTKEY, CONTROL, ALT, NOINVERT
+ "O", CMD_RELOADOEM, VIRTKEY, SHIFT, CONTROL,
+ NOINVERT
+ "P", IDM_FILE_PRINT, VIRTKEY, CONTROL, NOINVERT
+ "P", IDM_EDIT_COMPRESSWS, VIRTKEY, ALT, NOINVERT
+ "Q", IDM_EDIT_LINECOMMENT, VIRTKEY, CONTROL, NOINVERT
+ "Q", IDM_EDIT_ENCLOSESELECTION, VIRTKEY, ALT, NOINVERT
+ "Q", IDM_EDIT_STREAMCOMMENT, VIRTKEY, SHIFT, CONTROL,
+ NOINVERT
+ "R", IDM_FILE_RUN, VIRTKEY, CONTROL, NOINVERT
+ "R", IDM_EDIT_REMOVEBLANKLINES, VIRTKEY, ALT, NOINVERT
+ "R", IDM_EDIT_URLDECODE, VIRTKEY, SHIFT, CONTROL,
+ NOINVERT
+ "S", IDM_FILE_SAVE, VIRTKEY, CONTROL, NOINVERT
+ "S", IDM_EDIT_CONVERTTABS2, VIRTKEY, CONTROL, ALT, NOINVERT
+ "S", IDM_EDIT_CONVERTTABS, VIRTKEY, SHIFT, CONTROL,
+ NOINVERT
+ "T", IDM_VIEW_TABSETTINGS, VIRTKEY, CONTROL, NOINVERT
+ "T", IDM_VIEW_ALWAYSONTOP, VIRTKEY, ALT, NOINVERT
+ "T", IDM_EDIT_CONVERTSPACES2, VIRTKEY, CONTROL, ALT, NOINVERT
+ "T", IDM_EDIT_CONVERTSPACES, VIRTKEY, SHIFT, CONTROL,
+ NOINVERT
+ "U", IDM_EDIT_CONVERTLOWERCASE, VIRTKEY, CONTROL, NOINVERT
+ "U", IDM_EDIT_STRIPLASTCHAR, VIRTKEY, ALT, NOINVERT
+ "U", IDM_EDIT_INVERTCASE, VIRTKEY, CONTROL, ALT, NOINVERT
+ "U", IDM_EDIT_UNESCAPECCHARS, VIRTKEY, CONTROL, ALT, NOINVERT
+ "U", IDM_EDIT_CONVERTUPPERCASE, VIRTKEY, SHIFT, CONTROL,
+ NOINVERT
+ "V", IDM_EDIT_PASTE, VIRTKEY, CONTROL, NOINVERT
+ "V", IDM_VIEW_MATCHBRACES, VIRTKEY, SHIFT, CONTROL,
+ NOINVERT
+ VK_ADD, IDM_VIEW_ZOOMIN, VIRTKEY, CONTROL, NOINVERT
+ VK_ADD, CMD_INCLINELIMIT, VIRTKEY, ALT, NOINVERT
+ VK_ADD, CMD_INCREASENUM, VIRTKEY, CONTROL, ALT, NOINVERT
+ VK_BACK, CMD_CTRLBACK, VIRTKEY, CONTROL, NOINVERT
+ VK_BACK, IDM_EDIT_UNDO, VIRTKEY, ALT, NOINVERT
+ VK_BACK, IDM_EDIT_DELETELINELEFT, VIRTKEY, SHIFT, CONTROL,
+ NOINVERT
+ VK_DELETE, CMD_CTRLDEL, VIRTKEY, CONTROL, NOINVERT
+ VK_DELETE, IDM_EDIT_CUT, VIRTKEY, SHIFT, NOINVERT
+ VK_DELETE, IDM_EDIT_DELETELINERIGHT, VIRTKEY, SHIFT, CONTROL,
+ NOINVERT
+ VK_DIVIDE, IDM_VIEW_RESETZOOM, VIRTKEY, CONTROL, NOINVERT
+ VK_DOWN, IDM_EDIT_MOVELINEDOWN, VIRTKEY, SHIFT, CONTROL,
+ NOINVERT
+ VK_ESCAPE, CMD_ESCAPE, VIRTKEY, NOINVERT
+ VK_ESCAPE, CMD_SHIFTESC, VIRTKEY, SHIFT, NOINVERT
+ VK_F1, IDM_HELP_ABOUT, VIRTKEY, NOINVERT
+ VK_F11, CMD_LEXDEFAULT, VIRTKEY, NOINVERT
+ VK_F11, CMD_LEXHTML, VIRTKEY, CONTROL, NOINVERT
+ VK_F11, CMD_LEXXML, VIRTKEY, SHIFT, NOINVERT
+ VK_F12, IDM_VIEW_SCHEME, VIRTKEY, NOINVERT
+ VK_F12, IDM_VIEW_SCHEMECONFIG, VIRTKEY, CONTROL, NOINVERT
+ VK_F12, IDM_VIEW_FONT, VIRTKEY, ALT, NOINVERT
+ VK_F12, IDM_VIEW_USE2NDDEFAULT, VIRTKEY, SHIFT, NOINVERT
+ VK_F2, IDM_EDIT_SELTONEXT, VIRTKEY, NOINVERT
+ VK_F2, IDM_EDIT_SELTOPREV, VIRTKEY, SHIFT, NOINVERT
+ VK_F3, IDM_EDIT_FINDNEXT, VIRTKEY, NOINVERT
+ VK_F3, CMD_FINDNEXTSEL, VIRTKEY, CONTROL, NOINVERT
+ VK_F3, IDM_EDIT_SAVEFIND, VIRTKEY, ALT, NOINVERT
+ VK_F3, IDM_EDIT_FINDPREV, VIRTKEY, SHIFT, NOINVERT
+ VK_F3, CMD_FINDPREVSEL, VIRTKEY, SHIFT, CONTROL,
+ NOINVERT
+ VK_F4, IDM_EDIT_REPLACENEXT, VIRTKEY, NOINVERT
+ VK_F4, IDM_FILE_NEW, VIRTKEY, CONTROL, NOINVERT
+ VK_F4, IDM_FILE_NEW, VIRTKEY, CONTROL, NOINVERT
+ VK_F5, IDM_FILE_REVERT, VIRTKEY, NOINVERT
+ VK_F5, IDM_EDIT_INSERT_SHORTDATE, VIRTKEY, CONTROL, NOINVERT
+ VK_F5, IDM_VIEW_CHANGENOTIFY, VIRTKEY, ALT, NOINVERT
+ VK_F5, CMD_TIMESTAMPS, VIRTKEY, SHIFT, NOINVERT
+ VK_F5, IDM_EDIT_INSERT_LONGDATE, VIRTKEY, SHIFT, CONTROL,
+ NOINVERT
+ VK_F6, IDM_FILE_SAVEAS, VIRTKEY, NOINVERT
+ VK_F6, IDM_FILE_SAVECOPY, VIRTKEY, CONTROL, NOINVERT
+ VK_F7, IDM_VIEW_SAVESETTINGSNOW, VIRTKEY, NOINVERT
+ VK_F7, CMD_OPENINIFILE, VIRTKEY, CONTROL, NOINVERT
+ VK_F8, IDM_ENCODING_RECODE, VIRTKEY, NOINVERT
+ VK_F8, IDM_EDIT_INSERT_ENCODING, VIRTKEY, CONTROL, NOINVERT
+ VK_F8, CMD_RELOADNOFILEVARS, VIRTKEY, ALT, NOINVERT
+ VK_F8, CMD_RELOADASCIIASUTF8, VIRTKEY, SHIFT, NOINVERT
+ VK_F9, IDM_ENCODING_SELECT, VIRTKEY, NOINVERT
+ VK_F9, IDM_EDIT_INSERT_FILENAME, VIRTKEY, CONTROL, NOINVERT
+ VK_F9, IDM_FILE_MANAGEFAV, VIRTKEY, ALT, NOINVERT
+ VK_F9, CMD_COPYPATHNAME, VIRTKEY, SHIFT, NOINVERT
+ VK_F9, IDM_EDIT_INSERT_PATHNAME, VIRTKEY, SHIFT, CONTROL,
+ NOINVERT
+ VK_OEM_2, IDM_VIEW_RESETZOOM, VIRTKEY, CONTROL, NOINVERT
+ VK_OEM_COMMA, CMD_JUMP2SELSTART, VIRTKEY, CONTROL, NOINVERT
+ VK_OEM_MINUS, IDM_VIEW_ZOOMOUT, VIRTKEY, CONTROL, NOINVERT
+ VK_OEM_MINUS, CMD_DECREASENUM, VIRTKEY, CONTROL, ALT, NOINVERT
+ VK_OEM_PERIOD, CMD_JUMP2SELEND, VIRTKEY, CONTROL, NOINVERT
+ VK_OEM_PLUS, IDM_VIEW_ZOOMIN, VIRTKEY, CONTROL, NOINVERT
+ VK_OEM_PLUS, CMD_INCREASENUM, VIRTKEY, CONTROL, ALT, NOINVERT
+ VK_RETURN, CMD_CTRLENTER, VIRTKEY, CONTROL, NOINVERT
+ VK_SPACE, IDM_EDIT_SELECTWORD, VIRTKEY, CONTROL, NOINVERT
+ VK_SPACE, IDM_EDIT_SELECTLINE, VIRTKEY, SHIFT, CONTROL,
+ NOINVERT
+ VK_SUBTRACT, IDM_VIEW_ZOOMOUT, VIRTKEY, CONTROL, NOINVERT
+ VK_SUBTRACT, CMD_DECLINELIMIT, VIRTKEY, ALT, NOINVERT
+ VK_SUBTRACT, CMD_DECREASENUM, VIRTKEY, CONTROL, ALT, NOINVERT
+ VK_TAB, CMD_CTRLTAB, VIRTKEY, CONTROL, NOINVERT
+ VK_UP, IDM_EDIT_MOVELINEUP, VIRTKEY, SHIFT, CONTROL,
+ NOINVERT
+ "W", IDM_VIEW_WORDWRAP, VIRTKEY, CONTROL, NOINVERT
+ "W", IDM_EDIT_TRIMLINES, VIRTKEY, ALT, NOINVERT
+ "W", IDM_EDIT_COLUMNWRAP, VIRTKEY, SHIFT, CONTROL,
+ NOINVERT
+ "X", IDM_EDIT_CUT, VIRTKEY, CONTROL, NOINVERT
+ "X", IDM_EDIT_INSERT_TAG, VIRTKEY, ALT, NOINVERT
+ "X", IDM_EDIT_CUTLINE, VIRTKEY, SHIFT, CONTROL,
+ NOINVERT
+ "Y", IDM_EDIT_REDO, VIRTKEY, CONTROL, NOINVERT
+ "Y", IDM_EDIT_UNDO, VIRTKEY, SHIFT, CONTROL,
+ NOINVERT
+ "Z", IDM_EDIT_UNDO, VIRTKEY, CONTROL, NOINVERT
+ "Z", IDM_EDIT_STRIP1STCHAR, VIRTKEY, ALT, NOINVERT
+ "Z", IDM_EDIT_REDO, VIRTKEY, SHIFT, CONTROL,
+ NOINVERT
+END
+
+IDR_ACCFINDREPLACE ACCELERATORS
+BEGIN
+ "F", IDACC_FIND, VIRTKEY, CONTROL, NOINVERT
+ "H", IDACC_REPLACE, VIRTKEY, CONTROL, NOINVERT
+ "O", IDACC_SAVEPOS, VIRTKEY, CONTROL, NOINVERT
+ "P", IDACC_RESETPOS, VIRTKEY, CONTROL, NOINVERT
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_ABOUT DIALOGEX 0, 0, 226, 70
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_NOFAILCREATE | WS_POPUP |
+ WS_CAPTION | WS_SYSMENU
+CAPTION "Notepad2"
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ DEFPUSHBUTTON "OK",IDOK,169,49,50,14
+ ICON IDR_MAINWND,IDC_STATIC,7,7,20,20
+ LTEXT "",IDC_VERSION,45,7,174,8
+ LTEXT "Copyright © 2004-2010",IDC_STATIC,45,19,174,8
+ LTEXT "flo's freeware - http://www.flos-freeware.ch",
+ IDC_WEBPAGE2,45,31,174,8,NOT WS_VISIBLE | WS_DISABLED
+ CONTROL "",IDC_WEBPAGE,"SysLink",WS_TABSTOP,45,31,174,10
+ LTEXT "Florian Balmer",IDC_STATIC,45,43,116,8
+ LTEXT "florian.balmer@gmail.com",IDC_EMAIL2,45,55,116,8,NOT
+ WS_VISIBLE | WS_DISABLED
+ CONTROL "",IDC_EMAIL,"SysLink",WS_TABSTOP,45,55,116,10
+END
+
+IDD_FIND DIALOGEX 0, 0, 272, 101
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_NOFAILCREATE | WS_POPUP |
+ WS_CAPTION | WS_SYSMENU
+CAPTION "Find Text"
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ LTEXT "Search Strin&g:",IDC_STATIC,7,7,46,8
+ COMBOBOX IDC_FINDTEXT,7,17,192,116,CBS_DROPDOWN | CBS_AUTOHSCROLL |
+ WS_VSCROLL | WS_TABSTOP
+ CONTROL "Match &case",IDC_FINDCASE,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,7,37,53,10
+ CONTROL "Match &whole word only",IDC_FINDWORD,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,7,49,89,10
+ CONTROL "Match &beginning of word only",IDC_FINDSTART,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,7,61,110,10
+ CONTROL "Regular &expression search",IDC_FINDREGEXP,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,7,73,101,10
+ CONTROL "&Transform backslashes",IDC_FINDTRANSFORMBS,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,7,85,89,10
+ CONTROL "&Don't wrap around",IDC_NOWRAP,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,125,37,75,10
+ CONTROL "C&lose after find",IDC_FINDCLOSE,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,125,49,65,10
+ DEFPUSHBUTTON "&Find Next",IDOK,215,7,50,14
+ PUSHBUTTON "Find &Previous",IDC_FINDPREV,215,24,50,14
+ PUSHBUTTON "&Select Down",IDC_SELECTTO,215,41,50,14
+ PUSHBUTTON "Select &Up",IDC_SELECTUP,215,58,50,14
+ PUSHBUTTON "Close",IDCANCEL,215,75,50,14
+ CONTROL "<a>Goto Replace (Ctrl+H)</a>",IDC_TOGGLEFINDREPLACE,
+ "SysLink",0x0,125,85,74,10
+END
+
+IDD_REPLACE DIALOGEX 0, 0, 272, 130
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_NOFAILCREATE | WS_POPUP |
+ WS_CAPTION | WS_SYSMENU
+CAPTION "Replace Text"
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ LTEXT "Search Strin&g:",IDC_STATIC,7,7,46,8
+ COMBOBOX IDC_FINDTEXT,7,17,192,116,CBS_DROPDOWN | CBS_AUTOHSCROLL |
+ WS_VSCROLL | WS_TABSTOP
+ LTEXT "Replace wit&h:",IDC_STATIC,7,35,44,8
+ COMBOBOX IDC_REPLACETEXT,7,46,192,116,CBS_DROPDOWN |
+ CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
+ CONTROL "Match &case",IDC_FINDCASE,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,7,66,53,10
+ CONTROL "Match &whole word only",IDC_FINDWORD,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,7,78,89,10
+ CONTROL "Match &beginning of word only",IDC_FINDSTART,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,7,90,110,10
+ CONTROL "Regular &expression search",IDC_FINDREGEXP,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,7,102,101,10
+ CONTROL "&Transform backslashes",IDC_FINDTRANSFORMBS,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,7,114,89,10
+ CONTROL "&Don't wrap around",IDC_NOWRAP,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,125,66,75,10
+ CONTROL "C&lose after replace",IDC_FINDCLOSE,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,125,78,77,10
+ DEFPUSHBUTTON "&Find Next",IDOK,215,7,50,14
+ PUSHBUTTON "Find &Previous",IDC_FINDPREV,215,24,50,14
+ PUSHBUTTON "&Replace",IDC_REPLACE,215,41,50,14
+ PUSHBUTTON "Replace &All",IDC_REPLACEALL,215,58,50,14
+ PUSHBUTTON "In &Selection",IDC_REPLACEINSEL,215,75,50,14
+ PUSHBUTTON "Close",IDCANCEL,215,92,50,14
+ CONTROL "<a>Goto Find (Ctrl+F)</a>",IDC_TOGGLEFINDREPLACE,
+ "SysLink",0x0,125,114,74,10
+END
+
+IDD_RUN DIALOGEX 0, 0, 224, 85
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "Run"
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ ICON IDI_RUN,IDC_STATIC,7,7,20,20
+ LTEXT "Enter the name of an executable program file,\na folder or a document to open.",
+ IDC_STATIC,35,7,188,17
+ EDITTEXT IDC_COMMANDLINE,35,35,165,13,ES_AUTOHSCROLL
+ PUSHBUTTON "",IDC_SEARCHEXE,204,35,13,13
+ DEFPUSHBUTTON "OK",IDOK,112,64,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,167,64,50,14
+END
+
+IDD_OPENWITH DIALOGEX 0, 0, 165, 129
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "Open with..."
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ CONTROL "",IDC_OPENWITHDIR,"SysListView32",LVS_REPORT |
+ LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS |
+ LVS_AUTOARRANGE | LVS_NOCOLUMNHEADER | WS_BORDER |
+ WS_TABSTOP,7,7,151,69
+ PUSHBUTTON "",IDC_GETOPENWITHDIR,7,83,13,13
+ LTEXT "Click here to specify the directory with links to your favorite applications.",
+ IDC_OPENWITHDESCR,26,83,132,18
+ DEFPUSHBUTTON "OK",IDOK,52,108,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,108,108,50,14
+ SCROLLBAR IDC_RESIZEGRIP3,7,112,10,10
+END
+
+IDD_DEFENCODING DIALOGEX 0, 0, 180, 108
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "Encoding"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ LTEXT "&Default encoding:",IDC_STATIC,7,7,58,8
+ CONTROL "",IDC_ENCODINGLIST,"ComboBoxEx32",CBS_DROPDOWNLIST |
+ WS_CLIPSIBLINGS | WS_VSCROLL | WS_TABSTOP,7,20,166,128
+ CONTROL "Skip automatic &Unicode detection.",
+ IDC_NOUNICODEDETECTION,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,7,43,124,10
+ CONTROL "Open 7-bit &ASCII files in UTF-8 mode.",IDC_ASCIIASUTF8,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,53,136,10
+ CONTROL "Don't parse encoding &tags.",IDC_ENCODINGFROMFILEVARS,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,63,102,10
+ DEFPUSHBUTTON "OK",IDOK,68,87,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,123,87,50,14
+END
+
+IDD_DEFEOLMODE DIALOGEX 0, 0, 180, 78
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "Line Endings"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ LTEXT "&Default line ending mode:",IDC_STATIC,7,7,82,8
+ COMBOBOX 100,7,20,98,196,CBS_DROPDOWNLIST | WS_VSCROLL |
+ WS_TABSTOP
+ CONTROL "&Ensure consistent line endings when saving.",
+ IDC_CONSISTENTEOLS,"Button",BS_AUTOCHECKBOX | BS_VCENTER |
+ WS_TABSTOP,7,48,157,10
+ CONTROL "&Strip trailing blanks when saving.",
+ IDC_AUTOSTRIPBLANKS,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,7,60,121,10
+ DEFPUSHBUTTON "OK",IDOK,123,7,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,123,24,50,14
+END
+
+IDD_LINENUM DIALOGEX 0, 0, 186, 47
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "Goto"
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ LTEXT "&Line:",IDC_STATIC,7,7,16,8
+ EDITTEXT IDC_LINENUM,7,24,46,14,ES_AUTOHSCROLL
+ LTEXT "&Column:",IDC_STATIC,63,7,27,8
+ EDITTEXT IDC_COLNUM,63,24,46,14,ES_AUTOHSCROLL
+ DEFPUSHBUTTON "OK",IDOK,129,7,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14
+END
+
+IDD_FILEMRU DIALOGEX 0, 0, 180, 134
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "Open Recent File"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ CONTROL "",IDC_FILEMRU,"SysListView32",LVS_REPORT |
+ LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS |
+ LVS_AUTOARRANGE | LVS_NOCOLUMNHEADER | WS_BORDER |
+ WS_TABSTOP,7,7,166,80
+ CONTROL "&Save recent files on exit.",IDC_SAVEMRU,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,7,95,96,10
+ DEFPUSHBUTTON "OK",IDOK,67,113,50,14,WS_DISABLED
+ PUSHBUTTON "Cancel",IDCANCEL,123,113,50,14
+ SCROLLBAR IDC_RESIZEGRIP,7,117,10,10
+END
+
+IDD_CHANGENOTIFY DIALOGEX 0, 0, 184, 65
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "File Change Notification"
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ CONTROL "&None.",100,"Button",BS_AUTORADIOBUTTON | WS_GROUP |
+ WS_TABSTOP,7,7,35,10
+ CONTROL "&Display message.",101,"Button",BS_AUTORADIOBUTTON |
+ WS_TABSTOP,7,19,71,10
+ CONTROL "&Auto-reload (unmodified).",102,"Button",
+ BS_AUTORADIOBUTTON | WS_TABSTOP,7,31,99,10
+ CONTROL "&Reset if a new file is opened.",103,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,7,48,109,10
+ DEFPUSHBUTTON "OK",IDOK,127,7,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,127,24,50,14
+END
+
+IDD_STYLESELECT DIALOGEX 0, 0, 165, 134
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "Select Scheme"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ CONTROL "",IDC_STYLELIST,"SysListView32",LVS_REPORT |
+ LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS |
+ LVS_AUTOARRANGE | LVS_NOCOLUMNHEADER | WS_BORDER |
+ WS_TABSTOP,7,7,151,70
+ CONTROL "Set selected scheme as &default.",IDC_DEFAULTSCHEME,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,85,118,10
+ CONTROL "&Auto-select by filename extension.",IDC_AUTOSELECT,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,95,127,10
+ DEFPUSHBUTTON "OK",IDOK,53,113,50,14,WS_DISABLED
+ PUSHBUTTON "Cancel",IDCANCEL,108,113,50,14
+ SCROLLBAR IDC_RESIZEGRIP3,7,117,10,10
+END
+
+IDD_STYLECONFIG DIALOGEX 0, 0, 468, 238
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "Customize Schemes"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ CONTROL "",IDC_STYLELIST,"SysTreeView32",TVS_SHOWSELALWAYS |
+ WS_BORDER | WS_TABSTOP | 0x400,7,7,164,224
+ LTEXT "",IDC_STYLELABEL,181,140,280,8
+ EDITTEXT IDC_STYLEEDIT,181,152,280,15,ES_AUTOHSCROLL
+ PUSHBUTTON "For&e...",IDC_STYLEFORE,181,174,46,14
+ PUSHBUTTON "&Back...",IDC_STYLEBACK,232,174,46,14
+ PUSHBUTTON "&Font...",IDC_STYLEFONT,283,174,42,14
+ PUSHBUTTON "&Preview",IDC_PREVIEW,330,174,42,14
+ PUSHBUTTON "&Reset",IDC_STYLEDEFAULT,377,174,42,14
+ PUSHBUTTON "",IDC_PREVSTYLE,426,174,15,14
+ PUSHBUTTON "",IDC_NEXTSTYLE,446,174,15,14
+ PUSHBUTTON "&Import...",IDC_IMPORT,181,217,50,14
+ PUSHBUTTON "E&xport...",IDC_EXPORT,237,217,50,14
+ DEFPUSHBUTTON "OK",IDOK,355,217,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,411,217,50,14
+ GROUPBOX "Info",IDC_STATIC,181,7,280,127
+ ICON IDI_STYLES,IDC_STATIC,189,19,20,20
+ LTEXT "Customize Schemes",IDC_TITLE,220,25,200,12
+ LTEXT "Filename extensions must be separated by ;\n\nStyle format:\nfont:Name;size:nn;bold;italic;underline;fore:#ffffff;back:#bbbbbb;eolfilled\n\nStyle properties can be copied using copy and paste or drag and drop.\n\nThe ""Preview"" button will not apply any changes.",
+ IDC_STATIC,197,50,252,70
+ LTEXT "Associated file&name extensions:|Style &settings:",
+ IDC_STYLELABELS,315,230,152,8,NOT WS_VISIBLE
+END
+
+IDD_TABSETTINGS DIALOGEX 0, 0, 174, 76
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "Tab Settings"
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ LTEXT "&Tabulator width:",IDC_STATIC,7,10,54,8
+ EDITTEXT 100,67,7,30,14,ES_AUTOHSCROLL
+ LTEXT "&Indentation size:",IDC_STATIC,7,30,55,8
+ EDITTEXT 101,67,27,30,14,ES_AUTOHSCROLL
+ CONTROL "Insert tabs as &spaces.",102,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,7,47,87,10
+ CONTROL "Tab &key reformats indentation.",103,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,7,59,115,10
+ DEFPUSHBUTTON "OK",IDOK,117,7,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,117,24,50,14
+END
+
+IDD_LONGLINES DIALOGEX 0, 0, 184, 55
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "Long Lines"
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ LTEXT "&Limit for long lines:",IDC_STATIC,7,10,60,8
+ EDITTEXT 100,77,7,30,14,ES_AUTOHSCROLL
+ CONTROL "Show &edge line.",101,"Button",BS_AUTORADIOBUTTON |
+ WS_GROUP | WS_TABSTOP,7,27,67,10
+ CONTROL "Change &background color.",102,"Button",
+ BS_AUTORADIOBUTTON | WS_TABSTOP,7,38,100,10
+ DEFPUSHBUTTON "OK",IDOK,127,7,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,127,24,50,14
+END
+
+IDD_WORDWRAP DIALOGEX 0, 0, 196, 126
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "Word Wrap Settings"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ LTEXT "&Subline indent:",IDC_STATIC,7,7,48,8
+ COMBOBOX 100,7,17,182,196,CBS_DROPDOWNLIST | WS_VSCROLL |
+ WS_TABSTOP
+ LTEXT "&Visual indicators:",IDC_STATIC,7,33,54,8
+ COMBOBOX 101,7,43,182,196,CBS_DROPDOWNLIST | WS_VSCROLL |
+ WS_TABSTOP
+ COMBOBOX 102,7,57,182,196,CBS_DROPDOWNLIST | WS_VSCROLL |
+ WS_TABSTOP
+ LTEXT "Break &mode:",IDC_STATIC,7,73,41,8
+ COMBOBOX 103,7,83,182,196,CBS_DROPDOWNLIST | WS_VSCROLL |
+ WS_TABSTOP
+ DEFPUSHBUTTON "OK",IDOK,83,105,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,139,105,50,14
+ LTEXT "None|1 character|2 characters|1 indent level|2 indent levels|As first subline|1 level more than first subline",
+ 200,0,0,340,8,NOT WS_VISIBLE
+ LTEXT "No indicators before wrap|Show indicators before wrap (near text)|Show indicators before wrap (near borders)",
+ 201,0,0,358,8,NOT WS_VISIBLE
+ LTEXT "No indicators after wrap|Show indicators after wrap (near text)|Show indicators after wrap (near borders)",
+ 202,0,0,342,8,NOT WS_VISIBLE
+ LTEXT "Wrap text between words|Wrap text between any characters",
+ 203,0,0,200,8,NOT WS_VISIBLE
+END
+
+IDD_PAGESETUP DIALOGEX 5, 5, 356, 260
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "Page Setup"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ GROUPBOX "Paper",1073,8,8,224,56,WS_GROUP
+ LTEXT "Si&ze:",1089,16,24,36,8
+ COMBOBOX 1137,64,23,160,160,CBS_DROPDOWNLIST | CBS_SORT |
+ WS_VSCROLL | WS_GROUP | WS_TABSTOP
+ LTEXT "&Source:",1090,16,45,36,8
+ COMBOBOX 1138,64,42,160,160,CBS_DROPDOWNLIST | CBS_SORT |
+ WS_VSCROLL | WS_GROUP | WS_TABSTOP
+ GROUPBOX "Orientation",1072,8,69,64,56,WS_GROUP
+ CONTROL "P&ortrait",1056,"Button",BS_AUTORADIOBUTTON | WS_GROUP |
+ WS_TABSTOP,16,82,52,12
+ CONTROL "L&andscape",1057,"Button",BS_AUTORADIOBUTTON,16,103,52,
+ 12
+ GROUPBOX "Margins",1075,80,69,152,56,WS_GROUP
+ LTEXT "&Left:",1102,88,85,32,8
+ EDITTEXT 1155,120,82,28,12,WS_GROUP
+ LTEXT "&Top:",1104,88,104,32,8
+ EDITTEXT 1156,120,103,28,12,WS_GROUP
+ LTEXT "&Right:",1103,164,85,32,8
+ EDITTEXT 1157,196,82,28,12,WS_GROUP
+ LTEXT "&Bottom:",1105,164,104,32,8
+ EDITTEXT 1158,196,103,28,12,WS_GROUP
+ GROUPBOX "Headers and Footers",1074,8,130,224,56,WS_GROUP
+ LTEXT "&Header:",IDC_STATIC,16,146,36,8
+ COMBOBOX 32,64,145,160,160,CBS_DROPDOWNLIST | WS_VSCROLL |
+ WS_GROUP | WS_TABSTOP
+ LTEXT "&Footer:",IDC_STATIC,16,167,36,8
+ COMBOBOX 33,64,164,160,160,CBS_DROPDOWNLIST | WS_VSCROLL |
+ WS_GROUP | WS_TABSTOP
+ GROUPBOX "Print Colors",1076,8,191,224,37,WS_GROUP
+ LTEXT "Mo&de:",IDC_STATIC,16,207,36,8
+ COMBOBOX 34,64,206,160,160,CBS_DROPDOWNLIST | WS_VSCROLL |
+ WS_GROUP | WS_TABSTOP
+ GROUPBOX "Zoom",IDC_STATIC,240,170,108,58,WS_GROUP
+ LTEXT "Print zoo&m (-10 to +20):",IDC_STATIC,248,188,92,8
+ EDITTEXT 30,298,206,42,12,ES_AUTOHSCROLL
+ CONTROL "",31,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT |
+ UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_HOTTRACK,282,205,11,
+ 14
+ DEFPUSHBUTTON "OK",1,190,237,50,14,WS_GROUP
+ PUSHBUTTON "Cancel",2,244,237,50,14
+ PUSHBUTTON "&Printer...",1026,298,237,50,14
+ GROUPBOX "Preview",IDC_STATIC,240,8,108,157
+ CONTROL "",1080,"Static",SS_WHITERECT,254,47,80,80
+ CONTROL "",1081,"Static",SS_GRAYRECT,334,51,4,80
+ CONTROL "",1082,"Static",SS_GRAYRECT,262,123,80,4
+END
+
+IDD_FAVORITES DIALOGEX 0, 0, 165, 129
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "Favorites"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ CONTROL "",IDC_FAVORITESDIR,"SysListView32",LVS_REPORT |
+ LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS |
+ LVS_AUTOARRANGE | LVS_NOCOLUMNHEADER | WS_BORDER |
+ WS_TABSTOP,7,7,151,69
+ PUSHBUTTON "",IDC_GETFAVORITESDIR,7,83,13,13
+ LTEXT "Click here to specify the directory with links to your favorite files.",
+ IDC_FAVORITESDESCR,26,83,132,18
+ DEFPUSHBUTTON "OK",IDOK,52,108,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,108,108,50,14
+ SCROLLBAR IDC_RESIZEGRIP3,7,112,10,10
+END
+
+IDD_ADDTOFAV DIALOGEX 0, 0, 172, 66
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "Add to Favorites"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ LTEXT "Enter the name for the new favorites item:",IDC_STATIC,
+ 7,7,158,8
+ EDITTEXT 100,7,22,158,14,ES_AUTOHSCROLL
+ DEFPUSHBUTTON "OK",IDOK,59,45,50,14,WS_DISABLED
+ PUSHBUTTON "Cancel",IDCANCEL,115,45,50,14
+END
+
+IDD_COLUMNWRAP DIALOGEX 0, 0, 130, 47
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "Column Wrap"
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ LTEXT "&Boundary:",IDC_STATIC,7,7,34,8
+ EDITTEXT IDC_COLUMNWRAP,7,24,46,14,ES_AUTOHSCROLL
+ DEFPUSHBUTTON "OK",IDOK,73,7,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,73,24,50,14
+END
+
+IDD_MODIFYLINES DIALOGEX 0, 0, 182, 70
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "Modify Lines"
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ LTEXT "&Prefix text to lines:",IDC_STATIC,7,7,62,8
+ EDITTEXT 100,7,18,98,14,ES_AUTOHSCROLL
+ LTEXT "&Append text to lines:",IDC_STATIC,7,37,68,8
+ EDITTEXT 101,7,48,98,14,ES_AUTOHSCROLL
+ DEFPUSHBUTTON "OK",IDOK,125,7,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,125,24,50,14
+END
+
+IDD_INSERTTAG DIALOGEX 0, 0, 182, 70
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "Insert HTML/XML Tag"
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ LTEXT "&Opening tag (with attributes):",IDC_STATIC,7,7,97,8
+ EDITTEXT 100,7,18,98,14,ES_AUTOHSCROLL
+ LTEXT "&Closing tag (can be edited):",IDC_STATIC,7,37,90,8
+ EDITTEXT 101,7,48,98,14,ES_AUTOHSCROLL
+ DEFPUSHBUTTON "OK",IDOK,125,7,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,125,24,50,14
+END
+
+IDD_ENCLOSESELECTION DIALOGEX 0, 0, 182, 70
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "Enclose Selection"
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ LTEXT "Insert &before selection:",IDC_STATIC,7,7,76,8
+ EDITTEXT 100,7,18,98,14,ES_AUTOHSCROLL
+ LTEXT "Insert &after selection:",IDC_STATIC,7,37,71,8
+ EDITTEXT 101,7,48,98,14,ES_AUTOHSCROLL
+ DEFPUSHBUTTON "OK",IDOK,125,7,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,125,24,50,14
+END
+
+IDD_INFOBOX DIALOGEX 0, 0, 244, 71
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "Notepad2"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ ICON IDR_MAINWND,IDC_INFOBOXICON,7,7,21,20
+ LTEXT "",IDC_INFOBOXTEXT,35,7,202,34
+ DEFPUSHBUTTON "OK",IDOK,187,50,50,14
+ CONTROL "&Don't display this message again.",IDC_INFOBOXCHECK,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,54,122,10
+END
+
+IDD_INFOBOX2 DIALOGEX 0, 0, 244, 71
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "Notepad2"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ ICON IDR_MAINWND,IDC_INFOBOXICON,7,7,21,20
+ LTEXT "",IDC_INFOBOXTEXT,35,7,202,34
+ PUSHBUTTON "&Yes",IDYES,131,50,50,14
+ PUSHBUTTON "&No",IDNO,187,50,50,14
+ CONTROL "&Don't display this message again.",IDC_INFOBOXCHECK,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,54,122,10
+END
+
+IDD_SORT DIALOGEX 0, 0, 184, 65
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "Sort Lines"
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ CONTROL "Sort &ascending.",100,"Button",BS_AUTORADIOBUTTON |
+ WS_GROUP | WS_TABSTOP,7,7,66,10
+ CONTROL "Sort &descending.",101,"Button",BS_AUTORADIOBUTTON |
+ WS_TABSTOP,7,19,70,10
+ CONTROL "Remove d&uplicate lines.",102,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,7,36,91,10
+ CONTROL "Logical &number comparison.",103,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,7,48,104,10
+ DEFPUSHBUTTON "OK",IDOK,127,7,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,127,24,50,14
+END
+
+IDD_INFOBOX3 DIALOGEX 0, 0, 244, 71
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "Notepad2"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ ICON IDR_MAINWND,IDC_INFOBOXICON,7,7,21,20
+ LTEXT "",IDC_INFOBOXTEXT,35,7,202,34
+ DEFPUSHBUTTON "OK",IDOK,131,50,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,187,50,50,14
+ CONTROL "&Don't display this message again.",IDC_INFOBOXCHECK,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,54,122,10
+END
+
+IDD_RECODE DIALOGEX 0, 0, 165, 135
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "Recode"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ LTEXT "Select source &encoding to reload file:",IDC_STATIC,7,7,
+ 119,8
+ CONTROL "",IDC_ENCODINGLIST,"SysListView32",LVS_REPORT |
+ LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_AUTOARRANGE |
+ LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,7,19,151,87
+ DEFPUSHBUTTON "OK",IDOK,53,114,50,14,WS_DISABLED
+ PUSHBUTTON "Cancel",IDCANCEL,108,114,50,14
+ SCROLLBAR IDC_RESIZEGRIP4,7,118,10,10
+END
+
+IDD_ENCODING DIALOGEX 0, 0, 165, 135
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "Encoding"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ LTEXT "Select current file &encoding:",IDC_STATIC,7,7,90,8
+ CONTROL "",IDC_ENCODINGLIST,"SysListView32",LVS_REPORT |
+ LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_AUTOARRANGE |
+ LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,7,19,151,87
+ DEFPUSHBUTTON "OK",IDOK,53,114,50,14,WS_DISABLED
+ PUSHBUTTON "Cancel",IDCANCEL,108,114,50,14
+ SCROLLBAR IDC_RESIZEGRIP4,7,118,10,10
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ IDD_ABOUT, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 219
+ VERTGUIDE, 45
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 63
+ END
+
+ IDD_FIND, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 265
+ VERTGUIDE, 7
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 95
+ END
+
+ IDD_REPLACE, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 265
+ VERTGUIDE, 7
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 123
+ END
+
+ IDD_OPENWITH, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 158
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 122
+ END
+
+ IDD_DEFENCODING, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 173
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 101
+ END
+
+ IDD_DEFEOLMODE, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 173
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 71
+ END
+
+ IDD_LINENUM, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 179
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 40
+ END
+
+ IDD_FILEMRU, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 173
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 127
+ END
+
+ IDD_CHANGENOTIFY, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 177
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 58
+ END
+
+ IDD_STYLESELECT, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 158
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 127
+ END
+
+ IDD_STYLECONFIG, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 461
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 231
+ END
+
+ IDD_TABSETTINGS, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 167
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 69
+ END
+
+ IDD_LONGLINES, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 177
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 48
+ END
+
+ IDD_WORDWRAP, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 189
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 119
+ END
+
+ IDD_PAGESETUP, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 349
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 253
+ END
+
+ IDD_FAVORITES, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 158
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 122
+ END
+
+ IDD_ADDTOFAV, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 165
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 59
+ END
+
+ IDD_COLUMNWRAP, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 123
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 40
+ END
+
+ IDD_MODIFYLINES, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 175
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 63
+ END
+
+ IDD_INSERTTAG, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 175
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 63
+ END
+
+ IDD_ENCLOSESELECTION, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 175
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 63
+ END
+
+ IDD_INFOBOX, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 237
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 64
+ END
+
+ IDD_INFOBOX2, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 237
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 64
+ END
+
+ IDD_SORT, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 177
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 58
+ END
+
+ IDD_INFOBOX3, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 237
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 64
+ END
+
+ IDD_RECODE, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 158
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 128
+ END
+
+ IDD_ENCODING, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 158
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 128
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 4,1,24,0
+ PRODUCTVERSION 4,1,24,0
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x29L
+#else
+ FILEFLAGS 0x28L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x1L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "FileDescription", "Notepad2"
+ VALUE "FileVersion", "4.1.24"
+ VALUE "InternalName", "Notepad2"
+ VALUE "LegalCopyright", "© Florian Balmer 2004-2010"
+ VALUE "OriginalFilename", "Notepad2.exe"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE
+BEGIN
+ IDS_APPTITLE "Notepad2"
+ IDS_APPTITLE_ELEVATED "%s (Administrator)"
+ IDS_APPTITLE_PASTEBOARD "Notepad2 : Paste Board"
+ IDS_UNTITLED "Untitled"
+ IDS_TITLEEXCERPT """%s"""
+ IDS_READONLY "(Read Only)"
+ IDS_DOCPOS "Ln %s : %s Col %s Sel %s"
+ IDS_DOCPOS2 "Ln %s : %s Col %s : %s Sel %s"
+ IDS_DOCSIZE "%s"
+ IDS_LOADFILE "Loading ""%s""..."
+ IDS_SAVEFILE "Saving ""%s""..."
+ IDS_PRINTFILE "Printing page %i..."
+ IDS_SAVINGSETTINGS "Saving settings..."
+ IDS_LINKDESCRIPTION "Edit with Notepad2"
+ IDS_FILTER_ALL "All files (*.*)|*.*|"
+ IDS_FILTER_EXE "Executable files (*.exe;*.com;*.bat;*.cmd;*.lnk;*.pif)|*.exe;*.com;*.bat;*.cmd;*.lnk;*.pif|All files (*.*)|*.*|"
+END
+
+STRINGTABLE
+BEGIN
+ IDT_FILE_NEW "New"
+ IDT_FILE_OPEN "Open"
+ IDT_FILE_BROWSE "Browse"
+ IDT_FILE_SAVE "Save"
+END
+
+STRINGTABLE
+BEGIN
+ IDT_EDIT_UNDO "Undo"
+ IDT_EDIT_REDO "Redo"
+ IDT_EDIT_CUT "Cut"
+ IDT_EDIT_COPY "Copy"
+ IDT_EDIT_PASTE "Paste"
+ IDT_EDIT_FIND "Find"
+ IDT_EDIT_REPLACE "Replace"
+ IDT_VIEW_WORDWRAP "Word Wrap"
+ IDT_VIEW_ZOOMIN "Zoom In"
+ IDT_VIEW_ZOOMOUT "Zoom Out"
+ IDT_VIEW_SCHEME "Select Scheme"
+ IDT_VIEW_SCHEMECONFIG "Customize Schemes"
+ IDT_FILE_EXIT "Exit"
+ IDT_FILE_SAVEAS "Save As"
+ IDT_FILE_SAVECOPY "Save Copy"
+ IDT_EDIT_CLEAR "Clear"
+END
+
+STRINGTABLE
+BEGIN
+ IDT_FILE_PRINT "Print"
+ IDT_FILE_OPENFAV "Favorites"
+ IDT_FILE_ADDTOFAV "Add to Favorites"
+END
+
+STRINGTABLE
+BEGIN
+ IDS_ERR_LOADFILE "Error loading ""%s""."
+ IDS_ERR_SAVEFILE "Error saving ""%s""."
+ IDS_ERR_BROWSE "No file browser plugin was found.\nThe metapath file browser plugin can be downloaded from http://www.flos-freeware.ch."
+ IDS_ERR_MRUDLG "No access to the selected file!\nWould you like to remove it from the list?"
+ IDS_ERR_CREATELINK "Error creating the Desktop link."
+ IDS_ERR_PREVWINDISABLED "Existing Notepad2 window is busy or has an active dialog box.\nWould you like to open another Notepad2 window?"
+ IDS_SELRECT "This operation can't be perfomed within a rectangular selection."
+ IDS_FIND_WRAPFW "Reached the end of the document, restarting search at the beginning."
+ IDS_FIND_WRAPRE "Reached the beginning of the document, restarting search at the end."
+ IDS_NOTFOUND "The specified text was not found."
+ IDS_REPLCOUNT "%i occurrences of the specified text have been replaced."
+ IDS_ASK_ENCODING "Switching the file encoding from ANSI to non-ANSI (and vice versa) may replace unsupported text with default characters, and the undo history will be cleared. Continue?"
+ IDS_ASK_ENCODING2 "You are about to change the encoding of an empty file from ANSI to non-ANSI. Note that this will clear the undo history, as it can't be synchronized with the new encoding. Continue?"
+ IDS_ERR_ENCODINGNA "Code page conversion tables for the selected encoding are not available on your system."
+ IDS_ERR_UNICODE "Error converting this Unicode file.\nData will be lost if the file is saved!"
+ IDS_ERR_UNICODE2 "Certain characters in the current text are not supported by the selected encoding, and may be replaced by default placeholders when saving. It's recommended to choose another file encoding. Continue?"
+END
+
+STRINGTABLE
+BEGIN
+ IDS_CMDLINEHELP "Command Line Help\n\nfile\tMust be the last argument, no quoted spaces by default.\n+\tAccept multiple file arguments (with quoted spaces).\n-\tAccept single file argument (without quoted spaces).\n…\tEncoding (/ansi, /unicode, /unicodebe, /utf8, /utf8sig).\n…\tLine ending mode (/crlf, /lf, /cr).\n/e\tFile source encoding.\n/g\tJump to specified position (/g -1 end of file).\n/m\tMatch specified text (/m- last, /mr regex, /mb backslash).\n/q\tForce creation of new files without prompt.\n/s\tSelect specified syntax scheme.\n/d\tSelect default text scheme.\n/h\tSelect Web Source Code scheme.\n/x\tSelect XML Document scheme.\n/c\tOpen new window and paste clipboard contents.\n/b\tOpen new paste board to collect clipboard entries.\n/n\tAlways open a new window (/ns single file instance).\n/r\tReuse window (/rs single file instance).\n/p\tSet window position and size (/p0, /ps, /pf,l,t,r,b,m).\n/t\tSet window title.\n/i\tStart as tray icon.\n/f\tSpecify ini-file (/f0 no ini-file).\n/u\tLaunch with elevated privileges.\n/z\tSkip next (usable for registry-based Notepad replacement)."
+END
+
+STRINGTABLE
+BEGIN
+ IDS_WARNLOADBIGFILE "Are you sure you want to open this large file?"
+ IDS_ERR_DROP "Only one file can be dropped at the same time!"
+ IDS_ASK_SAVE "Save changes to ""%s""?"
+ IDS_ASK_REVERT "Revert file to last saved state? Your changes will be lost!"
+ IDS_ASK_RECODE "Recoding requires reloading file from disk, unsaved changes will be lost!"
+ IDS_ASK_CREATE """%s"" not found.\nWould you like to create this file?"
+ IDS_PRINT_HEADER "Filename, Current Date and Time|Filename, Current Date|Filename|Leave blank"
+ IDS_PRINT_FOOTER "Page Number|Leave blank"
+ IDS_PRINT_COLOR "Normal|Invert light (dark background)|Black on white|Color on white|Color on white (except line numbers)"
+ IDS_PRINT_PAGENUM "Page %i"
+ IDS_PRINT_EMPTY "This document doesn't contain any text to be printed."
+ IDS_PRINT_ERROR "Error printing ""%s""!"
+ IDS_FAV_SUCCESS "A shortcut to the current file has been created in the favorites directory."
+ IDS_FAV_FAILURE "The shortcut to the current file could not be created.\nMake sure there's no other file with the same name."
+ IDS_READONLY_MODIFY "The attributes of ""%s"" could not be modified."
+ IDS_READONLY_SAVE """%s"" is read only. Save to a different file?"
+END
+
+STRINGTABLE
+BEGIN
+ IDS_FILECHANGENOTIFY "The current file has been modified by an external program. Reload?"
+ IDS_FILECHANGENOTIFY2 "The current file has been deleted. Save now?"
+ IDS_STICKYWINPOS "Sticky Window Position is enabled. Any new Notepad2 windows will use the current window placement settings."
+ IDS_SAVEDSETTINGS "The current program settings have been saved."
+ IDS_CREATEINI_FAIL "Error creating configuration file."
+ IDS_WRITEINI_FAIL "Error writing settings to configuration file."
+ IDS_SETTINGSNOTSAVED "No existing configuration file was found.\nTo keep your style modifications, save settings now (F7) or go back to scheme configuration (Ctrl+F12) and export your styles."
+ IDS_IMPORT_OK "The style settings have been successfully imported from the specified file."
+ IDS_EXPORT_OK "The style settings have been successfully exported to the specified file."
+END
+
+STRINGTABLE
+BEGIN
+ SC_SAVEPOS "&Save Position\tCtrl+O"
+ SC_RESETPOS "&Reset Position\tCtrl+P"
+END
+
+STRINGTABLE
+BEGIN
+ 61000 "A0;ANSI;ANSI"
+ 61001 "A1;OEM;OEM"
+ 61002 "A2;Unicode (UTF-16 LE BOM);Unicode BOM"
+ 61003 "A3;Unicode (UTF-16 BE BOM);Unicode BE BOM"
+ 61004 "A4;Unicode (UTF-16 LE);Unicode"
+ 61005 "A5;Unicode (UTF-16 BE);Unicode;Unicode BE"
+ 61006 "A6;Unicode (UTF-8);UTF-8"
+ 61007 "A7;Unicode (UTF-8 Signature);UTF-8 Signature"
+END
+
+STRINGTABLE
+BEGIN
+ 61008 "A8;Unicode (UTF-7);UTF-7"
+ 61009 "C;Arabic (DOS-720);DOS-720"
+ 61010 "C;Arabic (ISO-8859-6);ISO-8859-6"
+ 61011 "C;Arabic (Mac);Mac (Arabic)"
+ 61012 "C;Arabic (Windows-1256);Windows-1256"
+ 61013 "C;Baltic (DOS-775);DOS-775"
+ 61014 "C;Baltic (ISO-8859-4);ISO-8859-4"
+ 61015 "C;Baltic (Windows-1257);Windows-1257"
+ 61016 "C;Central European (DOS-852);DOS-852"
+ 61017 "C;Central European (ISO-8859-2);ISO-8859-2"
+ 61018 "C;Central European (Mac);Mac (Central)"
+ 61019 "C;Central European (Windows-1250);Windows-1250"
+ 61020 "C;Chinese Simplified (GBK);GBK"
+ 61021 "C;Chinese Simplified (Mac);Mac (zh-cn)"
+ 61022 "C;Chinese Traditional (Big5);Big5"
+ 61023 "C;Chinese Traditional (Mac);Mac (zh-tw)"
+END
+
+STRINGTABLE
+BEGIN
+ 61024 "C;Croatian (Mac);Mac (Croatian)"
+ 61025 "C;Cyrillic (DOS-866);DOS-866"
+ 61026 "C;Cyrillic (ISO-8859-5);ISO-8859-5"
+ 61027 "C;Cyrillic (KOI8-R);KOI8-R"
+ 61028 "C;Cyrillic (KOI8-U);KOI8-U"
+ 61029 "C;Cyrillic (Mac);Mac (Cyrillic)"
+ 61030 "C;Cyrillic (Windows-1251);Windows-1251"
+ 61031 "C;Estonian (ISO-8859-13);ISO-8859-13"
+ 61032 "C;French Canadian (DOS-863);DOS-863"
+ 61033 "C;Greek (DOS-737);DOS-737"
+ 61034 "C;Greek (ISO-8859-7);ISO-8859-7"
+ 61035 "C;Greek (Mac);Mac (Greek)"
+ 61036 "C;Greek (Windows-1253);Windows-1253"
+ 61037 "C;Greek, Modern (DOS-869);DOS-869"
+ 61038 "C;Hebrew (DOS-862);DOS-862"
+ 61039 "C;Hebrew (ISO-8859-8-I);ISO-8859-8-I"
+END
+
+STRINGTABLE
+BEGIN
+ 61040 "C;Hebrew (ISO-8859-8);ISO-8859-8"
+ 61041 "C;Hebrew (Mac);Mac (Hebrew)"
+ 61042 "C;Hebrew (Windows-1255);Windows-1255"
+ 61043 "C;Icelandic (DOS-861);DOS-861"
+ 61044 "C;Icelandic (Mac);Mac (Icelandic)"
+ 61045 "C;Japanese (Mac);Mac (Japanese)"
+ 61046 "C;Japanese (Shift-JIS);Shift-JIS"
+ 61047 "C;Korean (Mac);Mac (Korean)"
+ 61048 "C;Korean (Windows-949);Windows-949"
+ 61049 "C;Latin 3 (ISO-8859-3);ISO-8859-3"
+ 61050 "C;Latin 9 (ISO-8859-15);ISO-8859-15"
+ 61051 "C;Nordic (DOS-865);DOS-865"
+ 61052 "C;OEM United States (DOS-437);DOS-437"
+ 61053 "C;OEM Multilingual Latin 1 (DOS-858);DOS-858"
+ 61054 "C;Portuguese (DOS-860);DOS-860"
+ 61055 "C;Romanian (Mac);Mac (Romanian)"
+END
+
+STRINGTABLE
+BEGIN
+ 61056 "C;Thai (Mac);Mac (Thai)"
+ 61057 "C;Thai (Windows-874);Windows-874"
+ 61058 "C;Turkish (DOS-857);DOS-857"
+ 61059 "C;Turkish (ISO-8859-9);ISO-8859-9"
+ 61060 "C;Turkish (Mac);Mac (Turkish)"
+ 61061 "C;Turkish (Windows-1254);Windows-1254"
+ 61062 "C;Ukrainian (Mac);Mac (Ukrainian)"
+ 61063 "C;Vietnamese (Windows-1258);Windows-1258"
+ 61064 "B;Western European (DOS-850);DOS-850"
+ 61065 "B;Western European (ISO-8859-1);ISO-8859-1"
+ 61066 "B;Western European (Mac);Mac (Western)"
+ 61067 "B;Western European (Windows-1252);Windows-1252"
+ 61068 "D0;IBM EBCDIC (US-Canada);EBCDIC (US)"
+ 61069 "D1;IBM EBCDIC (International);EBCDIC (Int.)"
+ 61070 "D2;IBM EBCDIC (Greek Modern);EBCDIC (GR)"
+ 61071 "D3;IBM EBCDIC (Turkish Latin-5);EBCDIC (Latin-5)"
+END
+
+STRINGTABLE
+BEGIN
+ 61072 "C;Chinese Simplified (GB18030);GB18030"
+END
+
+STRINGTABLE
+BEGIN
+ 62000 "Windows (CR+LF)"
+ 62001 "Unix (LF)"
+ 62002 "Mac (CR)"
+END
+
+STRINGTABLE
+BEGIN
+ 63000 "Default Text"
+ 63001 "Web Source Code"
+ 63002 "XML Document"
+ 63003 "CSS Style Sheets"
+ 63004 "C/C++ Source Code"
+ 63005 "C# Source Code"
+ 63006 "Resource Script"
+ 63007 "Makefiles"
+END
+
+STRINGTABLE
+BEGIN
+ 63008 "VBScript"
+ 63009 "Visual Basic"
+ 63010 "JavaScript"
+ 63011 "Java Source Code"
+ 63012 "Pascal Source Code"
+ 63013 "Assembly Script"
+ 63014 "Perl Script"
+ 63015 "Configuration Files"
+ 63016 "Batch Files"
+ 63017 "Diff Files"
+ 63018 "SQL Query"
+ 63019 "Python Script"
+ 63020 "Apache Config Files"
+ 63021 "PowerShell Script"
+END
+
+STRINGTABLE
+BEGIN
+ 63100 "Default Style"
+ 63101 "Margins and Line Numbers"
+ 63102 "Matching Braces"
+ 63103 "Matching Braces Error"
+END
+
+STRINGTABLE
+BEGIN
+ 63104 "Control Characters (Font)"
+ 63105 "Indentation Guide (Color)"
+ 63106 "Selected Text (Colors)"
+ 63107 "Whitespace (Colors, Size 0-5)"
+ 63108 "Current Line Background (Color)"
+ 63109 "Caret Foreground (Color)"
+ 63110 "Caret Width (Size 1-3)"
+ 63111 "Long Line Marker (Colors)"
+ 63112 "Extra Line Spacing (Size)"
+ 63113 "2nd Default Style"
+ 63114 "2nd Margins and Line Numbers"
+ 63115 "2nd Matching Braces"
+ 63116 "2nd Matching Braces Error"
+ 63117 "2nd Control Characters (Font)"
+ 63118 "2nd Indentation Guide (Color)"
+ 63119 "2nd Selected Text (Colors)"
+END
+
+STRINGTABLE
+BEGIN
+ 63120 "2nd Whitespace (Colors, Size 0-5)"
+ 63121 "2nd Current Line Background (Color)"
+ 63122 "2nd Caret Foreground (Color)"
+ 63123 "2nd Caret Width (Size 1-3)"
+ 63124 "2nd Long Line Marker (Colors)"
+ 63125 "2nd Extra Line Spacing (Size)"
+ 63126 "Default"
+ 63127 "Comment"
+ 63128 "Keyword"
+ 63129 "Identifier"
+ 63130 "Number"
+ 63131 "String"
+ 63132 "Operator"
+ 63133 "Preprocessor"
+ 63134 "Verbatim String"
+ 63135 "Regex"
+END
+
+STRINGTABLE
+BEGIN
+ 63136 "HTML Tag"
+ 63137 "HTML Unknown Tag"
+ 63138 "HTML Attribute"
+ 63139 "HTML Unknown Attribute"
+ 63140 "HTML Value"
+ 63141 "HTML String"
+ 63142 "HTML Other Inside Tag"
+ 63143 "HTML Comment"
+ 63144 "HTML Entity"
+ 63145 "XML Identifier"
+ 63146 "ASP Start Tag"
+ 63147 "CDATA"
+ 63148 "PHP Start Tag"
+ 63149 "PHP Default"
+ 63150 "PHP String"
+ 63151 "PHP Simple String"
+END
+
+STRINGTABLE
+BEGIN
+ 63152 "PHP Keyword"
+ 63153 "PHP Number"
+ 63154 "PHP Variable"
+ 63155 "PHP String Variable"
+ 63156 "PHP Complex Variable"
+ 63157 "PHP Comment"
+ 63158 "PHP Operator"
+ 63159 "JS Default"
+ 63160 "JS Comment"
+ 63161 "JS Number"
+ 63162 "JS Identifier"
+ 63163 "JS Keyword"
+ 63164 "JS String"
+ 63165 "JS Symbols"
+ 63166 "JS Regex"
+ 63167 "ASP JS Default"
+END
+
+STRINGTABLE
+BEGIN
+ 63168 "ASP JS Comment"
+ 63169 "ASP JS Number"
+ 63170 "ASP JS Identifier"
+ 63171 "ASP JS Keyword"
+ 63172 "ASP JS String"
+ 63173 "ASP JS Symbols"
+ 63174 "ASP JS Regex"
+ 63175 "VBS Default"
+ 63176 "VBS Comment"
+ 63177 "VBS Number"
+ 63178 "VBS Keyword"
+ 63179 "VBS String"
+ 63180 "VBS Identifier"
+ 63181 "ASP VBS Default"
+ 63182 "ASP VBS Comment"
+ 63183 "ASP VBS Number"
+END
+
+STRINGTABLE
+BEGIN
+ 63184 "ASP VBS Keyword"
+ 63185 "ASP VBS String"
+ 63186 "ASP VBS Identifier"
+ 63187 "XML Tag"
+ 63188 "XML Attribute"
+ 63189 "XML Value"
+ 63190 "XML String"
+ 63191 "XML Other Inside Tag"
+ 63192 "XML Comment"
+ 63193 "XML Entity"
+ 63194 "Tag-Class"
+ 63195 "Tag-Id"
+ 63196 "Tag-Attribute"
+ 63197 "Pseudo-class/element"
+ 63198 "Unknown Pseudo-class"
+ 63199 "CSS Property"
+END
+
+STRINGTABLE
+BEGIN
+ 63200 "Unknown Property"
+ 63201 "Value"
+ 63202 "Important"
+ 63203 "Directive"
+ 63204 "Target"
+ 63205 "Inline Asm"
+ 63206 "CPU Instruction"
+ 63207 "FPU Instruction"
+ 63208 "Register"
+ 63209 "Directive Operand"
+ 63210 "Extended Instruction"
+ 63211 "String double quoted"
+ 63212 "String single quoted"
+ 63213 "POD (common)"
+ 63214 "POD (verbatim)"
+ 63215 "Scalar $var"
+END
+
+STRINGTABLE
+BEGIN
+ 63216 "Array @var"
+ 63217 "Hash %var"
+ 63218 "Symbol table *var"
+ 63219 "Regex /re/ or m{re}"
+ 63220 "Substitution s/re/ore/"
+ 63221 "Back ticks"
+ 63222 "Data section"
+ 63223 "Here-doc (delimiter)"
+ 63224 "Here-doc (single quoted, q)"
+ 63225 "Here-doc (double quoted, qq)"
+ 63226 "Here-doc (back ticks, qx)"
+ 63227 "Single quoted string (generic, q)"
+ 63228 "Double quoted string (qq)"
+ 63229 "Back ticks (qx)"
+ 63230 "Regex (qr)"
+ 63231 "Array (qw)"
+END
+
+STRINGTABLE
+BEGIN
+ 63232 "Section"
+ 63233 "Assignment"
+ 63234 "Default Value"
+ 63235 "Label"
+ 63236 "Command"
+ 63237 "SGML"
+ 63238 "Source and Destination"
+ 63239 "Position Setting"
+ 63240 "Line Addition"
+ 63241 "Line Removal"
+ 63242 "Line Change"
+ 63243 "Quoted Identifier"
+ 63244 "String triple double quotes"
+ 63245 "String triple single quotes"
+ 63246 "Class name"
+ 63247 "Function name"
+END
+
+STRINGTABLE
+BEGIN
+ 63248 "IP Address"
+ 63249 "Variable"
+ 63250 "Cmdlet"
+ 63251 "Alias"
+ 63252 "Parsing error"
+ 63253 "Prototype"
+ 63254 "Format identifier"
+ 63255 "Format body"
+ 63256 "HTML Element Text"
+ 63257 "XML Element Text"
+END
+
+STRINGTABLE
+BEGIN
+ IDS_FILTER_INI "Configuration files (*.ini)|*.ini|All files (*.*)|*.*|"
+ IDS_OPENWITH "Select the directory with links to your favorite applications."
+ IDS_FAVORITES "Select the directory with links to your favorite files."
+END
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// German (Switzerland) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DES)
+#ifdef _WIN32
+LANGUAGE LANG_GERMAN, SUBLANG_GERMAN_SWISS
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "#include ""winres.h""\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+#endif // German (Switzerland) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/src/Print.cpp b/src/Print.cpp new file mode 100644 index 0000000..a8ad2eb --- /dev/null +++ b/src/Print.cpp @@ -0,0 +1,604 @@ +/******************************************************************************
+*
+*
+* Notepad2
+*
+* Print.cpp
+* Scintilla Printing Functionality
+* Mostly taken from SciTE, (c) Neil Hodgson, http://www.scintilla.org
+*
+* See Readme.txt for more information about this source code.
+* Please send me your comments to this work.
+*
+* See License.txt for details about distribution and modification.
+*
+* (c) Florian Balmer 1996-2010
+* florian.balmer@gmail.com
+* http://www.flos-freeware.ch
+*
+*
+******************************************************************************/
+#define _WIN32_WINNT 0x501
+#include <windows.h>
+#include <commctrl.h>
+#include <shlwapi.h>
+#include <commdlg.h>
+#include <string.h>
+#include "platform.h"
+#include "scintilla.h"
+#include "scilexer.h"
+extern "C" {
+#include "dialogs.h"
+#include "helpers.h"
+}
+#include "resource.h"
+
+
+extern "C" HINSTANCE g_hInstance;
+
+
+// Global settings...
+extern "C" int iPrintHeader;
+extern "C" int iPrintFooter;
+extern "C" int iPrintColor;
+extern "C" int iPrintZoom;
+extern "C" RECT pagesetupMargin;
+
+
+// Stored objects...
+HGLOBAL hDevMode = NULL;
+HGLOBAL hDevNames = NULL;
+
+
+//=============================================================================
+//
+// EditPrint() - Code from SciTE
+//
+extern "C" HWND hwndStatus;
+
+void StatusUpdatePrintPage(int iPageNum)
+{
+ WCHAR tch[32];
+
+ FormatString(tch,COUNTOF(tch),IDS_PRINTFILE,iPageNum);
+
+ StatusSetText(hwndStatus,255,tch);
+ StatusSetSimple(hwndStatus,TRUE);
+
+ InvalidateRect(hwndStatus,NULL,TRUE);
+ UpdateWindow(hwndStatus);
+}
+
+
+extern "C" BOOL EditPrint(HWND hwnd,LPCWSTR pszDocTitle,LPCWSTR pszPageFormat)
+{
+
+ // Don't print empty documents
+ if (SendMessage(hwnd,SCI_GETLENGTH,0,0) == 0) {
+ MsgBox(MBINFO,IDS_PRINT_EMPTY);
+ return TRUE;
+ }
+
+ int startPos;
+ int endPos;
+
+ HDC hdc;
+
+ RECT rectMargins;
+ RECT rectPhysMargins;
+ RECT rectSetup;
+ POINT ptPage;
+ POINT ptDpi;
+
+ //RECT rectSetup;
+
+ TEXTMETRIC tm;
+
+ int headerLineHeight;
+ HFONT fontHeader;
+
+ int footerLineHeight;
+ HFONT fontFooter;
+
+ WCHAR dateString[256];
+
+ DOCINFO di = {sizeof(DOCINFO), 0, 0, 0, 0};
+
+ LONG lengthDoc;
+ LONG lengthDocMax;
+ LONG lengthPrinted;
+
+ struct RangeToFormat frPrint;
+
+ int pageNum;
+ BOOL printPage;
+
+ WCHAR pageString[32];
+
+ HPEN pen;
+ HPEN penOld;
+
+ PRINTDLG pdlg = { sizeof(PRINTDLG), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ pdlg.hwndOwner = GetParent(hwnd);
+ pdlg.hInstance = g_hInstance;
+ pdlg.Flags = PD_USEDEVMODECOPIES | PD_ALLPAGES | PD_RETURNDC;
+ pdlg.nFromPage = 1;
+ pdlg.nToPage = 1;
+ pdlg.nMinPage = 1;
+ pdlg.nMaxPage = 0xffffU;
+ pdlg.nCopies = 1;
+ pdlg.hDC = 0;
+ pdlg.hDevMode = hDevMode;
+ pdlg.hDevNames = hDevNames;
+
+ startPos = SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0);;
+ endPos = SendMessage(hwnd,SCI_GETSELECTIONEND,0,0);
+
+ if (startPos == endPos) {
+ pdlg.Flags |= PD_NOSELECTION;
+ } else {
+ pdlg.Flags |= PD_SELECTION;
+ }
+ if (0) {
+ // Don't display dialog box, just use the default printer and options
+ pdlg.Flags |= PD_RETURNDEFAULT;
+ }
+ if (!PrintDlg(&pdlg)) {
+ return TRUE; // False means error...
+ }
+
+ hDevMode = pdlg.hDevMode;
+ hDevNames = pdlg.hDevNames;
+
+ hdc = pdlg.hDC;
+
+ // Get printer resolution
+ ptDpi.x = GetDeviceCaps(hdc, LOGPIXELSX); // dpi in X direction
+ ptDpi.y = GetDeviceCaps(hdc, LOGPIXELSY); // dpi in Y direction
+
+ // Start by getting the physical page size (in device units).
+ ptPage.x = GetDeviceCaps(hdc, PHYSICALWIDTH); // device units
+ ptPage.y = GetDeviceCaps(hdc, PHYSICALHEIGHT); // device units
+
+ // Get the dimensions of the unprintable
+ // part of the page (in device units).
+ rectPhysMargins.left = GetDeviceCaps(hdc, PHYSICALOFFSETX);
+ rectPhysMargins.top = GetDeviceCaps(hdc, PHYSICALOFFSETY);
+
+ // To get the right and lower unprintable area,
+ // we take the entire width and height of the paper and
+ // subtract everything else.
+ rectPhysMargins.right = ptPage.x // total paper width
+ - GetDeviceCaps(hdc, HORZRES) // printable width
+ - rectPhysMargins.left; // left unprintable margin
+
+ rectPhysMargins.bottom = ptPage.y // total paper height
+ - GetDeviceCaps(hdc, VERTRES) // printable height
+ - rectPhysMargins.top; // right unprintable margin
+
+ // At this point, rectPhysMargins contains the widths of the
+ // unprintable regions on all four sides of the page in device units.
+
+ // Take in account the page setup given by the user (if one value is not null)
+ if (pagesetupMargin.left != 0 || pagesetupMargin.right != 0 ||
+ pagesetupMargin.top != 0 || pagesetupMargin.bottom != 0) {
+
+ // Convert the hundredths of millimeters (HiMetric) or
+ // thousandths of inches (HiEnglish) margin values
+ // from the Page Setup dialog to device units.
+ // (There are 2540 hundredths of a mm in an inch.)
+
+ WCHAR localeInfo[3];
+ GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IMEASURE, localeInfo, 3);
+
+ if (localeInfo[0] == L'0') { // Metric system. L'1' is US System
+ rectSetup.left = MulDiv (pagesetupMargin.left, ptDpi.x, 2540);
+ rectSetup.top = MulDiv (pagesetupMargin.top, ptDpi.y, 2540);
+ rectSetup.right = MulDiv(pagesetupMargin.right, ptDpi.x, 2540);
+ rectSetup.bottom = MulDiv(pagesetupMargin.bottom, ptDpi.y, 2540);
+ } else {
+ rectSetup.left = MulDiv(pagesetupMargin.left, ptDpi.x, 1000);
+ rectSetup.top = MulDiv(pagesetupMargin.top, ptDpi.y, 1000);
+ rectSetup.right = MulDiv(pagesetupMargin.right, ptDpi.x, 1000);
+ rectSetup.bottom = MulDiv(pagesetupMargin.bottom, ptDpi.y, 1000);
+ }
+
+ // Dont reduce margins below the minimum printable area
+ rectMargins.left = max(rectPhysMargins.left, rectSetup.left);
+ rectMargins.top = max(rectPhysMargins.top, rectSetup.top);
+ rectMargins.right = max(rectPhysMargins.right, rectSetup.right);
+ rectMargins.bottom = max(rectPhysMargins.bottom, rectSetup.bottom);
+ } else {
+ rectMargins.left = rectPhysMargins.left;
+ rectMargins.top = rectPhysMargins.top;
+ rectMargins.right = rectPhysMargins.right;
+ rectMargins.bottom = rectPhysMargins.bottom;
+ }
+
+ // rectMargins now contains the values used to shrink the printable
+ // area of the page.
+
+ // Convert device coordinates into logical coordinates
+ DPtoLP(hdc, (LPPOINT)&rectMargins, 2);
+ DPtoLP(hdc, (LPPOINT)&rectPhysMargins, 2);
+
+ // Convert page size to logical units and we're done!
+ DPtoLP(hdc, (LPPOINT) &ptPage, 1);
+
+ headerLineHeight = MulDiv(8,ptDpi.y, 72);
+ fontHeader = CreateFont(headerLineHeight,
+ 0, 0, 0,
+ FW_BOLD,
+ 0,
+ 0,
+ 0, 0, 0,
+ 0, 0, 0,
+ L"Arial");
+ SelectObject(hdc, fontHeader);
+ GetTextMetrics(hdc, &tm);
+ headerLineHeight = tm.tmHeight + tm.tmExternalLeading;
+
+ if (iPrintHeader == 3)
+ headerLineHeight = 0;
+
+ footerLineHeight = MulDiv(7,ptDpi.y, 72);
+ fontFooter = CreateFont(footerLineHeight,
+ 0, 0, 0,
+ FW_NORMAL,
+ 0,
+ 0,
+ 0, 0, 0,
+ 0, 0, 0,
+ L"Arial");
+ SelectObject(hdc, fontFooter);
+ GetTextMetrics(hdc, &tm);
+ footerLineHeight = tm.tmHeight + tm.tmExternalLeading;
+
+ if (iPrintFooter == 1)
+ footerLineHeight = 0;
+
+ di.lpszDocName = pszDocTitle;
+ di.lpszOutput = 0;
+ di.lpszDatatype = 0;
+ di.fwType = 0;
+ if (StartDoc(hdc, &di) < 0) {
+ DeleteDC(hdc);
+ if (fontHeader)
+ DeleteObject(fontHeader);
+ if (fontFooter)
+ DeleteObject(fontFooter);
+ return FALSE;
+ }
+
+ // Get current date...
+ SYSTEMTIME st;
+ GetLocalTime(&st);
+ GetDateFormat(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&st,NULL,dateString,256);
+
+ // Get current time...
+ if (iPrintHeader == 0)
+ {
+ WCHAR timeString[128];
+ GetTimeFormat(LOCALE_USER_DEFAULT,TIME_NOSECONDS,&st,NULL,timeString,128);
+ lstrcat(dateString,L" ");
+ lstrcat(dateString,timeString);
+ }
+
+ // Set print color mode
+ int printColorModes[5] = {
+ SC_PRINT_NORMAL,
+ SC_PRINT_INVERTLIGHT,
+ SC_PRINT_BLACKONWHITE,
+ SC_PRINT_COLOURONWHITE,
+ SC_PRINT_COLOURONWHITEDEFAULTBG };
+ SendMessage(hwnd,SCI_SETPRINTCOLOURMODE,printColorModes[iPrintColor],0);
+
+ // Set print zoom...
+ SendMessage(hwnd,SCI_SETPRINTMAGNIFICATION,(WPARAM)iPrintZoom,0);
+
+ lengthDoc = SendMessage(hwnd,SCI_GETLENGTH,0,0);
+ lengthDocMax = lengthDoc;
+ lengthPrinted = 0;
+
+ // Requested to print selection
+ if (pdlg.Flags & PD_SELECTION) {
+ if (startPos > endPos) {
+ lengthPrinted = endPos;
+ lengthDoc = startPos;
+ } else {
+ lengthPrinted = startPos;
+ lengthDoc = endPos;
+ }
+
+ if (lengthPrinted < 0)
+ lengthPrinted = 0;
+ if (lengthDoc > lengthDocMax)
+ lengthDoc = lengthDocMax;
+ }
+
+ // We must substract the physical margins from the printable area
+ frPrint.hdc = hdc;
+ frPrint.hdcTarget = hdc;
+ frPrint.rc.left = rectMargins.left - rectPhysMargins.left;
+ frPrint.rc.top = rectMargins.top - rectPhysMargins.top;
+ frPrint.rc.right = ptPage.x - rectMargins.right - rectPhysMargins.left;
+ frPrint.rc.bottom = ptPage.y - rectMargins.bottom - rectPhysMargins.top;
+ frPrint.rcPage.left = 0;
+ frPrint.rcPage.top = 0;
+ frPrint.rcPage.right = ptPage.x - rectPhysMargins.left - rectPhysMargins.right - 1;
+ frPrint.rcPage.bottom = ptPage.y - rectPhysMargins.top - rectPhysMargins.bottom - 1;
+ frPrint.rc.top += headerLineHeight + headerLineHeight / 2;
+ frPrint.rc.bottom -= footerLineHeight + footerLineHeight / 2;
+ // Print each page
+ pageNum = 1;
+
+ while (lengthPrinted < lengthDoc) {
+ printPage = (!(pdlg.Flags & PD_PAGENUMS) ||
+ (pageNum >= pdlg.nFromPage) && (pageNum <= pdlg.nToPage));
+
+ wsprintf(pageString, pszPageFormat, pageNum);
+
+ if (printPage) {
+
+ // Show wait cursor...
+ SendMessage(hwnd,SCI_SETCURSOR,SC_CURSORWAIT,0);
+
+ // Display current page number in Statusbar
+ StatusUpdatePrintPage(pageNum);
+
+ StartPage(hdc);
+
+ SetTextColor(hdc, RGB(0,0,0));
+ SetBkColor(hdc, RGB(255,255,255));
+ SelectObject(hdc, fontHeader);
+ UINT ta = SetTextAlign(hdc, TA_BOTTOM);
+ RECT rcw = {frPrint.rc.left, frPrint.rc.top - headerLineHeight - headerLineHeight / 2,
+ frPrint.rc.right, frPrint.rc.top - headerLineHeight / 2};
+ rcw.bottom = rcw.top + headerLineHeight;
+
+ if (iPrintHeader < 3)
+ {
+ ExtTextOut(hdc, frPrint.rc.left + 5, frPrint.rc.top - headerLineHeight / 2,
+ /*ETO_OPAQUE*/0, &rcw, pszDocTitle,
+ lstrlen(pszDocTitle), NULL);
+ }
+
+ // Print date in header
+ if (iPrintHeader == 0 || iPrintHeader == 1)
+ {
+ SIZE sizeInfo;
+ SelectObject(hdc,fontFooter);
+ GetTextExtentPoint32(hdc,dateString,lstrlen(dateString),&sizeInfo);
+ ExtTextOut(hdc, frPrint.rc.right - 5 - sizeInfo.cx, frPrint.rc.top - headerLineHeight / 2,
+ /*ETO_OPAQUE*/0, &rcw, dateString,
+ lstrlen(dateString), NULL);
+ }
+
+ if (iPrintHeader < 3)
+ {
+ SetTextAlign(hdc, ta);
+ pen = CreatePen(0, 1, RGB(0,0,0));
+ penOld = (HPEN)SelectObject(hdc, pen);
+ MoveToEx(hdc, frPrint.rc.left, frPrint.rc.top - headerLineHeight / 4, NULL);
+ LineTo(hdc, frPrint.rc.right, frPrint.rc.top - headerLineHeight / 4);
+ SelectObject(hdc, penOld);
+ DeleteObject(pen);
+ }
+ }
+
+ frPrint.chrg.cpMin = lengthPrinted;
+ frPrint.chrg.cpMax = lengthDoc;
+
+ lengthPrinted = SendMessage(hwnd,SCI_FORMATRANGE,printPage,(LPARAM)&frPrint);
+
+ if (printPage) {
+ SetTextColor(hdc, RGB(0,0,0));
+ SetBkColor(hdc, RGB(255,255,255));
+ SelectObject(hdc, fontFooter);
+ UINT ta = SetTextAlign(hdc, TA_TOP);
+ RECT rcw = {frPrint.rc.left, frPrint.rc.bottom + footerLineHeight / 2,
+ frPrint.rc.right, frPrint.rc.bottom + footerLineHeight + footerLineHeight / 2};
+
+ if (iPrintFooter == 0)
+ {
+ SIZE sizeFooter;
+ GetTextExtentPoint32(hdc,pageString,lstrlen(pageString),&sizeFooter);
+ ExtTextOut(hdc, frPrint.rc.right - 5 - sizeFooter.cx, frPrint.rc.bottom + footerLineHeight / 2,
+ /*ETO_OPAQUE*/0, &rcw, pageString,
+ lstrlen(pageString), NULL);
+
+ SetTextAlign(hdc, ta);
+ pen = ::CreatePen(0, 1, RGB(0,0,0));
+ penOld = (HPEN)SelectObject(hdc, pen);
+ SetBkColor(hdc, RGB(0,0,0));
+ MoveToEx(hdc, frPrint.rc.left, frPrint.rc.bottom + footerLineHeight / 4, NULL);
+ LineTo(hdc, frPrint.rc.right, frPrint.rc.bottom + footerLineHeight / 4);
+ SelectObject(hdc, penOld);
+ DeleteObject(pen);
+ }
+
+ EndPage(hdc);
+ }
+ pageNum++;
+
+ if ((pdlg.Flags & PD_PAGENUMS) && (pageNum > pdlg.nToPage))
+ break;
+ }
+
+ SendMessage(hwnd,SCI_FORMATRANGE, FALSE, 0);
+
+ EndDoc(hdc);
+ DeleteDC(hdc);
+ if (fontHeader)
+ DeleteObject(fontHeader);
+ if (fontFooter)
+ DeleteObject(fontFooter);
+
+ // Reset Statusbar to default mode
+ StatusSetSimple(hwndStatus,FALSE);
+
+ // Remove wait cursor...
+ SendMessage(hwnd,SCI_SETCURSOR,SC_CURSORNORMAL,0);
+
+ return TRUE;
+}
+
+
+//=============================================================================
+//
+// EditPrintSetup() - Code from SciTE
+//
+// Custom controls: 30 Zoom
+// 31 Spin
+// 32 Header
+// 33 Footer
+// 34 Colors
+//
+extern "C" UINT_PTR CALLBACK PageSetupHook(HWND hwnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
+{
+ switch (uiMsg)
+ {
+ case WM_INITDIALOG:
+ {
+ WCHAR tch[512];
+ WCHAR *p1,*p2;
+
+ SendDlgItemMessage(hwnd,30,EM_LIMITTEXT,32,0);
+
+ SendDlgItemMessage(hwnd,31,UDM_SETRANGE,0,MAKELONG((short)20,(short)-10));
+ SendDlgItemMessage(hwnd,31,UDM_SETPOS,0,MAKELONG((short)iPrintZoom,0));
+
+ // Set header options
+ GetString(IDS_PRINT_HEADER,tch,COUNTOF(tch));
+ lstrcat(tch,L"|");
+ p1 = tch;
+ while (p2 = StrChr(p1,L'|')) {
+ *p2++ = L'\0';
+ if (*p1)
+ SendDlgItemMessage(hwnd,32,CB_ADDSTRING,0,(LPARAM)p1);
+ p1 = p2; }
+ SendDlgItemMessage(hwnd,32,CB_SETCURSEL,(WPARAM)iPrintHeader,0);
+
+ // Set footer options
+ GetString(IDS_PRINT_FOOTER,tch,COUNTOF(tch));
+ lstrcat(tch,L"|");
+ p1 = tch;
+ while (p2 = StrChr(p1,L'|')) {
+ *p2++ = L'\0';
+ if (*p1)
+ SendDlgItemMessage(hwnd,33,CB_ADDSTRING,0,(LPARAM)p1);
+ p1 = p2; }
+ SendDlgItemMessage(hwnd,33,CB_SETCURSEL,(WPARAM)iPrintFooter,0);
+
+ // Set color options
+ GetString(IDS_PRINT_COLOR,tch,COUNTOF(tch));
+ lstrcat(tch,L"|");
+ p1 = tch;
+ while (p2 = StrChr(p1,L'|')) {
+ *p2++ = L'\0';
+ if (*p1)
+ SendDlgItemMessage(hwnd,34,CB_ADDSTRING,0,(LPARAM)p1);
+ p1 = p2; }
+ SendDlgItemMessage(hwnd,34,CB_SETCURSEL,(WPARAM)iPrintColor,0);
+
+ // Make combos handier
+ SendDlgItemMessage(hwnd,32,CB_SETEXTENDEDUI,TRUE,0);
+ SendDlgItemMessage(hwnd,33,CB_SETEXTENDEDUI,TRUE,0);
+ SendDlgItemMessage(hwnd,34,CB_SETEXTENDEDUI,TRUE,0);
+ SendDlgItemMessage(hwnd,1137,CB_SETEXTENDEDUI,TRUE,0);
+ SendDlgItemMessage(hwnd,1138,CB_SETEXTENDEDUI,TRUE,0);
+ }
+ break;
+
+ case WM_COMMAND:
+ if (LOWORD(wParam) == IDOK)
+ {
+ LONG lPos = SendDlgItemMessage(hwnd,31,UDM_GETPOS,0,0);
+ if (HIWORD(lPos) == 0)
+ iPrintZoom = (int)(short)LOWORD(lPos);
+ else
+ iPrintZoom = 0;
+
+ iPrintHeader = SendDlgItemMessage(hwnd,32,CB_GETCURSEL,0,0);
+ iPrintFooter = SendDlgItemMessage(hwnd,33,CB_GETCURSEL,0,0);
+ iPrintColor = SendDlgItemMessage(hwnd,34,CB_GETCURSEL,0,0);
+ }
+ break;
+
+ default:
+ break;
+ }
+ return(0);
+}
+
+
+extern "C" void EditPrintSetup(HWND hwnd)
+{
+ DLGTEMPLATE* pDlgTemplate =
+ LoadThemedDialogTemplate(MAKEINTRESOURCE(IDD_PAGESETUP),g_hInstance);
+
+ PAGESETUPDLG pdlg;
+ ZeroMemory(&pdlg,sizeof(PAGESETUPDLG));
+ pdlg.lStructSize = sizeof(PAGESETUPDLG);
+ pdlg.Flags = PSD_ENABLEPAGESETUPHOOK | PSD_ENABLEPAGESETUPTEMPLATEHANDLE;
+ pdlg.lpfnPageSetupHook = PageSetupHook;
+ pdlg.hPageSetupTemplate = pDlgTemplate;
+ pdlg.hwndOwner = GetParent(hwnd);
+ pdlg.hInstance = g_hInstance;
+
+ if (pagesetupMargin.left != 0 || pagesetupMargin.right != 0 ||
+ pagesetupMargin.top != 0 || pagesetupMargin.bottom != 0) {
+ pdlg.Flags |= PSD_MARGINS;
+
+ pdlg.rtMargin.left = pagesetupMargin.left;
+ pdlg.rtMargin.top = pagesetupMargin.top;
+ pdlg.rtMargin.right = pagesetupMargin.right;
+ pdlg.rtMargin.bottom = pagesetupMargin.bottom;
+ }
+
+ pdlg.hDevMode = hDevMode;
+ pdlg.hDevNames = hDevNames;
+
+ if (PageSetupDlg(&pdlg)) {
+
+ pagesetupMargin.left = pdlg.rtMargin.left;
+ pagesetupMargin.top = pdlg.rtMargin.top;
+ pagesetupMargin.right = pdlg.rtMargin.right;
+ pagesetupMargin.bottom = pdlg.rtMargin.bottom;
+
+ hDevMode = pdlg.hDevMode;
+ hDevNames = pdlg.hDevNames;
+ }
+
+ LocalFree(pDlgTemplate);
+}
+
+
+//=============================================================================
+//
+// EditPrintInit() - Setup default page margin if no values from registry
+//
+extern "C" void EditPrintInit()
+{
+ if (pagesetupMargin.left == -1 || pagesetupMargin.top == -1 ||
+ pagesetupMargin.right == -1 || pagesetupMargin.bottom == -1)
+ {
+ WCHAR localeInfo[3];
+ GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IMEASURE, localeInfo, 3);
+
+ if (localeInfo[0] == L'0') { // Metric system. L'1' is US System
+ pagesetupMargin.left = 2000;
+ pagesetupMargin.top = 2000;
+ pagesetupMargin.right = 2000;
+ pagesetupMargin.bottom = 2000; }
+
+ else {
+ pagesetupMargin.left = 1000;
+ pagesetupMargin.top = 1000;
+ pagesetupMargin.right = 1000;
+ pagesetupMargin.bottom = 1000; }
+ }
+}
+
+
+// End of Print.cpp
diff --git a/src/Styles.c b/src/Styles.c new file mode 100644 index 0000000..7f7d8d5 --- /dev/null +++ b/src/Styles.c @@ -0,0 +1,3437 @@ +/******************************************************************************
+*
+*
+* Notepad2
+*
+* Styles.c
+* Scintilla Style Management
+*
+* See Readme.txt for more information about this source code.
+* Please send me your comments to this work.
+*
+* See License.txt for details about distribution and modification.
+*
+* (c) Florian Balmer 1996-2010
+* florian.balmer@gmail.com
+* http://www.flos-freeware.ch
+*
+*
+******************************************************************************/
+#define _WIN32_WINNT 0x501
+#include <windows.h>
+#include <commctrl.h>
+#include <commdlg.h>
+#include <shlobj.h>
+#include <shlwapi.h>
+#include <stdio.h>
+#include "dialogs.h"
+#include "helpers.h"
+#include "notepad2.h"
+#include "scintilla.h"
+#include "scilexer.h"
+#include "edit.h"
+#include "styles.h"
+#include "resource.h"
+
+
+#define MULTI_STYLE(a,b,c,d) ((a)|(b<<8)|(c<<16)|(d<<24))
+
+
+KEYWORDLIST KeyWords_NULL = {
+"", "", "", "", "", "", "", "", "" };
+
+
+EDITLEXER lexDefault = { SCLEX_NULL, 63000, L"Default Text", L"txt; text; wtx; log; asc; doc; diz; nfo", L"", &KeyWords_NULL, {
+ /* 0 */ { STYLE_DEFAULT, 63100, L"Default Style", L"font:Lucida Console; size:10", L"" },
+ /* 1 */ { STYLE_LINENUMBER, 63101, L"Margins and Line Numbers", L"size:-2; fore:#FF0000", L"" },
+ /* 2 */ { STYLE_BRACELIGHT, 63102, L"Matching Braces", L"size:+1; bold; fore:#FF0000", L"" },
+ /* 3 */ { STYLE_BRACEBAD, 63103, L"Matching Braces Error", L"size:+1; bold; fore:#000080", L"" },
+ /* 4 */ { STYLE_CONTROLCHAR, 63104, L"Control Characters (Font)", L"size:-1", L"" },
+ /* 5 */ { STYLE_INDENTGUIDE, 63105, L"Indentation Guide (Color)", L"fore:#FFC000", L"" },
+ /* 6 */ { SCI_SETSELFORE+SCI_SETSELBACK, 63106, L"Selected Text (Colors)", L"back:#0A246A; eolfilled; alpha:95", L"" },
+ /* 7 */ { SCI_SETWHITESPACEFORE+SCI_SETWHITESPACEBACK+SCI_SETWHITESPACESIZE, 63107, L"Whitespace (Colors, Size 0-5)", L"fore:#FF4000", L"" },
+ /* 8 */ { SCI_SETCARETLINEBACK, 63108, L"Current Line Background (Color)", L"back:#FFFF00; alpha:50", L"" },
+ /* 9 */ { SCI_SETCARETFORE, 63109, L"Caret Foreground (Color)", L"", L"" },
+ /* 10 */ { SCI_SETCARETWIDTH, 63110, L"Caret Width (Size 1-3)", L"", L"" },
+ /* 11 */ { SCI_SETEDGECOLOUR, 63111, L"Long Line Marker (Colors)", L"fore:#FFC000", L"" },
+ /* 12 */ { SCI_SETEXTRAASCENT+SCI_SETEXTRADESCENT, 63112, L"Extra Line Spacing (Size)", L"size:2", L"" },
+
+ /* 13 */ { STYLE_DEFAULT, 63113, L"2nd Default Style", L"font:Courier New; size:10", L"" },
+ /* 14 */ { STYLE_LINENUMBER, 63114, L"2nd Margins and Line Numbers", L"font:Tahoma; size:-2; fore:#FF0000", L"" },
+ /* 15 */ { STYLE_BRACELIGHT, 63115, L"2nd Matching Braces", L"bold; fore:#FF0000", L"" },
+ /* 16 */ { STYLE_BRACEBAD, 63116, L"2nd Matching Braces Error", L"bold; fore:#000080", L"" },
+ /* 17 */ { STYLE_CONTROLCHAR, 63117, L"2nd Control Characters (Font)", L"size:-1", L"" },
+ /* 18 */ { STYLE_INDENTGUIDE, 63118, L"2nd Indentation Guide (Color)", L"fore:#FFC000", L"" },
+ /* 19 */ { SCI_SETSELFORE+SCI_SETSELBACK, 63119, L"2nd Selected Text (Colors)", L"eolfilled", L"" },
+ /* 20 */ { SCI_SETWHITESPACEFORE+SCI_SETWHITESPACEBACK+SCI_SETWHITESPACESIZE, 63120, L"2nd Whitespace (Colors, Size 0-5)", L"fore:#FF4000", L"" },
+ /* 21 */ { SCI_SETCARETLINEBACK, 63121, L"2nd Current Line Background (Color)", L"", L"" },
+ /* 22 */ { SCI_SETCARETFORE, 63122, L"2nd Caret Foreground (Color)", L"", L"" },
+ /* 23 */ { SCI_SETCARETWIDTH, 63123, L"2nd Caret Width (Size 1-3)", L"", L"" },
+ /* 24 */ { SCI_SETEDGECOLOUR, 63124, L"2nd Long Line Marker (Colors)", L"fore:#FFC000", L"" },
+ /* 25 */ { SCI_SETEXTRAASCENT+SCI_SETEXTRADESCENT, 63125, L"2nd Extra Line Spacing (Size)", L"", L"" },
+ { -1, 00000, L"", L"", L"" } } };
+
+
+KEYWORDLIST KeyWords_HTML = {
+"a abbr accept accept-charset accesskey acronym action address align alink alt and applet archive "
+"area article aside async audio autocomplete autofocus axis b background base basefont bb bdo "
+"bgcolor big blockquote body border bordercolor br button canvas caption cellpadding cellspacing "
+"center char charoff charset checkbox checked cite class classid clear code codebase codetype col "
+"colgroup color cols colspan command compact content contenteditable contextmenu coords data "
+"datafld dataformatas datagrid datalist datapagesize datasrc datetime dd declare defer del "
+"details dfn dialog dir disabled div dl draggable dt em embed enctype event eventsource face "
+"fieldset figure file font footer for form formaction formenctype formmethod formnovalidate "
+"formtarget frame frameborder frameset h1 h2 h3 h4 h5 h6 head header headers height hidden hr "
+"href hreflang hspace html http-equiv i id iframe image img input ins isindex ismap kbd keygen "
+"label lang language leftmargin legend li link list longdesc manifest map marginheight "
+"marginwidth mark max maxlength media menu meta meter method min multiple name nav noframes "
+"nohref noresize noscript noshade novalidate nowrap object ol onblur onchange onclick ondblclick "
+"onfocus onkeydown onkeypress onkeyup onload onmessage onmousedown onmousemove onmouseout "
+"onmouseover onmouseup onreset onselect onsubmit onunload optgroup option output p param password "
+"pattern ping placeholder pre profile progress prompt public q radio readonly rel required reset "
+"rev reversed rows rowspan rp rt ruby rules s samp sandbox scheme scope scoped script scrolling "
+"seamless section select selected shape size sizes small source span spellcheck src standby start "
+"step strike strong style sub submit summary sup tabindex table target tbody td text textarea "
+"tfoot th thead time title topmargin tr tt type u ul usemap valign value valuetype var version "
+"video vlink vspace width xml xmlns !doctype",
+"abstract boolean break byte case catch char class const continue debugger default delete do "
+"double else enum export extends false final finally float for function goto if implements "
+"import in instanceof int interface long native new null package private protected public "
+"return short static super switch synchronized this throw throws transient true try typeof var "
+"void volatile while with",
+"and begin case call continue do each else elseif end erase error event exit false for function get "
+"gosub goto if implement in load loop lset me mid new next not nothing on or property raiseevent "
+"rem resume return rset select set stop sub then to true unload until wend while with withevents "
+"attribute alias as boolean byref byte byval const compare currency date declare dim double enum "
+"explicit friend global integer let lib long module object option optional preserve private property "
+"public redim single static string type variant",
+"and assert break class continue def del elif else except exec finally for from global if import in is "
+"lambda None not or pass print raise return try while yield",
+"__callstatic __class__ __dir__ __file__ __function__ __get __isset __line__ __method__ "
+"__namespace__ __set __sleep __unset __wakeup abstract and argc argv array as break case catch "
+"cfunction class clone const continue declare default define die do e_all e_error e_fatal "
+"e_notice e_parse e_strict e_warning echo else elseif empty enddeclare endfor endforeach endif "
+"endswitch endwhile eval exception exit extends false final for foreach function global goto "
+"http_cookie_vars http_env_vars http_get_vars http_post_files http_post_vars http_server_vars if "
+"implements include include_once instanceof interface isset list namespace new not null "
+"old_function or parent php_self print private protected public require require_once return "
+"static stdclass switch this throw true try unset use var virtual while xor",
+"", "", "", "" };
+
+
+EDITLEXER lexHTML = { SCLEX_HTML, 63001, L"Web Source Code", L"html; htm; asp; aspx; shtml; htd; xhtml; php; php3; phtml; htt; cfm; tpl; dtd; hta; htc", L"", &KeyWords_HTML, {
+ { STYLE_DEFAULT, 63126, L"Default", L"", L"" },
+ { MULTI_STYLE(SCE_H_TAG,SCE_H_TAGEND,0,0), 63136, L"HTML Tag", L"fore:#648000", L"" },
+ { SCE_H_TAGUNKNOWN, 63137, L"HTML Unknown Tag", L"fore:#C80000; back:#FFFF80", L"" },
+ { SCE_H_ATTRIBUTE, 63138, L"HTML Attribute", L"fore:#FF4000", L"" },
+ { SCE_H_ATTRIBUTEUNKNOWN, 63139, L"HTML Unknown Attribute", L"fore:#C80000; back:#FFFF80", L"" },
+ { SCE_H_VALUE, 63140, L"HTML Value", L"fore:#3A6EA5", L"" },
+ { MULTI_STYLE(SCE_H_DOUBLESTRING,SCE_H_SINGLESTRING,0,0), 63141, L"HTML String", L"fore:#3A6EA5", L"" },
+ { SCE_H_OTHER, 63142, L"HTML Other Inside Tag", L"fore:#3A6EA5", L"" },
+ { MULTI_STYLE(SCE_H_COMMENT,SCE_H_XCCOMMENT,0,0), 63143, L"HTML Comment", L"fore:#646464", L"" },
+ { SCE_H_ENTITY, 63144, L"HTML Entity", L"fore:#B000B0", L"" },
+ { SCE_H_DEFAULT, 63256, L"HTML Element Text", L"", L"" },
+ { MULTI_STYLE(SCE_H_XMLSTART,SCE_H_XMLEND,0,0), 63145, L"XML Identifier", L"bold; fore:#881280", L"" },
+ { SCE_H_SGML_DEFAULT, 63237, L"SGML", L"fore:#881280", L"" },
+ { SCE_H_CDATA, 63147, L"CDATA", L"fore:#646464", L"" },
+ { MULTI_STYLE(SCE_H_ASP,SCE_H_ASPAT,0,0), 63146, L"ASP Start Tag", L"bold; fore:#000080", L"" },
+ //{ SCE_H_SCRIPT, L"Script", L"", L"" },
+ { SCE_H_QUESTION, 63148, L"PHP Start Tag", L"bold; fore:#000080", L"" },
+ { SCE_HPHP_DEFAULT, 63149, L"PHP Default", L"", L"" },
+ { MULTI_STYLE(SCE_HPHP_COMMENT,SCE_HPHP_COMMENTLINE,0,0), 63157, L"PHP Comment", L"fore:#FF8000", L"" },
+ { SCE_HPHP_WORD, 63152, L"PHP Keyword", L"bold; fore:#A46000", L"" },
+ { SCE_HPHP_HSTRING, 63150, L"PHP String", L"fore:#008000", L"" },
+ { SCE_HPHP_SIMPLESTRING, 63151, L"PHP Simple String", L"fore:#008000", L"" },
+ { SCE_HPHP_NUMBER, 63153, L"PHP Number", L"fore:#FF0000", L"" },
+ { SCE_HPHP_OPERATOR, 63158, L"PHP Operator", L"fore:#B000B0", L"" },
+ { SCE_HPHP_VARIABLE, 63154, L"PHP Variable", L"italic; fore:#000080", L"" },
+ { SCE_HPHP_HSTRING_VARIABLE, 63155, L"PHP String Variable", L"italic; fore:#000080", L"" },
+ { SCE_HPHP_COMPLEX_VARIABLE, 63156, L"PHP Complex Variable", L"italic; fore:#000080", L"" },
+ { MULTI_STYLE(SCE_HJ_DEFAULT,SCE_HJ_START,0,0), 63159, L"JS Default", L"", L"" },
+ { MULTI_STYLE(SCE_HJ_COMMENT,SCE_HJ_COMMENTLINE,SCE_HJ_COMMENTDOC,0), 63160, L"JS Comment", L"fore:#646464", L"" },
+ { SCE_HJ_KEYWORD, 63163, L"JS Keyword", L"bold; fore:#A46000", L"" },
+ { SCE_HJ_WORD, 63162, L"JS Identifier", L"", L"" },
+ { MULTI_STYLE(SCE_HJ_DOUBLESTRING,SCE_HJ_SINGLESTRING,SCE_HJ_STRINGEOL,0), 63164, L"JS String", L"fore:#008000", L"" },
+ { SCE_HJ_REGEX, 63166, L"JS Regex", L"fore:#006633; back:#FFF1A8", L"" },
+ { SCE_HJ_NUMBER, 63161, L"JS Number", L"fore:#FF0000", L"" },
+ { SCE_HJ_SYMBOLS, 63165, L"JS Symbols", L"fore:#B000B0", L"" },
+ { MULTI_STYLE(SCE_HJA_DEFAULT,SCE_HJA_START,0,0), 63167, L"ASP JS Default", L"", L"" },
+ { MULTI_STYLE(SCE_HJA_COMMENT,SCE_HJA_COMMENTLINE,SCE_HJA_COMMENTDOC,0), 63168, L"ASP JS Comment", L"fore:#646464", L"" },
+ { SCE_HJA_KEYWORD, 63171, L"ASP JS Keyword", L"bold; fore:#A46000", L"" },
+ { SCE_HJA_WORD, 63170, L"ASP JS Identifier", L"", L"" },
+ { MULTI_STYLE(SCE_HJA_DOUBLESTRING,SCE_HJA_SINGLESTRING,SCE_HJA_STRINGEOL,0), 63172, L"ASP JS String", L"fore:#008000", L"" },
+ { SCE_HJA_REGEX, 63174, L"ASP JS Regex", L"fore:#006633; back:#FFF1A8", L"" },
+ { SCE_HJA_NUMBER, 63169, L"ASP JS Number", L"fore:#FF0000", L"" },
+ { SCE_HJA_SYMBOLS, 63173, L"ASP JS Symbols", L"fore:#B000B0", L"" },
+ { MULTI_STYLE(SCE_HB_DEFAULT,SCE_HB_START,0,0), 63175, L"VBS Default", L"", L"" },
+ { SCE_HB_COMMENTLINE, 63176, L"VBS Comment", L"fore:#646464", L"" },
+ { SCE_HB_WORD, 63178, L"VBS Keyword", L"bold; fore:#B000B0", L"" },
+ { SCE_HB_IDENTIFIER, 63180, L"VBS Identifier", L"", L"" },
+ { MULTI_STYLE(SCE_HB_STRING,SCE_HB_STRINGEOL,0,0), 63179, L"VBS String", L"fore:#008000", L"" },
+ { SCE_HB_NUMBER, 63177, L"VBS Number", L"fore:#FF0000", L"" },
+ { MULTI_STYLE(SCE_HBA_DEFAULT,SCE_HBA_START,0,0), 63181, L"ASP VBS Default", L"", L"" },
+ { SCE_HBA_COMMENTLINE, 63182, L"ASP VBS Comment", L"fore:#646464", L"" },
+ { SCE_HBA_WORD, 63184, L"ASP VBS Keyword", L"bold; fore:#B000B0", L"" },
+ { SCE_HBA_IDENTIFIER, 63186, L"ASP VBS Identifier", L"", L"" },
+ { MULTI_STYLE(SCE_HBA_STRING,SCE_HBA_STRINGEOL,0,0), 63185, L"ASP VBS String", L"fore:#008000", L"" },
+ { SCE_HBA_NUMBER, 63183, L"ASP VBS Number", L"fore:#FF0000", L"" },
+ //{ SCE_HP_START, L"Phyton Start", L"", L"" },
+ //{ SCE_HP_DEFAULT, L"Phyton Default", L"", L"" },
+ //{ SCE_HP_COMMENTLINE, L"Phyton Comment Line", L"", L"" },
+ //{ SCE_HP_NUMBER, L"Phyton Number", L"", L"" },
+ //{ SCE_HP_STRING, L"Phyton String", L"", L"" },
+ //{ SCE_HP_CHARACTER, L"Phyton Character", L"", L"" },
+ //{ SCE_HP_WORD, L"Phyton Keyword", L"", L"" },
+ //{ SCE_HP_TRIPLE, L"Phyton Triple", L"", L"" },
+ //{ SCE_HP_TRIPLEDOUBLE, L"Phyton Triple Double", L"", L"" },
+ //{ SCE_HP_CLASSNAME, L"Phyton Class Name", L"", L"" },
+ //{ SCE_HP_DEFNAME, L"Phyton Def Name", L"", L"" },
+ //{ SCE_HP_OPERATOR, L"Phyton Operator", L"", L"" },
+ //{ SCE_HP_IDENTIFIER, L"Phyton Identifier", L"", L"" },
+ //{ SCE_HPA_START, L"ASP Phyton Start", L"", L"" },
+ //{ SCE_HPA_DEFAULT, L"ASP Phyton Default", L"", L"" },
+ //{ SCE_HPA_COMMENTLINE, L"ASP Phyton Comment Line", L"", L"" },
+ //{ SCE_HPA_NUMBER, L"ASP Phyton Number", L"", L"" },
+ //{ SCE_HPA_STRING, L"ASP Phyton String", L"", L"" },
+ //{ SCE_HPA_CHARACTER, L"ASP Phyton Character", L"", L"" },
+ //{ SCE_HPA_WORD, L"ASP Phyton Keyword", L"", L"" },
+ //{ SCE_HPA_TRIPLE, L"ASP Phyton Triple", L"", L"" },
+ //{ SCE_HPA_TRIPLEDOUBLE, L"ASP Phyton Triple Double", L"", L"" },
+ //{ SCE_HPA_CLASSNAME, L"ASP Phyton Class Name", L"", L"" },
+ //{ SCE_HPA_DEFNAME, L"ASP Phyton Def Name", L"", L"" },
+ //{ SCE_HPA_OPERATOR, L"ASP Phyton Operator", L"", L"" },
+ //{ SCE_HPA_IDENTIFIER, L"ASP Phyton Identifier", L"", L"" },
+ { -1, 00000, L"", L"", L"" } } };
+
+
+KEYWORDLIST KeyWords_XML = {
+"", "", "", "", "", "", "", "", "" };
+
+
+EDITLEXER lexXML = { SCLEX_XML, 63002, L"XML Document", L"xml; xsl; rss; svg; xul; xsd; xslt; axl; rdf; xaml; vcproj", L"", &KeyWords_XML, {
+ { STYLE_DEFAULT, 63126, L"Default", L"", L"" },
+ { MULTI_STYLE(SCE_H_TAG,SCE_H_TAGUNKNOWN,SCE_H_TAGEND,0), 63187, L"XML Tag", L"fore:#881280", L"" },
+ { MULTI_STYLE(SCE_H_ATTRIBUTE,SCE_H_ATTRIBUTEUNKNOWN,0,0), 63188, L"XML Attribute", L"fore:#994500", L"" },
+ { SCE_H_VALUE, 63189, L"XML Value", L"fore:#1A1AA6", L"" },
+ { MULTI_STYLE(SCE_H_DOUBLESTRING,SCE_H_SINGLESTRING,0,0), 63190, L"XML String", L"fore:#1A1AA6", L"" },
+ { SCE_H_OTHER, 63191, L"XML Other Inside Tag", L"fore:#1A1AA6", L"" },
+ { MULTI_STYLE(SCE_H_COMMENT,SCE_H_XCCOMMENT,0,0), 63192, L"XML Comment", L"fore:#646464", L"" },
+ { SCE_H_ENTITY, 63193, L"XML Entity", L"fore:#B000B0", L"" },
+ { SCE_H_DEFAULT, 63257, L"XML Element Text", L"", L"" },
+ { MULTI_STYLE(SCE_H_XMLSTART,SCE_H_XMLEND,0,0), 63145, L"XML Identifier", L"bold; fore:#881280", L"" },
+ { SCE_H_SGML_DEFAULT, 63237, L"SGML", L"fore:#881280", L"" },
+ { SCE_H_CDATA, 63147, L"CDATA", L"fore:#646464", L"" },
+ { -1, 00000, L"", L"", L"" } } };
+
+
+KEYWORDLIST KeyWords_CSS = {
+"background background-attachment background-color background-image "
+"background-position background-repeat border border-bottom "
+"border-bottom-width border-color border-left border-left-width border-right "
+"border-right-width border-style border-top border-top-width border-width "
+"clear color display float font font-family font-size font-style font-variant "
+"font-weight height letter-spacing line-height list-style list-style-image "
+"list-style-position list-style-type margin margin-bottom margin-left "
+"margin-right margin-top padding padding-bottom padding-left padding-right "
+"padding-top text-align text-decoration text-indent text-transform "
+"vertical-align white-space width word-spacing",
+"first-letter first-line link active visited first-child "
+"focus hover lang before after left right first",
+"ascent azimuth baseline bbox border-bottom-color border-bottom-style "
+"border-collapse border-color border-left-color border-left-style "
+"border-right-color border-right-style border-spacing border-style "
+"border-top-color border-top-style bottom cap-height caption-side centerline "
+"clip content counter-increment counter-reset cue cue-after cue-before cursor "
+"definition-src descent direction elevation empty-cells font-size-adjust "
+"font-stretch left marker-offset marks mathline max-height max-width "
+"min-height min-width orphans outline outline-color outline-style "
+"outline-width overflow page page-break-after page-break-before "
+"page-break-inside panose-1 pause pause-after pause-before pitch pitch-range "
+"play-during position quotes richness right size slope speak speak-header "
+"speak-numeral speak-punctuation speech-rate src stemh stemv stress "
+"table-layout text-shadow top topline unicode-bidi unicode-range units-per-em "
+"visibility voice-family volume widows widths x-height z-index",
+"", "", "", "", "", "" };
+
+
+EDITLEXER lexCSS = { SCLEX_CSS, 63003, L"CSS Style Sheets", L"css", L"", &KeyWords_CSS, {
+ { STYLE_DEFAULT, 63126, L"Default", L"", L"" },
+ //{ SCE_CSS_DEFAULT, L"Default", L"", L"" },
+ { SCE_CSS_COMMENT, 63127, L"Comment", L"fore:#646464", L"" },
+ { SCE_CSS_TAG, 63136, L"HTML Tag", L"bold; fore:#0A246A", L"" },
+ { SCE_CSS_CLASS, 63194, L"Tag-Class", L"fore:#648000", L"" },
+ { SCE_CSS_ID, 63195, L"Tag-Id", L"fore:#648000", L"" },
+ { SCE_CSS_ATTRIBUTE, 63196, L"Tag-Attribute", L"italic; fore:#648000", L"" },
+ { MULTI_STYLE(SCE_CSS_PSEUDOCLASS,SCE_CSS_EXTENDED_PSEUDOCLASS,SCE_CSS_PSEUDOELEMENT,SCE_CSS_EXTENDED_PSEUDOELEMENT), 63197, L"Pseudo-class/element", L"fore:#B000B0", L"" },
+ { SCE_CSS_UNKNOWN_PSEUDOCLASS, 63198, L"Unknown Pseudo-class", L"fore:#C80000; back:#FFFF80", L"" },
+ { MULTI_STYLE(SCE_CSS_IDENTIFIER,SCE_CSS_IDENTIFIER2,SCE_CSS_IDENTIFIER3,SCE_CSS_EXTENDED_IDENTIFIER), 63199, L"CSS Property", L"fore:#FF4000", L"" },
+ { SCE_CSS_UNKNOWN_IDENTIFIER, 63200, L"Unknown Property", L"fore:#C80000; back:#FFFF80", L"" },
+ { MULTI_STYLE(SCE_CSS_DOUBLESTRING,SCE_CSS_SINGLESTRING,0,0), 63131, L"String", L"fore:#008000", L"" },
+ { SCE_CSS_VALUE, 63201, L"Value", L"fore:#3A6EA5", L"" },
+ { SCE_CSS_OPERATOR, 63132, L"Operator", L"fore:#B000B0", L"" },
+ { SCE_CSS_IMPORTANT, 63202, L"Important", L"bold; fore:#C80000", L"" },
+ { SCE_CSS_DIRECTIVE, 63203, L"Directive", L"bold; fore:#000000; back:#FFF1A8", L"" },
+ { -1, 00000, L"", L"", L"" } } };
+
+
+KEYWORDLIST KeyWords_CPP = {
+"__abstract __alignof __asm __assume __based __box __cdecl __declspec __delegate __event "
+"__except __except__try __fastcall __finally __forceinline __gc __hook __identifier "
+"__if_exists __if_not_exists __inline __int16 __int32 __int64 __int8 __interface __leave "
+"__m128 __m128d __m128i __m64 __multiple_inheritance __nogc __noop __pin __property __raise "
+"__sealed __single_inheritance __stdcall __super __try __try_cast __unhook __uuidof __value "
+"__virtual_inheritance __wchar_t auto bool break case catch char class const const_cast "
+"continue default defined delete do double dynamic_cast else enum explicit extern false float "
+"for friend goto if inline int long mutable naked namespace new operator private protected "
+"public register reinterpret_cast return short signed size_t sizeof static static_cast struct "
+"switch template this throw true try typedef typeid typename union unsigned using uuid "
+"virtual void volatile wchar_t while",
+"",
+"", "", "", "", "", "", "" };
+
+
+EDITLEXER lexCPP = { SCLEX_CPP, 63004, L"C/C++ Source Code", L"c; cpp; cxx; cc; h; hpp; hxx; hh; m; mm; idl; inl; odl", L"", &KeyWords_CPP, {
+ { STYLE_DEFAULT, 63126, L"Default", L"", L"" },
+ //{ SCE_C_DEFAULT, L"Default", L"", L"" },
+ { SCE_C_COMMENT, 63127, L"Comment", L"fore:#008000", L"" },
+ { SCE_C_WORD, 63128, L"Keyword", L"bold; fore:#0A246A", L"" },
+ { SCE_C_IDENTIFIER, 63129, L"Identifier", L"", L"" },
+ { MULTI_STYLE(SCE_C_STRING,SCE_C_CHARACTER,SCE_C_STRINGEOL,SCE_C_VERBATIM), 63131, L"String", L"fore:#008000", L"" },
+ { SCE_C_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" },
+ { SCE_C_OPERATOR, 63132, L"Operator", L"fore:#B000B0", L"" },
+ { SCE_C_PREPROCESSOR, 63133, L"Preprocessor", L"fore:#FF8000", L"" },
+ //{ SCE_C_UUID, L"UUID", L"", L"" },
+ //{ SCE_C_REGEX, L"Regex", L"", L"" },
+ //{ SCE_C_WORD2, L"Word 2", L"", L"" },
+ //{ SCE_C_GLOBALCLASS, L"Global Class", L"", L"" },
+ { -1, 00000, L"", L"", L"" } } };
+
+
+KEYWORDLIST KeyWords_CS = {
+"abstract as base bool break byte case catch char checked class const "
+"continue decimal default delegate do double else enum event explicit "
+"extern false finally fixed float for foreach goto if implicit in int interface "
+"internal is lock long namespace new null object operator out override "
+"params private protected public readonly ref return sbyte sealed short "
+"sizeof stackalloc static string struct switch this throw true try typeof "
+"uint ulong unchecked unsafe ushort using virtual void while",
+"",
+"", "", "", "", "", "", "" };
+
+
+EDITLEXER lexCS = { SCLEX_CPP, 63005, L"C# Source Code", L"cs", L"", &KeyWords_CS, {
+ { STYLE_DEFAULT, 63126, L"Default", L"", L"" },
+ //{ SCE_C_DEFAULT, L"Default", L"", L"" },
+ { SCE_C_COMMENT, 63127, L"Comment", L"fore:#008000", L"" },
+ { SCE_C_WORD, 63128, L"Keyword", L"bold; fore:#804000", L"" },
+ { SCE_C_IDENTIFIER, 63129, L"Identifier", L"", L"" },
+ { MULTI_STYLE(SCE_C_STRING,SCE_C_CHARACTER,SCE_C_STRINGEOL,0), 63131, L"String", L"fore:#008000", L"" },
+ { SCE_C_VERBATIM, 63134, L"Verbatim String", L"fore:#008000", L"" },
+ { SCE_C_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" },
+ { SCE_C_OPERATOR, 63132, L"Operator", L"fore:#B000B0", L"" },
+ { SCE_C_PREPROCESSOR, 63133, L"Preprocessor", L"fore:#FF8000", L"" },
+ //{ SCE_C_UUID, L"UUID", L"", L"" },
+ //{ SCE_C_REGEX, L"Regex", L"", L"" },
+ //{ SCE_C_WORD2, L"Word 2", L"", L"" },
+ //{ SCE_C_GLOBALCLASS, L"Global Class", L"", L"" },
+ { -1, 00000, L"", L"", L"" } } };
+
+
+KEYWORDLIST KeyWords_RC = {
+"ACCELERATORS ALT AUTO3STATE AUTOCHECKBOX AUTORADIOBUTTON "
+"BEGIN BITMAP BLOCK BUTTON CAPTION CHARACTERISTICS CHECKBOX "
+"CLASS COMBOBOX CONTROL CTEXT CURSOR DEFPUSHBUTTON DIALOG "
+"DIALOGEX DISCARDABLE EDITTEXT END EXSTYLE FONT GROUPBOX "
+"ICON LANGUAGE LISTBOX LTEXT MENU MENUEX MENUITEM "
+"MESSAGETABLE POPUP PUSHBUTTON RADIOBUTTON RCDATA RTEXT "
+"SCROLLBAR SEPARATOR SHIFT STATE3 STRINGTABLE STYLE "
+"TEXTINCLUDE VALUE VERSION VERSIONINFO VIRTKEY",
+"", "", "", "", "", "", "", "" };
+
+
+EDITLEXER lexRC = { SCLEX_CPP, 63006, L"Resource Script", L"rc; rc2; rct; rh; r; dlg", L"", &KeyWords_RC, {
+ { STYLE_DEFAULT, 63126, L"Default", L"", L"" },
+ //{ SCE_C_DEFAULT, L"Default", L"", L"" },
+ { SCE_C_COMMENT, 63127, L"Comment", L"fore:#008000", L"" },
+ { SCE_C_WORD, 63128, L"Keyword", L"bold; fore:#0A246A", L"" },
+ { SCE_C_IDENTIFIER, 63129, L"Identifier", L"", L"" },
+ { MULTI_STYLE(SCE_C_STRING,SCE_C_CHARACTER,SCE_C_STRINGEOL,SCE_C_VERBATIM), 63131, L"String", L"fore:#008000", L"" },
+ { SCE_C_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" },
+ { SCE_C_OPERATOR, 63132, L"Operator", L"fore:#0A246A", L"" },
+ { SCE_C_PREPROCESSOR, 63133, L"Preprocessor", L"fore:#FF8000", L"" },
+ //{ SCE_C_UUID, L"UUID", L"", L"" },
+ //{ SCE_C_REGEX, L"Regex", L"", L"" },
+ //{ SCE_C_WORD2, L"Word 2", L"", L"" },
+ //{ SCE_C_GLOBALCLASS, L"Global Class", L"", L"" },
+ { -1, 00000, L"", L"", L"" } } };
+
+
+KEYWORDLIST KeyWords_MAK = {
+"", "", "", "", "", "", "", "", "" };
+
+
+EDITLEXER lexMAK = { SCLEX_MAKEFILE, 63007, L"Makefiles", L"mak; make; dsp", L"", &KeyWords_MAK, {
+ { STYLE_DEFAULT, 63126, L"Default", L"fore:#0A246A", L"" },
+ //{ SCE_MAKE_DEFAULT, L"Default", L"", L"" },
+ { SCE_MAKE_COMMENT, 63127, L"Comment", L"fore:#008000", L"" },
+ { MULTI_STYLE(SCE_MAKE_IDENTIFIER,SCE_MAKE_IDEOL,0,0), 63129, L"Identifier", L"fore:#003CE6", L"" },
+ { SCE_MAKE_OPERATOR, 63132, L"Operator", L"", L"" },
+ { SCE_MAKE_TARGET, 63204, L"Target", L"fore:#003CE6; back:#FFC000", L"" },
+ { SCE_MAKE_PREPROCESSOR, 63133, L"Preprocessor", L"fore:#FF8000", L"" },
+ { -1, 00000, L"", L"", L"" } } };
+
+
+KEYWORDLIST KeyWords_VBS = {
+"alias and as attribute begin boolean byref byte byval call case class compare const continue "
+"currency date declare dim do double each else elseif empty end enum eqv erase error event exit "
+"explicit false for friend function get global gosub goto if imp implement in integer is let lib "
+"load long loop lset me mid mod module new next not nothing null object on option optional or "
+"preserve private property public raiseevent redim rem resume return rset select set single "
+"static stop string sub then to true type unload until variant wend while with withevents xor",
+"", "", "", "", "", "", "", "" };
+
+
+EDITLEXER lexVBS = { SCLEX_VBSCRIPT, 63008, L"VBScript", L"vbs; dsm", L"", &KeyWords_VBS, {
+ { STYLE_DEFAULT, 63126, L"Default", L"", L"" },
+ //{ SCE_B_DEFAULT, L"Default", L"", L"" },
+ { SCE_B_COMMENT, 63127, L"Comment", L"fore:#808080", L"" },
+ { SCE_B_KEYWORD, 63128, L"Keyword", L"bold; fore:#B000B0", L"" },
+ { SCE_B_IDENTIFIER, 63129, L"Identifier", L"", L"" },
+ { MULTI_STYLE(SCE_B_STRING,SCE_B_STRINGEOL,0,0), 63131, L"String", L"fore:#008000", L"" },
+ { SCE_B_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" },
+ { SCE_B_OPERATOR, 63132, L"Operator", L"", L"" },
+ //{ SCE_B_PREPROCESSOR, 63133, L"Preprocessor", L"fore:#FF9C00", L"" },
+ //{ SCE_B_CONSTANT, L"Constant", L"", L"" },
+ //{ SCE_B_DATE, L"Date", L"", L"" },
+ //{ SCE_B_KEYWORD2, L"Keyword 2", L"", L"" },
+ //{ SCE_B_KEYWORD3, L"Keyword 3", L"", L"" },
+ //{ SCE_B_KEYWORD4, L"Keyword 4", L"", L"" },
+ //{ SCE_B_ASM, L"Inline Asm", L"fore:#FF8000", L"" },
+ { -1, 00000, L"", L"", L"" } } };
+
+
+KEYWORDLIST KeyWords_VB = {
+"addhandler addressof alias and andalso ansi any as assembly auto boolean byref byte byval call "
+"case catch cbool cbyte cchar cdate cdbl cdec char cint class clng cobj compare const cshort csng "
+"cstr ctype date decimal declare default delegate dim directcast do double each else elseif end "
+"enum erase error event exit explicit externalsource false finally for friend function get "
+"gettype gosub goto handles if implements imports in inherits integer interface is let lib like "
+"long loop me mid mod module mustinherit mustoverride mybase myclass namespace new next not "
+"nothing notinheritable notoverridable object on option optional or orelse overloads overridable "
+"overrides paramarray preserve private property protected public raiseevent randomize readonly "
+"redim rem removehandler resume return select set shadows shared short single static step stop "
+"strict string structure sub synclock then throw to true try typeof unicode until variant when "
+"while with withevents writeonly xor",
+"", "", "", "", "", "", "", "" };
+
+
+EDITLEXER lexVB = { SCLEX_VB, 63009, L"Visual Basic", L"vb; bas; frm; cls; ctl; pag; dsr; dob", L"", &KeyWords_VB, {
+ { STYLE_DEFAULT, 63126, L"Default", L"", L"" },
+ //{ SCE_B_DEFAULT, L"Default", L"", L"" },
+ { SCE_B_COMMENT, 63127, L"Comment", L"fore:#808080", L"" },
+ { SCE_B_KEYWORD, 63128, L"Keyword", L"bold; fore:#B000B0", L"" },
+ { SCE_B_IDENTIFIER, 63129, L"Identifier", L"", L"" },
+ { MULTI_STYLE(SCE_B_STRING,SCE_B_STRINGEOL,0,0), 63131, L"String", L"fore:#008000", L"" },
+ { SCE_B_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" },
+ { SCE_B_OPERATOR, 63132, L"Operator", L"", L"" },
+ { SCE_B_PREPROCESSOR, 63133, L"Preprocessor", L"fore:#FF9C00", L"" },
+ //{ SCE_B_CONSTANT, L"Constant", L"", L"" },
+ //{ SCE_B_DATE, L"Date", L"", L"" },
+ //{ SCE_B_KEYWORD2, L"Keyword 2", L"", L"" },
+ //{ SCE_B_KEYWORD3, L"Keyword 3", L"", L"" },
+ //{ SCE_B_KEYWORD4, L"Keyword 4", L"", L"" },
+ //{ SCE_B_ASM, L"Inline Asm", L"fore:#FF8000", L"" },
+ { -1, 00000, L"", L"", L"" } } };
+
+
+KEYWORDLIST KeyWords_JS = {
+"abstract boolean break byte case catch char class const continue debugger default delete do "
+"double else enum export extends false final finally float for function goto if implements "
+"import in instanceof int interface long native new null package private protected public "
+"return short static super switch synchronized this throw throws transient true try typeof var "
+"void volatile while with",
+"", "", "", "", "", "", "", "" };
+
+
+EDITLEXER lexJS = { SCLEX_CPP, 63010, L"JavaScript", L"js; jse; jsm; json; as", L"", &KeyWords_JS, {
+ { STYLE_DEFAULT, 63126, L"Default", L"", L"" },
+ //{ SCE_C_DEFAULT, L"Default", L"", L"" },
+ { SCE_C_COMMENT, 63127, L"Comment", L"fore:#646464", L"" },
+ { SCE_C_WORD, 63128, L"Keyword", L"bold; fore:#A46000", L"" },
+ { SCE_C_IDENTIFIER, 63129, L"Identifier", L"", L"" },
+ { MULTI_STYLE(SCE_C_STRING,SCE_C_CHARACTER,SCE_C_STRINGEOL,SCE_C_VERBATIM), 63131, L"String", L"fore:#008000", L"" },
+ { SCE_C_REGEX, 63135, L"Regex", L"fore:#006633; back:#FFF1A8", L"" },
+ { SCE_C_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" },
+ { SCE_C_OPERATOR, 63132, L"Operator", L"fore:#B000B0", L"" },
+ //{ SCE_C_UUID, L"UUID", L"", L"" },
+ //{ SCE_C_PREPROCESSOR, L"Preprocessor", L"fore:#FF8000", L"" },
+ //{ SCE_C_WORD2, L"Word 2", L"", L"" },
+ //{ SCE_C_GLOBALCLASS, L"Global Class", L"", L"" },
+ { -1, 00000, L"", L"", L"" } } };
+
+
+KEYWORDLIST KeyWords_JAVA = {
+"abstract assert boolean break byte case catch char class const "
+"continue default do double else extends final finally float for future "
+"generic goto if implements import inner instanceof int interface long "
+"native new null outer package private protected public rest return "
+"short static super switch synchronized this throw throws transient try "
+"var void volatile while",
+"", "", "", "", "", "", "", "" };
+
+
+EDITLEXER lexJAVA = { SCLEX_CPP, 63011, L"Java Source Code", L"java", L"", &KeyWords_JAVA, {
+ { STYLE_DEFAULT, 63126, L"Default", L"", L"" },
+ //{ SCE_C_DEFAULT, L"Default", L"", L"" },
+ { SCE_C_COMMENT, 63127, L"Comment", L"fore:#646464", L"" },
+ { SCE_C_WORD, 63128, L"Keyword", L"bold; fore:#A46000", L"" },
+ { SCE_C_IDENTIFIER, 63129, L"Identifier", L"", L"" },
+ { MULTI_STYLE(SCE_C_STRING,SCE_C_CHARACTER,SCE_C_STRINGEOL,SCE_C_VERBATIM), 63131, L"String", L"fore:#008000", L"" },
+ { SCE_C_REGEX, 63135, L"Regex", L"fore:#006633; back:#FFF1A8", L"" },
+ { SCE_C_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" },
+ { SCE_C_OPERATOR, 63132, L"Operator", L"fore:#B000B0", L"" },
+ //{ SCE_C_UUID, L"UUID", L"", L"" },
+ //{ SCE_C_PREPROCESSOR, L"Preprocessor", L"fore:#FF8000", L"" },
+ //{ SCE_C_WORD2, L"Word 2", L"", L"" },
+ //{ SCE_C_GLOBALCLASS, L"Global Class", L"", L"" },
+ { -1, 00000, L"", L"", L"" } } };
+
+
+KEYWORDLIST KeyWords_PAS = {
+"absolute abstract alias and array as asm assembler begin break case cdecl class const constructor continue cppdecl default "
+"destructor dispose div do downto else end end. except exit export exports external false far far16 file finalization finally for "
+"forward function goto if implementation in index inherited initialization inline interface is label library local message mod "
+"name near new nil nostackframe not object of oldfpccall on operator or out overload override packed pascal private procedure "
+"program property protected public published raise read record register reintroduce repeat resourcestring safecall self set shl "
+"shr softfloat stdcall stored string then threadvar to true try type unit until uses var virtual while with write xor",
+"", "", "", "", "", "", "", "" };
+
+
+EDITLEXER lexPAS = { SCLEX_PASCAL, 63012, L"Pascal Source Code", L"pas; dpr; dpk; dfm; inc; pp", L"", &KeyWords_PAS, {
+ { STYLE_DEFAULT, 63126, L"Default", L"", L"" },
+ //{ SCE_PAS_DEFAULT, L"Default", L"", L"" },
+ { MULTI_STYLE(SCE_PAS_COMMENT,SCE_PAS_COMMENT2,SCE_PAS_COMMENTLINE,0), 63127, L"Comment", L"fore:#646464", L"" },
+ { SCE_PAS_WORD, 63128, L"Keyword", L"bold; fore:#800080", L"" },
+ { SCE_PAS_IDENTIFIER, 63129, L"Identifier", L"", L"" },
+ { MULTI_STYLE(SCE_PAS_STRING,SCE_PAS_CHARACTER,SCE_PAS_STRINGEOL,0), 63131, L"String", L"fore:#008000", L"" },
+ { MULTI_STYLE(SCE_PAS_NUMBER,SCE_PAS_HEXNUMBER,0,0), 63130, L"Number", L"fore:#FF0000", L"" },
+ { SCE_PAS_OPERATOR, 63132, L"Operator", L"bold", L"" },
+ { SCE_PAS_ASM, 63205, L"Inline Asm", L"fore:#0000FF", L"" },
+ { MULTI_STYLE(SCE_PAS_PREPROCESSOR,SCE_PAS_PREPROCESSOR2,0,0), 63133, L"Preprocessor", L"fore:#FF00FF", L"" },
+ { -1, 00000, L"", L"", L"" } } };
+
+
+KEYWORDLIST KeyWords_ASM = {
+"aaa aad aam aas adc add and call cbw clc cld cli cmc cmp cmps cmpsb "
+"cmpsw cwd daa das dec div esc hlt idiv imul in inc int into iret ja jae jb jbe "
+"jc jcxz je jg jge jl jle jmp jna jnae jnb jnbe jnc jne jng jnge jnl jnle jno jnp "
+"jns jnz jo jp jpe jpo js jz lahf lds lea les lods lodsb lodsw loop loope loopew "
+"loopne loopnew loopnz loopnzw loopw loopz loopzw mov movs movsb "
+"movsw mul neg nop not or out pop popf push pushf rcl rcr ret retf retn rol "
+"ror sahf sal sar sbb scas scasb scasw shl shr stc std sti stos stosb stosw "
+"sub test wait xchg xlat xlatb xor bound enter ins insb insw leave outs "
+"outsb outsw popa pusha pushw arpl lar lsl sgdt sidt sldt smsw str verr "
+"verw clts lgdt lidt lldt lmsw ltr bsf bsr bt btc btr bts cdq cmpsd cwde insd "
+"iretd iretdf iretf jecxz lfs lgs lodsd loopd looped loopned loopnzd loopzd "
+"lss movsd movsx movzx outsd popad popfd pushad pushd pushfd scasd "
+"seta setae setb setbe setc sete setg setge setl setle setna setnae "
+"setnb setnbe setnc setne setng setnge setnl setnle setno setnp setns "
+"setnz seto setp setpe setpo sets setz shld shrd stosd bswap cmpxchg "
+"invd invlpg wbinvd xadd lock rep repe repne repnz repz cflush cpuid emms "
+"femms cmovo cmovno cmovb cmovc cmovnae cmovae cmovnb cmovnc "
+"cmove cmovz cmovne cmovnz cmovbe cmovna cmova cmovnbe cmovs "
+"cmovns cmovp cmovpe cmovnp cmovpo cmovl cmovnge cmovge cmovnl "
+"cmovle cmovng cmovg cmovnle cmpxchg486 cmpxchg8b loadall loadall286 "
+"ibts icebp int1 int3 int01 int03 iretw popaw popfw pushaw pushfw rdmsr "
+"rdpmc rdshr rdtsc rsdc rsldt rsm rsts salc smi smint smintold svdc svldt "
+"svts syscall sysenter sysexit sysret ud0 ud1 ud2 umov xbts wrmsr wrshr",
+"f2xm1 fabs fadd faddp fbld fbstp fchs fclex fcom fcomp fcompp fdecstp "
+"fdisi fdiv fdivp fdivr fdivrp feni ffree fiadd ficom ficomp fidiv fidivr fild fimul "
+"fincstp finit fist fistp fisub fisubr fld fld1 fldcw fldenv fldenvw fldl2e fldl2t "
+"fldlg2 fldln2 fldpi fldz fmul fmulp fnclex fndisi fneni fninit fnop fnsave "
+"fnsavew fnstcw fnstenv fnstenvw fnstsw fpatan fprem fptan frndint frstor "
+"frstorw fsave fsavew fscale fsqrt fst fstcw fstenv fstenvw fstp fstsw fsub "
+"fsubp fsubr fsubrp ftst fwait fxam fxch fxtract fyl2x fyl2xp1 fsetpm fcos "
+"fldenvd fnsaved fnstenvd fprem1 frstord fsaved fsin fsincos fstenvd fucom "
+"fucomp fucompp fcomi fcomip ffreep fcmovb fcmove fcmovbe fcmovu "
+"fcmovnb fcmovne fcmovnbe fcmovnu",
+"ah al ax bh bl bp bx ch cl cr0 cr2 cr3 cr4 cs cx dh di dl dr0 dr1 dr2 dr3 dr6 "
+"dr7 ds dx eax ebp ebx ecx edi edx es esi esp fs gs si sp ss st tr3 tr4 tr5 "
+"tr6 tr7 st0 st1 st2 st3 st4 st5 st6 st7 mm0 mm1 mm2 mm3 mm4 mm5 "
+"mm6 mm7 xmm0 xmm1 xmm2 xmm3 xmm4 xmm5 xmm6 xmm7",
+".186 .286 .286c .286p .287 .386 .386c .386p .387 .486 .486p .8086 .8087 "
+".alpha .break .code .const .continue .cref .data .data? .dosseg .else "
+".elseif .endif .endw .err .err1 .err2 .errb .errdef .errdif .errdifi .erre .erridn "
+".erridni .errnb .errndef .errnz .exit .fardata .fardata? .if .lall .lfcond .list "
+".listall .listif .listmacro .listmacroall .model .no87 .nocref .nolist .nolistif "
+".nolistmacro .radix .repeat .sall .seq .sfcond .stack .startup .tfcond .type "
+".until .untilcxz .while .xall .xcref .xlist alias align assume catstr comm "
+"comment db dd df dosseg dq dt dup dw echo else elseif elseif1 elseif2 "
+"elseifb elseifdef elseifdif elseifdifi elseife elseifidn elseifidni elseifnb "
+"elseifndef end endif endm endp ends eq equ even exitm extern externdef "
+"extrn for forc ge goto group gt high highword if if1 if2 ifb ifdef ifdif ifdifi ife "
+"ifidn ifidni ifnb ifndef include includelib instr invoke irp irpc label le length "
+"lengthof local low lowword lroffset lt macro mask mod .msfloat name ne "
+"offset opattr option org %out page popcontext proc proto ptr public "
+"purge pushcontext record repeat rept seg segment short size sizeof "
+"sizestr struc struct substr subtitle subttl textequ this title type typedef "
+"union while width db dw dd dq dt resb resw resd resq rest incbin equ "
+"times %define %idefine %xdefine %xidefine %undef %assign %iassign "
+"%strlen %substr %macro %imacro %endmacro %rotate .nolist %if %elif "
+"%else %endif %ifdef %ifndef %elifdef %elifndef %ifmacro %ifnmacro "
+"%elifmacro %elifnmacro %ifctk %ifnctk %elifctk %elifnctk %ifidn %ifnidn "
+"%elifidn %elifnidn %ifidni %ifnidni %elifidni %elifnidni %ifid %ifnid %elifid "
+"%elifnid %ifstr %ifnstr %elifstr %elifnstr %ifnum %ifnnum %elifnum "
+"%elifnnum %error %rep %endrep %exitrep %include %push %pop %repl "
+"struct endstruc istruc at iend align alignb %arg %stacksize %local %line "
+"bits use16 use32 section absolute extern global common cpu org section "
+"group import export",
+"$ ? @b @f addr basic byte c carry? dword far far16 fortran fword near "
+"near16 overflow? parity? pascal qword real4 real8 real10 sbyte sdword "
+"sign? stdcall sword syscall tbyte vararg word zero? flat near32 far32 abs "
+"all assumes at casemap common compact cpu dotname emulator epilogue "
+"error export expr16 expr32 farstack flat forceframe huge language large "
+"listing ljmp loadds m510 medium memory nearstack nodotname noemulator "
+"nokeyword noljmp nom510 none nonunique nooldmacros nooldstructs "
+"noreadonly noscoped nosignextend nothing notpublic oldmacros oldstructs "
+"os_dos para private prologue radix readonly req scoped setif2 smallstack "
+"tiny use16 use32 uses # nasm directives, mostly complete, does not parse "
+"properly a16 a32 o16 o32 byte word dword nosplit $ $$ seq wrt flat large "
+"small .text .data .bss near far %0 %1 %2 %3 %4 %5 %6 %7 %8 %9",
+"addpd addps addsd addss andpd andps andnpd andnps cmpeqpd cmpltpd "
+"cmplepd cmpunordpd cmpnepd cmpnltpd cmpnlepd cmpordpd cmpeqps "
+"cmpltps cmpleps cmpunordps cmpneps cmpnltps cmpnleps cmpordps "
+"cmpeqsd cmpltsd cmplesd cmpunordsd cmpnesd cmpnltsd cmpnlesd "
+"cmpordsd cmpeqss cmpltss cmpless cmpunordss cmpness cmpnltss "
+"cmpnless cmpordss comisd comiss cvtdq2pd cvtdq2ps cvtpd2dq cvtpd2pi "
+"cvtpd2ps cvtpi2pd cvtpi2ps cvtps2dq cvtps2pd cvtps2pi cvtss2sd "
+"cvtss2si cvtsd2si cvtsd2ss cvtsi2sd cvtsi2ss cvttpd2dq cvttpd2pi "
+"cvttps2dq cvttps2pi cvttsd2si cvttss2si divpd divps divsd divss fxrstor "
+"fxsave ldmxscr lfence mfence maskmovdqu maskmovdq maxpd maxps "
+"paxsd maxss minpd minps minsd minss movapd movaps movdq2q movdqa "
+"movdqu movhlps movhpd movhps movd movq movlhps movlpd movlps "
+"movmskpd movmskps movntdq movnti movntpd movntps movntq "
+"movq2dq movsd movss movupd movups mulpd mulps mulsd mulss orpd "
+"orps packssdw packsswb packuswb paddb paddsb paddw paddsw paddd "
+"paddsiw paddq paddusb paddusw pand pandn pause paveb pavgb pavgw "
+"pavgusb pdistib pextrw pcmpeqb pcmpeqw pcmpeqd pcmpgtb pcmpgtw "
+"pcmpgtd pf2id pf2iw pfacc pfadd pfcmpeq pfcmpge pfcmpgt pfmax pfmin "
+"pfmul pmachriw pmaddwd pmagw pmaxsw pmaxub pminsw pminub "
+"pmovmskb pmulhrwc pmulhriw pmulhrwa pmulhuw pmulhw pmullw pmuludq "
+"pmvzb pmvnzb pmvlzb pmvgezb pfnacc pfpnacc por prefetch prefetchw "
+"prefetchnta prefetcht0 prefetcht1 prefetcht2 pfrcp pfrcpit1 pfrcpit2 "
+"pfrsqit1 pfrsqrt pfsub pfsubr pi2fd pf2iw pinsrw psadbw pshufd pshufhw "
+"pshuflw pshufw psllw pslld psllq pslldq psraw psrad psrlw psrld psrlq psrldq "
+"psubb psubw psubd psubq psubsb psubsw psubusb psubusw psubsiw "
+"pswapd punpckhbw punpckhwd punpckhdq punpckhqdq punpcklbw "
+"punpcklwd punpckldq punpcklqdq pxor rcpps rcpss rsqrtps rsqrtss sfence "
+"shufpd shufps sqrtpd sqrtps sqrtsd sqrtss stmxcsr subpd subps subsd "
+"subss ucomisd ucomiss unpckhpd unpckhps unpcklpd unpcklps xorpd xorps",
+"", "", "" };
+
+
+EDITLEXER lexASM = { SCLEX_ASM, 63013, L"Assembly Script", L"asm", L"", &KeyWords_ASM, {
+ { STYLE_DEFAULT, 63126, L"Default", L"", L"" },
+ //{ SCE_ASM_DEFAULT, L"Default", L"", L"" },
+ { MULTI_STYLE(SCE_ASM_COMMENT,SCE_ASM_COMMENTBLOCK,0,0), 63127, L"Comment", L"fore:#008000", L"" },
+ { SCE_ASM_IDENTIFIER, 63129, L"Identifier", L"", L"" },
+ { MULTI_STYLE(SCE_ASM_STRING,SCE_ASM_CHARACTER,SCE_ASM_STRINGEOL,0), 63131, L"String", L"fore:#008000", L"" },
+ { SCE_ASM_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" },
+ { SCE_ASM_OPERATOR, 63132, L"Operator", L"fore:#0A246A", L"" },
+ { SCE_ASM_CPUINSTRUCTION, 63206, L"CPU Instruction", L"fore:#0A246A", L"" },
+ { SCE_ASM_MATHINSTRUCTION, 63207, L"FPU Instruction", L"fore:#0A246A", L"" },
+ { SCE_ASM_EXTINSTRUCTION, 63210, L"Extended Instruction", L"fore:#0A246A", L"" },
+ { SCE_ASM_DIRECTIVE, 63203, L"Directive", L"fore:#0A246A", L"" },
+ { SCE_ASM_DIRECTIVEOPERAND, 63209, L"Directive Operand", L"fore:#0A246A", L"" },
+ { SCE_ASM_REGISTER, 63208, L"Register", L"fore:#FF8000", L"" },
+ { -1, 00000, L"", L"", L"" } } };
+
+
+KEYWORDLIST KeyWords_PL = {
+"__DATA__ __END__ __FILE__ __LINE__ __PACKAGE__ abs accept alarm and atan2 AUTOLOAD BEGIN "
+"bind binmode bless caller chdir CHECK chmod chomp chop chown chr chroot close closedir cmp "
+"connect continue CORE cos crypt dbmclose dbmopen default defined delete DESTROY die do "
+"dump each else elsif END endgrent endhostent endnetent endprotoent endpwent endservent eof "
+"eq EQ eval exec exists exit exp fcntl fileno flock for foreach fork format formline ge GE "
+"getc getgrent getgrgid getgrnam gethostbyaddr gethostbyname gethostent getlogin "
+"getnetbyaddr getnetbyname getnetent getpeername getpgrp getppid getpriority getprotobyname "
+"getprotobynumber getprotoent getpwent getpwnam getpwuid getservbyname getservbyport "
+"getservent getsockname getsockopt given glob gmtime goto grep gt GT hex if index INIT int "
+"ioctl join keys kill last lc lcfirst le LE length link listen local localtime lock log "
+"lstat lt LT map mkdir msgctl msgget msgrcv msgsnd my ne NE next no not NULL oct open "
+"opendir or ord our pack package pipe pop pos print printf prototype push qu quotemeta rand "
+"read readdir readline readlink readpipe recv redo ref rename require reset return reverse "
+"rewinddir rindex rmdir say scalar seek seekdir select semctl semget semop send setgrent "
+"sethostent setnetent setpgrp setpriority setprotoent setpwent setservent setsockopt shift "
+"shmctl shmget shmread shmwrite shutdown sin sleep socket socketpair sort splice split "
+"sprintf sqrt srand stat state study sub substr symlink syscall sysopen sysread sysseek "
+"system syswrite tell telldir tie tied time times truncate uc ucfirst umask undef UNITCHECK "
+"unless unlink unpack unshift untie until use utime values vec wait waitpid wantarray warn "
+"when while write xor",
+"", "", "", "", "", "", "", "" };
+
+
+EDITLEXER lexPL = { SCLEX_PERL, 63014, L"Perl Script", L"pl; pm; cgi; pod", L"", &KeyWords_PL, {
+ { STYLE_DEFAULT, 63126, L"Default", L"", L"" },
+ //{ SCE_PL_DEFAULT, L"Default", L"", L"" },
+ { SCE_PL_COMMENTLINE, 63127, L"Comment", L"fore:#646464", L"" },
+ { SCE_PL_WORD, 63128, L"Keyword", L"bold; fore:#804000", L"" },
+ { SCE_PL_IDENTIFIER, 63129, L"Identifier", L"", L"" },
+ { SCE_PL_STRING, 63211, L"String double quoted", L"fore:#008000", L"" },
+ { SCE_PL_CHARACTER, 63212, L"String single quoted", L"fore:#008000", L"" },
+ { SCE_PL_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" },
+ { SCE_PL_OPERATOR, 63132, L"Operator", L"bold", L"" },
+ { SCE_PL_SCALAR, 63215, L"Scalar $var", L"fore:#0A246A", L"" },
+ { SCE_PL_ARRAY, 63216, L"Array @var", L"fore:#003CE6", L"" },
+ { SCE_PL_HASH, 63217, L"Hash %var", L"fore:#B000B0", L"" },
+ { SCE_PL_SYMBOLTABLE, 63218, L"Symbol table *var", L"fore:#3A6EA5", L"" },
+ { SCE_PL_REGEX, 63219, L"Regex /re/ or m{re}", L"fore:#006633; back:#FFF1A8", L"" },
+ { SCE_PL_REGSUBST, 63220, L"Substitution s/re/ore/", L"fore:#006633; back:#FFF1A8", L"" },
+ { SCE_PL_BACKTICKS, 63221, L"Back ticks", L"fore:#E24000; back:#FFF1A8", L"" },
+ { SCE_PL_HERE_DELIM, 63223, L"Here-doc (delimiter)", L"fore:#648000", L"" },
+ { SCE_PL_HERE_Q, 63224, L"Here-doc (single quoted, q)", L"fore:#648000", L"" },
+ { SCE_PL_HERE_QQ, 63225, L"Here-doc (double quoted, qq)", L"fore:#648000", L"" },
+ { SCE_PL_HERE_QX, 63226, L"Here-doc (back ticks, qx)", L"fore:#E24000; back:#FFF1A8", L"" },
+ { SCE_PL_STRING_Q, 63227, L"Single quoted string (generic, q)", L"fore:#008000", L"" },
+ { SCE_PL_STRING_QQ, 63228, L"Double quoted string (qq)", L"fore:#008000", L"" },
+ { SCE_PL_STRING_QX, 63229, L"Back ticks (qx)", L"fore:#E24000; back:#FFF1A8", L"" },
+ { SCE_PL_STRING_QR, 63230, L"Regex (qr)", L"fore:#006633; back:#FFF1A8", L"" },
+ { SCE_PL_STRING_QW, 63231, L"Array (qw)", L"fore:#003CE6", L"" },
+ { SCE_PL_SUB_PROTOTYPE, 63253, L"Prototype", L"fore:#800080; back:#FFE2FF", L"" },
+ { SCE_PL_FORMAT_IDENT, 63254, L"Format identifier", L"bold; fore:#648000; back:#FFF1A8", L"" },
+ { SCE_PL_FORMAT, 63255, L"Format body", L"fore:#648000; back:#FFF1A8", L"" },
+ { SCE_PL_POD, 63213, L"POD (common)", L"fore:#A46000; back:#FFFFC0; eolfilled", L"" },
+ { SCE_PL_POD_VERB, 63214, L"POD (verbatim)", L"fore:#A46000; back:#FFFFC0; eolfilled", L"" },
+ { SCE_PL_DATASECTION, 63222, L"Data section", L"fore:#A46000; back:#FFFFC0; eolfilled", L"" },
+ { SCE_PL_ERROR, 63252, L"Parsing error", L"fore:#C80000; back:#FFFF80", L"" },
+ //{ SCE_PL_PUNCTUATION, L"Symbols / punctuation (not used)", L"", L"" },
+ //{ SCE_PL_PREPROCESSOR, L"Preprocessor (not used)", L"", L"" },
+ //{ SCE_PL_LONGQUOTE, L"Long quote (qq, qr, qw, qx) (not used)", L"", L"" },
+ { -1, 00000, L"", L"", L"" } } };
+
+
+KEYWORDLIST KeyWords_INI = {
+"", "", "", "", "", "", "", "", "" };
+
+
+EDITLEXER lexINI = { SCLEX_PROPERTIES, 63015, L"Configuration Files", L"ini; inf; reg; cfg; properties; oem; sif; url; sed; theme", L"", &KeyWords_INI, {
+ { STYLE_DEFAULT, 63126, L"Default", L"", L"" },
+ //{ SCE_PROPS_DEFAULT, L"Default", L"", L"" },
+ { SCE_PROPS_COMMENT, 63127, L"Comment", L"fore:#008000", L"" },
+ { SCE_PROPS_SECTION, 63232, L"Section", L"bold; fore:#000000; back:#FFD24D; eolfilled", L"" },
+ { SCE_PROPS_ASSIGNMENT, 63233, L"Assignment", L"fore:#FF0000", L"" },
+ { SCE_PROPS_DEFVAL, 63234, L"Default Value", L"fore:#FF0000", L"" },
+ { -1, 00000, L"", L"", L"" } } };
+
+
+KEYWORDLIST KeyWords_BAT = {
+"rem set if exist errorlevel for in do break call chcp cd chdir choice cls "
+"country ctty date del erase dir echo exit goto loadfix loadhigh mkdir md "
+"move path pause prompt rename ren rmdir rd shift time type ver verify vol "
+"com con lpt nul echo.",
+"", "", "", "", "", "", "", "" };
+
+
+EDITLEXER lexBAT = { SCLEX_BATCH, 63016, L"Batch Files", L"bat; cmd", L"", &KeyWords_BAT, {
+ { STYLE_DEFAULT, 63126, L"Default", L"", L"" },
+ //{ SCE_BAT_DEFAULT, L"Default", L"", L"" },
+ { SCE_BAT_COMMENT, 63127, L"Comment", L"fore:#008000", L"" },
+ { SCE_BAT_WORD, 63128, L"Keyword", L"bold; fore:#0A246A", L"" },
+ { SCE_BAT_IDENTIFIER, 63129, L"Identifier", L"fore:#003CE6; back:#FFF1A8", L"" },
+ { SCE_BAT_OPERATOR, 63132, L"Operator", L"", L"" },
+ { MULTI_STYLE(SCE_BAT_COMMAND,SCE_BAT_HIDE,0,0), 63236, L"Command", L"bold", L"" },
+ { SCE_BAT_LABEL, 63235, L"Label", L"fore:#C80000; back:#F4F4F4; eolfilled", L"" },
+ { -1, 00000, L"", L"", L"" } } };
+
+
+KEYWORDLIST KeyWords_DIFF = {
+"", "", "", "", "", "", "", "", "" };
+
+
+EDITLEXER lexDIFF = { SCLEX_DIFF, 63017, L"Diff Files", L"diff; patch", L"", &KeyWords_DIFF, {
+ { STYLE_DEFAULT, 63126, L"Default", L"", L"" },
+ //{ SCE_DIFF_DEFAULT, L"Default", L"", L"" },
+ { SCE_DIFF_COMMENT, 63127, L"Comment", L"fore:#008000", L"" },
+ { SCE_DIFF_COMMAND, 63236, L"Command", L"bold; fore:#0A246A", L"" },
+ { SCE_DIFF_HEADER, 63238, L"Source and Destination", L"fore:#C80000; back:#FFF1A8; eolfilled", L"" },
+ { SCE_DIFF_POSITION, 63239, L"Position Setting", L"fore:#0000FF", L"" },
+ { SCE_DIFF_ADDED, 63240, L"Line Addition", L"fore:#000000; back:#C0FF60; eolfilled", L"" },
+ { SCE_DIFF_DELETED, 63241, L"Line Removal", L"fore:#000000; back:#FF8060; eolfilled", L"" },
+ { SCE_DIFF_CHANGED, 63242, L"Line Change", L"fore:#000000; back:#99D7FF; eolfilled", L"" },
+ { -1, 00000, L"", L"", L"" } } };
+
+
+KEYWORDLIST KeyWords_SQL = {
+"abort accessible action add after all alter analyze and as asc asensitive attach autoincrement "
+"before begin between bigint binary bit blob both by call cascade case cast change char character "
+"check collate column commit condition conflict constraint continue convert create cross current_date "
+"current_time current_timestamp current_user cursor database databases date day_hour day_microsecond "
+"day_minute day_second dec decimal declare default deferrable deferred delayed delete desc describe "
+"detach deterministic distinct distinctrow div double drop dual each else elseif enclosed end enum "
+"escape escaped except exclusive exists exit explain fail false fetch float float4 float8 for force "
+"foreign from full fulltext glob grant group having high_priority hour_microsecond hour_minute "
+"hour_second if ignore immediate in index infile initially inner inout insensitive insert instead int "
+"int1 int2 int3 int4 int8 integer intersect interval into is isnull iterate join key keys kill "
+"leading leave left like limit linear lines load localtime localtimestamp lock long longblob longtext "
+"loop low_priority master_ssl_verify_server_cert match mediumblob mediumint mediumtext middleint "
+"minute_microsecond minute_second mod modifies natural no no_write_to_binlog not notnull null numeric "
+"of offset on optimize option optionally or order out outer outfile plan pragma precision primary "
+"procedure purge query raise range read read_only read_write reads real references regexp reindex "
+"release rename repeat replace require restrict return revoke right rlike rollback row rowid schema "
+"schemas second_microsecond select sensitive separator set show smallint spatial specific sql "
+"sql_big_result sql_calc_found_rows sql_small_result sqlexception sqlstate sqlwarning ssl starting "
+"straight_join table temp temporary terminated text then time timestamp tinyblob tinyint tinytext to "
+"trailing transaction trigger true undo union unique unlock unsigned update usage use using utc_date "
+"utc_time utc_timestamp vacuum values varbinary varchar varcharacter varying view virtual when where "
+"while with write xor year_month zerofill",
+"", "", "", "", "", "", "", "" };
+
+
+EDITLEXER lexSQL = { SCLEX_SQL, 63018, L"SQL Query", L"sql", L"", &KeyWords_SQL, {
+ { STYLE_DEFAULT, 63126, L"Default", L"", L"" },
+ //{ SCE_SQL_DEFAULT, L"Default", L"", L"" },
+ { SCE_SQL_COMMENT, 63127, L"Comment", L"fore:#505050", L"" },
+ { SCE_SQL_WORD, 63128, L"Keyword", L"bold; fore:#800080", L"" },
+ { MULTI_STYLE(SCE_SQL_STRING,SCE_SQL_CHARACTER,0,0), 63131, L"String", L"fore:#008000; back:#FFF1A8", L"" },
+ { SCE_SQL_IDENTIFIER, 63129, L"Identifier", L"fore:#800080", L"" },
+ { SCE_SQL_QUOTEDIDENTIFIER, 63243, L"Quoted Identifier", L"fore:#800080; back:#FFCCFF", L"" },
+ { SCE_SQL_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" },
+ { SCE_SQL_OPERATOR, 63132, L"Operator", L"bold; fore:#800080", L"" },
+ { -1, 00000, L"", L"", L"" } } };
+
+
+KEYWORDLIST KeyWords_PY = {
+"and as assert break class continue def del elif else except "
+"exec False finally for from global if import in is lambda None "
+"not or pass print raise return True try with while yield",
+"", "", "", "", "", "", "", "" };
+
+
+EDITLEXER lexPY = { SCLEX_PYTHON, 63019, L"Python Script", L"py; pyw", L"", &KeyWords_PY, {
+ { STYLE_DEFAULT, 63126, L"Default", L"", L"" },
+ //{ SCE_P_DEFAULT, L"Default", L"", L"" },
+ { MULTI_STYLE(SCE_P_COMMENTLINE,SCE_P_COMMENTBLOCK,0,0), 63127, L"Comment", L"fore:#880000", L"" },
+ { SCE_P_WORD, 63128, L"Keyword", L"fore:#000088", L"" },
+ { SCE_P_IDENTIFIER, 63129, L"Identifier", L"", L"" },
+ { MULTI_STYLE(SCE_P_STRING,SCE_P_STRINGEOL,0,0), 63211, L"String double quoted", L"fore:#008800", L"" },
+ { SCE_P_CHARACTER, 63212, L"String single quoted", L"fore:#008800", L"" },
+ { SCE_P_TRIPLEDOUBLE, 63244, L"String triple double quotes", L"fore:#008800", L"" },
+ { SCE_P_TRIPLE, 63245, L"String triple single quotes", L"fore:#008800", L"" },
+ { SCE_P_NUMBER, 63130, L"Number", L"fore:#FF4000", L"" },
+ { SCE_P_OPERATOR, 63132, L"Operator", L"bold; fore:#666600", L"" },
+ { SCE_P_DEFNAME, 63247, L"Function name", L"fore:#660066", L"" },
+ { SCE_P_CLASSNAME, 63246, L"Class name", L"fore:#660066", L"" },
+ { -1, 00000, L"", L"", L"" } } };
+
+
+KEYWORDLIST KeyWords_CONF = {
+"acceptmutex acceptpathinfo accessconfig accessfilename action addalt addaltbyencoding addaltbytype addcharset adddefaultcharset "
+"adddescription addencoding addhandler addicon addiconbyencoding addiconbytype addinputfilter addlanguage addmodule addmoduleinfo "
+"addoutputfilter addoutputfilterbytype addtype agentlog alias aliasmatch all allow allowconnect allowencodedslashes allowoverride "
+"anonymous anonymous_authoritative anonymous_logemail anonymous_mustgiveemail anonymous_nouserid anonymous_verifyemail "
+"assignuserid authauthoritative authdbauthoritative authdbgroupfile authdbmauthoritative authdbmgroupfile authdbmtype "
+"authdbmuserfile authdbuserfile authdigestalgorithm authdigestdomain authdigestfile authdigestgroupfile authdigestnccheck "
+"authdigestnonceformat authdigestnoncelifetime authdigestqop authdigestshmemsize authgroupfile authldapauthoritative "
+"authldapbinddn authldapbindpassword authldapcharsetconfig authldapcomparednonserver authldapdereferencealiases authldapenabled "
+"authldapfrontpagehack authldapgroupattribute authldapgroupattributeisdn authldapremoteuserisdn authldapurl authname authtype "
+"authuserfile bindaddress browsermatch browsermatchnocase bs2000account bufferedlogs cachedefaultexpire cachedirlength "
+"cachedirlevels cachedisable cacheenable cacheexpirycheck cachefile cacheforcecompletion cachegcclean cachegcdaily "
+"cachegcinterval cachegcmemusage cachegcunused cacheignorecachecontrol cacheignoreheaders cacheignorenolastmod "
+"cachelastmodifiedfactor cachemaxexpire cachemaxfilesize cacheminfilesize cachenegotiateddocs cacheroot cachesize cachetimemargin "
+"cgimapextension charsetdefault charsetoptions charsetsourceenc checkspelling childperuserid clearmodulelist contentdigest "
+"cookiedomain cookieexpires cookielog cookiename cookiestyle cookietracking coredumpdirectory customlog dav davdepthinfinity "
+"davlockdb davmintimeout defaulticon defaultlanguage defaulttype define deflatebuffersize deflatecompressionlevel "
+"deflatefilternote deflatememlevel deflatewindowsize deny directory directoryindex directorymatch directoryslash documentroot "
+"dumpioinput dumpiooutput enableexceptionhook enablemmap enablesendfile errordocument errorlog example expiresactive "
+"expiresbytype expiresdefault extendedstatus extfilterdefine extfilteroptions fancyindexing fileetag files filesmatch "
+"forcelanguagepriority forcetype forensiclog from group header headername hostnamelookups identitycheck ifdefine ifmodule "
+"imapbase imapdefault imapmenu include indexignore indexoptions indexorderdefault isapiappendlogtoerrors isapiappendlogtoquery "
+"isapicachefile isapifakeasync isapilognotsupported isapireadaheadbuffer keepalive keepalivetimeout languagepriority "
+"ldapcacheentries ldapcachettl ldapconnectiontimeout ldapopcacheentries ldapopcachettl ldapsharedcachefile ldapsharedcachesize "
+"ldaptrustedca ldaptrustedcatype limit limitexcept limitinternalrecursion limitrequestbody limitrequestfields "
+"limitrequestfieldsize limitrequestline limitxmlrequestbody listen listenbacklog loadfile loadmodule location locationmatch "
+"lockfile logformat loglevel maxclients maxkeepaliverequests maxmemfree maxrequestsperchild maxrequestsperthread maxspareservers "
+"maxsparethreads maxthreads maxthreadsperchild mcachemaxobjectcount mcachemaxobjectsize mcachemaxstreamingbuffer "
+"mcacheminobjectsize mcacheremovalalgorithm mcachesize metadir metafiles metasuffix mimemagicfile minspareservers minsparethreads "
+"mmapfile modmimeusepathinfo multiviewsmatch namevirtualhost nocache noproxy numservers nwssltrustedcerts nwsslupgradeable "
+"options order passenv pidfile port protocolecho proxy proxybadheader proxyblock proxydomain proxyerroroverride proxyiobuffersize "
+"proxymatch proxymaxforwards proxypass proxypassreverse proxypreservehost proxyreceivebuffersize proxyremote proxyremotematch "
+"proxyrequests proxytimeout proxyvia qsc readmename redirect redirectmatch redirectpermanent redirecttemp refererignore "
+"refererlog removecharset removeencoding removehandler removeinputfilter removelanguage removeoutputfilter removetype "
+"requestheader require resourceconfig rewritebase rewritecond rewriteengine rewritelock rewritelog rewriteloglevel rewritemap "
+"rewriteoptions rewriterule rlimitcpu rlimitmem rlimitnproc satisfy scoreboardfile script scriptalias scriptaliasmatch "
+"scriptinterpretersource scriptlog scriptlogbuffer scriptloglength scriptsock securelisten sendbuffersize serveradmin serveralias "
+"serverlimit servername serverpath serverroot serversignature servertokens servertype setenv setenvif setenvifnocase sethandler "
+"setinputfilter setoutputfilter singlelisten ssiendtag ssierrormsg ssistarttag ssitimeformat ssiundefinedecho "
+"sslcacertificatefile sslcacertificatepath sslcarevocationfile sslcarevocationpath sslcertificatechainfile sslcertificatefile "
+"sslcertificatekeyfile sslciphersuite sslengine sslmutex ssloptions sslpassphrasedialog sslprotocol sslproxycacertificatefile "
+"sslproxycacertificatepath sslproxycarevocationfile sslproxycarevocationpath sslproxyciphersuite sslproxyengine "
+"sslproxymachinecertificatefile sslproxymachinecertificatepath sslproxyprotocol sslproxyverify sslproxyverifydepth sslrandomseed "
+"sslrequire sslrequiressl sslsessioncache sslsessioncachetimeout sslusername sslverifyclient sslverifydepth startservers "
+"startthreads suexecusergroup threadlimit threadsperchild threadstacksize timeout transferlog typesconfig unsetenv "
+"usecanonicalname user userdir virtualdocumentroot virtualdocumentrootip virtualhost virtualscriptalias virtualscriptaliasip "
+"win32disableacceptex xbithack",
+"", //"on off standalone inetd force-response-1.0 downgrade-1.0 nokeepalive indexes includes followsymlinks none x-compress x-gzip",
+"", "", "", "", "", "", "" };
+
+
+EDITLEXER lexCONF = { SCLEX_CONF, 63020, L"Apache Config Files", L"conf; htaccess", L"", &KeyWords_CONF, {
+ { STYLE_DEFAULT, 63126, L"Default", L"", L"" },
+ { SCE_CONF_COMMENT, 63127, L"Comment", L"fore:#648000", L"" },
+ { SCE_CONF_STRING, 63131, L"String", L"fore:#B000B0", L"" },
+ { SCE_CONF_NUMBER, 63130, L"Number", L"fore:#FF4000", L"" },
+ { SCE_CONF_DIRECTIVE, 63203, L"Directive", L"fore:#003CE6", L"" },
+ { SCE_CONF_IP, 63248, L"IP Address", L"bold; fore:#FF4000", L"" },
+// Not used by lexer { SCE_CONF_IDENTIFIER, L"Identifier", L"", L"" },
+// Lexer is buggy { SCE_CONF_OPERATOR, L"Operator", L"", L"" },
+// Lexer is buggy { SCE_CONF_PARAMETER, L"Runtime Directive Parameter", L"", L"" },
+// Lexer is buggy { SCE_CONF_EXTENSION, L"Extension", L"", L"" },
+ { -1, 00000, L"", L"", L"" } } };
+
+
+KEYWORDLIST KeyWords_PS = {
+"break continue do else elseif filter for foreach function if in return switch until where while",
+"add-computer add-content add-history add-member add-pssnapin add-type checkpoint-computer "
+"clear-content clear-eventlog clear-history clear-host clear-item clear-itemproperty "
+"clear-variable compare-object complete-transaction connect-wsman convertfrom-csv "
+"convertfrom-securestring convertfrom-stringdata convert-path convertto-csv convertto-html "
+"convertto-securestring convertto-xml copy-item copy-itemproperty debug-process "
+"disable-computerrestore disable-psbreakpoint disable-psremoting disable-pssessionconfiguration "
+"disable-wsmancredssp disconnect-wsman enable-computerrestore enable-psbreakpoint "
+"enable-psremoting enable-pssessionconfiguration enable-wsmancredssp enter-pssession "
+"exit-pssession export-alias export-clixml export-console export-counter export-csv "
+"export-formatdata export-modulemember export-pssession foreach-object format-custom format-list "
+"format-table format-wide get-acl get-alias get-authenticodesignature get-childitem get-command "
+"get-computerrestorepoint get-content get-counter get-credential get-culture get-date get-event "
+"get-eventlog get-eventsubscriber get-executionpolicy get-formatdata get-help get-history "
+"get-host get-hotfix get-item get-itemproperty get-job get-location get-member get-module "
+"get-pfxcertificate get-process get-psbreakpoint get-pscallstack get-psdrive get-psprovider "
+"get-pssession get-pssessionconfiguration get-pssnapin get-random get-service get-tracesource "
+"get-transaction get-uiculture get-unique get-variable get-verb get-winevent get-wmiobject "
+"get-wsmancredssp get-wsmaninstance group-object help import-alias import-clixml import-counter "
+"import-csv import-localizeddata import-module import-pssession importsystemmodules "
+"invoke-command invoke-expression invoke-history invoke-item invoke-wmimethod invoke-wsmanaction "
+"join-path limit-eventlog measure-command measure-object mkdir more move-item move-itemproperty "
+"new-alias new-event new-eventlog new-item new-itemproperty new-module new-modulemanifest "
+"new-object new-psdrive new-pssession new-pssessionoption new-service new-timespan new-variable "
+"new-webserviceproxy new-wsmaninstance new-wsmansessionoption out-default out-file out-gridview "
+"out-host out-null out-printer out-string pop-location prompt push-location read-host receive-job "
+"register-engineevent register-objectevent register-pssessionconfiguration register-wmievent "
+"remove-computer remove-event remove-eventlog remove-item remove-itemproperty remove-job "
+"remove-module remove-psbreakpoint remove-psdrive remove-pssession remove-pssnapin "
+"remove-variable remove-wmiobject remove-wsmaninstance rename-item rename-itemproperty "
+"reset-computermachinepassword resolve-path restart-computer restart-service restore-computer "
+"resume-service select-object select-string select-xml send-mailmessage set-acl set-alias "
+"set-authenticodesignature set-content set-date set-executionpolicy set-item set-itemproperty "
+"set-location set-psbreakpoint set-psdebug set-pssessionconfiguration set-service set-strictmode "
+"set-tracesource set-variable set-wmiinstance set-wsmaninstance set-wsmanquickconfig "
+"show-eventlog sort-object split-path start-job start-process start-service start-sleep "
+"start-transaction start-transcript stop-computer stop-job stop-process stop-service "
+"stop-transcript suspend-service tee-object test-computersecurechannel test-connection "
+"test-modulemanifest test-path test-wsman trace-command undo-transaction unregister-event "
+"unregister-pssessionconfiguration update-formatdata update-list update-typedata use-transaction "
+"wait-event wait-job wait-process where-object write-debug write-error write-eventlog write-host "
+"write-output write-progress write-verbose write-warning",
+"ac asnp cat cd chdir clc clear clhy cli clp cls clv compare copy cp cpi cpp cvpa dbp del diff "
+"dir ebp echo epal epcsv epsn erase etsn exsn fc fl foreach ft fw gal gbp gc gci gcm gcs gdr ghy "
+"gi gjb gl gm gmo gp gps group gsn gsnp gsv gu gv gwmi h history icm iex ihy ii ipal ipcsv ipmo "
+"ipsn ise iwmi kill lp ls man md measure mi mount move mp mv nal ndr ni nmo nsn nv ogv oh popd ps "
+"pushd pwd r rbp rcjb rd rdr ren ri rjb rm rmdir rmo rni rnp rp rsn rsnp rv rvpa rwmi sajb sal "
+"saps sasv sbp sc select set si sl sleep sort sp spjb spps spsv start sv swmi tee type where wjb "
+"write", "", "", "", "", "", "" };
+
+
+EDITLEXER lexPS = { SCLEX_POWERSHELL, 63021, L"PowerShell Script", L"ps1; psc1", L"", &KeyWords_PS, {
+ { STYLE_DEFAULT, 63126, L"Default", L"", L"" },
+ //{ SCE_POWERSHELL_DEFAULT, L"Default", L"", L"" },
+ { SCE_POWERSHELL_COMMENT, 63127, L"Comment", L"fore:#646464", L"" },
+ { SCE_POWERSHELL_KEYWORD, 63128, L"Keyword", L"bold; fore:#804000", L"" },
+ { SCE_POWERSHELL_IDENTIFIER, 63129, L"Identifier", L"", L"" },
+ { MULTI_STYLE(SCE_POWERSHELL_STRING,SCE_POWERSHELL_CHARACTER,0,0), 63131, L"String", L"fore:#008000", L"" },
+ { SCE_POWERSHELL_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" },
+ { SCE_POWERSHELL_OPERATOR, 63132, L"Operator", L"bold", L"" },
+ { SCE_POWERSHELL_VARIABLE, 63249, L"Variable", L"fore:#0A246A", L"" },
+ { SCE_POWERSHELL_CMDLET, 63250, L"Cmdlet", L"fore:#804000; back:#FFF1A8", L"" },
+ { SCE_POWERSHELL_ALIAS, 63251, L"Alias", L"bold; fore:#0A246A", L"" },
+ { -1, 00000, L"", L"", L"" } } };
+
+
+// This array holds all the lexers...
+PEDITLEXER pLexArray[NUMLEXERS] =
+{
+ &lexDefault,
+ &lexHTML,
+ &lexXML,
+ &lexCSS,
+ &lexJS,
+ &lexVBS,
+ &lexCPP,
+ &lexCS,
+ &lexRC,
+ &lexMAK,
+ &lexJAVA,
+ &lexVB,
+ &lexPAS,
+ &lexASM,
+ &lexSQL,
+ &lexPL,
+ &lexPY,
+ &lexINI,
+ &lexCONF,
+ &lexPS,
+ &lexBAT,
+ &lexDIFF
+};
+
+
+// Currently used lexer
+PEDITLEXER pLexCurrent = &lexDefault;
+COLORREF crCustom[16];
+BOOL bUse2ndDefaultStyle;
+BOOL fStylesModified = FALSE;
+BOOL fWarnedNoIniFile = FALSE;
+int iBaseFontSize = 10;
+int iDefaultLexer;
+BOOL bAutoSelect;
+int cxStyleSelectDlg;
+int cyStyleSelectDlg;
+extern int iDefaultCodePage;
+extern int iDefaultCharSet;
+extern BOOL bHiliteCurrentLine;
+
+
+//=============================================================================
+//
+// Style_Load()
+//
+void Style_Load()
+{
+ int i,iLexer;
+ WCHAR tch[32];
+ WCHAR *pIniSection = LocalAlloc(LPTR,sizeof(WCHAR)*32*1024);
+ int cchIniSection = LocalSize(pIniSection)/sizeof(WCHAR);
+
+ // Custom colors
+ crCustom [0] = RGB(0x00,0x00,0x00);
+ crCustom [1] = RGB(0x0A,0x24,0x6A);
+ crCustom [2] = RGB(0x3A,0x6E,0xA5);
+ crCustom [3] = RGB(0x00,0x3C,0xE6);
+ crCustom [4] = RGB(0x00,0x66,0x33);
+ crCustom [5] = RGB(0x60,0x80,0x20);
+ crCustom [6] = RGB(0x64,0x80,0x00);
+ crCustom [7] = RGB(0xA4,0x60,0x00);
+ crCustom [8] = RGB(0xFF,0xFF,0xFF);
+ crCustom [9] = RGB(0xFF,0xFF,0xE2);
+ crCustom[10] = RGB(0xFF,0xF1,0xA8);
+ crCustom[11] = RGB(0xFF,0xC0,0x00);
+ crCustom[12] = RGB(0xFF,0x40,0x00);
+ crCustom[13] = RGB(0xC8,0x00,0x00);
+ crCustom[14] = RGB(0xB0,0x00,0xB0);
+ crCustom[15] = RGB(0xB2,0x8B,0x40);
+
+ LoadIniSection(L"Custom Colors",pIniSection,cchIniSection);
+ for (i = 0; i < 16; i++) {
+ wsprintf(tch,L"%02i",i+1);
+ crCustom[i] = IniSectionGetInt(pIniSection,tch,crCustom[i]);
+ }
+
+ LoadIniSection(L"Styles",pIniSection,cchIniSection);
+ // 2nd default
+ bUse2ndDefaultStyle = (IniSectionGetInt(pIniSection,L"Use2ndDefaultStyle",0)) ? 1 : 0;
+
+ // default scheme
+ iDefaultLexer = IniSectionGetInt(pIniSection,L"DefaultScheme",0);
+ iDefaultLexer = min(max(iDefaultLexer,0),NUMLEXERS-1);
+
+ // auto select
+ bAutoSelect = (IniSectionGetInt(pIniSection,L"AutoSelect",1)) ? 1 : 0;
+
+ // scheme select dlg dimensions
+ cxStyleSelectDlg = IniSectionGetInt(pIniSection,L"SelectDlgSizeX",304);
+ cxStyleSelectDlg = max(cxStyleSelectDlg,0);
+
+ cyStyleSelectDlg = IniSectionGetInt(pIniSection,L"SelectDlgSizeY",0);
+ cyStyleSelectDlg = max(cyStyleSelectDlg,324);
+
+ for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) {
+ LoadIniSection(pLexArray[iLexer]->pszName,pIniSection,cchIniSection);
+ if (!IniSectionGetString(pIniSection,L"FileNameExtensions",pLexArray[iLexer]->pszDefExt,
+ pLexArray[iLexer]->szExtensions,COUNTOF(pLexArray[iLexer]->szExtensions)))
+ lstrcpyn(pLexArray[iLexer]->szExtensions,pLexArray[iLexer]->pszDefExt,
+ COUNTOF(pLexArray[iLexer]->szExtensions));
+ i = 0;
+ while (pLexArray[iLexer]->Styles[i].iStyle != -1) {
+ IniSectionGetString(pIniSection,pLexArray[iLexer]->Styles[i].pszName,
+ pLexArray[iLexer]->Styles[i].pszDefault,
+ pLexArray[iLexer]->Styles[i].szValue,
+ COUNTOF(pLexArray[iLexer]->Styles[i].szValue));
+ i++;
+ }
+ }
+ LocalFree(pIniSection);
+}
+
+
+//=============================================================================
+//
+// Style_Save()
+//
+void Style_Save()
+{
+ int i,iLexer;
+ WCHAR tch[32];
+ WCHAR *pIniSection = LocalAlloc(LPTR,sizeof(WCHAR)*32*1024);
+ int cchIniSection = LocalSize(pIniSection)/sizeof(WCHAR);
+
+ // Custom colors
+ for (i = 0; i < 16; i++) {
+ wsprintf(tch,L"%02i",i+1);
+ IniSectionSetInt(pIniSection,tch,crCustom[i]);
+ }
+ SaveIniSection(L"Custom Colors",pIniSection);
+ ZeroMemory(pIniSection,cchIniSection);
+
+ // auto select
+ IniSectionSetInt(pIniSection,L"Use2ndDefaultStyle",bUse2ndDefaultStyle);
+
+ // default scheme
+ IniSectionSetInt(pIniSection,L"DefaultScheme",iDefaultLexer);
+
+ // auto select
+ IniSectionSetInt(pIniSection,L"AutoSelect",bAutoSelect);
+
+ // scheme select dlg dimensions
+ IniSectionSetInt(pIniSection,L"SelectDlgSizeX",cxStyleSelectDlg);
+ IniSectionSetInt(pIniSection,L"SelectDlgSizeY",cyStyleSelectDlg);
+
+ SaveIniSection(L"Styles",pIniSection);
+
+ if (!fStylesModified) {
+ LocalFree(pIniSection);
+ return;
+ }
+
+ ZeroMemory(pIniSection,cchIniSection);
+ for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) {
+ IniSectionSetString(pIniSection,L"FileNameExtensions",pLexArray[iLexer]->szExtensions);
+ i = 0;
+ while (pLexArray[iLexer]->Styles[i].iStyle != -1) {
+ IniSectionSetString(pIniSection,pLexArray[iLexer]->Styles[i].pszName,pLexArray[iLexer]->Styles[i].szValue);
+ i++;
+ }
+ SaveIniSection(pLexArray[iLexer]->pszName,pIniSection);
+ ZeroMemory(pIniSection,cchIniSection);
+ }
+ LocalFree(pIniSection);
+}
+
+
+//=============================================================================
+//
+// Style_Import()
+//
+BOOL Style_Import(HWND hwnd)
+{
+ WCHAR szFile[MAX_PATH * 2] = L"";
+ WCHAR szFilter[256];
+ OPENFILENAME ofn;
+
+ ZeroMemory(&ofn,sizeof(OPENFILENAME));
+ GetString(IDS_FILTER_INI,szFilter,COUNTOF(szFilter));
+ PrepareFilterStr(szFilter);
+
+ ofn.lStructSize = sizeof(OPENFILENAME);
+ ofn.hwndOwner = hwnd;
+ ofn.lpstrFilter = szFilter;
+ ofn.lpstrFile = szFile;
+ ofn.lpstrDefExt = L"ini";
+ ofn.nMaxFile = COUNTOF(szFile);
+ ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_DONTADDTORECENT
+ | OFN_PATHMUSTEXIST | OFN_SHAREAWARE /*| OFN_NODEREFERENCELINKS*/;
+
+ if (GetOpenFileName(&ofn)) {
+
+ int i,iLexer;
+ WCHAR *pIniSection = LocalAlloc(LPTR,sizeof(WCHAR)*32*1024);
+ int cchIniSection = LocalSize(pIniSection)/sizeof(WCHAR);
+
+ for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) {
+ if (GetPrivateProfileSection(pLexArray[iLexer]->pszName,pIniSection,cchIniSection,szFile)) {
+ if (!IniSectionGetString(pIniSection,L"FileNameExtensions",pLexArray[iLexer]->pszDefExt,
+ pLexArray[iLexer]->szExtensions,COUNTOF(pLexArray[iLexer]->szExtensions)))
+ lstrcpyn(pLexArray[iLexer]->szExtensions,pLexArray[iLexer]->pszDefExt,
+ COUNTOF(pLexArray[iLexer]->szExtensions));
+ i = 0;
+ while (pLexArray[iLexer]->Styles[i].iStyle != -1) {
+ IniSectionGetString(pIniSection,pLexArray[iLexer]->Styles[i].pszName,
+ pLexArray[iLexer]->Styles[i].pszDefault,
+ pLexArray[iLexer]->Styles[i].szValue,
+ COUNTOF(pLexArray[iLexer]->Styles[i].szValue));
+ i++;
+ }
+ }
+ }
+ LocalFree(pIniSection);
+ return(TRUE);
+ }
+ else
+ return(FALSE);
+}
+
+//=============================================================================
+//
+// Style_Export()
+//
+BOOL Style_Export(HWND hwnd)
+{
+ WCHAR szFile[MAX_PATH * 2] = L"";
+ WCHAR szFilter[256];
+ OPENFILENAME ofn;
+
+ ZeroMemory(&ofn,sizeof(OPENFILENAME));
+ GetString(IDS_FILTER_INI,szFilter,COUNTOF(szFilter));
+ PrepareFilterStr(szFilter);
+
+ ofn.lStructSize = sizeof(OPENFILENAME);
+ ofn.hwndOwner = hwnd;
+ ofn.lpstrFilter = szFilter;
+ ofn.lpstrFile = szFile;
+ ofn.lpstrDefExt = L"ini";
+ ofn.nMaxFile = COUNTOF(szFile);
+ ofn.Flags = /*OFN_FILEMUSTEXIST |*/ OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_DONTADDTORECENT
+ | OFN_PATHMUSTEXIST | OFN_SHAREAWARE /*| OFN_NODEREFERENCELINKS*/ | OFN_OVERWRITEPROMPT;
+
+ if (GetSaveFileName(&ofn)) {
+
+ int i,iLexer;
+ WCHAR *pIniSection = LocalAlloc(LPTR,sizeof(WCHAR)*32*1024);
+ int cchIniSection = LocalSize(pIniSection)/sizeof(WCHAR);
+
+ for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) {
+ IniSectionSetString(pIniSection,L"FileNameExtensions",pLexArray[iLexer]->szExtensions);
+ i = 0;
+ while (pLexArray[iLexer]->Styles[i].iStyle != -1) {
+ IniSectionSetString(pIniSection,pLexArray[iLexer]->Styles[i].pszName,pLexArray[iLexer]->Styles[i].szValue);
+ i++;
+ }
+ WritePrivateProfileSection(pLexArray[iLexer]->pszName,pIniSection,szFile);
+ ZeroMemory(pIniSection,cchIniSection);
+ }
+ LocalFree(pIniSection);
+ return(TRUE);
+ }
+ else
+ return(FALSE);
+}
+
+
+//=============================================================================
+//
+// Style_SetLexer()
+//
+void Style_SetLexer(HWND hwnd,PEDITLEXER pLexNew)
+{
+ int i;
+ //WCHAR *p;
+ int rgb;
+ int iValue;
+ int iIdx;
+
+ // Select default if NULL is specified
+ if (!pLexNew)
+ pLexNew = pLexArray[iDefaultLexer];
+
+ // Lexer
+ SendMessage(hwnd,SCI_SETLEXER,pLexNew->iLexer,0);
+
+ if (pLexNew->iLexer == SCLEX_HTML || pLexNew->iLexer == SCLEX_XML || pLexNew->iLexer == SCLEX_PERL)
+ SendMessage(hwnd,SCI_SETSTYLEBITS,7,0);
+ else
+ SendMessage(hwnd,SCI_SETSTYLEBITS,5,0);
+
+ if (pLexNew->iLexer == SCLEX_CPP)
+ SendMessage(hwnd,SCI_SETPROPERTY,(WPARAM)"styling.within.preprocessor",(LPARAM)"1");
+ else if (pLexNew->iLexer == SCLEX_PASCAL)
+ SendMessage(hwnd,SCI_SETPROPERTY,(WPARAM)"lexer.pascal.smart.highlighting",(LPARAM)"1");
+ else if (pLexNew->iLexer == SCLEX_SQL) {
+ SendMessage(hwnd,SCI_SETPROPERTY,(WPARAM)"sql.backslash.escapes",(LPARAM)"1");
+ SendMessage(hwnd,SCI_SETPROPERTY,(WPARAM)"lexer.sql.backticks.identifier",(LPARAM)"1");
+ }
+
+ // Add KeyWord Lists
+ for (i = 0; i < 9; i++)
+ SendMessage(hwnd,SCI_SETKEYWORDS,i,(LPARAM)pLexNew->pKeyWords->pszKeyWords[i]);
+
+ // Use 2nd default style
+ iIdx = (bUse2ndDefaultStyle) ? 13 : 0;
+
+ // Font Quality
+ Style_SetFontQuality(hwnd,lexDefault.Styles[0+iIdx].szValue);
+
+ // Clear
+ SendMessage(hwnd,SCI_CLEARDOCUMENTSTYLE,0,0);
+
+ // Default Values are always set
+ SendMessage(hwnd,SCI_STYLERESETDEFAULT,0,0);
+ SendMessage(hwnd,SCI_STYLESETCHARACTERSET,STYLE_DEFAULT,(LPARAM)DEFAULT_CHARSET);
+ iBaseFontSize = 10;
+ Style_SetStyles(hwnd,lexDefault.Styles[0+iIdx].iStyle,lexDefault.Styles[0+iIdx].szValue); // default
+ Style_StrGetSize(lexDefault.Styles[0+iIdx].szValue,&iBaseFontSize); // base size
+
+ // Auto-select codepage according to charset
+ //Style_SetACPfromCharSet(hwnd);
+
+ if (!Style_StrGetColor(TRUE,lexDefault.Styles[0+iIdx].szValue,&iValue))
+ SendMessage(hwnd,SCI_STYLESETFORE,STYLE_DEFAULT,(LPARAM)GetSysColor(COLOR_WINDOWTEXT)); // default text color
+ if (!Style_StrGetColor(FALSE,lexDefault.Styles[0+iIdx].szValue,&iValue))
+ SendMessage(hwnd,SCI_STYLESETBACK,STYLE_DEFAULT,(LPARAM)GetSysColor(COLOR_WINDOW)); // default window color
+
+ if (pLexNew->iLexer != SCLEX_NULL)
+ Style_SetStyles(hwnd,pLexNew->Styles[0].iStyle,pLexNew->Styles[0].szValue); // lexer default
+ SendMessage(hwnd,SCI_STYLECLEARALL,0,0);
+
+ Style_SetStyles(hwnd,lexDefault.Styles[1+iIdx].iStyle,lexDefault.Styles[1+iIdx].szValue); // linenumber
+ Style_SetStyles(hwnd,lexDefault.Styles[2+iIdx].iStyle,lexDefault.Styles[2+iIdx].szValue); // brace light
+ Style_SetStyles(hwnd,lexDefault.Styles[3+iIdx].iStyle,lexDefault.Styles[3+iIdx].szValue); // brace bad
+ Style_SetStyles(hwnd,lexDefault.Styles[4+iIdx].iStyle,lexDefault.Styles[4+iIdx].szValue); // control char
+ Style_SetStyles(hwnd,lexDefault.Styles[5+iIdx].iStyle,lexDefault.Styles[5+iIdx].szValue); // indent guide
+
+ // More default values...
+ if (Style_StrGetColor(TRUE,lexDefault.Styles[6+iIdx].szValue,&rgb)) { // selection fore
+ SendMessage(hwnd,SCI_SETSELFORE,TRUE,rgb);
+ SendMessage(hwnd,SCI_SETADDITIONALSELFORE,rgb,0);
+ }
+ else {
+ SendMessage(hwnd,SCI_SETSELFORE,0,0);
+ SendMessage(hwnd,SCI_SETADDITIONALSELFORE,0,0);
+ }
+
+ if (Style_StrGetColor(FALSE,lexDefault.Styles[6+iIdx].szValue,&iValue)) { // selection back
+ SendMessage(hwnd,SCI_SETSELBACK,TRUE,iValue);
+ SendMessage(hwnd,SCI_SETADDITIONALSELBACK,iValue,0);
+ }
+ else {
+ SendMessage(hwnd,SCI_SETSELBACK,TRUE,RGB(0xC0,0xC0,0xC0)); // use a default value...
+ SendMessage(hwnd,SCI_SETADDITIONALSELBACK,RGB(0xC0,0xC0,0xC0),0);
+ }
+
+ if (Style_StrGetAlpha(lexDefault.Styles[6+iIdx].szValue,&iValue)) { // selection alpha
+ SendMessage(hwnd,SCI_SETSELALPHA,iValue,0);
+ SendMessage(hwnd,SCI_SETADDITIONALSELALPHA,iValue,0);
+ }
+ else {
+ SendMessage(hwnd,SCI_SETSELALPHA,SC_ALPHA_NOALPHA,0);
+ SendMessage(hwnd,SCI_SETADDITIONALSELALPHA,SC_ALPHA_NOALPHA,0);
+ }
+
+ if (StrStrI(lexDefault.Styles[6+iIdx].szValue,L"eolfilled")) // selection eolfilled
+ SendMessage(hwnd,SCI_SETSELEOLFILLED,1,0);
+ else
+ SendMessage(hwnd,SCI_SETSELEOLFILLED,0,0);
+
+ if (Style_StrGetColor(TRUE,lexDefault.Styles[7+iIdx].szValue,&rgb)) // whitespace fore
+ SendMessage(hwnd,SCI_SETWHITESPACEFORE,TRUE,rgb);
+ else
+ SendMessage(hwnd,SCI_SETWHITESPACEFORE,0,0);
+
+ if (Style_StrGetColor(FALSE,lexDefault.Styles[7+iIdx].szValue,&rgb)) // whitespace back
+ SendMessage(hwnd,SCI_SETWHITESPACEBACK,TRUE,rgb);
+ else
+ SendMessage(hwnd,SCI_SETWHITESPACEBACK,0,0); // use a default value...
+
+ // whitespace dot size
+ iValue = 1;
+ if (Style_StrGetSize(lexDefault.Styles[7+iIdx].szValue,&iValue)) {
+
+ WCHAR tch[32];
+ WCHAR wchStyle[COUNTOF(lexDefault.Styles[0].szValue)];
+ lstrcpyn(wchStyle,lexDefault.Styles[7+iIdx].szValue,COUNTOF(lexDefault.Styles[0].szValue));
+
+ iValue = max(min(iValue,5),0);
+ wsprintf(lexDefault.Styles[7+iIdx].szValue,L"size:%i",iValue);
+
+ if (Style_StrGetColor(TRUE,wchStyle,&rgb)) {
+ wsprintf(tch,L"; fore:#%02X%02X%02X",
+ (int)GetRValue(rgb),
+ (int)GetGValue(rgb),
+ (int)GetBValue(rgb));
+ lstrcat(lexDefault.Styles[7+iIdx].szValue,tch);
+ }
+
+ if (Style_StrGetColor(FALSE,wchStyle,&rgb)) {
+ wsprintf(tch,L"; back:#%02X%02X%02X",
+ (int)GetRValue(rgb),
+ (int)GetGValue(rgb),
+ (int)GetBValue(rgb));
+ lstrcat(lexDefault.Styles[7+iIdx].szValue,tch);
+ }
+ }
+ SendMessage(hwnd,SCI_SETWHITESPACESIZE,iValue,0);
+
+ if (bHiliteCurrentLine) {
+
+ if (Style_StrGetColor(FALSE,lexDefault.Styles[8+iIdx].szValue,&rgb)) // caret line back
+ {
+ SendMessage(hwnd,SCI_SETCARETLINEVISIBLE,TRUE,0);
+ SendMessage(hwnd,SCI_SETCARETLINEBACK,rgb,0);
+
+ if (Style_StrGetAlpha(lexDefault.Styles[8+iIdx].szValue,&iValue))
+ SendMessage(hwnd,SCI_SETCARETLINEBACKALPHA,iValue,0);
+ else
+ SendMessage(hwnd,SCI_SETCARETLINEBACKALPHA,SC_ALPHA_NOALPHA,0);
+ }
+ else
+ SendMessage(hwnd,SCI_SETCARETLINEVISIBLE,FALSE,0);
+ }
+ else
+ SendMessage(hwnd,SCI_SETCARETLINEVISIBLE,FALSE,0);
+
+ // caret fore
+ if (!Style_StrGetColor(TRUE,lexDefault.Styles[9+iIdx].szValue,&rgb))
+ rgb = GetSysColor(COLOR_WINDOWTEXT);
+ if (!VerifyContrast(rgb,SendMessage(hwnd,SCI_STYLEGETBACK,0,0)))
+ rgb = SendMessage(hwnd,SCI_STYLEGETFORE,0,0);
+ SendMessage(hwnd,SCI_SETCARETFORE,rgb,0);
+ SendMessage(hwnd,SCI_SETADDITIONALCARETFORE,rgb,0);
+
+ // caret style and width
+ if (StrStr(lexDefault.Styles[10+iIdx].szValue,L"block"))
+ SendMessage(hwnd,SCI_SETCARETSTYLE,CARETSTYLE_BLOCK,0);
+ else {
+ iValue = 1;
+ if (Style_StrGetSize(lexDefault.Styles[10+iIdx].szValue,&iValue)) {
+ iValue = max(min(iValue,3),1);
+ wsprintf(lexDefault.Styles[10+iIdx].szValue,L"size:%i",iValue);
+ }
+ SendMessage(hwnd,SCI_SETCARETSTYLE,CARETSTYLE_LINE,0);
+ SendMessage(hwnd,SCI_SETCARETWIDTH,iValue,0);
+ }
+
+ if (SendMessage(hwnd,SCI_GETEDGEMODE,0,0) == EDGE_LINE) {
+ if (Style_StrGetColor(TRUE,lexDefault.Styles[11+iIdx].szValue,&rgb)) // edge fore
+ SendMessage(hwnd,SCI_SETEDGECOLOUR,rgb,0);
+ else
+ SendMessage(hwnd,SCI_SETEDGECOLOUR,GetSysColor(COLOR_3DLIGHT),0);
+ }
+ else {
+ if (Style_StrGetColor(FALSE,lexDefault.Styles[11+iIdx].szValue,&rgb)) // edge back
+ SendMessage(hwnd,SCI_SETEDGECOLOUR,rgb,0);
+ else
+ SendMessage(hwnd,SCI_SETEDGECOLOUR,GetSysColor(COLOR_3DLIGHT),0);
+ }
+
+ // Extra Line Spacing
+ if (Style_StrGetSize(lexDefault.Styles[12+iIdx].szValue,&iValue)) {
+ int iAscent = 0;
+ int iDescent = 0;
+ iValue = min(max(iValue,0),64);
+ if (iValue % 2) {
+ iAscent++;
+ iValue--;
+ }
+ iAscent += iValue / 2;
+ iDescent += iValue / 2;
+ SendMessage(hwnd,SCI_SETEXTRAASCENT,(WPARAM)iAscent,0);
+ SendMessage(hwnd,SCI_SETEXTRADESCENT,(WPARAM)iDescent,0);
+ wsprintf(lexDefault.Styles[12+iIdx].szValue,L"size:%i",iValue);
+ }
+ else {
+ SendMessage(hwnd,SCI_SETEXTRAASCENT,0,0);
+ SendMessage(hwnd,SCI_SETEXTRADESCENT,0,0);
+ //wsprintf(lexDefault.Styles[12+iIdx].szValue,L"size:0");
+ }
+
+ if (SendMessage(hwnd,SCI_GETINDENTATIONGUIDES,0,0) != SC_IV_NONE)
+ Style_SetIndentGuides(hwnd,TRUE);
+
+ if (pLexNew->iLexer != SCLEX_NULL)
+ {
+ int j;
+ i = 1;
+ while (pLexNew->Styles[i].iStyle != -1) {
+
+ for (j = 0; j < 4 && (pLexNew->Styles[i].iStyle8[j] != 0 || j == 0); ++j)
+ Style_SetStyles(hwnd,pLexNew->Styles[i].iStyle8[j],pLexNew->Styles[i].szValue);
+
+ if (pLexNew->iLexer == SCLEX_HTML && pLexNew->Styles[i].iStyle8[0] == SCE_HPHP_DEFAULT) {
+ int iRelated[] = { SCE_HPHP_COMMENT, SCE_HPHP_COMMENTLINE, SCE_HPHP_WORD, SCE_HPHP_HSTRING, SCE_HPHP_SIMPLESTRING, SCE_HPHP_NUMBER,
+ SCE_HPHP_OPERATOR, SCE_HPHP_VARIABLE, SCE_HPHP_HSTRING_VARIABLE, SCE_HPHP_COMPLEX_VARIABLE };
+ for (j = 0; j < COUNTOF(iRelated); j++)
+ Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue);
+ }
+
+ if (pLexNew->iLexer == SCLEX_HTML && pLexNew->Styles[i].iStyle8[0] == SCE_HJ_DEFAULT) {
+ int iRelated[] = { SCE_HJ_COMMENT, SCE_HJ_COMMENTLINE, SCE_HJ_COMMENTDOC, SCE_HJ_KEYWORD, SCE_HJ_WORD, SCE_HJ_DOUBLESTRING,
+ SCE_HJ_SINGLESTRING, SCE_HJ_STRINGEOL, SCE_HJ_REGEX, SCE_HJ_NUMBER, SCE_HJ_SYMBOLS };
+ for (j = 0; j < COUNTOF(iRelated); j++)
+ Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue);
+ }
+
+ if (pLexNew->iLexer == SCLEX_HTML && pLexNew->Styles[i].iStyle8[0] == SCE_HJA_DEFAULT) {
+ int iRelated[] = { SCE_HJA_COMMENT, SCE_HJA_COMMENTLINE, SCE_HJA_COMMENTDOC, SCE_HJA_KEYWORD, SCE_HJA_WORD, SCE_HJA_DOUBLESTRING,
+ SCE_HJA_SINGLESTRING, SCE_HJA_STRINGEOL, SCE_HJA_REGEX, SCE_HJA_NUMBER, SCE_HJA_SYMBOLS };
+ for (j = 0; j < COUNTOF(iRelated); j++)
+ Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue);
+ }
+
+ if (pLexNew->iLexer == SCLEX_HTML && pLexNew->Styles[i].iStyle8[0] == SCE_HB_DEFAULT) {
+ int iRelated[] = { SCE_HB_COMMENTLINE, SCE_HB_WORD, SCE_HB_IDENTIFIER, SCE_HB_STRING, SCE_HB_STRINGEOL, SCE_HB_NUMBER };
+ for (j = 0; j < COUNTOF(iRelated); j++)
+ Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue);
+ }
+
+ if (pLexNew->iLexer == SCLEX_HTML && pLexNew->Styles[i].iStyle8[0] == SCE_HBA_DEFAULT) {
+ int iRelated[] = { SCE_HBA_COMMENTLINE, SCE_HBA_WORD, SCE_HBA_IDENTIFIER, SCE_HBA_STRING, SCE_HBA_STRINGEOL, SCE_HBA_NUMBER };
+ for (j = 0; j < COUNTOF(iRelated); j++)
+ Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue);
+ }
+
+ if ((pLexNew->iLexer == SCLEX_HTML || pLexNew->iLexer == SCLEX_XML) && pLexNew->Styles[i].iStyle8[0] == SCE_H_SGML_DEFAULT) {
+ int iRelated[] = { SCE_H_SGML_COMMAND, SCE_H_SGML_1ST_PARAM, SCE_H_SGML_DOUBLESTRING, SCE_H_SGML_SIMPLESTRING, SCE_H_SGML_ERROR,
+ SCE_H_SGML_SPECIAL, SCE_H_SGML_ENTITY, SCE_H_SGML_COMMENT, SCE_H_SGML_1ST_PARAM_COMMENT, SCE_H_SGML_BLOCK_DEFAULT };
+ for (j = 0; j < COUNTOF(iRelated); j++)
+ Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue);
+ }
+
+ if ((pLexNew->iLexer == SCLEX_HTML || pLexNew->iLexer == SCLEX_XML) && pLexNew->Styles[i].iStyle8[0] == SCE_H_CDATA) {
+ int iRelated[] = { SCE_HP_START, SCE_HP_DEFAULT, SCE_HP_COMMENTLINE, SCE_HP_NUMBER, SCE_HP_STRING,
+ SCE_HP_CHARACTER, SCE_HP_WORD, SCE_HP_TRIPLE, SCE_HP_TRIPLEDOUBLE, SCE_HP_CLASSNAME,
+ SCE_HP_DEFNAME, SCE_HP_OPERATOR, SCE_HP_IDENTIFIER, SCE_HPA_START, SCE_HPA_DEFAULT,
+ SCE_HPA_COMMENTLINE, SCE_HPA_NUMBER, SCE_HPA_STRING, SCE_HPA_CHARACTER, SCE_HPA_WORD,
+ SCE_HPA_TRIPLE, SCE_HPA_TRIPLEDOUBLE, SCE_HPA_CLASSNAME, SCE_HPA_DEFNAME, SCE_HPA_OPERATOR,
+ SCE_HPA_IDENTIFIER };
+ for (j = 0; j < COUNTOF(iRelated); j++)
+ Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue);
+ }
+
+ if (pLexNew->iLexer == SCLEX_XML && pLexNew->Styles[i].iStyle8[0] == SCE_H_CDATA) {
+ int iRelated[] = { SCE_H_SCRIPT, SCE_H_ASP, SCE_H_ASPAT, SCE_H_QUESTION,
+ SCE_HPHP_DEFAULT, SCE_HPHP_COMMENT, SCE_HPHP_COMMENTLINE, SCE_HPHP_WORD, SCE_HPHP_HSTRING,
+ SCE_HPHP_SIMPLESTRING, SCE_HPHP_NUMBER, SCE_HPHP_OPERATOR, SCE_HPHP_VARIABLE,
+ SCE_HPHP_HSTRING_VARIABLE, SCE_HPHP_COMPLEX_VARIABLE, SCE_HJ_START, SCE_HJ_DEFAULT,
+ SCE_HJ_COMMENT, SCE_HJ_COMMENTLINE, SCE_HJ_COMMENTDOC, SCE_HJ_KEYWORD, SCE_HJ_WORD,
+ SCE_HJ_DOUBLESTRING, SCE_HJ_SINGLESTRING, SCE_HJ_STRINGEOL, SCE_HJ_REGEX, SCE_HJ_NUMBER,
+ SCE_HJ_SYMBOLS, SCE_HJA_START, SCE_HJA_DEFAULT, SCE_HJA_COMMENT, SCE_HJA_COMMENTLINE,
+ SCE_HJA_COMMENTDOC, SCE_HJA_KEYWORD, SCE_HJA_WORD, SCE_HJA_DOUBLESTRING, SCE_HJA_SINGLESTRING,
+ SCE_HJA_STRINGEOL, SCE_HJA_REGEX, SCE_HJA_NUMBER, SCE_HJA_SYMBOLS, SCE_HB_START, SCE_HB_DEFAULT,
+ SCE_HB_COMMENTLINE, SCE_HB_WORD, SCE_HB_IDENTIFIER, SCE_HB_STRING, SCE_HB_STRINGEOL,
+ SCE_HB_NUMBER, SCE_HBA_START, SCE_HBA_DEFAULT, SCE_HBA_COMMENTLINE, SCE_HBA_WORD,
+ SCE_HBA_IDENTIFIER, SCE_HBA_STRING, SCE_HBA_STRINGEOL, SCE_HBA_NUMBER, SCE_HP_START,
+ SCE_HP_DEFAULT, SCE_HP_COMMENTLINE, SCE_HP_NUMBER, SCE_HP_STRING, SCE_HP_CHARACTER, SCE_HP_WORD,
+ SCE_HP_TRIPLE, SCE_HP_TRIPLEDOUBLE, SCE_HP_CLASSNAME, SCE_HP_DEFNAME, SCE_HP_OPERATOR,
+ SCE_HP_IDENTIFIER, SCE_HPA_START, SCE_HPA_DEFAULT, SCE_HPA_COMMENTLINE, SCE_HPA_NUMBER,
+ SCE_HPA_STRING, SCE_HPA_CHARACTER, SCE_HPA_WORD, SCE_HPA_TRIPLE, SCE_HPA_TRIPLEDOUBLE,
+ SCE_HPA_CLASSNAME, SCE_HPA_DEFNAME, SCE_HPA_OPERATOR, SCE_HPA_IDENTIFIER };
+ for (j = 0; j < COUNTOF(iRelated); j++)
+ Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue);
+ }
+
+ if (pLexNew->iLexer == SCLEX_CPP && pLexNew->Styles[i].iStyle8[0] == SCE_C_COMMENT) {
+ int iRelated[] = { SCE_C_COMMENTLINE, SCE_C_COMMENTDOC, SCE_C_COMMENTLINEDOC, SCE_C_COMMENTDOCKEYWORD, SCE_C_COMMENTDOCKEYWORDERROR };
+ for (j = 0; j < COUNTOF(iRelated); j++)
+ Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue);
+ }
+
+ if (pLexNew -> iLexer == SCLEX_SQL && pLexNew->Styles[i].iStyle8[0] == SCE_SQL_COMMENT) {
+ int iRelated[] = { SCE_SQL_COMMENTLINE, SCE_SQL_COMMENTDOC, SCE_SQL_COMMENTLINEDOC, SCE_SQL_COMMENTDOCKEYWORD, SCE_SQL_COMMENTDOCKEYWORDERROR };
+ for (j = 0; j < COUNTOF(iRelated); j++)
+ Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue);
+ }
+ i++;
+ }
+ }
+
+ SendMessage(hwnd,SCI_COLOURISE,0,(LPARAM)-1);
+
+ // Save current lexer
+ pLexCurrent = pLexNew;
+}
+
+
+//=============================================================================
+//
+// Style_SetLongLineColors()
+//
+void Style_SetLongLineColors(HWND hwnd)
+{
+ int rgb;
+
+ // Use 2nd default style
+ int iIdx = (bUse2ndDefaultStyle) ? 13 : 0;
+
+ if (SendMessage(hwnd,SCI_GETEDGEMODE,0,0) == EDGE_LINE) {
+ if (Style_StrGetColor(TRUE,lexDefault.Styles[11+iIdx].szValue,&rgb)) // edge fore
+ SendMessage(hwnd,SCI_SETEDGECOLOUR,rgb,0);
+ else
+ SendMessage(hwnd,SCI_SETEDGECOLOUR,GetSysColor(COLOR_3DLIGHT),0);
+ }
+ else {
+ if (Style_StrGetColor(FALSE,lexDefault.Styles[11+iIdx].szValue,&rgb)) // edge back
+ SendMessage(hwnd,SCI_SETEDGECOLOUR,rgb,0);
+ else
+ SendMessage(hwnd,SCI_SETEDGECOLOUR,GetSysColor(COLOR_3DLIGHT),0);
+ }
+}
+
+
+//=============================================================================
+//
+// Style_SetCurrentLineBackground()
+//
+void Style_SetCurrentLineBackground(HWND hwnd)
+{
+ int rgb, iValue;
+
+ // Use 2nd default style
+ int iIdx = (bUse2ndDefaultStyle) ? 13 : 0;
+
+ if (bHiliteCurrentLine) {
+
+ if (Style_StrGetColor(FALSE,lexDefault.Styles[8+iIdx].szValue,&rgb)) // caret line back
+ {
+ SendMessage(hwnd,SCI_SETCARETLINEVISIBLE,TRUE,0);
+ SendMessage(hwnd,SCI_SETCARETLINEBACK,rgb,0);
+
+ if (Style_StrGetAlpha(lexDefault.Styles[8+iIdx].szValue,&iValue))
+ SendMessage(hwnd,SCI_SETCARETLINEBACKALPHA,iValue,0);
+ else
+ SendMessage(hwnd,SCI_SETCARETLINEBACKALPHA,SC_ALPHA_NOALPHA,0);
+ }
+ else
+ SendMessage(hwnd,SCI_SETCARETLINEVISIBLE,FALSE,0);
+ }
+ else
+ SendMessage(hwnd,SCI_SETCARETLINEVISIBLE,FALSE,0);
+}
+
+
+//=============================================================================
+//
+// Style_SniffShebang()
+//
+PEDITLEXER __fastcall Style_SniffShebang(char *pchText)
+{
+ if (StrCmpNA(pchText,"#!",2) == 0) {
+ char *pch = pchText + 2;
+ while (*pch == ' ' || *pch == '\t')
+ pch++;
+ while (*pch && *pch != ' ' && *pch != '\t' && *pch != '\r' && *pch != '\n')
+ pch++;
+ if ((pch - pchText) >= 3 && StrCmpNA(pch-3,"env",3) == 0) {
+ while (*pch == ' ')
+ pch++;
+ while (*pch && *pch != ' ' && *pch != '\t' && *pch != '\r' && *pch != '\n')
+ pch++;
+ }
+ if ((pch - pchText) >= 3 && StrCmpNIA(pch-3,"php",3) == 0)
+ return(&lexHTML);
+ else if ((pch - pchText) >= 4 && StrCmpNIA(pch-4,"perl",4) == 0)
+ return(&lexPL);
+ else if ((pch - pchText) >= 6 && StrCmpNIA(pch-6,"python",6) == 0)
+ return(&lexPY);
+ }
+
+ return(NULL);
+}
+
+
+//=============================================================================
+//
+// Style_MatchLexer()
+//
+PEDITLEXER __fastcall Style_MatchLexer(LPCWSTR lpszMatch,BOOL bCheckNames)
+{
+ int i;
+ WCHAR tch[256+16];
+ WCHAR *p1,*p2;
+
+ if (!bCheckNames) {
+
+ for (i = 0; i < NUMLEXERS; i++) {
+
+ ZeroMemory(tch,sizeof(WCHAR)*COUNTOF(tch));
+ lstrcpy(tch,pLexArray[i]->szExtensions);
+ p1 = tch;
+ while (*p1) {
+ if (p2 = StrChr(p1,L';'))
+ *p2 = L'\0';
+ else
+ p2 = StrEnd(p1);
+ StrTrim(p1,L" .");
+ if (lstrcmpi(p1,lpszMatch) == 0)
+ return(pLexArray[i]);
+ p1 = p2+1;
+ }
+ }
+ }
+
+ else {
+
+ int cch = lstrlen(lpszMatch);
+ if (cch >= 3) {
+
+ for (i = 0; i < NUMLEXERS; i++) {
+ if (StrCmpNI(pLexArray[i]->pszName,lpszMatch,cch) == 0)
+ return(pLexArray[i]);
+ }
+ }
+ }
+ return(NULL);
+}
+
+
+//=============================================================================
+//
+// Style_SetLexerFromFile()
+//
+extern int fNoHTMLGuess;
+extern int fNoCGIGuess;
+extern FILEVARS fvCurFile;
+
+void Style_SetLexerFromFile(HWND hwnd,LPCWSTR lpszFile)
+{
+ LPWSTR lpszExt;
+ BOOL bFound = FALSE;
+ PEDITLEXER pLexNew = pLexArray[iDefaultLexer];
+ PEDITLEXER pLexSniffed;
+
+ if ((fvCurFile.mask & FV_MODE) && fvCurFile.tchMode[0]) {
+
+ WCHAR wchMode[32];
+ PEDITLEXER pLexMode;
+ UINT cp = SendMessage(hwnd,SCI_GETCODEPAGE,0,0);
+ MultiByteToWideChar(cp,0,fvCurFile.tchMode,-1,wchMode,COUNTOF(wchMode));
+
+ if (!fNoCGIGuess && (lstrcmpi(wchMode,L"cgi") == 0 || lstrcmpi(wchMode,L"fcgi") == 0)) {
+ char tchText[256];
+ SendMessage(hwnd,SCI_GETTEXT,(WPARAM)COUNTOF(tchText)-1,(LPARAM)tchText);
+ StrTrimA(tchText," \t\n\r");
+ if (pLexSniffed = Style_SniffShebang(tchText)) {
+ pLexNew = pLexSniffed;
+ bFound = TRUE;
+ }
+ }
+
+ if (!bFound) {
+ if (pLexMode = Style_MatchLexer(wchMode,FALSE)) {
+ pLexNew = pLexMode;
+ bFound = TRUE;
+ }
+ else if (pLexMode = Style_MatchLexer(wchMode,TRUE)) {
+ pLexNew = pLexMode;
+ bFound = TRUE;
+ }
+ }
+ }
+
+ lpszExt = PathFindExtension(lpszFile);
+ if (!bFound && bAutoSelect && /* bAutoSelect == FALSE skips lexer search */
+ (lpszFile && lstrlen(lpszFile) > 0 && *lpszExt)) {
+
+ if (*lpszExt == L'.')
+ lpszExt++;
+
+ if (!fNoCGIGuess && (lstrcmpi(lpszExt,L"cgi") == 0 || lstrcmpi(lpszExt,L"fcgi") == 0)) {
+ char tchText[256];
+ SendMessage(hwnd,SCI_GETTEXT,(WPARAM)COUNTOF(tchText)-1,(LPARAM)tchText);
+ StrTrimA(tchText," \t\n\r");
+ if (pLexSniffed = Style_SniffShebang(tchText)) {
+ pLexNew = pLexSniffed;
+ bFound = TRUE;
+ }
+ }
+
+ // check associated extensions
+ if (!bFound) {
+ if (pLexSniffed = Style_MatchLexer(lpszExt,FALSE)) {
+ pLexNew = pLexSniffed;
+ bFound = TRUE;
+ }
+ }
+ }
+
+ if (!bFound && bAutoSelect &&
+ lstrcmpi(PathFindFileName(lpszFile),L"makefile") == 0) {
+ pLexNew = &lexMAK;
+ bFound = TRUE;
+ }
+
+ if (!bFound && bAutoSelect && (!fNoHTMLGuess || !fNoCGIGuess)) {
+ char tchText[512];
+ SendMessage(hwnd,SCI_GETTEXT,(WPARAM)COUNTOF(tchText)-1,(LPARAM)tchText);
+ StrTrimA(tchText," \t\n\r");
+ if (!fNoHTMLGuess && tchText[0] == '<') {
+ if (StrStrIA(tchText,"<html"))
+ pLexNew = &lexHTML;
+ else
+ pLexNew = &lexXML;
+ bFound = TRUE;
+ }
+ else if (!fNoCGIGuess && (pLexSniffed = Style_SniffShebang(tchText))) {
+ pLexNew = pLexSniffed;
+ bFound = TRUE;
+ }
+ }
+
+ // Apply the new lexer
+ Style_SetLexer(hwnd,pLexNew);
+}
+
+
+//=============================================================================
+//
+// Style_SetLexerFromName()
+//
+void Style_SetLexerFromName(HWND hwnd,LPCWSTR lpszFile,LPCWSTR lpszName)
+{
+ PEDITLEXER pLexNew;
+ if (pLexNew = Style_MatchLexer(lpszName,FALSE))
+ Style_SetLexer(hwnd,pLexNew);
+ else if (pLexNew = Style_MatchLexer(lpszName,TRUE))
+ Style_SetLexer(hwnd,pLexNew);
+ else
+ Style_SetLexerFromFile(hwnd,lpszFile);
+}
+
+
+//=============================================================================
+//
+// Style_SetDefaultLexer()
+//
+void Style_SetDefaultLexer(HWND hwnd)
+{
+ Style_SetLexer(hwnd,pLexArray[0]);
+}
+
+
+//=============================================================================
+//
+// Style_SetHTMLLexer()
+//
+void Style_SetHTMLLexer(HWND hwnd)
+{
+ Style_SetLexer(hwnd,pLexArray[1]);
+}
+
+
+//=============================================================================
+//
+// Style_SetXMLLexer()
+//
+void Style_SetXMLLexer(HWND hwnd)
+{
+ Style_SetLexer(hwnd,pLexArray[2]);
+}
+
+
+//=============================================================================
+//
+// Style_SetLexerFromID()
+//
+void Style_SetLexerFromID(HWND hwnd,int id)
+{
+ if (id >= 0 && id < NUMLEXERS) {
+ Style_SetLexer(hwnd,pLexArray[id]);
+ }
+}
+
+
+//=============================================================================
+//
+// Style_ToggleUse2ndDefault()
+//
+void Style_ToggleUse2ndDefault(HWND hwnd)
+{
+ bUse2ndDefaultStyle = (bUse2ndDefaultStyle) ? 0 : 1;
+ Style_SetLexer(hwnd,pLexCurrent);
+}
+
+
+//=============================================================================
+//
+// Style_SetDefaultFont()
+//
+void Style_SetDefaultFont(HWND hwnd)
+{
+ int iIdx = (bUse2ndDefaultStyle) ? 13 : 0;
+ if (Style_SelectFont(hwnd,
+ lexDefault.Styles[0+iIdx].szValue,
+ COUNTOF(lexDefault.Styles[0+iIdx].szValue),
+ TRUE)) {
+ fStylesModified = TRUE;
+ Style_SetLexer(hwnd,pLexCurrent);
+ }
+}
+
+
+//=============================================================================
+//
+// Style_GetUse2ndDefault()
+//
+BOOL Style_GetUse2ndDefault(HWND hwnd)
+{
+ return (bUse2ndDefaultStyle);
+}
+
+
+//=============================================================================
+//
+// Style_SetIndentGuides()
+//
+extern int flagSimpleIndentGuides;
+
+void Style_SetIndentGuides(HWND hwnd,BOOL bShow)
+{
+ int iIndentView = SC_IV_NONE;
+ if (bShow) {
+ if (!flagSimpleIndentGuides) {
+ if (SendMessage(hwnd,SCI_GETLEXER,0,0) == SCLEX_PYTHON)
+ iIndentView = SC_IV_LOOKFORWARD;
+ else
+ iIndentView = SC_IV_LOOKBOTH;
+ }
+ else
+ iIndentView = SC_IV_REAL;
+ }
+ SendMessage(hwnd,SCI_SETINDENTATIONGUIDES,iIndentView,0);
+}
+
+
+//=============================================================================
+//
+// Style_GetFileOpenDlgFilter()
+//
+extern WCHAR tchFileDlgFilters[5*1024];
+
+BOOL Style_GetOpenDlgFilterStr(LPWSTR lpszFilter,int cchFilter)
+{
+ if (lstrlen(tchFileDlgFilters) == 0)
+ GetString(IDS_FILTER_ALL,lpszFilter,cchFilter);
+ else {
+ lstrcpyn(lpszFilter,tchFileDlgFilters,cchFilter-2);
+ lstrcat(lpszFilter,L"||");
+ }
+ PrepareFilterStr(lpszFilter);
+ return TRUE;
+}
+
+
+//=============================================================================
+//
+// Style_StrGetFont()
+//
+BOOL Style_StrGetFont(LPCWSTR lpszStyle,LPWSTR lpszFont,int cchFont)
+{
+ WCHAR tch[256];
+ WCHAR *p;
+
+ if (p = StrStrI(lpszStyle,L"font:"))
+ {
+ lstrcpy(tch,p + lstrlen(L"font:"));
+ if (p = StrChr(tch,L';'))
+ *p = L'\0';
+ TrimString(tch);
+ lstrcpyn(lpszFont,tch,cchFont);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+//=============================================================================
+//
+// Style_StrGetFontQuality()
+//
+BOOL Style_StrGetFontQuality(LPCWSTR lpszStyle,LPWSTR lpszQuality,int cchQuality)
+{
+ WCHAR tch[256];
+ WCHAR *p;
+
+ if (p = StrStrI(lpszStyle,L"smoothing:"))
+ {
+ lstrcpy(tch,p + lstrlen(L"smoothing:"));
+ if (p = StrChr(tch,L';'))
+ *p = L'\0';
+ TrimString(tch);
+ if (lstrcmpi(tch,L"none") == 0 ||
+ lstrcmpi(tch,L"standard") == 0 ||
+ lstrcmpi(tch,L"cleartype") == 0 ||
+ lstrcmpi(tch,L"default") == 0) {
+ lstrcpyn(lpszQuality,tch,cchQuality);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+
+//=============================================================================
+//
+// Style_StrGetCharSet()
+//
+BOOL Style_StrGetCharSet(LPCWSTR lpszStyle,int *i)
+{
+ WCHAR tch[256];
+ WCHAR *p;
+ int iValue;
+ int itok;
+
+ if (p = StrStrI(lpszStyle,L"charset:"))
+ {
+ lstrcpy(tch,p + lstrlen(L"charset:"));
+ if (p = StrChr(tch,L';'))
+ *p = L'\0';
+ TrimString(tch);
+ itok = swscanf(tch,L"%i",&iValue);
+ if (itok == 1)
+ {
+ *i = iValue;
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+
+//=============================================================================
+//
+// Style_StrGetSize()
+//
+BOOL Style_StrGetSize(LPCWSTR lpszStyle,int *i)
+{
+ WCHAR tch[256];
+ WCHAR *p;
+ int iValue;
+ int iSign = 0;
+ int itok;
+
+ if (p = StrStrI(lpszStyle,L"size:"))
+ {
+ lstrcpy(tch,p + lstrlen(L"size:"));
+ if (tch[0] == L'+')
+ {
+ iSign = 1;
+ tch[0] = L' ';
+ }
+ else if (tch[0] == L'-')
+ {
+ iSign = -1;
+ tch[0] = L' ';
+ }
+ if (p = StrChr(tch,L';'))
+ *p = L'\0';
+ TrimString(tch);
+ itok = swscanf(tch,L"%i",&iValue);
+ if (itok == 1)
+ {
+ if (iSign == 0)
+ *i = iValue;
+ else
+ *i = max(0,iBaseFontSize + iValue * iSign); // size must be +
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+
+//=============================================================================
+//
+// Style_StrGetSizeStr()
+//
+BOOL Style_StrGetSizeStr(LPCWSTR lpszStyle,LPWSTR lpszSize,int cchSize)
+{
+ WCHAR tch[256];
+ WCHAR *p;
+
+ if (p = StrStrI(lpszStyle,L"size:"))
+ {
+ lstrcpy(tch,p + lstrlen(L"size:"));
+ if (p = StrChr(tch,L';'))
+ *p = L'\0';
+ TrimString(tch);
+ lstrcpyn(lpszSize,tch,cchSize);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+//=============================================================================
+//
+// Style_StrGetColor()
+//
+BOOL Style_StrGetColor(BOOL bFore,LPCWSTR lpszStyle,int *rgb)
+{
+ WCHAR tch[256];
+ WCHAR *p;
+ int iValue;
+ int itok;
+ WCHAR *pItem = (bFore) ? L"fore:" : L"back:";
+
+ if (p = StrStrI(lpszStyle,pItem))
+ {
+ lstrcpy(tch,p + lstrlen(pItem));
+ if (tch[0] == L'#')
+ tch[0] = L' ';
+ if (p = StrChr(tch,L';'))
+ *p = L'\0';
+ TrimString(tch);
+ itok = swscanf(tch,L"%x",&iValue);
+ if (itok == 1)
+ {
+ *rgb = RGB((iValue&0xFF0000) >> 16,(iValue&0xFF00) >> 8,iValue&0xFF);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+
+//=============================================================================
+//
+// Style_StrGetCase()
+//
+BOOL Style_StrGetCase(LPCWSTR lpszStyle,int *i)
+{
+ WCHAR tch[256];
+ WCHAR *p;
+
+ if (p = StrStrI(lpszStyle,L"case:"))
+ {
+ lstrcpy(tch,p + lstrlen(L"case:"));
+ if (p = StrChr(tch,L';'))
+ *p = L'\0';
+ TrimString(tch);
+ if (tch[0] == L'u' || tch[0] == L'U') {
+ *i = SC_CASE_UPPER;
+ return TRUE;
+ }
+ else if (tch[0] == L'l' || tch[0] == L'L') {
+ *i = SC_CASE_LOWER;
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+
+//=============================================================================
+//
+// Style_StrGetAlpha()
+//
+BOOL Style_StrGetAlpha(LPCWSTR lpszStyle,int *i)
+{
+ WCHAR tch[256];
+ WCHAR *p;
+ int iValue;
+ int itok;
+
+ if (p = StrStrI(lpszStyle,L"alpha:"))
+ {
+ lstrcpy(tch,p + lstrlen(L"alpha:"));
+ if (p = StrChr(tch,L';'))
+ *p = L'\0';
+ TrimString(tch);
+ itok = swscanf(tch,L"%i",&iValue);
+ if (itok == 1)
+ {
+ *i = min(max(SC_ALPHA_TRANSPARENT,iValue),SC_ALPHA_OPAQUE);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+
+//=============================================================================
+//
+// Style_SelectFont()
+//
+BOOL Style_SelectFont(HWND hwnd,LPWSTR lpszStyle,int cchStyle,BOOL bDefaultStyle)
+{
+ CHOOSEFONT cf;
+ LOGFONT lf;
+ WCHAR szNewStyle[512];
+ int iValue;
+ WCHAR tch[32];
+ HDC hdc;
+
+ ZeroMemory(&cf,sizeof(CHOOSEFONT));
+ ZeroMemory(&lf,sizeof(LOGFONT));
+
+ // Map lpszStyle to LOGFONT
+ if (Style_StrGetFont(lpszStyle,tch,COUNTOF(tch)))
+ lstrcpyn(lf.lfFaceName,tch,COUNTOF(lf.lfFaceName));
+ if (Style_StrGetCharSet(lpszStyle,&iValue))
+ lf.lfCharSet = iValue;
+ if (Style_StrGetSize(lpszStyle,&iValue)) {
+ hdc = GetDC(hwnd);
+ lf.lfHeight = -MulDiv(iValue,GetDeviceCaps(hdc,LOGPIXELSY),72);
+ ReleaseDC(hwnd,hdc);
+ }
+ lf.lfWeight = (StrStrI(lpszStyle,L"bold")) ? FW_BOLD : FW_NORMAL;
+ lf.lfItalic = (StrStrI(lpszStyle,L"italic")) ? 1 : 0;
+
+ // Init cf
+ cf.lStructSize = sizeof(CHOOSEFONT);
+ cf.hwndOwner = hwnd;
+ cf.lpLogFont = &lf;
+ cf.Flags = CF_INITTOLOGFONTSTRUCT /*| CF_NOSCRIPTSEL*/ | CF_SCREENFONTS;
+
+ if (HIBYTE(GetKeyState(VK_SHIFT)))
+ cf.Flags |= CF_FIXEDPITCHONLY;
+
+ if (!ChooseFont(&cf) || !lstrlen(lf.lfFaceName))
+ return FALSE;
+
+ // Map back to lpszStyle
+ lstrcpy(szNewStyle,L"font:");
+ lstrcat(szNewStyle,lf.lfFaceName);
+ if (Style_StrGetFontQuality(lpszStyle,tch,COUNTOF(tch)))
+ {
+ lstrcat(szNewStyle,L"; smoothing:");
+ lstrcat(szNewStyle,tch);
+ }
+ if (bDefaultStyle &&
+ lf.lfCharSet != DEFAULT_CHARSET &&
+ lf.lfCharSet != ANSI_CHARSET &&
+ lf.lfCharSet != iDefaultCharSet) {
+ lstrcat(szNewStyle,L"; charset:");
+ wsprintf(tch,L"%i",lf.lfCharSet);
+ lstrcat(szNewStyle,tch);
+ }
+ lstrcat(szNewStyle,L"; size:");
+ wsprintf(tch,L"%i",cf.iPointSize/10);
+ lstrcat(szNewStyle,tch);
+ if (cf.nFontType & BOLD_FONTTYPE)
+ lstrcat(szNewStyle,L"; bold");
+ if (cf.nFontType & ITALIC_FONTTYPE)
+ lstrcat(szNewStyle,L"; italic");
+
+ if (StrStrI(lpszStyle,L"underline"))
+ lstrcat(szNewStyle,L"; underline");
+
+ // save colors
+ if (Style_StrGetColor(TRUE,lpszStyle,&iValue))
+ {
+ wsprintf(tch,L"; fore:#%02X%02X%02X",
+ (int)GetRValue(iValue),
+ (int)GetGValue(iValue),
+ (int)GetBValue(iValue));
+ lstrcat(szNewStyle,tch);
+ }
+ if (Style_StrGetColor(FALSE,lpszStyle,&iValue))
+ {
+ wsprintf(tch,L"; back:#%02X%02X%02X",
+ (int)GetRValue(iValue),
+ (int)GetGValue(iValue),
+ (int)GetBValue(iValue));
+ lstrcat(szNewStyle,tch);
+ }
+
+ if (StrStrI(lpszStyle,L"eolfilled"))
+ lstrcat(szNewStyle,L"; eolfilled");
+
+ if (Style_StrGetCase(lpszStyle,&iValue)) {
+ lstrcat(szNewStyle,L"; case:");
+ lstrcat(szNewStyle,(iValue == SC_CASE_UPPER) ? L"u" : L"");
+ }
+
+ if (Style_StrGetAlpha(lpszStyle,&iValue)) {
+ lstrcat(szNewStyle,L"; alpha:");
+ wsprintf(tch,L"%i",iValue);
+ lstrcat(szNewStyle,tch);
+ }
+
+ lstrcpyn(lpszStyle,szNewStyle,cchStyle);
+ return TRUE;
+}
+
+
+//=============================================================================
+//
+// Style_SelectColor()
+//
+BOOL Style_SelectColor(HWND hwnd,BOOL bFore,LPWSTR lpszStyle,int cchStyle)
+{
+ CHOOSECOLOR cc;
+ WCHAR szNewStyle[512];
+ int iRGBResult;
+ int iValue;
+ WCHAR tch[32];
+
+ ZeroMemory(&cc,sizeof(CHOOSECOLOR));
+
+ iRGBResult = (bFore) ? GetSysColor(COLOR_WINDOWTEXT) : GetSysColor(COLOR_WINDOW);
+ Style_StrGetColor(bFore,lpszStyle,&iRGBResult);
+
+ cc.lStructSize = sizeof(CHOOSECOLOR);
+ cc.hwndOwner = hwnd;
+ cc.rgbResult = iRGBResult;
+ cc.lpCustColors = crCustom;
+ cc.Flags = CC_FULLOPEN | CC_RGBINIT | CC_SOLIDCOLOR;
+
+ if (!ChooseColor(&cc))
+ return FALSE;
+
+ iRGBResult = cc.rgbResult;
+
+ // Rebuild style string
+ lstrcpy(szNewStyle,L"");
+ if (Style_StrGetFont(lpszStyle,tch,COUNTOF(tch)))
+ {
+ lstrcat(szNewStyle,L"font:");
+ lstrcat(szNewStyle,tch);
+ }
+ if (Style_StrGetFontQuality(lpszStyle,tch,COUNTOF(tch)))
+ {
+ if (lstrlen(szNewStyle))
+ lstrcat(szNewStyle,L"; ");
+ lstrcat(szNewStyle,L"smoothing:");
+ lstrcat(szNewStyle,tch);
+ }
+ if (Style_StrGetCharSet(lpszStyle,&iValue))
+ {
+ if (lstrlen(szNewStyle))
+ lstrcat(szNewStyle,L"; ");
+ wsprintf(tch,L"charset:%i",iValue);
+ lstrcat(szNewStyle,tch);
+ }
+ if (Style_StrGetSizeStr(lpszStyle,tch,COUNTOF(tch)))
+ {
+ if (lstrlen(szNewStyle))
+ lstrcat(szNewStyle,L"; ");
+ lstrcat(szNewStyle,L"size:");
+ lstrcat(szNewStyle,tch);
+ }
+
+ if (StrStrI(lpszStyle,L"bold"))
+ {
+ if (lstrlen(szNewStyle))
+ lstrcat(szNewStyle,L"; ");
+ lstrcat(szNewStyle,L"bold");
+ }
+ if (StrStrI(lpszStyle,L"italic"))
+ {
+ if (lstrlen(szNewStyle))
+ lstrcat(szNewStyle,L"; ");
+ lstrcat(szNewStyle,L"italic");
+ }
+ if (StrStrI(lpszStyle,L"underline"))
+ {
+ if (lstrlen(szNewStyle))
+ lstrcat(szNewStyle,L"; ");
+ lstrcat(szNewStyle,L"underline");
+ }
+
+ if (bFore)
+ {
+ if (lstrlen(szNewStyle))
+ lstrcat(szNewStyle,L"; ");
+ wsprintf(tch,L"fore:#%02X%02X%02X",
+ (int)GetRValue(iRGBResult),
+ (int)GetGValue(iRGBResult),
+ (int)GetBValue(iRGBResult));
+ lstrcat(szNewStyle,tch);
+ if (Style_StrGetColor(FALSE,lpszStyle,&iValue))
+ {
+ wsprintf(tch,L"; back:#%02X%02X%02X",
+ (int)GetRValue(iValue),
+ (int)GetGValue(iValue),
+ (int)GetBValue(iValue));
+ lstrcat(szNewStyle,tch);
+ }
+ }
+ else
+ {
+ if (lstrlen(szNewStyle))
+ lstrcat(szNewStyle,L"; ");
+ if (Style_StrGetColor(TRUE,lpszStyle,&iValue))
+ {
+ wsprintf(tch,L"fore:#%02X%02X%02X; ",
+ (int)GetRValue(iValue),
+ (int)GetGValue(iValue),
+ (int)GetBValue(iValue));
+ lstrcat(szNewStyle,tch);
+ }
+ wsprintf(tch,L"back:#%02X%02X%02X",
+ (int)GetRValue(iRGBResult),
+ (int)GetGValue(iRGBResult),
+ (int)GetBValue(iRGBResult));
+ lstrcat(szNewStyle,tch);
+ }
+
+ if (StrStrI(lpszStyle,L"eolfilled"))
+ lstrcat(szNewStyle,L"; eolfilled");
+
+ if (Style_StrGetCase(lpszStyle,&iValue)) {
+ lstrcat(szNewStyle,L"; case:");
+ lstrcat(szNewStyle,(iValue == SC_CASE_UPPER) ? L"u" : L"");
+ }
+
+ if (Style_StrGetAlpha(lpszStyle,&iValue)) {
+ lstrcat(szNewStyle,L"; alpha:");
+ wsprintf(tch,L"%i",iValue);
+ lstrcat(szNewStyle,tch);
+ }
+
+ lstrcpyn(lpszStyle,szNewStyle,cchStyle);
+ return TRUE;
+}
+
+
+//=============================================================================
+//
+// Style_SetStyles()
+//
+void Style_SetStyles(HWND hwnd,int iStyle,LPCWSTR lpszStyle)
+{
+
+ WCHAR tch[256];
+ WCHAR *p;
+ int iValue;
+
+ // Font
+ if (Style_StrGetFont(lpszStyle,tch,COUNTOF(tch))) {
+ char mch[256];
+ WideCharToMultiByte(CP_ACP,0,tch,-1,mch,COUNTOF(mch),NULL,NULL);
+ SendMessage(hwnd,SCI_STYLESETFONT,iStyle,(LPARAM)mch);
+ }
+
+ // Size
+ if (Style_StrGetSize(lpszStyle,&iValue))
+ SendMessage(hwnd,SCI_STYLESETSIZE,iStyle,(LPARAM)iValue);
+
+ // Fore
+ if (Style_StrGetColor(TRUE,lpszStyle,&iValue))
+ SendMessage(hwnd,SCI_STYLESETFORE,iStyle,(LPARAM)iValue);
+
+ // Back
+ if (Style_StrGetColor(FALSE,lpszStyle,&iValue))
+ SendMessage(hwnd,SCI_STYLESETBACK,iStyle,(LPARAM)iValue);
+
+ // Bold
+ if (p = StrStrI(lpszStyle,L"bold"))
+ SendMessage(hwnd,SCI_STYLESETBOLD,iStyle,(LPARAM)TRUE);
+ else
+ SendMessage(hwnd,SCI_STYLESETBOLD,iStyle,(LPARAM)FALSE);
+
+ // Italic
+ if (p = StrStrI(lpszStyle,L"italic"))
+ SendMessage(hwnd,SCI_STYLESETITALIC,iStyle,(LPARAM)TRUE);
+ else
+ SendMessage(hwnd,SCI_STYLESETITALIC,iStyle,(LPARAM)FALSE);
+
+ // Underline
+ if (p = StrStrI(lpszStyle,L"underline"))
+ SendMessage(hwnd,SCI_STYLESETUNDERLINE,iStyle,(LPARAM)TRUE);
+ else
+ SendMessage(hwnd,SCI_STYLESETUNDERLINE,iStyle,(LPARAM)FALSE);
+
+ // EOL Filled
+ if (p = StrStrI(lpszStyle,L"eolfilled"))
+ SendMessage(hwnd,SCI_STYLESETEOLFILLED,iStyle,(LPARAM)TRUE);
+ else
+ SendMessage(hwnd,SCI_STYLESETEOLFILLED,iStyle,(LPARAM)FALSE);
+
+ // Case
+ if (Style_StrGetCase(lpszStyle,&iValue))
+ SendMessage(hwnd,SCI_STYLESETCASE,iStyle,(LPARAM)iValue);
+
+ // Character Set
+ if (Style_StrGetCharSet(lpszStyle,&iValue))
+ SendMessage(hwnd,SCI_STYLESETCHARACTERSET,iStyle,(LPARAM)iValue);
+
+}
+
+
+//=============================================================================
+//
+// Style_SetFontQuality()
+//
+void Style_SetFontQuality(HWND hwnd,LPCWSTR lpszStyle) {
+
+ WPARAM wQuality = SC_EFF_QUALITY_DEFAULT;
+ WCHAR tch[32];
+
+ if (Style_StrGetFontQuality(lpszStyle,tch,COUNTOF(tch))) {
+ if (lstrcmpi(tch,L"none") == 0)
+ wQuality = SC_EFF_QUALITY_NON_ANTIALIASED;
+ else if (lstrcmpi(tch,L"standard") == 0)
+ wQuality = SC_EFF_QUALITY_ANTIALIASED;
+ else if (lstrcmpi(tch,L"cleartype") == 0)
+ wQuality = SC_EFF_QUALITY_LCD_OPTIMIZED;
+ else
+ wQuality = SC_EFF_QUALITY_DEFAULT;
+ }
+ else {
+ WCHAR tch[32];
+ if (Style_StrGetFont(lpszStyle,tch,COUNTOF(tch))) {
+ if (lstrcmpi(tch,L"Calibri") == 0 ||
+ lstrcmpi(tch,L"Cambria") == 0 ||
+ lstrcmpi(tch,L"Candara") == 0 ||
+ lstrcmpi(tch,L"Consolas") == 0 ||
+ lstrcmpi(tch,L"Constantia") == 0 ||
+ lstrcmpi(tch,L"Corbel") == 0 ||
+ lstrcmpi(tch,L"Segoe UI") == 0)
+ wQuality = SC_EFF_QUALITY_LCD_OPTIMIZED;
+ }
+ else
+ wQuality = SC_EFF_QUALITY_DEFAULT;
+ }
+ SendMessage(hwnd,SCI_SETFONTQUALITY,wQuality,0);
+}
+
+
+//=============================================================================
+//
+// Style_GetCurrentLexerName()
+//
+void Style_GetCurrentLexerName(LPWSTR lpszName,int cchName)
+{
+ if (!GetString(pLexCurrent->rid,lpszName,cchName))
+ lstrcpyn(lpszName,pLexCurrent->pszName,cchName);
+}
+
+
+//=============================================================================
+//
+// Style_GetLexerIconId()
+//
+int Style_GetLexerIconId(PEDITLEXER plex)
+{
+ WCHAR *p;
+ WCHAR *pszExtensions;
+ WCHAR *pszFile;
+
+ SHFILEINFO shfi;
+
+ if (lstrlen(plex->szExtensions))
+ pszExtensions = plex->szExtensions;
+ else
+ pszExtensions = plex->pszDefExt;
+
+ pszFile = GlobalAlloc(GPTR,sizeof(WCHAR)*(lstrlen(pszExtensions) + lstrlen(L"*.txt") + 16));
+ lstrcpy(pszFile,L"*.");
+ lstrcat(pszFile,pszExtensions);
+ if (p = StrChr(pszFile,L';'))
+ *p = L'\0';
+
+ // check for ; at beginning
+ if (lstrlen(pszFile) < 3)
+ lstrcat(pszFile,L"txt");
+
+ SHGetFileInfo(pszFile,FILE_ATTRIBUTE_NORMAL,&shfi,sizeof(SHFILEINFO),
+ SHGFI_SMALLICON | SHGFI_SYSICONINDEX | SHGFI_USEFILEATTRIBUTES);
+
+ GlobalFree(pszFile);
+
+ return (shfi.iIcon);
+}
+
+
+//=============================================================================
+//
+// Style_AddLexerToTreeView()
+//
+void Style_AddLexerToTreeView(HWND hwnd,PEDITLEXER plex)
+{
+ int i = 0;
+ WCHAR tch[128];
+
+ HTREEITEM hTreeNode;
+
+ TVINSERTSTRUCT tvis;
+ ZeroMemory(&tvis,sizeof(TVINSERTSTRUCT));
+
+ tvis.hInsertAfter = TVI_LAST;
+
+ tvis.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
+ if (GetString(plex->rid,tch,COUNTOF(tch)))
+ tvis.item.pszText = tch;
+ else
+ tvis.item.pszText = plex->pszName;
+ tvis.item.iImage = Style_GetLexerIconId(plex);
+ tvis.item.iSelectedImage = tvis.item.iImage;
+ tvis.item.lParam = (LPARAM)plex;
+
+ hTreeNode = (HTREEITEM)TreeView_InsertItem(hwnd,&tvis);
+
+ tvis.hParent = hTreeNode;
+
+ tvis.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
+ //tvis.item.iImage = -1;
+ //tvis.item.iSelectedImage = -1;
+
+ while (plex->Styles[i].iStyle != -1) {
+
+ if (GetString(plex->Styles[i].rid,tch,COUNTOF(tch)))
+ tvis.item.pszText = tch;
+ else
+ tvis.item.pszText = plex->Styles[i].pszName;
+ tvis.item.lParam = (LPARAM)(&plex->Styles[i]);
+ TreeView_InsertItem(hwnd,&tvis);
+ i++;
+ }
+}
+
+
+//=============================================================================
+//
+// Style_AddLexerToListView()
+//
+void Style_AddLexerToListView(HWND hwnd,PEDITLEXER plex)
+{
+ WCHAR tch[128];
+ LVITEM lvi;
+ ZeroMemory(&lvi,sizeof(LVITEM));
+
+ lvi.mask = LVIF_IMAGE | LVIF_PARAM | LVIF_TEXT;
+ lvi.iItem = ListView_GetItemCount(hwnd);
+ if (GetString(plex->rid,tch,COUNTOF(tch)))
+ lvi.pszText = tch;
+ else
+ lvi.pszText = plex->pszName;
+ lvi.iImage = Style_GetLexerIconId(plex);
+ lvi.lParam = (LPARAM)plex;
+
+ ListView_InsertItem(hwnd,&lvi);
+}
+
+
+//=============================================================================
+//
+// Style_ConfigDlgProc()
+//
+BOOL CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
+{
+
+ static HWND hwndTV;
+ static BOOL fDragging;
+ static PEDITLEXER pCurrentLexer;
+ static PEDITSTYLE pCurrentStyle;
+ static HFONT hFontTitle;
+ static HBRUSH hbrFore;
+ static HBRUSH hbrBack;
+
+ switch(umsg)
+ {
+
+ case WM_INITDIALOG:
+ {
+ int i;
+ SHFILEINFO shfi;
+ LOGFONT lf;
+
+ hwndTV = GetDlgItem(hwnd,IDC_STYLELIST);
+ fDragging = FALSE;
+
+ TreeView_SetImageList(hwndTV,
+ (HIMAGELIST)SHGetFileInfo(L"C:\\",0,&shfi,sizeof(SHFILEINFO),
+ SHGFI_SMALLICON | SHGFI_SYSICONINDEX),TVSIL_NORMAL);
+
+ // Add lexers
+ for (i = 0; i < NUMLEXERS; i++)
+ Style_AddLexerToTreeView(hwndTV,pLexArray[i]);
+
+ pCurrentLexer = 0;
+ pCurrentStyle = 0;
+
+ //SetExplorerTheme(hwndTV);
+ //TreeView_Expand(hwndTV,TreeView_GetRoot(hwndTV),TVE_EXPAND);
+ TreeView_Select(hwndTV,TreeView_GetRoot(hwndTV),TVGN_CARET);
+
+ SendDlgItemMessage(hwnd,IDC_STYLEEDIT,EM_LIMITTEXT,COUNTOF(lexDefault.Styles[0].szValue)-1,0);
+
+ MakeBitmapButton(hwnd,IDC_PREVSTYLE,g_hInstance,IDB_PREV);
+ MakeBitmapButton(hwnd,IDC_NEXTSTYLE,g_hInstance,IDB_NEXT);
+
+ // Setup title font
+ if (hFontTitle)
+ DeleteObject(hFontTitle);
+ if (NULL == (hFontTitle = (HFONT)SendDlgItemMessage(hwnd,IDC_TITLE,WM_GETFONT,0,0)))
+ hFontTitle = GetStockObject(DEFAULT_GUI_FONT);
+ GetObject(hFontTitle,sizeof(LOGFONT),&lf);
+ lf.lfHeight += lf.lfHeight / 5;
+ lf.lfWeight = FW_BOLD;
+ hFontTitle = CreateFontIndirect(&lf);
+ SendDlgItemMessage(hwnd,IDC_TITLE,WM_SETFONT,(WPARAM)hFontTitle,TRUE);
+
+ CenterDlgInParent(hwnd);
+ }
+ return TRUE;
+
+
+ case WM_DESTROY:
+ DeleteBitmapButton(hwnd,IDC_STYLEFORE);
+ DeleteBitmapButton(hwnd,IDC_STYLEBACK);
+ DeleteBitmapButton(hwnd,IDC_PREVSTYLE);
+ DeleteBitmapButton(hwnd,IDC_NEXTSTYLE);
+ return FALSE;
+
+
+ case WM_NOTIFY:
+
+ if (((LPNMHDR)(lParam))->idFrom == IDC_STYLELIST)
+ {
+ LPNMTREEVIEW lpnmtv = (LPNMTREEVIEW)lParam;
+
+ switch (lpnmtv->hdr.code)
+ {
+
+ case TVN_SELCHANGED:
+ {
+ if (pCurrentStyle)
+ GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue,COUNTOF(pCurrentStyle->szValue));
+
+ else if (pCurrentLexer) {
+ if (!GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentLexer->szExtensions,COUNTOF(pCurrentLexer->szExtensions)))
+ lstrcpy(pCurrentLexer->szExtensions,pCurrentLexer->pszDefExt);
+ }
+
+ // a lexer has been selected
+ if (!TreeView_GetParent(hwndTV,lpnmtv->itemNew.hItem))
+ {
+ WCHAR wch[128];
+
+ GetDlgItemText(hwnd,IDC_STYLELABELS,wch,COUNTOF(wch));
+ if (StrChr(wch,L'|')) *StrChr(wch,L'|') = 0;
+
+ pCurrentStyle = 0;
+ if (pCurrentLexer = (PEDITLEXER)lpnmtv->itemNew.lParam)
+ {
+ SetDlgItemText(hwnd,IDC_STYLELABEL,wch);
+ EnableWindow(GetDlgItem(hwnd,IDC_STYLEEDIT),TRUE);
+ EnableWindow(GetDlgItem(hwnd,IDC_STYLEFONT),FALSE);
+ EnableWindow(GetDlgItem(hwnd,IDC_STYLEFORE),FALSE);
+ EnableWindow(GetDlgItem(hwnd,IDC_STYLEBACK),FALSE);
+ EnableWindow(GetDlgItem(hwnd,IDC_STYLEDEFAULT),TRUE);
+ //EnableWindow(GetDlgItem(hwnd,IDC_STYLEBOLD),FALSE);
+ //EnableWindow(GetDlgItem(hwnd,IDC_STYLEITALIC),FALSE);
+ //EnableWindow(GetDlgItem(hwnd,IDC_STYLEUNDERLINE),FALSE);
+ //EnableWindow(GetDlgItem(hwnd,IDC_STYLEEOLFILLED),FALSE);
+ //CheckDlgButton(hwnd,IDC_STYLEBOLD,BST_UNCHECKED);
+ //CheckDlgButton(hwnd,IDC_STYLEITALIC,BST_UNCHECKED);
+ //CheckDlgButton(hwnd,IDC_STYLEUNDERLINE,BST_UNCHECKED);
+ //CheckDlgButton(hwnd,IDC_STYLEEOLFILLED,BST_UNCHECKED);
+ SetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentLexer->szExtensions);
+ }
+ else
+ {
+ SetDlgItemText(hwnd,IDC_STYLELABEL,L"");
+ EnableWindow(GetDlgItem(hwnd,IDC_STYLEEDIT),FALSE);
+ EnableWindow(GetDlgItem(hwnd,IDC_STYLEFONT),FALSE);
+ EnableWindow(GetDlgItem(hwnd,IDC_STYLEFORE),FALSE);
+ EnableWindow(GetDlgItem(hwnd,IDC_STYLEBACK),FALSE);
+ EnableWindow(GetDlgItem(hwnd,IDC_STYLEDEFAULT),FALSE);
+ //EnableWindow(GetDlgItem(hwnd,IDC_STYLEBOLD),FALSE);
+ //EnableWindow(GetDlgItem(hwnd,IDC_STYLEITALIC),FALSE);
+ //EnableWindow(GetDlgItem(hwnd,IDC_STYLEUNDERLINE),FALSE);
+ //EnableWindow(GetDlgItem(hwnd,IDC_STYLEEOLFILLED),FALSE);
+ //CheckDlgButton(hwnd,IDC_STYLEBOLD,BST_UNCHECKED);
+ //CheckDlgButton(hwnd,IDC_STYLEITALIC,BST_UNCHECKED);
+ //CheckDlgButton(hwnd,IDC_STYLEUNDERLINE,BST_UNCHECKED);
+ //CheckDlgButton(hwnd,IDC_STYLEEOLFILLED,BST_UNCHECKED);
+ SetDlgItemText(hwnd,IDC_STYLEEDIT,L"");
+ }
+ }
+
+ // a style has been selected
+ else
+ {
+ WCHAR wch[128];
+
+ GetDlgItemText(hwnd,IDC_STYLELABELS,wch,COUNTOF(wch));
+ if (StrChr(wch,L'|')) *StrChr(wch,L'|') = 0;
+
+
+ pCurrentLexer = 0;
+ if (pCurrentStyle = (PEDITSTYLE)lpnmtv->itemNew.lParam)
+ {
+ SetDlgItemText(hwnd,IDC_STYLELABEL,StrEnd(wch)+1);
+ EnableWindow(GetDlgItem(hwnd,IDC_STYLEEDIT),TRUE);
+ EnableWindow(GetDlgItem(hwnd,IDC_STYLEFONT),TRUE);
+ EnableWindow(GetDlgItem(hwnd,IDC_STYLEFORE),TRUE);
+ EnableWindow(GetDlgItem(hwnd,IDC_STYLEBACK),TRUE);
+ EnableWindow(GetDlgItem(hwnd,IDC_STYLEDEFAULT),TRUE);
+ //EnableWindow(GetDlgItem(hwnd,IDC_STYLEBOLD),TRUE);
+ //EnableWindow(GetDlgItem(hwnd,IDC_STYLEITALIC),TRUE);
+ //EnableWindow(GetDlgItem(hwnd,IDC_STYLEUNDERLINE),TRUE);
+ //EnableWindow(GetDlgItem(hwnd,IDC_STYLEEOLFILLED),TRUE);
+ //CheckDlgButton(hwnd,IDC_STYLEBOLD,(Style_StrGetAttribute(pCurrentStyle->szValue,L"bold") ? BST_CHECKED : BST_UNCHECKED));
+ //CheckDlgButton(hwnd,IDC_STYLEITALIC,(Style_StrGetAttribute(pCurrentStyle->szValue,L"italic") ? BST_CHECKED : BST_UNCHECKED));
+ //CheckDlgButton(hwnd,IDC_STYLEUNDERLINE,(Style_StrGetAttribute(pCurrentStyle->szValue,L"underline") ? BST_CHECKED : BST_UNCHECKED));
+ //CheckDlgButton(hwnd,IDC_STYLEEOLFILLED,(Style_StrGetAttribute(pCurrentStyle->szValue,L"eolfilled") ? BST_CHECKED : BST_UNCHECKED));
+ SetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue);
+ }
+ else
+ {
+ SetDlgItemText(hwnd,IDC_STYLELABEL,L"");
+ EnableWindow(GetDlgItem(hwnd,IDC_STYLEEDIT),FALSE);
+ EnableWindow(GetDlgItem(hwnd,IDC_STYLEFONT),FALSE);
+ EnableWindow(GetDlgItem(hwnd,IDC_STYLEFORE),FALSE);
+ EnableWindow(GetDlgItem(hwnd,IDC_STYLEBACK),FALSE);
+ EnableWindow(GetDlgItem(hwnd,IDC_STYLEDEFAULT),FALSE);
+ //EnableWindow(GetDlgItem(hwnd,IDC_STYLEBOLD),FALSE);
+ //EnableWindow(GetDlgItem(hwnd,IDC_STYLEITALIC),FALSE);
+ //EnableWindow(GetDlgItem(hwnd,IDC_STYLEUNDERLINE),FALSE);
+ //EnableWindow(GetDlgItem(hwnd,IDC_STYLEEOLFILLED),FALSE);
+ //CheckDlgButton(hwnd,IDC_STYLEBOLD,BST_UNCHECKED);
+ //CheckDlgButton(hwnd,IDC_STYLEITALIC,BST_UNCHECKED);
+ //CheckDlgButton(hwnd,IDC_STYLEUNDERLINE,BST_UNCHECKED);
+ //CheckDlgButton(hwnd,IDC_STYLEEOLFILLED,BST_UNCHECKED);
+ SetDlgItemText(hwnd,IDC_STYLEEDIT,L"");
+ }
+ }
+ }
+ break;
+
+ case TVN_BEGINDRAG:
+ {
+ //HIMAGELIST himl;
+
+ //if (pCurrentStyle)
+ // GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue,COUNTOF(pCurrentStyle->szValue));
+ TreeView_Select(hwndTV,lpnmtv->itemNew.hItem,TVGN_CARET);
+
+ //himl = TreeView_CreateDragImage(hwndTV,lpnmtv->itemNew.hItem);
+ //ImageList_BeginDrag(himl,0,0,0);
+ //ImageList_DragEnter(hwndTV,lpnmtv->ptDrag.x,lpnmtv->ptDrag.y);
+ if (pCurrentStyle)
+ DestroyCursor(SetCursor(LoadCursor(g_hInstance,MAKEINTRESOURCE(IDC_COPY))));
+ else
+ DestroyCursor(SetCursor(LoadCursor(NULL,IDC_NO)));
+
+ SetCapture(hwnd);
+ fDragging = TRUE;
+ }
+
+ }
+ }
+
+ break;
+
+
+ case WM_MOUSEMOVE:
+ {
+ HTREEITEM htiTarget;
+ TVHITTESTINFO tvht;
+
+ if (fDragging && pCurrentStyle)
+ {
+ LONG xCur = LOWORD(lParam);
+ LONG yCur = HIWORD(lParam);
+
+ //ImageList_DragMove(xCur,yCur);
+ //ImageList_DragShowNolock(FALSE);
+
+ tvht.pt.x = xCur;
+ tvht.pt.y = yCur;
+
+ //ClientToScreen(hwnd,&tvht.pt);
+ //ScreenToClient(hwndTV,&tvht.pt);
+ MapWindowPoints(hwnd,hwndTV,&tvht.pt,1);
+
+ if ((htiTarget = TreeView_HitTest(hwndTV,&tvht)) != NULL &&
+ TreeView_GetParent(hwndTV,htiTarget) != NULL)
+ {
+ TreeView_SelectDropTarget(hwndTV,htiTarget);
+ //TreeView_Expand(hwndTV,htiTarget,TVE_EXPAND);
+ TreeView_EnsureVisible(hwndTV,htiTarget);
+ }
+ else
+ TreeView_SelectDropTarget(hwndTV,NULL);
+
+ //ImageList_DragShowNolock(TRUE);
+ }
+ }
+ break;
+
+
+ case WM_LBUTTONUP:
+ {
+ if (fDragging)
+ {
+ HTREEITEM htiTarget;
+
+ //ImageList_EndDrag();
+
+ if (htiTarget = TreeView_GetDropHilight(hwndTV))
+ {
+ WCHAR tchCopy[256];
+ TreeView_SelectDropTarget(hwndTV,NULL);
+ GetDlgItemText(hwnd,IDC_STYLEEDIT,tchCopy,COUNTOF(tchCopy));
+ TreeView_Select(hwndTV,htiTarget,TVGN_CARET);
+
+ // after select, this is new current item
+ if (pCurrentStyle)
+ {
+ lstrcpy(pCurrentStyle->szValue,tchCopy);
+ SetDlgItemText(hwnd,IDC_STYLEEDIT,tchCopy);
+ //CheckDlgButton(hwnd,IDC_STYLEBOLD,(Style_StrGetAttribute(tchCopy,L"bold") ? BST_CHECKED : BST_UNCHECKED));
+ //CheckDlgButton(hwnd,IDC_STYLEITALIC,(Style_StrGetAttribute(tchCopy,L"italic") ? BST_CHECKED : BST_UNCHECKED));
+ //CheckDlgButton(hwnd,IDC_STYLEUNDERLINE,(Style_StrGetAttribute(tchCopy,L"underline") ? BST_CHECKED : BST_UNCHECKED));
+ //CheckDlgButton(hwnd,IDC_STYLEEOLFILLED,(Style_StrGetAttribute(tchCopy,L"eolfilled") ? BST_CHECKED : BST_UNCHECKED));
+ }
+ }
+ ReleaseCapture();
+ DestroyCursor(SetCursor(LoadCursor(NULL,IDC_ARROW)));
+ fDragging = FALSE;
+ }
+ }
+ break;
+
+
+ case WM_CANCELMODE:
+ {
+ if (fDragging)
+ {
+ //ImageList_EndDrag();
+ TreeView_SelectDropTarget(hwndTV,NULL);
+ ReleaseCapture();
+ DestroyCursor(SetCursor(LoadCursor(NULL,IDC_ARROW)));
+ fDragging = FALSE;
+ }
+ }
+ break;
+
+
+ case WM_COMMAND:
+
+ switch(LOWORD(wParam))
+ {
+
+ case IDC_PREVSTYLE:
+ if (TreeView_GetSelection(hwndTV))
+ TreeView_Select(hwndTV,TreeView_GetPrevVisible(hwndTV,
+ TreeView_GetSelection(hwndTV)),TVGN_CARET);
+ PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_STYLEEDIT)),1);
+ break;
+
+ case IDC_NEXTSTYLE:
+ if (TreeView_GetSelection(hwndTV))
+ TreeView_Select(hwndTV,TreeView_GetNextVisible(hwndTV,
+ TreeView_GetSelection(hwndTV)),TVGN_CARET);
+ PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_STYLEEDIT)),1);
+ break;
+
+ case IDC_STYLEFONT:
+ if (pCurrentStyle)
+ {
+ WCHAR tch[256];
+ GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch));
+ if (Style_SelectFont(hwnd,tch,COUNTOF(tch),
+ lstrcmpi(pCurrentStyle->pszName,L"Default Style") == 0 ||
+ lstrcmpi(pCurrentStyle->pszName,L"2nd Default Style") == 0)) {
+ SetDlgItemText(hwnd,IDC_STYLEEDIT,tch);
+ //CheckDlgButton(hwnd,IDC_STYLEBOLD,(Style_StrGetAttribute(tch,L"bold") ? BST_CHECKED : BST_UNCHECKED));
+ //CheckDlgButton(hwnd,IDC_STYLEITALIC,(Style_StrGetAttribute(tch,L"italic") ? BST_CHECKED : BST_UNCHECKED));
+ //CheckDlgButton(hwnd,IDC_STYLEUNDERLINE,(Style_StrGetAttribute(tch,L"underline") ? BST_CHECKED : BST_UNCHECKED));
+ //CheckDlgButton(hwnd,IDC_STYLEEOLFILLED,(Style_StrGetAttribute(tch,L"eolfilled") ? BST_CHECKED : BST_UNCHECKED));
+ }
+ }
+ PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_STYLEEDIT)),1);
+ break;
+
+ case IDC_STYLEFORE:
+ if (pCurrentStyle)
+ {
+ WCHAR tch[256];
+ GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch));
+ if (Style_SelectColor(hwnd,TRUE,tch,COUNTOF(tch))) {
+ SetDlgItemText(hwnd,IDC_STYLEEDIT,tch);
+ //CheckDlgButton(hwnd,IDC_STYLEBOLD,(Style_StrGetAttribute(tch,L"bold") ? BST_CHECKED : BST_UNCHECKED));
+ //CheckDlgButton(hwnd,IDC_STYLEITALIC,(Style_StrGetAttribute(tch,L"italic") ? BST_CHECKED : BST_UNCHECKED));
+ //CheckDlgButton(hwnd,IDC_STYLEUNDERLINE,(Style_StrGetAttribute(tch,L"underline") ? BST_CHECKED : BST_UNCHECKED));
+ //CheckDlgButton(hwnd,IDC_STYLEEOLFILLED,(Style_StrGetAttribute(tch,L"eolfilled") ? BST_CHECKED : BST_UNCHECKED));
+ }
+ }
+ PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_STYLEEDIT)),1);
+ break;
+
+ case IDC_STYLEBACK:
+ if (pCurrentStyle)
+ {
+ WCHAR tch[256];
+ GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch));
+ if (Style_SelectColor(hwnd,FALSE,tch,COUNTOF(tch))) {
+ SetDlgItemText(hwnd,IDC_STYLEEDIT,tch);
+ //CheckDlgButton(hwnd,IDC_STYLEBOLD,(Style_StrGetAttribute(tch,L"bold") ? BST_CHECKED : BST_UNCHECKED));
+ //CheckDlgButton(hwnd,IDC_STYLEITALIC,(Style_StrGetAttribute(tch,L"italic") ? BST_CHECKED : BST_UNCHECKED));
+ //CheckDlgButton(hwnd,IDC_STYLEUNDERLINE,(Style_StrGetAttribute(tch,L"underline") ? BST_CHECKED : BST_UNCHECKED));
+ //CheckDlgButton(hwnd,IDC_STYLEEOLFILLED,(Style_StrGetAttribute(tch,L"eolfilled") ? BST_CHECKED : BST_UNCHECKED));
+ }
+ }
+ PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_STYLEEDIT)),1);
+ break;
+
+ case IDC_STYLEDEFAULT:
+ if (pCurrentStyle)
+ {
+ lstrcpy(pCurrentStyle->szValue,pCurrentStyle->pszDefault);
+ SetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue);
+ //CheckDlgButton(hwnd,IDC_STYLEBOLD,(Style_StrGetAttribute(pCurrentStyle->szValue,L"bold") ? BST_CHECKED : BST_UNCHECKED));
+ //CheckDlgButton(hwnd,IDC_STYLEITALIC,(Style_StrGetAttribute(pCurrentStyle->szValue,L"italic") ? BST_CHECKED : BST_UNCHECKED));
+ //CheckDlgButton(hwnd,IDC_STYLEUNDERLINE,(Style_StrGetAttribute(pCurrentStyle->szValue,L"underline") ? BST_CHECKED : BST_UNCHECKED));
+ //CheckDlgButton(hwnd,IDC_STYLEEOLFILLED,(Style_StrGetAttribute(pCurrentStyle->szValue,L"eolfilled") ? BST_CHECKED : BST_UNCHECKED));
+ }
+ else if (pCurrentLexer) {
+ lstrcpy(pCurrentLexer->szExtensions,pCurrentLexer->pszDefExt);
+ SetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentLexer->szExtensions);
+ }
+ PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_STYLEEDIT)),1);
+ break;
+
+ //case IDC_STYLEBOLD:
+ // if (pCurrentStyle)
+ // {
+ // WCHAR tch[256];
+ // GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch));
+ // Style_StrSetAttribute(tch,COUNTOF(tch),L"bold",IsDlgButtonChecked(hwnd,IDC_STYLEBOLD));
+ // SetDlgItemText(hwnd,IDC_STYLEEDIT,tch);
+ // }
+ // break;
+
+ //case IDC_STYLEITALIC:
+ // if (pCurrentStyle)
+ // {
+ // WCHAR tch[256];
+ // GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch));
+ // Style_StrSetAttribute(tch,COUNTOF(tch),L"italic",IsDlgButtonChecked(hwnd,IDC_STYLEITALIC));
+ // SetDlgItemText(hwnd,IDC_STYLEEDIT,tch);
+ // }
+ // break;
+
+ //case IDC_STYLEUNDERLINE:
+ // if (pCurrentStyle)
+ // {
+ // WCHAR tch[256];
+ // GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch));
+ // Style_StrSetAttribute(tch,COUNTOF(tch),L"underline",IsDlgButtonChecked(hwnd,IDC_STYLEUNDERLINE));
+ // SetDlgItemText(hwnd,IDC_STYLEEDIT,tch);
+ // }
+ // break;
+
+ //case IDC_STYLEEOLFILLED:
+ // if (pCurrentStyle)
+ // {
+ // WCHAR tch[256];
+ // GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch));
+ // Style_StrSetAttribute(tch,COUNTOF(tch),L"eolfilled",IsDlgButtonChecked(hwnd,IDC_STYLEEOLFILLED));
+ // SetDlgItemText(hwnd,IDC_STYLEEDIT,tch);
+ // }
+ // break;
+
+ case IDC_STYLEEDIT:
+ {
+ if (HIWORD(wParam) == EN_CHANGE) {
+ int cr;
+ WCHAR tch[256];
+
+ GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch));
+
+ cr = -1;
+ Style_StrGetColor(TRUE,tch,&cr);
+ MakeColorPickButton(hwnd,IDC_STYLEFORE,g_hInstance,cr);
+
+ cr = -1;
+ Style_StrGetColor(FALSE,tch,&cr);
+ MakeColorPickButton(hwnd,IDC_STYLEBACK,g_hInstance,cr);
+ }
+ }
+ break;
+
+ case IDC_IMPORT:
+ {
+ HWND hwndTV = GetDlgItem(hwnd,IDC_STYLELIST);
+
+ if (pCurrentStyle)
+ GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue,COUNTOF(pCurrentStyle->szValue));
+ else if (pCurrentLexer) {
+ if (!GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentLexer->szExtensions,COUNTOF(pCurrentLexer->szExtensions)))
+ lstrcpy(pCurrentLexer->szExtensions,pCurrentLexer->pszDefExt);
+ }
+
+ if (Style_Import(hwnd)) {
+
+ if (pCurrentStyle)
+ SetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue);
+ else if (pCurrentLexer)
+ SetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentLexer->szExtensions);
+
+ TreeView_Select(hwndTV,TreeView_GetRoot(hwndTV),TVGN_CARET);
+
+ MsgBox(0,IDS_IMPORT_OK);
+ }
+ }
+ break;
+
+ case IDC_EXPORT:
+ {
+ if (pCurrentStyle)
+ GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue,COUNTOF(pCurrentStyle->szValue));
+ else if (pCurrentLexer) {
+ if (!GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentLexer->szExtensions,COUNTOF(pCurrentLexer->szExtensions)))
+ lstrcpy(pCurrentLexer->szExtensions,pCurrentLexer->pszDefExt);
+ }
+
+ if (Style_Export(hwnd))
+ MsgBox(0,IDS_EXPORT_OK);
+ }
+ break;
+
+ case IDC_PREVIEW:
+ {
+ // Hack from outside
+ extern HWND hwndEdit;
+ extern void UpdateLineNumerWidth();
+
+ if (pCurrentStyle)
+ GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue,COUNTOF(pCurrentStyle->szValue));
+ else if (pCurrentLexer) {
+ if (!GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentLexer->szExtensions,COUNTOF(pCurrentLexer->szExtensions)))
+ lstrcpy(pCurrentLexer->szExtensions,pCurrentLexer->pszDefExt);
+ }
+
+ Style_SetLexer(hwndEdit,pLexCurrent);
+ UpdateLineNumberWidth();
+ }
+ break;
+
+ case IDOK:
+ if (pCurrentStyle)
+ GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue,COUNTOF(pCurrentStyle->szValue));
+ else if (pCurrentLexer) {
+ if (!GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentLexer->szExtensions,COUNTOF(pCurrentLexer->szExtensions)))
+ lstrcpy(pCurrentLexer->szExtensions,pCurrentLexer->pszDefExt);
+ }
+ EndDialog(hwnd,IDOK);
+ break;
+
+ case IDCANCEL:
+ if (fDragging)
+ SendMessage(hwnd,WM_CANCELMODE,0,0);
+ else
+ EndDialog(hwnd,IDCANCEL);
+ break;
+
+ }
+
+ return TRUE;
+
+ }
+
+ return FALSE;
+
+}
+
+
+//=============================================================================
+//
+// Style_ConfigDlg()
+//
+void Style_ConfigDlg(HWND hwnd)
+{
+
+ WCHAR *StyleBackup[1024];
+ int c,cItems,i,iLexer;
+
+ // Backup Styles
+ c = 0;
+ for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) {
+ StyleBackup[c++] = StrDup(pLexArray[iLexer]->szExtensions);
+ i = 0;
+ while (pLexArray[iLexer]->Styles[i].iStyle != -1) {
+ StyleBackup[c++] = StrDup(pLexArray[iLexer]->Styles[i].szValue);
+ i++;
+ }
+ }
+ cItems = c;
+
+ if (IDCANCEL == ThemedDialogBoxParam(g_hInstance,
+ MAKEINTRESOURCE(IDD_STYLECONFIG),
+ GetParent(hwnd),Style_ConfigDlgProc,
+ (LPARAM)&StyleBackup))
+ {
+ // Restore Styles
+ c = 0;
+ for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) {
+ lstrcpy(pLexArray[iLexer]->szExtensions,StyleBackup[c++]);
+ i = 0;
+ while (pLexArray[iLexer]->Styles[i].iStyle != -1) {
+ lstrcpy(pLexArray[iLexer]->Styles[i].szValue,StyleBackup[c++]);
+ i++;
+ }
+ }
+ }
+
+ else {
+ fStylesModified = TRUE;
+ if (lstrlen(szIniFile) == 0 && !fWarnedNoIniFile) {
+ MsgBox(MBINFO,IDS_SETTINGSNOTSAVED);
+ fWarnedNoIniFile = TRUE;
+ }
+ }
+
+ for (c = 0; c < cItems; c++)
+ LocalFree(StyleBackup[c]);
+
+ // Apply new (or previous) Styles
+ Style_SetLexer(hwnd,pLexCurrent);
+}
+
+
+//=============================================================================
+//
+// Style_SelectLexerDlgProc()
+//
+BOOL CALLBACK Style_SelectLexerDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
+{
+
+ static int cxClient;
+ static int cyClient;
+ static int mmiPtMaxY;
+ static int mmiPtMinX;
+
+ static HWND hwndLV;
+ static int iInternalDefault;
+
+ switch(umsg)
+ {
+
+ case WM_INITDIALOG:
+ {
+ int i;
+ int lvItems;
+ LVITEM lvi;
+ SHFILEINFO shfi;
+ LVCOLUMN lvc = { LVCF_FMT|LVCF_TEXT, LVCFMT_LEFT, 0, L"", -1, 0, 0, 0 };
+
+ RECT rc;
+ WCHAR tch[MAX_PATH];
+ int cGrip;
+
+ GetClientRect(hwnd,&rc);
+ cxClient = rc.right - rc.left;
+ cyClient = rc.bottom - rc.top;
+
+ AdjustWindowRectEx(&rc,GetWindowLongPtr(hwnd,GWL_STYLE)|WS_THICKFRAME,FALSE,0);
+ mmiPtMinX = rc.right-rc.left;
+ mmiPtMaxY = rc.bottom-rc.top;
+
+ if (cxStyleSelectDlg < (rc.right-rc.left))
+ cxStyleSelectDlg = rc.right-rc.left;
+ if (cyStyleSelectDlg < (rc.bottom-rc.top))
+ cyStyleSelectDlg = rc.bottom-rc.top;
+ SetWindowPos(hwnd,NULL,rc.left,rc.top,cxStyleSelectDlg,cyStyleSelectDlg,SWP_NOZORDER);
+
+ SetWindowLongPtr(hwnd,GWL_STYLE,GetWindowLongPtr(hwnd,GWL_STYLE)|WS_THICKFRAME);
+ SetWindowPos(hwnd,NULL,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED);
+
+ GetMenuString(GetSystemMenu(GetParent(hwnd),FALSE),SC_SIZE,tch,COUNTOF(tch),MF_BYCOMMAND);
+ InsertMenu(GetSystemMenu(hwnd,FALSE),SC_CLOSE,MF_BYCOMMAND|MF_STRING|MF_ENABLED,SC_SIZE,tch);
+ InsertMenu(GetSystemMenu(hwnd,FALSE),SC_CLOSE,MF_BYCOMMAND|MF_SEPARATOR,0,NULL);
+
+ SetWindowLongPtr(GetDlgItem(hwnd,IDC_RESIZEGRIP3),GWL_STYLE,
+ GetWindowLongPtr(GetDlgItem(hwnd,IDC_RESIZEGRIP3),GWL_STYLE)|SBS_SIZEGRIP|WS_CLIPSIBLINGS);
+
+ cGrip = GetSystemMetrics(SM_CXHTHUMB);
+ SetWindowPos(GetDlgItem(hwnd,IDC_RESIZEGRIP3),NULL,cxClient-cGrip,
+ cyClient-cGrip,cGrip,cGrip,SWP_NOZORDER);
+
+ hwndLV = GetDlgItem(hwnd,IDC_STYLELIST);
+
+ ListView_SetImageList(hwndLV,
+ (HIMAGELIST)SHGetFileInfo(L"C:\\",0,&shfi,sizeof(SHFILEINFO),SHGFI_SMALLICON | SHGFI_SYSICONINDEX),
+ LVSIL_SMALL);
+
+ ListView_SetImageList(hwndLV,
+ (HIMAGELIST)SHGetFileInfo(L"C:\\",0,&shfi,sizeof(SHFILEINFO),SHGFI_LARGEICON | SHGFI_SYSICONINDEX),
+ LVSIL_NORMAL);
+
+ //SetExplorerTheme(hwndLV);
+ ListView_SetExtendedListViewStyle(hwndLV,/*LVS_EX_FULLROWSELECT|*/LVS_EX_DOUBLEBUFFER|LVS_EX_LABELTIP);
+ ListView_InsertColumn(hwndLV,0,&lvc);
+
+ // Add lexers
+ for (i = 0; i < NUMLEXERS; i++)
+ Style_AddLexerToListView(hwndLV,pLexArray[i]);
+
+ ListView_SetColumnWidth(hwndLV,0,LVSCW_AUTOSIZE_USEHEADER);
+
+ // Select current lexer
+ lvItems = ListView_GetItemCount(hwndLV);
+ lvi.mask = LVIF_PARAM;
+ for (i = 0; i < lvItems; i++) {
+ lvi.iItem = i;
+ ListView_GetItem(hwndLV,&lvi);;
+ if (lstrcmp(((PEDITLEXER)lvi.lParam)->pszName,pLexCurrent->pszName) == 0) {
+ ListView_SetItemState(hwndLV,i,LVIS_FOCUSED|LVIS_SELECTED,LVIS_FOCUSED|LVIS_SELECTED);
+ ListView_EnsureVisible(hwndLV,i,FALSE);
+ if (iDefaultLexer == i) {
+ CheckDlgButton(hwnd,IDC_DEFAULTSCHEME,BST_CHECKED);
+ }
+ }
+ }
+
+ iInternalDefault = iDefaultLexer;
+
+ if (bAutoSelect)
+ CheckDlgButton(hwnd,IDC_AUTOSELECT,BST_CHECKED);
+
+ CenterDlgInParent(hwnd);
+ }
+ return TRUE;
+
+
+ case WM_DESTROY:
+ {
+ RECT rc;
+
+ GetWindowRect(hwnd,&rc);
+ cxStyleSelectDlg = rc.right-rc.left;
+ cyStyleSelectDlg = rc.bottom-rc.top;
+ }
+ return FALSE;
+
+
+ case WM_SIZE:
+ {
+ RECT rc;
+
+ int dxClient = LOWORD(lParam) - cxClient;
+ int dyClient = HIWORD(lParam) - cyClient;
+ cxClient = LOWORD(lParam);
+ cyClient = HIWORD(lParam);
+
+ GetWindowRect(GetDlgItem(hwnd,IDC_RESIZEGRIP3),&rc);
+ MapWindowPoints(NULL,hwnd,(LPPOINT)&rc,2);
+ SetWindowPos(GetDlgItem(hwnd,IDC_RESIZEGRIP3),NULL,rc.left+dxClient,rc.top+dyClient,0,0,SWP_NOZORDER|SWP_NOSIZE);
+ InvalidateRect(GetDlgItem(hwnd,IDC_RESIZEGRIP3),NULL,TRUE);
+
+ GetWindowRect(GetDlgItem(hwnd,IDOK),&rc);
+ MapWindowPoints(NULL,hwnd,(LPPOINT)&rc,2);
+ SetWindowPos(GetDlgItem(hwnd,IDOK),NULL,rc.left+dxClient,rc.top+dyClient,0,0,SWP_NOZORDER|SWP_NOSIZE);
+ InvalidateRect(GetDlgItem(hwnd,IDOK),NULL,TRUE);
+
+ GetWindowRect(GetDlgItem(hwnd,IDCANCEL),&rc);
+ MapWindowPoints(NULL,hwnd,(LPPOINT)&rc,2);
+ SetWindowPos(GetDlgItem(hwnd,IDCANCEL),NULL,rc.left+dxClient,rc.top+dyClient,0,0,SWP_NOZORDER|SWP_NOSIZE);
+ InvalidateRect(GetDlgItem(hwnd,IDCANCEL),NULL,TRUE);
+
+ GetWindowRect(GetDlgItem(hwnd,IDC_STYLELIST),&rc);
+ MapWindowPoints(NULL,hwnd,(LPPOINT)&rc,2);
+ SetWindowPos(GetDlgItem(hwnd,IDC_STYLELIST),NULL,0,0,rc.right-rc.left+dxClient,rc.bottom-rc.top+dyClient,SWP_NOZORDER|SWP_NOMOVE);
+ ListView_SetColumnWidth(GetDlgItem(hwnd,IDC_STYLELIST),0,LVSCW_AUTOSIZE_USEHEADER);
+ InvalidateRect(GetDlgItem(hwnd,IDC_STYLELIST),NULL,TRUE);
+
+ GetWindowRect(GetDlgItem(hwnd,IDC_AUTOSELECT),&rc);
+ MapWindowPoints(NULL,hwnd,(LPPOINT)&rc,2);
+ SetWindowPos(GetDlgItem(hwnd,IDC_AUTOSELECT),NULL,rc.left,rc.top+dyClient,0,0,SWP_NOZORDER|SWP_NOSIZE);
+ InvalidateRect(GetDlgItem(hwnd,IDC_AUTOSELECT),NULL,TRUE);
+
+ GetWindowRect(GetDlgItem(hwnd,IDC_DEFAULTSCHEME),&rc);
+ MapWindowPoints(NULL,hwnd,(LPPOINT)&rc,2);
+ SetWindowPos(GetDlgItem(hwnd,IDC_DEFAULTSCHEME),NULL,rc.left,rc.top+dyClient,0,0,SWP_NOZORDER|SWP_NOSIZE);
+ InvalidateRect(GetDlgItem(hwnd,IDC_DEFAULTSCHEME),NULL,TRUE);
+ }
+ return TRUE;
+
+
+ case WM_GETMINMAXINFO:
+ {
+ LPMINMAXINFO lpmmi = (LPMINMAXINFO)lParam;
+ lpmmi->ptMinTrackSize.x = mmiPtMinX;
+ lpmmi->ptMinTrackSize.y = mmiPtMaxY;
+ //lpmmi->ptMaxTrackSize.y = mmiPtMaxY;
+ }
+ return TRUE;
+
+
+ case WM_NOTIFY: {
+ if (((LPNMHDR)(lParam))->idFrom == IDC_STYLELIST) {
+
+ switch (((LPNMHDR)(lParam))->code) {
+
+ case NM_DBLCLK:
+ SendMessage(hwnd,WM_COMMAND,MAKELONG(IDOK,1),0);
+ break;
+
+ case LVN_ITEMCHANGED:
+ case LVN_DELETEITEM: {
+ int i = ListView_GetNextItem(hwndLV,-1,LVNI_ALL | LVNI_SELECTED);
+ if (iInternalDefault == i)
+ CheckDlgButton(hwnd,IDC_DEFAULTSCHEME,BST_CHECKED);
+ else
+ CheckDlgButton(hwnd,IDC_DEFAULTSCHEME,BST_UNCHECKED);
+ EnableWindow(GetDlgItem(hwnd,IDC_DEFAULTSCHEME),i != -1);
+ EnableWindow(GetDlgItem(hwnd,IDOK),i != -1);
+ }
+ break;
+ }
+ }
+ }
+
+ return TRUE;
+
+
+ case WM_COMMAND:
+
+ switch(LOWORD(wParam))
+ {
+
+ case IDC_DEFAULTSCHEME:
+ if (IsDlgButtonChecked(hwnd,IDC_DEFAULTSCHEME) == BST_CHECKED)
+ iInternalDefault = ListView_GetNextItem(hwndLV,-1,LVNI_ALL | LVNI_SELECTED);
+ else
+ iInternalDefault = 0;
+ break;
+
+
+ case IDOK:
+ {
+ LVITEM lvi;
+
+ lvi.mask = LVIF_PARAM;
+ lvi.iItem = ListView_GetNextItem(hwndLV,-1,LVNI_ALL | LVNI_SELECTED);
+ if (ListView_GetItem(hwndLV,&lvi)) {
+ pLexCurrent = (PEDITLEXER)lvi.lParam;
+ iDefaultLexer = iInternalDefault;
+ bAutoSelect = (IsDlgButtonChecked(hwnd,IDC_AUTOSELECT) == BST_CHECKED) ? 1 : 0;
+ EndDialog(hwnd,IDOK);
+ }
+ }
+ break;
+
+
+ case IDCANCEL:
+ EndDialog(hwnd,IDCANCEL);
+ break;
+
+ }
+
+ return TRUE;
+
+ }
+
+ return FALSE;
+
+}
+
+
+//=============================================================================
+//
+// Style_SelectLexerDlg()
+//
+void Style_SelectLexerDlg(HWND hwnd)
+{
+ if (IDOK == ThemedDialogBoxParam(g_hInstance,
+ MAKEINTRESOURCE(IDD_STYLESELECT),
+ GetParent(hwnd),Style_SelectLexerDlgProc,0))
+
+ Style_SetLexer(hwnd,pLexCurrent);
+}
+
+
+// End of Styles.c
diff --git a/src/Styles.h b/src/Styles.h new file mode 100644 index 0000000..46e5ec0 --- /dev/null +++ b/src/Styles.h @@ -0,0 +1,100 @@ +/******************************************************************************
+*
+*
+* Notepad2
+*
+* Styles.h
+* Scintilla Style Management
+*
+* See Readme.txt for more information about this source code.
+* Please send me your comments to this work.
+*
+* See License.txt for details about distribution and modification.
+*
+* (c) Florian Balmer 1996-2010
+* florian.balmer@gmail.com
+* http://www.flos-freeware.ch
+*
+*
+******************************************************************************/
+
+
+typedef struct _editstyle
+{
+ union
+ {
+ INT32 iStyle;
+ UINT8 iStyle8[4];
+ };
+ int rid;
+ WCHAR* pszName;
+ WCHAR* pszDefault;
+ WCHAR szValue[128];
+
+} EDITSTYLE, *PEDITSTYLE;
+
+
+typedef struct _keywordlist
+{
+ char *pszKeyWords[9];
+
+} KEYWORDLIST, *PKEYWORDLIST;
+
+
+typedef struct _editlexer
+{
+ int iLexer;
+ int rid;
+ WCHAR* pszName;
+ WCHAR* pszDefExt;
+ WCHAR szExtensions[128];
+ PKEYWORDLIST pKeyWords;
+ EDITSTYLE Styles[];
+
+} EDITLEXER, *PEDITLEXER;
+
+
+// Number of Lexers in pLexArray
+#define NUMLEXERS 22
+
+
+void Style_Load();
+void Style_Save();
+BOOL Style_Import(HWND);
+BOOL Style_Export(HWND);
+void Style_SetLexer(HWND,PEDITLEXER);
+void Style_SetLongLineColors(HWND);
+void Style_SetCurrentLineBackground(HWND);
+void Style_SetLexerFromFile(HWND,LPCWSTR);
+void Style_SetLexerFromName(HWND,LPCWSTR,LPCWSTR);
+void Style_SetDefaultLexer(HWND);
+void Style_SetHTMLLexer(HWND);
+void Style_SetXMLLexer(HWND);
+void Style_SetLexerFromID(HWND,int);
+void Style_SetDefaultFont(HWND);
+void Style_ToggleUse2ndDefault(HWND);
+BOOL Style_GetUse2ndDefault(HWND);
+void Style_SetIndentGuides(HWND,BOOL);
+BOOL Style_GetOpenDlgFilterStr(LPWSTR,int);
+BOOL Style_StrGetFont(LPCWSTR,LPWSTR,int);
+BOOL Style_StrGetFontQuality(LPCWSTR,LPWSTR,int);
+BOOL Style_StrGetCharSet(LPCWSTR,int*);
+BOOL Style_StrGetSize(LPCWSTR,int*);
+BOOL Style_StrGetSizeStr(LPCWSTR,LPWSTR,int);
+BOOL Style_StrGetColor(BOOL,LPCWSTR,int*);
+BOOL Style_StrGetCase(LPCWSTR,int*);
+BOOL Style_StrGetAlpha(LPCWSTR,int*);
+BOOL Style_SelectFont(HWND,LPWSTR,int,BOOL);
+BOOL Style_SelectColor(HWND,BOOL,LPWSTR,int);
+void Style_SetStyles(HWND,int,LPCWSTR);
+void Style_SetFontQuality(HWND,LPCWSTR);
+void Style_GetCurrentLexerName(LPWSTR,int);
+int Style_GetLexerIconId(PEDITLEXER);
+void Style_AddLexerToTreeView(HWND,PEDITLEXER);
+BOOL CALLBACK Styles_ConfigDlgProc(HWND,UINT,WPARAM,LPARAM);
+void Style_ConfigDlg(HWND);
+BOOL CALLBACK Style_SelectLexerDlgProc(HWND,UINT,WPARAM,LPARAM);
+void Style_SelectLexerDlg(HWND);
+
+
+// End of Style.h
diff --git a/src/resource.h b/src/resource.h new file mode 100644 index 0000000..3955790 --- /dev/null +++ b/src/resource.h @@ -0,0 +1,392 @@ +//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by Notepad2.rc
+//
+#define IDR_RT_MANIFEST 1
+#define IDR_MAINWND 100
+#define IDC_FINDTEXT 100
+#define IDC_LINENUM 100
+#define IDC_COMMANDLINE 100
+#define IDD_ABOUT 100
+#define IDC_VERSION 100
+#define IDC_OPENWITHDIR 100
+#define IDC_FILEMRU 100
+#define IDC_STYLELIST 100
+#define IDC_FAVORITESDIR 100
+#define IDC_COLUMNWRAP 100
+#define IDC_INFOBOXICON 100
+#define IDC_COPY 100
+#define IDC_ENCODINGLIST 100
+#define IDC_SEARCHEXE 101
+#define IDR_POPUPMENU 101
+#define IDC_GETOPENWITHDIR 101
+#define IDC_RESIZEGRIP 101
+#define IDD_OPENWITH 101
+#define IDC_REPLACETEXT 101
+#define IDI_RUN 101
+#define IDC_COLNUM 101
+#define IDC_DEFAULTSCHEME 101
+#define IDC_GETFAVORITESDIR 101
+#define IDC_INFOBOXTEXT 101
+#define IDB_OPEN 101
+#define IDR_ACCFINDREPLACE 101
+#define IDC_STYLELABEL 101
+#define IDC_WEBPAGE 101
+#define IDC_RESIZEGRIP4 101
+#define IDC_NOUNICODEDETECTION 101
+#define IDC_EMAIL 102
+#define IDC_STYLEEDIT 102
+#define IDC_FINDCASE 102
+#define IDC_OPENWITHDESCR 102
+#define IDC_SAVEMRU 102
+#define IDD_RUN 102
+#define IDC_AUTOSELECT 102
+#define IDC_FAVORITESDESCR 102
+#define IDC_INFOBOXCHECK 102
+#define IDC_CONSISTENTEOLS 102
+#define IDB_PREV 102
+#define IDI_STYLES 102
+#define IDC_ASCIIASUTF8 102
+#define IDC_WEBPAGE2 103
+#define IDD_DEFENCODING 103
+#define IDC_FINDWORD 103
+#define IDC_RESIZEGRIP3 103
+#define IDB_NEXT 103
+#define IDC_STYLEFORE 103
+#define IDC_AUTOSTRIPBLANKS 103
+#define IDC_ENCODINGFROMFILEVARS 103
+#define IDD_ENCODING 104
+#define IDC_EMAIL2 104
+#define IDC_FINDSTART 104
+#define IDB_PICK 104
+#define IDC_STYLEBACK 104
+#define IDD_RECODE 105
+#define IDC_FINDREGEXP 105
+#define IDC_STYLEFONT 105
+#define IDB_ENCODING 105
+#define IDD_DEFEOLMODE 106
+#define IDC_FINDTRANSFORMBS 106
+#define IDC_PREVIEW 106
+#define IDD_FAVORITES 107
+#define IDC_NOWRAP 107
+#define IDC_STYLEDEFAULT 107
+#define IDD_ADDTOFAV 108
+#define IDC_PREVSTYLE 108
+#define IDC_FINDCLOSE 108
+#define IDD_FILEMRU 109
+#define IDC_FINDPREV 109
+#define IDC_NEXTSTYLE 109
+#define IDD_CHANGENOTIFY 110
+#define IDC_SELECTTO 110
+#define IDC_IMPORT 110
+#define IDD_MODIFYLINES 111
+#define IDC_SELECTUP 111
+#define IDC_EXPORT 111
+#define IDD_ENCLOSESELECTION 112
+#define IDC_REPLACE 112
+#define IDC_TITLE 112
+#define IDD_INSERTTAG 113
+#define IDC_REPLACEALL 113
+#define IDC_STYLELABELS 113
+#define IDD_SORT 114
+#define IDC_REPLACEINSEL 114
+#define IDD_COLUMNWRAP 115
+#define IDC_TOGGLEFINDREPLACE 115
+#define IDD_LINENUM 116
+#define IDD_FIND 117
+#define IDD_REPLACE 118
+#define IDD_STYLESELECT 119
+#define IDD_STYLECONFIG 120
+#define IDD_WORDWRAP 121
+#define IDD_LONGLINES 122
+#define IDD_TABSETTINGS 123
+#define IDD_PAGESETUP 124
+#define IDD_INFOBOX 125
+#define IDD_INFOBOX2 126
+#define IDD_INFOBOX3 127
+#define IDACC_FIND 200
+#define IDACC_REPLACE 201
+#define IDACC_SAVEPOS 202
+#define IDACC_RESETPOS 203
+#define IDS_APPTITLE 10000
+#define IDS_APPTITLE_ELEVATED 10001
+#define IDS_APPTITLE_PASTEBOARD 10002
+#define IDS_UNTITLED 10003
+#define IDS_TITLEEXCERPT 10004
+#define IDS_READONLY 10005
+#define IDS_DOCPOS 10006
+#define IDS_DOCPOS2 10007
+#define IDS_DOCSIZE 10008
+#define IDS_LOADFILE 10009
+#define IDS_SAVEFILE 10010
+#define IDS_PRINTFILE 10011
+#define IDS_SAVINGSETTINGS 10012
+#define IDS_LINKDESCRIPTION 10013
+#define IDS_FILTER_ALL 10014
+#define IDS_FILTER_EXE 10015
+#define IDS_FILTER_INI 10016
+#define IDS_OPENWITH 10017
+#define IDS_FAVORITES 10018
+#define CMD_ESCAPE 20000
+#define CMD_SHIFTESC 20001
+#define CMD_CTRLENTER 20002
+#define CMD_CTRLBACK 20003
+#define CMD_CTRLDEL 20004
+#define CMD_CTRLTAB 20005
+#define CMD_RELOADANSI 20006
+#define CMD_RELOADOEM 20007
+#define CMD_RELOADASCIIASUTF8 20008
+#define CMD_RELOADNOFILEVARS 20009
+#define CMD_LEXDEFAULT 20010
+#define CMD_LEXHTML 20011
+#define CMD_LEXXML 20012
+#define CMD_TIMESTAMPS 20013
+#define CMD_WEBACTION1 20014
+#define CMD_WEBACTION2 20015
+#define CMD_FINDNEXTSEL 20016
+#define CMD_FINDPREVSEL 20017
+#define CMD_INCLINELIMIT 20018
+#define CMD_DECLINELIMIT 20019
+#define CMD_STRINGIFY 20020
+#define CMD_STRINGIFY2 20021
+#define CMD_EMBRACE 20022
+#define CMD_EMBRACE2 20023
+#define CMD_EMBRACE3 20024
+#define CMD_EMBRACE4 20025
+#define CMD_INCREASENUM 20026
+#define CMD_DECREASENUM 20027
+#define CMD_TOGGLETITLE 20028
+#define CMD_JUMP2SELSTART 20029
+#define CMD_JUMP2SELEND 20030
+#define CMD_COPYPATHNAME 20031
+#define CMD_OPENINIFILE 20032
+#define IDM_FILE_NEW 40000
+#define IDM_FILE_OPEN 40001
+#define IDM_FILE_REVERT 40002
+#define IDM_FILE_BROWSE 40003
+#define IDM_FILE_SAVE 40004
+#define IDM_FILE_SAVEAS 40005
+#define IDM_FILE_SAVECOPY 40006
+#define IDM_FILE_READONLY 40007
+#define IDM_FILE_LAUNCH 40008
+#define IDM_FILE_OPENWITH 40009
+#define IDM_FILE_RUN 40010
+#define IDM_FILE_NEWWINDOW 40011
+#define IDM_FILE_NEWWINDOW2 40012
+#define IDM_FILE_PAGESETUP 40013
+#define IDM_FILE_PRINT 40014
+#define IDM_FILE_PROPERTIES 40015
+#define IDM_FILE_CREATELINK 40016
+#define IDM_FILE_OPENFAV 40017
+#define IDM_FILE_ADDTOFAV 40018
+#define IDM_FILE_MANAGEFAV 40019
+#define IDM_FILE_RECENT 40020
+#define IDM_FILE_EXIT 40021
+#define IDM_ENCODING_ANSI 40100
+#define IDM_ENCODING_UNICODE 40101
+#define IDM_ENCODING_UNICODEREV 40102
+#define IDM_ENCODING_UTF8 40103
+#define IDM_ENCODING_UTF8SIGN 40104
+#define IDM_ENCODING_SELECT 40105
+#define IDM_ENCODING_RECODE 40106
+#define IDM_ENCODING_SETDEFAULT 40107
+#define IDM_LINEENDINGS_CRLF 40200
+#define IDM_LINEENDINGS_LF 40201
+#define IDM_LINEENDINGS_CR 40202
+#define IDM_LINEENDINGS_SETDEFAULT 40203
+#define IDM_EDIT_UNDO 40300
+#define IDM_EDIT_REDO 40301
+#define IDM_EDIT_CUT 40302
+#define IDM_EDIT_COPY 40303
+#define IDM_EDIT_COPYALL 40304
+#define IDM_EDIT_COPYADD 40305
+#define IDM_EDIT_PASTE 40306
+#define IDM_EDIT_SWAP 40307
+#define IDM_EDIT_CLEAR 40308
+#define IDM_EDIT_CLEARCLIPBOARD 40309
+#define IDM_EDIT_SELECTALL 40310
+#define IDM_EDIT_SELECTWORD 40311
+#define IDM_EDIT_SELECTLINE 40312
+#define IDM_EDIT_MOVELINEUP 40313
+#define IDM_EDIT_MOVELINEDOWN 40314
+#define IDM_EDIT_DUPLICATELINE 40315
+#define IDM_EDIT_CUTLINE 40316
+#define IDM_EDIT_COPYLINE 40317
+#define IDM_EDIT_DELETELINE 40318
+#define IDM_EDIT_DELETELINELEFT 40319
+#define IDM_EDIT_DELETELINERIGHT 40320
+#define IDM_EDIT_COLUMNWRAP 40321
+#define IDM_EDIT_SPLITLINES 40322
+#define IDM_EDIT_JOINLINES 40323
+#define IDM_EDIT_JOINLINESEX 40324
+#define IDM_EDIT_INDENT 40325
+#define IDM_EDIT_UNINDENT 40326
+#define IDM_EDIT_ENCLOSESELECTION 40327
+#define IDM_EDIT_SELECTIONDUPLICATE 40328
+#define IDM_EDIT_PADWITHSPACES 40329
+#define IDM_EDIT_STRIP1STCHAR 40330
+#define IDM_EDIT_STRIPLASTCHAR 40331
+#define IDM_EDIT_TRIMLINES 40332
+#define IDM_EDIT_COMPRESSWS 40333
+#define IDM_EDIT_REMOVEBLANKLINES 40334
+#define IDM_EDIT_MODIFYLINES 40335
+#define IDM_EDIT_SORTLINES 40336
+#define IDM_EDIT_CONVERTUPPERCASE 40337
+#define IDM_EDIT_CONVERTLOWERCASE 40338
+#define IDM_EDIT_INVERTCASE 40339
+#define IDM_EDIT_TITLECASE 40340
+#define IDM_EDIT_SENTENCECASE 40341
+#define IDM_EDIT_CONVERTTABS 40342
+#define IDM_EDIT_CONVERTSPACES 40343
+#define IDM_EDIT_CONVERTTABS2 40344
+#define IDM_EDIT_CONVERTSPACES2 40345
+#define IDM_EDIT_INSERT_TAG 40346
+#define IDM_EDIT_INSERT_ENCODING 40347
+#define IDM_EDIT_INSERT_SHORTDATE 40348
+#define IDM_EDIT_INSERT_LONGDATE 40349
+#define IDM_EDIT_INSERT_FILENAME 40350
+#define IDM_EDIT_INSERT_PATHNAME 40351
+#define IDM_EDIT_LINECOMMENT 40352
+#define IDM_EDIT_STREAMCOMMENT 40353
+#define IDM_EDIT_URLENCODE 40354
+#define IDM_EDIT_URLDECODE 40355
+#define IDM_EDIT_ESCAPECCHARS 40356
+#define IDM_EDIT_UNESCAPECCHARS 40357
+#define IDM_EDIT_FINDMATCHINGBRACE 40358
+#define IDM_EDIT_SELTOMATCHINGBRACE 40359
+#define IDM_EDIT_FIND 40360
+#define IDM_EDIT_SAVEFIND 40361
+#define IDM_EDIT_FINDNEXT 40362
+#define IDM_EDIT_FINDPREV 40363
+#define IDM_EDIT_SELTONEXT 40364
+#define IDM_EDIT_SELTOPREV 40365
+#define IDM_EDIT_REPLACE 40366
+#define IDM_EDIT_REPLACENEXT 40367
+#define IDM_EDIT_GOTOLINE 40368
+#define IDM_VIEW_SCHEME 40400
+#define IDM_VIEW_USE2NDDEFAULT 40401
+#define IDM_VIEW_SCHEMECONFIG 40402
+#define IDM_VIEW_FONT 40403
+#define IDM_VIEW_WORDWRAP 40404
+#define IDM_VIEW_LONGLINEMARKER 40405
+#define IDM_VIEW_SHOWINDENTGUIDES 40406
+#define IDM_VIEW_SHOWWHITESPACE 40407
+#define IDM_VIEW_SHOWEOLS 40408
+#define IDM_VIEW_WORDWRAPSYMBOLS 40409
+#define IDM_VIEW_MATCHBRACES 40410
+#define IDM_VIEW_HILITECURRENTLINE 40411
+#define IDM_VIEW_LINENUMBERS 40412
+#define IDM_VIEW_MARGIN 40413
+#define IDM_VIEW_ZOOMIN 40414
+#define IDM_VIEW_ZOOMOUT 40415
+#define IDM_VIEW_RESETZOOM 40416
+#define IDM_VIEW_TABSASSPACES 40417
+#define IDM_VIEW_TABSETTINGS 40418
+#define IDM_VIEW_WORDWRAPSETTINGS 40419
+#define IDM_VIEW_LONGLINESETTINGS 40420
+#define IDM_VIEW_AUTOINDENTTEXT 40421
+#define IDM_VIEW_AUTOCLOSETAGS 40422
+#define IDM_VIEW_REUSEWINDOW 40423
+#define IDM_VIEW_STICKYWINPOS 40424
+#define IDM_VIEW_ALWAYSONTOP 40425
+#define IDM_VIEW_MINTOTRAY 40426
+#define IDM_VIEW_TRANSPARENT 40427
+#define IDM_VIEW_SINGLEFILEINSTANCE 40428
+#define IDM_VIEW_CHANGENOTIFY 40429
+#define IDM_VIEW_SHOWFILENAMEONLY 40430
+#define IDM_VIEW_SHOWFILENAMEFIRST 40431
+#define IDM_VIEW_SHOWFULLPATH 40432
+#define IDM_VIEW_SHOWEXCERPT 40433
+#define IDM_VIEW_NOESCFUNC 40434
+#define IDM_VIEW_ESCMINIMIZE 40435
+#define IDM_VIEW_ESCEXIT 40436
+#define IDM_VIEW_SAVEBEFORERUNNINGTOOLS 40437
+#define IDM_VIEW_NOSAVERECENT 40438
+#define IDM_VIEW_NOSAVEFINDREPL 40439
+#define IDM_VIEW_TOOLBAR 40440
+#define IDM_VIEW_CUSTOMIZETB 40441
+#define IDM_VIEW_STATUSBAR 40442
+#define IDM_VIEW_SAVESETTINGS 40443
+#define IDM_VIEW_SAVESETTINGSNOW 40444
+#define IDM_HELP_ABOUT 40500
+#define IDM_TRAY_RESTORE 40600
+#define IDM_TRAY_EXIT 40601
+#define IDT_FILE_NEW 40700
+#define IDT_FILE_OPEN 40701
+#define IDT_FILE_BROWSE 40702
+#define IDT_FILE_SAVE 40703
+#define IDT_EDIT_UNDO 40704
+#define IDT_EDIT_REDO 40705
+#define IDT_EDIT_CUT 40706
+#define IDT_EDIT_COPY 40707
+#define IDT_EDIT_PASTE 40708
+#define IDT_EDIT_FIND 40709
+#define IDT_EDIT_REPLACE 40710
+#define IDT_VIEW_WORDWRAP 40711
+#define IDT_VIEW_ZOOMIN 40712
+#define IDT_VIEW_ZOOMOUT 40713
+#define IDT_VIEW_SCHEME 40714
+#define IDT_VIEW_SCHEMECONFIG 40715
+#define IDT_FILE_EXIT 40716
+#define IDT_FILE_SAVEAS 40717
+#define IDT_FILE_SAVECOPY 40718
+#define IDT_EDIT_CLEAR 40719
+#define IDT_FILE_PRINT 40720
+#define IDT_FILE_OPENFAV 40721
+#define IDT_FILE_ADDTOFAV 40722
+#define SC_SAVEPOS 40800
+#define SC_RESETPOS 40801
+#define IDS_ERR_LOADFILE 50000
+#define IDS_ERR_SAVEFILE 50001
+#define IDS_ERR_BROWSE 50002
+#define IDS_ERR_MRUDLG 50003
+#define IDS_ERR_CREATELINK 50004
+#define IDS_ERR_PREVWINDISABLED 50005
+#define IDS_SELRECT 50006
+#define IDS_FIND_WRAPFW 50007
+#define IDS_FIND_WRAPRE 50008
+#define IDS_NOTFOUND 50009
+#define IDS_REPLCOUNT 50010
+#define IDS_ASK_ENCODING 50011
+#define IDS_ASK_ENCODING2 50012
+#define IDS_ERR_ENCODINGNA 50013
+#define IDS_ERR_UNICODE 50014
+#define IDS_ERR_UNICODE2 50015
+#define IDS_WARNLOADBIGFILE 50016
+#define IDS_ERR_DROP 50017
+#define IDS_ASK_SAVE 50018
+#define IDS_ASK_REVERT 50019
+#define IDS_ASK_RECODE 50020
+#define IDS_ASK_CREATE 50021
+#define IDS_PRINT_HEADER 50022
+#define IDS_PRINT_FOOTER 50023
+#define IDS_PRINT_COLOR 50024
+#define IDS_PRINT_PAGENUM 50025
+#define IDS_PRINT_EMPTY 50026
+#define IDS_PRINT_ERROR 50027
+#define IDS_FAV_SUCCESS 50028
+#define IDS_FAV_FAILURE 50029
+#define IDS_READONLY_MODIFY 50030
+#define IDS_READONLY_SAVE 50031
+#define IDS_FILECHANGENOTIFY 50032
+#define IDS_FILECHANGENOTIFY2 50033
+#define IDS_STICKYWINPOS 50034
+#define IDS_SAVEDSETTINGS 50035
+#define IDS_CREATEINI_FAIL 50036
+#define IDS_WRITEINI_FAIL 50037
+#define IDS_SETTINGSNOTSAVED 50038
+#define IDS_IMPORT_OK 50039
+#define IDS_EXPORT_OK 50040
+#define IDS_CMDLINEHELP 60000
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NO_MFC 1
+#define _APS_NEXT_RESOURCE_VALUE 361
+#define _APS_NEXT_COMMAND_VALUE 40238
+#define _APS_NEXT_CONTROL_VALUE 1152
+#define _APS_NEXT_SYMED_VALUE 180
+#endif
+#endif
diff --git a/wdkbuild/build.cmd b/wdkbuild/build.cmd new file mode 100644 index 0000000..6d39a63 --- /dev/null +++ b/wdkbuild/build.cmd @@ -0,0 +1,19 @@ +@echo off
+
+rem set WDKBASEDIR=C:\WinDDK\7600.16385.1
+set WDKBASEDIR=D:\Programme\Microsoft wdk7
+
+set INCLUDE=%WDKBASEDIR%\inc\crt;%WDKBASEDIR%\inc\api;%WDKBASEDIR%\inc\api\crt\stl60;%WDKBASEDIR%\inc\ddk
+set LIB=%WDKBASEDIR%\lib\crt\i386;%WDKBASEDIR%\lib\win7\i386
+set LIBPATH=
+set VSCOMNTOOLS=
+
+md "../Release"
+del "../Release/*.obj"
+del "../Release/*.exe"
+del "../Release/*.pdb"
+del "../Release/*.idb"
+
+"%WDKBASEDIR%\bin\x86\x86\cl.exe" @cl.txt
+"%WDKBASEDIR%\bin\x86\rc.exe" /fo"../Release/Notepad2.res" "..\src\Notepad2.rc"
+"%WDKBASEDIR%\bin\x86\x86\link.exe" @link.txt
diff --git a/wdkbuild/cl.txt b/wdkbuild/cl.txt new file mode 100644 index 0000000..c49d671 --- /dev/null +++ b/wdkbuild/cl.txt @@ -0,0 +1,49 @@ +/Fo"../Release/" /I "..\scintilla\include" /I "..\scintilla\src" /I "..\scintilla\win32" /D "STATIC_BUILD" /D "SCI_LEXER" /D "WIN32" /D "_WINDOWS" /D "NDEBUG" /D "_UNICODE" /D "UNICODE" /c /EHsc /GF /MD /O1 /Os /W3
+/Tp "..\scintilla\win32\PlatWin.cxx"
+/Tp "..\scintilla\win32\ScintillaWin.cxx"
+/Tp "..\scintilla\src\AutoComplete.cxx"
+/Tp "..\scintilla\src\CallTip.cxx"
+/Tp "..\scintilla\src\CellBuffer.cxx"
+/Tp "..\scintilla\src\CharClassify.cxx"
+/Tp "..\scintilla\src\ContractionState.cxx"
+/Tp "..\scintilla\src\Decoration.cxx"
+/Tp "..\scintilla\src\Document.cxx"
+/Tp "..\scintilla\src\DocumentAccessor.cxx"
+/Tp "..\scintilla\src\Editor.cxx"
+/Tp "..\scintilla\src\ExternalLexer.cxx"
+/Tp "..\scintilla\src\Indicator.cxx"
+/Tp "..\scintilla\src\KeyMap.cxx"
+/Tp "..\scintilla\src\KeyWords.cxx"
+/Tp "..\scintilla\src\LexAsm.cxx"
+/Tp "..\scintilla\src\LexConf.cxx"
+/Tp "..\scintilla\src\LexCPP.cxx"
+/Tp "..\scintilla\src\LexCSS.cxx"
+/Tp "..\scintilla\src\LexHTML.cxx"
+/Tp "..\scintilla\src\LexOthers.cxx"
+/Tp "..\scintilla\src\LexPascal.cxx"
+/Tp "..\scintilla\src\LexPerl.cxx"
+/Tp "..\scintilla\src\LexPowerShell.cxx"
+/Tp "..\scintilla\src\LexPython.cxx"
+/Tp "..\scintilla\src\LexSQL.cxx"
+/Tp "..\scintilla\src\LexVB.cxx"
+/Tp "..\scintilla\src\LineMarker.cxx"
+/Tp "..\scintilla\src\PerLine.cxx"
+/Tp "..\scintilla\src\PositionCache.cxx"
+/Tp "..\scintilla\src\PropSet.cxx"
+/Tp "..\scintilla\src\RESearch.cxx"
+/Tp "..\scintilla\src\RunStyles.cxx"
+/Tp "..\scintilla\src\ScintillaBase.cxx"
+/Tp "..\scintilla\src\Selection.cxx"
+/Tp "..\scintilla\src\Style.cxx"
+/Tp "..\scintilla\src\StyleContext.cxx"
+/Tp "..\scintilla\src\UniConversion.cxx"
+/Tp "..\scintilla\src\ViewStyle.cxx"
+/Tp "..\scintilla\src\WindowAccessor.cxx"
+/Tp "..\scintilla\src\XPM.cxx"
+/Tc "..\src\Dialogs.c"
+/Tc "..\src\Dlapi.c"
+/Tc "..\src\Edit.c"
+/Tc "..\src\Helpers.c"
+/Tc "..\src\Notepad2.c"
+/Tc "..\src\Styles.c"
+/Tp "..\src\Print.cpp"
diff --git a/wdkbuild/link.txt b/wdkbuild/link.txt new file mode 100644 index 0000000..1ee0006 --- /dev/null +++ b/wdkbuild/link.txt @@ -0,0 +1,51 @@ +/OUT:"../Release/Notepad2.exe" /INCREMENTAL:NO /RELEASE /VERSION:5.0 /SUBSYSTEM:WINDOWS,5.0 /OSVERSION:5.0 /MACHINE:IX86 /OPT:REF /OPT:ICF /MERGE:.rdata=.text /IGNORE:4078 kernel32.lib user32.lib gdi32.lib advapi32.lib shell32.lib shlwapi.lib comdlg32.lib comctl32.lib winspool.lib imm32.lib ole32.lib oleaut32.lib psapi.lib
+"..\Release\AutoComplete.obj"
+"..\Release\CallTip.obj"
+"..\Release\CellBuffer.obj"
+"..\Release\CharClassify.obj"
+"..\Release\ContractionState.obj"
+"..\Release\Decoration.obj"
+"..\Release\Dialogs.obj"
+"..\Release\Dlapi.obj"
+"..\Release\Document.obj"
+"..\Release\DocumentAccessor.obj"
+"..\Release\Edit.obj"
+"..\Release\Editor.obj"
+"..\Release\ExternalLexer.obj"
+"..\Release\Helpers.obj"
+"..\Release\Indicator.obj"
+"..\Release\KeyMap.obj"
+"..\Release\KeyWords.obj"
+"..\Release\LexAsm.obj"
+"..\Release\LexConf.obj"
+"..\Release\LexCPP.obj"
+"..\Release\LexCSS.obj"
+"..\Release\LexHTML.obj"
+"..\Release\LexOthers.obj"
+"..\Release\LexPascal.obj"
+"..\Release\LexPerl.obj"
+"..\Release\LexPowerShell.obj"
+"..\Release\LexPython.obj"
+"..\Release\LexSQL.obj"
+"..\Release\LexVB.obj"
+"..\Release\LineMarker.obj"
+"..\Release\Notepad2.obj"
+"..\Release\Notepad2.res"
+"..\Release\PerLine.obj"
+"..\Release\PlatWin.obj"
+"..\Release\PositionCache.obj"
+"..\Release\Print.obj"
+"..\Release\PropSet.obj"
+"..\Release\RESearch.obj"
+"..\Release\RunStyles.obj"
+"..\Release\ScintillaBase.obj"
+"..\Release\ScintillaWin.obj"
+"..\Release\Selection.obj"
+"..\Release\Style.obj"
+"..\Release\StyleContext.obj"
+"..\Release\Styles.obj"
+"..\Release\UniConversion.obj"
+"..\Release\ViewStyle.obj"
+"..\Release\WindowAccessor.obj"
+"..\Release\XPM.obj"
+"msvcrt_win2000.obj"
|