Moved PowerEditor in trunk remotely

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@460 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2009-04-24 23:34:47 +00:00
parent ce52758909
commit 4dd3b257e0
354 changed files with 75270 additions and 0 deletions

View File

@ -0,0 +1,29 @@
Notepad++ v5.3.1 new features and fixed bugs (from v5.3) :
1. Fix inaccurate replace bug.
2. Increase Find what and replace with fields to 2047 characters.
3. Stop the indicator highlighting while the line change marker margin is hidden.
4. SConstruct and SConscript are recognized as python file.
Included plugins (Unicode):
1. TextFX v0.26
2. NppExec v0.3 RC1
3. Spell Checker v1.3.2
4. MIME Tools v1.5
5. FTP_synchronize v0.9.6
6. NppExport v0.2.8
7. Doc Monitor v2.2
8. NppNetNote v0.1
Included plugins (ANSI):
1. TextFX v0.25
2. NppExec v0.3 RC1
3. Spell Checker v1.3.1
4. MIME Tools v1.5
5. FTP_synchronize v0.9.6
6. NppExport v0.2.8
7. Light Explorer v1.5
8. Doc Monitor v2.2
9. NppNetNote v0.1

View File

@ -0,0 +1,88 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.
Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and modification follow.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.
You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.
In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.
10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS

BIN
PowerEditor/bin/npp.pdb Normal file

Binary file not shown.

View File

@ -0,0 +1,45 @@
Notepad++ release Note :
What is Notepad++?
******************
Notepad++ is a generic source editor (it tries to be anyway) and Notepad replacement written in C++ with the win32 API. The aim of Notepad++ is to offer a slim and efficient binary with a totally customizable GUI. This project is under the GPL Licence (http://www.gnu.org/copyleft/gpl.html).
Why another source editor?
**************************
I worked for a big smart card company as an engineer developer. On 2003, I took charge of looking for an alternative solution for an internal tool coded in Java. The internal tool needed an edit component, and I discovered Scintilla (which allows me to develop in C++) on the Internet. I began my conception and development on this project.
In the mean time, the company where I worked began to use a new development environment, and a proprietary language as well, to re-develop all internal tools. All the developers were forced to use this unstable and uncomfortable IDE and the incoherent proprietary language. This project was unfortunately abandoned (or on the contrary?).
As a C++/Java developer, I decided to continue the project in my spare time. The prototype of project was already done, I removed the components which depend on the specification of the abandoned project - It made a generic code editor. Then I made it available on sourceforge : that's the beginning of Notepad++.
Time moves on, and I continue to improve Notepad++. Two things make me continue this project : my need to work on a coherent project by using my beloved language C++ and the encouragement from Notepad++ users. So you asked me "Why another source editor", the answer that I can give you is : "Why not? Since I enjoy myself doing it."
How to install :
****************
From the installer :
Just follow the install wizard.
From the zip :
just unzip all the files into a directory you want then launch it.
Project web sites :
*******************
Notepad++ official site :
http://notepad-plus.sourceforge.net/
Here you can find all the informations about Notepad++, such as FAQ/tutorial, plugins/extension download, news, shops, etc...
Notepad++ project site :
http://sourceforge.net/projects/notepad-plus/
It is Notepad++ project site. The source codes and binaries are distributed here. You can do your feature requests or bug reports by using the trackers, you can ask your question regarding Notepad++ in the divers forums as well.
Don HO <don.h@free.fr>
**********************

View File

@ -0,0 +1,4 @@
@echo off
FOR /F "tokens=*" %%G IN ('dir /b /s ..\src\*.o') DO del "%%G"
del resources.res
@echo on

View File

@ -0,0 +1,7 @@
#ifndef EH_H
typedef void (*exFunc)(unsigned int, EXCEPTION_POINTERS *);
void _set_se_translator(exFunc) {};
#endif //EH_H

View File

@ -0,0 +1,51 @@
//this file contains definitions not available in gcc 3.4.5,
//but are needed for Notepad++
//the makefile will automatically include this header file
//GetLongPathName = 410
//Multimonitor: 410
#define _WIN32_WINDOWS 0x0410
//Toolbar imagelist = 300
//TCS_BOTTOM = 300
//LVS_EX_BORDERSELECT = 500
//TBSTYLE_EX_HIDECLIPPEDBUTTONS = 501
#define _WIN32_IE 0x501
//Theme (uxtheme)
#define _WIN32_WINNT 0x0501
//#include <windows.h>
#if (_WIN32_IE >= 0x0400)
#define TCN_GETOBJECT (TCN_FIRST - 3)
#endif
#if (_WIN32_IE >= 0x0500)
#define RBN_CHEVRONPUSHED (RBN_FIRST - 10)
#endif // _WIN32_IE >= 0x0500
/*
#ifndef max
#define max(a,b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef min
#define min(a,b) (((a) < (b)) ? (a) : (b))
#endif
*/
static inline int max(unsigned int a, unsigned int b) {
return (((a) > (b)) ? (a) : (b));
}
static inline int min(unsigned int a, unsigned int b) {
return (((a) < (b)) ? (a) : (b));
}
//__try and __except dont work in gcc, so heres some defines to take em out
#define __try
#define __except(x) if(false)
#define GetExceptionCode() 0
#define GetExceptionInformation() NULL
//Missing unicode CRT funcs
double _wtof(const wchar_t * string);

203
PowerEditor/gcc/makefile Normal file
View File

@ -0,0 +1,203 @@
# this file is part of notepad++
# Copyright (C)2008 Harry Bruin <harrybharry@users.sourceforge.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
# Directories:
NPP_DIR = ../src
SCI_DIR = ../../scintilla/include
GCC_DIR = .
GCCINCLUDE_DIR = $(GCC_DIR)/include
#MISC:
MISC_DIR = $(NPP_DIR)/MISC
COMMON_DIR = $(MISC_DIR)/Common
EXCEPTION_DIR = $(MISC_DIR)/Exception
PLUGINS_DIR = $(MISC_DIR)/PluginsManager
PROCESS_DIR = $(MISC_DIR)/Process
REGEXT_DIR = $(MISC_DIR)/RegExt
#ScintillaComponent:
SCINT_DIR = $(NPP_DIR)/ScitillaComponent
#TinyXml
TIXML_DIR = $(NPP_DIR)/TinyXml
#WinControls
WIN_DIR = $(NPP_DIR)/WinControls
ABOUT_DIR = $(WIN_DIR)/AboutDlg
CONTEXT_DIR = $(WIN_DIR)/ContextMenu
COLOUR_DIR = $(WIN_DIR)/ColourPicker
DOCKING_DIR = $(WIN_DIR)/DockingWnd
GRID_DIR = $(WIN_DIR)/Grid
IMLIST_DIR = $(WIN_DIR)/ImageListSet
OPENSAVE_DIR = $(WIN_DIR)/OpenSaveFileDialog
# PANNER_DIR = $(WIN_DIR)/Panner
PREFERENCE_DIR = $(WIN_DIR)/Preference
SHORTCUT_DIR = $(WIN_DIR)/shortcut
SPLITTER_DIR = $(WIN_DIR)/SplitterContainer
STATICDLG_DIR = $(WIN_DIR)/StaticDialog
RUNDLG_DIR = $(STATICDLG_DIR)/RunDlg
STATUSBAR_DIR = $(WIN_DIR)/StatusBar
TABBAR_DIR = $(WIN_DIR)/TabBar
TASKLIST_DIR = $(WIN_DIR)/TaskList
TOOLBAR_DIR = $(WIN_DIR)/ToolBar
TOOLTIP_DIR = $(WIN_DIR)/ToolTip
TRAYICON_DIR = $(WIN_DIR)/TrayIcon
TREEVIEW_DIR = $(WIN_DIR)/TreeView
WINDOWSDLG_DIR = $(WIN_DIR)/WindowsDlg
# Sources:
SRC_NPP = $(wildcard $(NPP_DIR)/*.cpp)
SRC_GCCINCLUDE = $(wildcard $(GCCINCLUDE_DIR)/*.cpp)
#MISC
SRC_MISC = $(wildcard $(MISC_DIR)/*.cpp)
SRC_COMMON = $(wildcard $(COMMON_DIR)/*.cpp)
SRC_EXCEPTION = $(wildcard $(EXCEPTION_DIR)/*.cpp)
SRC_PLUGINS = $(wildcard $(PLUGINS_DIR)/*.cpp)
SRC_PROCESS = $(wildcard $(PROCESS_DIR)/*.cpp)
SRC_REGEXT = $(wildcard $(REGEXT_DIR)/*.cpp)
#ScintillaComponent
SRC_SCINT = $(wildcard $(SCINT_DIR)/*.cpp)
#TinyXml
SRC_TIXML = $(wildcard $(TIXML_DIR)/*.cpp)
#WinControls
SRC_WIN = $(wildcard $(WIN_DIR)/*.cpp)
SRC_ABOUT = $(wildcard $(ABOUT_DIR)/*.cpp)
SRC_CONTEXT = $(wildcard $(CONTEXT_DIR)/*.cpp)
SRC_COLOUR = $(wildcard $(COLOUR_DIR)/*.cpp)
SRC_DOCKING = $(wildcard $(DOCKING_DIR)/*.cpp)
SRC_GRID = $(wildcard $(GRID_DIR)/*.cpp)
SRC_IMLIST = $(wildcard $(IMLIST_DIR)/*.cpp)
SRC_OPENSAVE = $(wildcard $(OPENSAVE_DIR)/*.cpp)
SRC_PREFERENCE = $(wildcard $(PREFERENCE_DIR)/*.cpp)
SRC_SHORTCUT = $(wildcard $(SHORTCUT_DIR)/*.cpp)
SRC_SPLITTER = $(wildcard $(SPLITTER_DIR)/*.cpp)
SRC_STATICDLG = $(wildcard $(STATICDLG_DIR)/*.cpp)
SRC_RUNDLG = $(wildcard $(RUNDLG_DIR)/*.cpp)
SRC_STATUSBAR = $(wildcard $(STATUSBAR_DIR)/*.cpp)
SRC_TABBAR = $(wildcard $(TABBAR_DIR)/*.cpp)
SRC_TASKLIST = $(wildcard $(TASKLIST_DIR)/*.cpp)
SRC_TOOLBAR = $(wildcard $(TOOLBAR_DIR)/*.cpp)
SRC_TOOLTIP = $(wildcard $(TOOLTIP_DIR)/*.cpp)
SRC_TRAYICON = $(wildcard $(TRAYICON_DIR)/*.cpp)
SRC_TREEVIEW = $(wildcard $(TREEVIEW_DIR)/*.cpp)
SRC_WINDOWSDLG = $(wildcard $(WINDOWSDLG_DIR)/*.cpp)
# Objects:
OBJ_NPP = $(patsubst %.cpp,%.o,$(SRC_NPP))
OBJ_GCCINCLUDE = $(patsubst %.cpp,%.o,$(SRC_GCCINCLUDE))
#MISC
OBJ_MISC = $(patsubst %.cpp,%.o,$(SRC_MISC))
OBJ_COMMON = $(patsubst %.cpp,%.o,$(SRC_COMMON))
OBJ_EXCEPTION = $(patsubst %.cpp,%.o,$(SRC_EXCEPTION))
OBJ_PLUGINS = $(patsubst %.cpp,%.o,$(SRC_PLUGINS))
OBJ_PROCESS = $(patsubst %.cpp,%.o,$(SRC_PROCESS))
OBJ_REGEXT = $(patsubst %.cpp,%.o,$(SRC_REGEXT))
#ScintillaComponent
OBJ_SCINT = $(patsubst %.cpp,%.o,$(SRC_SCINT))
#TinyXml
OBJ_TIXML = $(patsubst %.cpp,%.o,$(SRC_TIXML))
#WinControls
OBJ_WIN = $(patsubst %.cpp,%.o,$(SRC_WIN))
OBJ_ABOUT = $(patsubst %.cpp,%.o,$(SRC_ABOUT))
OBJ_CONTEXT = $(patsubst %.cpp,%.o,$(SRC_CONTEXT))
OBJ_COLOUR = $(patsubst %.cpp,%.o,$(SRC_COLOUR))
OBJ_DOCKING = $(patsubst %.cpp,%.o,$(SRC_DOCKING))
OBJ_GRID = $(patsubst %.cpp,%.o,$(SRC_GRID))
OBJ_IMLIST = $(patsubst %.cpp,%.o,$(SRC_IMLIST))
OBJ_OPENSAVE = $(patsubst %.cpp,%.o,$(SRC_OPENSAVE))
OBJ_PREFERENCE = $(patsubst %.cpp,%.o,$(SRC_PREFERENCE))
OBJ_SHORTCUT = $(patsubst %.cpp,%.o,$(SRC_SHORTCUT))
OBJ_SPLITTER = $(patsubst %.cpp,%.o,$(SRC_SPLITTER))
OBJ_STATICDLG = $(patsubst %.cpp,%.o,$(SRC_STATICDLG))
OBJ_RUNDLG = $(patsubst %.cpp,%.o,$(SRC_RUNDLG))
OBJ_STATUSBAR = $(patsubst %.cpp,%.o,$(SRC_STATUSBAR))
OBJ_TABBAR = $(patsubst %.cpp,%.o,$(SRC_TABBAR))
OBJ_TASKLIST = $(patsubst %.cpp,%.o,$(SRC_TASKLIST))
OBJ_TOOLBAR = $(patsubst %.cpp,%.o,$(SRC_TOOLBAR))
OBJ_TOOLTIP = $(patsubst %.cpp,%.o,$(SRC_TOOLTIP))
OBJ_TRAYICON = $(patsubst %.cpp,%.o,$(SRC_TRAYICON))
OBJ_TREEVIEW = $(patsubst %.cpp,%.o,$(SRC_TREEVIEW))
OBJ_WINDOWSDLG = $(patsubst %.cpp,%.o,$(SRC_WINDOWSDLG))
# Collections
DIRS_WIN = $(WIN_DIR) $(ABOUT_DIR) $(CONTEXT_DIR) $(COLOUR_DIR) $(DOCKING_DIR) $(GRID_DIR) $(IMLIST_DIR) $(OPENSAVE_DIR) $(PREFERENCE_DIR) $(SHORTCUT_DIR) $(SPLITTER_DIR) $(STATICDLG_DIR) $(RUNDLG_DIR) $(STATUSBAR_DIR) $(TABBAR_DIR) $(TASKLIST_DIR) $(TOOLBAR_DIR) $(TOOLTIP_DIR) $(TRAYICON_DIR) $(TREEVIEW_DIR) $(WINDOWSDLG_DIR)
DIRS_TIXML = $(TIXML_DIR)
DIRS_SCINT = $(SCINT_DIR)
DIRS_MISC = $(MISC_DIR) $(COMMON_DIR) $(EXCEPTION_DIR) $(PLUGINS_DIR) $(PROCESS_DIR) $(REGEXT_DIR)
DIRS = $(NPP_DIR) $(DIRS_WIN) $(DIRS_TIXML) $(DIRS_SCINT) $(DIRS_MISC) $(SCI_DIR)
SRCS_WIN = $(SRC_WIN) $(SRC_ABOUT) $(SRC_CONTEXT) $(SRC_COLOUR) $(SRC_DOCKING) $(SRC_GRID) $(SRC_IMLIST) $(SRC_OPENSAVE) $(SRC_PREFERENCE) $(SRC_SHORTCUT) $(SRC_SPLITTER) $(SRC_STATICDLG) $(SRC_RUNDLG) $(SRC_STATUSBAR) $(SRC_TABBAR) $(SRC_TASKLIST) $(SRC_TOOLBAR) $(SRC_TOOLTIP) $(SRC_TRAYICON) $(SRC_TREEVIEW) $(SRC_WINDOWSDLG)
SRCS_TIXML = $(SRC_TIXML)
SRCS_SCINT = $(SRC_SCINT)
SRCS_MISC = $(SRC_MISC) $(SRC_COMMON) $(SRC_EXCEPTION) $(SRC_PLUGINS) $(SRC_PROCESS) $(SRC_REGEXT)
SRCS = $(SRC_NPP) $(SRCS_WIN) $(SRCS_TIXML) $(SRCS_SCINT) $(SRCS_MISC) $(SRC_GCCINCLUDE)
OBJS_WIN = $(OBJ_WIN) $(OBJ_ABOUT) $(OBJ_CONTEXT) $(OBJ_COLOUR) $(OBJ_DOCKING) $(OBJ_GRID) $(OBJ_IMLIST) $(OBJ_OPENSAVE) $(OBJ_PREFERENCE) $(OBJ_SHORTCUT) $(OBJ_SPLITTER) $(OBJ_STATICDLG) $(OBJ_RUNDLG) $(OBJ_STATUSBAR) $(OBJ_TABBAR) $(OBJ_TASKLIST) $(OBJ_TOOLBAR) $(OBJ_TOOLTIP) $(OBJ_TRAYICON) $(OBJ_TREEVIEW) $(OBJ_WINDOWSDLG)
OBJS_TIXML = $(OBJ_TIXML)
OBJS_SCINT = $(OBJ_SCINT)
OBJS_MISC = $(OBJ_MISC) $(OBJ_COMMON) $(OBJ_EXCEPTION) $(OBJ_PLUGINS) $(OBJ_PROCESS) $(OBJ_REGEXT)
OBJS = $(OBJ_NPP) $(OBJS_WIN) $(OBJS_TIXML) $(OBJS_SCINT) $(OBJS_MISC) $(OBJ_GCCINCLUDE)
# Main resource file
SRC_RES = ./resources.rc
OBJ_RES = $(patsubst %.rc,%.res,$(SRC_RES))
# Parameters
INCLUDESPECIAL = -include./include/various.h -includeCommon.h
# Comment this out for ANSI build
UNICODE = -DUNICODE -D_UNICODE
CXX = g++
#CXXFLAGS = -O2 $(INCLUDESPECIAL)
CXXFLAGS = $(INCLUDESPECIAL) -DTIXML_USE_STL $(UNICODE)
INCLUDES = $(patsubst %,-I%,$(DIRS)) -I./include
LDFLAGS = -Wl,--subsystem,windows
LIBS = -lcomdlg32 -lcomctl32 -lgdi32 -lole32 -loleacc -lshell32 -lshlwapi
RC = windres
OUT_NPP = NotepadPP.exe
EXEC = ../bin/$(OUT_NPP)
all: NotepadPP
# Main Notepad++ rule
NotepadPP: $(OBJS) $(OBJ_RES)
$(CXX) $(CXXFLAGS) $(INCLUDES) $(LDFLAGS) $(OBJS) $(OBJ_RES) -o $(EXEC) $(LIBS)
NotepadPPUnicode: $(OBJS) $(OBJ_RES)
$(CXX) $(CXXFLAGS) $(INCLUDES) $(LDFLAGS) $(OBJS) $(OBJ_RES) -o $(EXEC) $(LIBS)
%.o: %.cpp
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
%.res: %.rc
$(RC) $(INCLUDES) $(UNICODE) --input=$< --output=$@ --input-format=rc --output-format=coff
# Cleanup
clean:
@delete.bat

View File

@ -0,0 +1,5 @@
makefile was renewed after the v5.0 release.
It was testing with a MingW distribution containing
gcc (GCC) 3.4.5 (mingw-vista special r3)
The default make rule should suffice for building Notepad++,
the clean rule call batch file with commands to remove .o files and resource file

View File

@ -0,0 +1,19 @@
#include "./include/various.h"
#define TEXT(quote) quote
#include "../src/ScitillaComponent/columnEditor.rc"
#include "../src/ScitillaComponent/FindReplaceDlg.rc"
#include "../src/ScitillaComponent/UserDefineDialog.rc"
#include "../src/MISC/RegExt/regExtDlg.rc"
#include "../src/WinControls/ColourPicker/ColourPopup.rc"
#include "../src/WinControls/ColourPicker/WordStyleDlg.rc"
#include "../src/WinControls/DockingWnd/DockingGUIWidget.rc"
#include "../src/WinControls/Grid/ShortcutMapper.rc"
#include "../src/WinControls/Preference/preference.rc"
#include "../src/WinControls/shortcut/RunMacroDlg.rc"
#include "../src/WinControls/shortcut/shortcut.rc"
#include "../src/WinControls/TaskList/TaskListDlg.rc"
#include "../src/WinControls/StaticDialog/RunDlg/RunDlg.rc"
#include "../src/WinControls/WindowsDlg/WindowsDlg.rc"
#include "../src/Notepad_plus.rc"

Binary file not shown.

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="Windows-1252" ?>
<Node nodeName="NotepadPlus">
<Node nodeName="GUIConfigs" name="">
<Node nodeName="GUIConfig" name="name"/>
</Node>
</Node>

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="Windows-1252" ?>
<Node nodeName="NotepadPlus">
<Node nodeName="Languages" name="">
<Node nodeName="Language" name="name"/>
</Node>
</Node>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,48 @@
copy /Y ".\nativeLang\*.*" ..\bin\localization
cd ..\bin\
del /F /S /Q .\zipped.package.release\unicode\*.*
copy /Y license.txt .\zipped.package.release\unicode\
copy /Y readme.txt .\zipped.package.release\unicode\
copy /Y NppHelp.chm .\zipped.package.release\unicode\
copy /Y change.log .\zipped.package.release\unicode\
copy /Y config.model.xml .\zipped.package.release\unicode\
copy /Y langs.model.xml .\zipped.package.release\unicode\
copy /Y stylers.model.xml .\zipped.package.release\unicode\
copy /Y contextMenu.xml .\zipped.package.release\unicode\
copy /Y shortcuts.xml .\zipped.package.release\unicode\
copy /Y doLocalConf.xml .\zipped.package.release\unicode\
copy /Y LINEDRAW.TTF .\zipped.package.release\unicode\
copy /Y "notepad++.exe" .\zipped.package.release\unicode\
copy /Y SciLexer.dll .\zipped.package.release\unicode\
copy /Y ".\plugins\*.*" .\zipped.package.release\unicode\plugins\
copy /Y ".\plugins\APIs\*.xml" .\zipped.package.release\unicode\plugins\APIs
copy /Y ".\plugins\doc\*.*" .\zipped.package.release\unicode\plugins\doc
copy /Y ".\plugins\Config\tidy\*.*" .\zipped.package.release\unicode\plugins\Config\tidy
copy /Y ".\localization\*.*" .\zipped.package.release\unicode\localization
del /F /S /Q .\zipped.package.release\ansi\config.xml
del /F /S /Q .\zipped.package.release\ansi\langs.xml
del /F /S /Q .\zipped.package.release\ansi\stylers.xml
del /F /S /Q .\zipped.package.release\ansi\session.xml
copy /Y SciLexer.dll .\zipped.package.release\ansi\
copy /Y license.txt .\zipped.package.release\ansi\
copy /Y readme.txt .\zipped.package.release\ansi\
copy /Y NppHelp.chm .\zipped.package.release\ansi\
copy /Y change.log .\zipped.package.release\ansi\
copy /Y config.model.xml .\zipped.package.release\ansi\
copy /Y langs.model.xml .\zipped.package.release\ansi\
copy /Y stylers.model.xml .\zipped.package.release\ansi\
copy /Y contextMenu.xml .\zipped.package.release\ansi\
copy /Y shortcuts.xml .\zipped.package.release\ansi\
copy /Y doLocalConf.xml .\zipped.package.release\ansi\
copy /Y LINEDRAW.TTF .\zipped.package.release\ansi\
copy /Y ".\plugins\Config\tidy\*.*" .\zipped.package.release\ansi\plugins\Config\tidy
"C:\Program Files\7-Zip\7z.exe" a -tzip -r npp.bin.zip .\zipped.package.release\*
"C:\Program Files\7-Zip\7z.exe" a -r npp.bin.7z .\zipped.package.release\*
"C:\Program Files\NSIS\makensis.exe" ..\installer\nppSetup.nsi
cd ..\installer\

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="Windows-1252" ?>
<Node nodeName="NotepadPlus">
<Node nodeName="GlobalStyles">
<Node nodeName="WidgetStyle" name="name" />
</Node>
</Node>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="Windows-1252" ?>
<Node nodeName="NotepadPlus">
<Node nodeName="LexerStyles">
<Node nodeName="LexerType" name="name"/>
</Node>
</Node>

88
PowerEditor/license.txt Normal file
View File

@ -0,0 +1,88 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.
Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and modification follow.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.
You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.
In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.
10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS

View File

@ -0,0 +1,182 @@
# @file:<dictaolib-root>/CMakeLists.txt
# TODO
# - Move defs XX_INCLUDE_DIR, XX_LIBRARIES, XX_LIBRARY_DIRS to the subdirector?es'
# scripts. I could not find a way to export a variables defined in a subscript
# so as a workaround, I define the variables myself in the top script. This is
# not optimal.
#
PROJECT(Notepad++)
SET(projIncludDir ../../scintilla/include/
./
./ScitillaComponent/
./WinControls/
./WinControls/AboutDlg/
./WinControls/ColourPicker/
./WinControls/ContextMenu/
./WinControls/DockingWnd/
./WinControls/Grid/
./WinControls/ImageListSet/
./WinControls/OpenSaveFileDialog/
./WinControls/Preference/
./WinControls/shortcut/
./WinControls/SplitterContainer/
./WinControls/StaticDialog/
./WinControls/StaticDialog/RunDlg
./WinControls/StatusBar/
./WinControls/TabBar/
./WinControls/TaskList/
./WinControls/ToolBar/
./WinControls/TrayIcon/
./WinControls/TreeView/
./WinControls/WindowsDlg/
./MISC/
./MISC/PluginsManager/
./MISC/RegExt/
./MISC/SysMsg/
./TinyXml/)
set(parameters ./Parameters.h ./Parameters.cpp)
set(scintilla ./ScitillaComponent/ScintillaEditView.h ./ScitillaComponent/ScintillaEditView.cpp)
set(buffer ./ScitillaComponent/ScintillaEditView.h ./ScitillaComponent/ScintillaEditView.cpp)
set(tinystr ./TinyXml/tinystr.h ./TinyXml/tinystr.cpp)
set(tinyxml ./TinyXml/tinyxml.h ./TinyXml/tinyxml.cpp)
set(tinyxmlerror ./TinyXml/tinyxmlerror.cpp)
set(tinyxmlparser ./TinyXml/tinyxmlparser.cpp)
SET (tinyxmlObjs ${tinystr} ${tinyxml} ${tinyxmlerror} ${tinyxmlparser})
SET(objs ./winmain.cpp
./Notepad_plus.cpp
./Notepad_plus.h
./UniConversion.cpp
./UniConversion.h
./Utf8_16.cpp
./Utf8_16.h
./ScitillaComponent/DocTabView.cpp
./ScitillaComponent/DocTabView.h
./ScitillaComponent/FindReplaceDlg.cpp
./ScitillaComponent/FindReplaceDlg.h
./ScitillaComponent/GoToLineDlg.cpp
./ScitillaComponent/GoToLineDlg.h
./ScitillaComponent/Printer.cpp
./ScitillaComponent/Printer.h
./ScitillaComponent/UserDefineDialog.cpp
./ScitillaComponent/UserDefineDialog.h
./WinControls/AboutDlg/AboutDlg.cpp
./WinControls/AboutDlg/AboutDlg.h
./WinControls/AboutDlg/URLCtrl.cpp
./WinControls/AboutDlg/URLCtrl.h
./WinControls/ColourPicker/ColourPicker.cpp
./WinControls/ColourPicker/ColourPicker.h
./WinControls/ColourPicker/ColourPopup.cpp
./WinControls/ColourPicker/ColourPopup.h
#./WinControls/ColourPicker/FontPreviewCombo.cpp
./WinControls/ColourPicker/WordStyleDlg.cpp
./WinControls/ColourPicker/WordStyleDlg.h
./WinControls/DockingWnd/DockingCont.cpp
./WinControls/DockingWnd/DockingCont.h
./WinControls/DockingWnd/DockingManager.cpp
./WinControls/DockingWnd/DockingManager.h
./WinControls/DockingWnd/DockingSplitter.cpp
./WinControls/DockingWnd/DockingSplitter.h
#./WinControls/DockingWnd/DropData.cpp
./WinControls/DockingWnd/Gripper.cpp
./WinControls/DockingWnd/Gripper.h
./WinControls/DockingWnd/common_func.cpp
./WinControls/DockingWnd/common_func.h
./WinControls/Grid/BabyGrid.cpp
./WinControls/Grid/BabyGrid.h
./WinControls/Grid/BabyGridWrapper.cpp
./WinControls/Grid/BabyGridWrapper.h
./WinControls/Grid/ShortcutMapper.cpp
./WinControls/Grid/ShortcutMapper.h
./WinControls/ImageListSet/ImageListSet.cpp
./WinControls/ImageListSet/ImageListSet.h
./WinControls/OpenSaveFileDialog/FileDialog.cpp
./WinControls/OpenSaveFileDialog/FileDialog.h
./WinControls/Preference/preferenceDlg.cpp
./WinControls/Preference/preferenceDlg.h
./WinControls/shortcut/shortcut.cpp
./WinControls/shortcut/shortcut.h
./WinControls/shortcut/RunMacroDlg.cpp
./WinControls/shortcut/RunMacroDlg.h
./WinControls/SplitterContainer/Splitter.cpp
./WinControls/SplitterContainer/Splitter.h
./WinControls/SplitterContainer/SplitterContainer.cpp
./WinControls/SplitterContainer/SplitterContainer.h
./WinControls/StaticDialog/StaticDialog.cpp
./WinControls/StaticDialog/StaticDialog.h
./WinControls/StaticDialog/RunDlg/RunDlg.cpp
./WinControls/StaticDialog/RunDlg/RunDlg.h
./WinControls/StatusBar/StatusBar.cpp
./WinControls/StatusBar/StatusBar.h
./WinControls/TabBar/TabBar.cpp
./WinControls/TabBar/TabBar.h
./WinControls/TabBar/ControlsTab.cpp
./WinControls/TabBar/ControlsTab.h
./WinControls/TaskList/TaskList.cpp
./WinControls/TaskList/TaskList.h
./WinControls/ToolBar/ToolBar.cpp
./WinControls/ToolBar/ToolBar.h
./WinControls/TrayIcon/trayIconControler.cpp
./WinControls/TrayIcon/trayIconControler.h
./WinControls/TreeView/TreeView.cpp
./WinControls/TreeView/TreeView.h
./WinControls/WindowsDlg/SizeableDlg.cpp
./WinControls/WindowsDlg/SizeableDlg.h
./WinControls/WindowsDlg/WindowsDlg.cpp
./WinControls/WindowsDlg/WindowsDlg.h
./WinControls/WindowsDlg/WinMgr.cpp
./WinControls/WindowsDlg/WinMgr.h
./WinControls/WindowsDlg/WinRect.cpp
./MISC/PluginsManager/PluginsManager.cpp
./MISC/PluginsManager/PluginsManager.h
./MISC/RegExt/regExtDlg.cpp
./MISC/RegExt/regExtDlg.h
./MISC/SysMsg/SysMsg.cpp
./MISC/SysMsg/SysMsg.h
${tinyxmlObjs}
)
SET(rcFiles ./Notepad_plus.rc
./ScitillaComponent/FindReplaceDlg.rc
./ScitillaComponent/UserDefineDialog.rc
./WinControls/ColourPicker/ColourPopup.rc
./WinControls/ColourPicker/WordStyleDlg.rc
./WinControls/DockingWnd/DockingGUIWidget.rc
./WinControls/Grid/ShortcutMapper.rc
./WinControls/Preference/preference.rc
./WinControls/shortcut/RunMacroDlg.rc
./WinControls/shortcut/shortcut.rc
./WinControls/StaticDialog/RunDlg/RunDlg.rc
./WinControls/TaskList/TaskListDlg.rc
./WinControls/WindowsDlg/WindowsDlg.rc
)
SET(vendorIncludDir ../../../vendor/Gemalto/Current/SDK_IASAPI/Output/include)
IF (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
SET(option WIN32)
SET(win32_LIBRARIES comctl32.lib shlwapi.lib shell32.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib)
#SET(defs -DUNICODE -D_UNICODE)
ENDIF (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
#ADD_DEFINITIONS(${defs})
INCLUDE_DIRECTORIES(${projIncludDir})
ADD_EXECUTABLE(notepad++ ${option} ${objs} ${rcFiles})
TARGET_LINK_LIBRARIES (notepad++ ${win32_LIBRARIES})

View File

@ -0,0 +1,377 @@
//this file is part of notepad++
//Copyright (C)2003 Don HO ( donho@altern.org )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//#include "Common.h" //use force include
#include <memory>
#include <algorithm>
#include "Common.h"
WcharMbcsConvertor * WcharMbcsConvertor::_pSelf = new WcharMbcsConvertor;
void systemMessage(const TCHAR *title)
{
LPVOID lpMsgBuf;
FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
::GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL );// Process any inserts in lpMsgBuf.
MessageBox( NULL, (LPTSTR)lpMsgBuf, title, MB_OK | MB_ICONSTOP);
::LocalFree(lpMsgBuf);
}
void printInt(int int2print)
{
TCHAR str[32];
wsprintf(str, TEXT("%d"), int2print);
::MessageBox(NULL, str, TEXT(""), MB_OK);
};
void printStr(const TCHAR *str2print)
{
::MessageBox(NULL, str2print, TEXT(""), MB_OK);
};
void writeLog(const TCHAR *logFileName, const char *log2write)
{
FILE *f = generic_fopen(logFileName, TEXT("a+"));
fwrite(log2write, sizeof(log2write[0]), strlen(log2write), f);
fputc('\n', f);
fflush(f);
fclose(f);
}
void folderBrowser(HWND parent, int outputCtrlID, const TCHAR *defaultStr)
{
// This code was copied and slightly modifed from:
// http://www.bcbdev.com/faqs/faq62.htm
// SHBrowseForFolder returns a PIDL. The memory for the PIDL is
// allocated by the shell. Eventually, we will need to free this
// memory, so we need to get a pointer to the shell malloc COM
// object that will free the PIDL later on.
LPMALLOC pShellMalloc = 0;
if (::SHGetMalloc(&pShellMalloc) == NO_ERROR)
{
// If we were able to get the shell malloc object,
// then proceed by initializing the BROWSEINFO stuct
BROWSEINFO info;
memset(&info, 0, sizeof(info));
info.hwndOwner = parent;
info.pidlRoot = NULL;
TCHAR szDisplayName[MAX_PATH];
info.pszDisplayName = szDisplayName;
info.lpszTitle = TEXT("Select a folder to search from");
info.ulFlags = 0;
info.lpfn = BrowseCallbackProc;
TCHAR directory[MAX_PATH];
::GetDlgItemText(parent, outputCtrlID, directory, sizeof(directory));
if (!directory[0] && defaultStr)
info.lParam = reinterpret_cast<LPARAM>(defaultStr);
else
info.lParam = reinterpret_cast<LPARAM>(directory);
// Execute the browsing dialog.
LPITEMIDLIST pidl = ::SHBrowseForFolder(&info);
// pidl will be null if they cancel the browse dialog.
// pidl will be not null when they select a folder.
if (pidl)
{
// Try to convert the pidl to a display generic_string.
// Return is true if success.
TCHAR szDir[MAX_PATH];
if (::SHGetPathFromIDList(pidl, szDir))
// Set edit control to the directory path.
::SetDlgItemText(parent, outputCtrlID, szDir);
pShellMalloc->Free(pidl);
}
pShellMalloc->Release();
}
}
void ClientRectToScreenRect(HWND hWnd, RECT* rect)
{
POINT pt;
pt.x = rect->left;
pt.y = rect->top;
::ClientToScreen( hWnd, &pt );
rect->left = pt.x;
rect->top = pt.y;
pt.x = rect->right;
pt.y = rect->bottom;
::ClientToScreen( hWnd, &pt );
rect->right = pt.x;
rect->bottom = pt.y;
};
std::vector<std::generic_string> tokenizeString(const std::generic_string & tokenString, const char delim) {
//Vector is created on stack and copied on return
std::vector<std::generic_string> tokens;
// Skip delimiters at beginning.
std::string::size_type lastPos = tokenString.find_first_not_of(delim, 0);
// Find first "non-delimiter".
std::string::size_type pos = tokenString.find_first_of(delim, lastPos);
while (pos != std::string::npos || lastPos != std::string::npos)
{
// Found a token, add it to the vector.
tokens.push_back(tokenString.substr(lastPos, pos - lastPos));
// Skip delimiters. Note the "not_of"
lastPos = tokenString.find_first_not_of(delim, pos);
// Find next "non-delimiter"
pos = tokenString.find_first_of(delim, lastPos);
}
return tokens;
}
void ScreenRectToClientRect(HWND hWnd, RECT* rect)
{
POINT pt;
pt.x = rect->left;
pt.y = rect->top;
::ScreenToClient( hWnd, &pt );
rect->left = pt.x;
rect->top = pt.y;
pt.x = rect->right;
pt.y = rect->bottom;
::ScreenToClient( hWnd, &pt );
rect->right = pt.x;
rect->bottom = pt.y;
};
int filter(unsigned int code, struct _EXCEPTION_POINTERS *ep)
{
if (code == EXCEPTION_ACCESS_VIOLATION)
return EXCEPTION_EXECUTE_HANDLER;
return EXCEPTION_CONTINUE_SEARCH;
}
int getCpFromStringValue(const char * encodingStr)
{
if (!encodingStr)
return CP_ACP;
if (stricmp("windows-1250", encodingStr) == 0)
return 1250;
if (stricmp("windows-1251", encodingStr) == 0)
return 1251;
if (stricmp("windows-1252", encodingStr) == 0)
return 1252;
if (stricmp("windows-1253", encodingStr) == 0)
return 1253;
if (stricmp("windows-1254", encodingStr) == 0)
return 1254;
if (stricmp("windows-1255", encodingStr) == 0)
return 1255;
if (stricmp("windows-1256", encodingStr) == 0)
return 1256;
if (stricmp("windows-1257", encodingStr) == 0)
return 1257;
if (stricmp("windows-1258", encodingStr) == 0)
return 1258;
if (stricmp("big5", encodingStr) == 0)
return 950;
if (stricmp("gb2312", encodingStr) == 0)
return 936;
if (stricmp("shift_jis", encodingStr) == 0)
return 932;
if (stricmp("euc-kr", encodingStr) == 0)
return 51949;
if (stricmp("tis-620", encodingStr) == 0)
return 874;
if (stricmp("iso-8859-8", encodingStr) == 0)
return 28598;
if (stricmp("utf-8", encodingStr) == 0)
return 65001;
return CP_ACP;
}
std::generic_string purgeMenuItemString(const TCHAR * menuItemStr, bool keepAmpersand)
{
TCHAR cleanedName[64] = TEXT("");
size_t j = 0;
size_t menuNameLen = lstrlen(menuItemStr);
for(size_t k = 0 ; k < menuNameLen ; k++)
{
if (menuItemStr[k] == '\t')
{
cleanedName[k] = 0;
break;
}
else if (menuItemStr[k] == '&')
{
if (keepAmpersand)
cleanedName[j++] = menuItemStr[k];
//else skip
}
else
{
cleanedName[j++] = menuItemStr[k];
}
}
cleanedName[j] = 0;
return cleanedName;
};
const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, UINT codepage)
{
if (!_wideCharStr)
{
_wideCharStr = new wchar_t[initSize];
_wideCharAllocLen = initSize;
}
int len = MultiByteToWideChar(codepage, 0, mbcs2Convert, -1, _wideCharStr, 0);
if (len > 0)
{
if (len > int(_wideCharAllocLen))
{
delete [] _wideCharStr;
_wideCharAllocLen = len;
_wideCharStr = new wchar_t[_wideCharAllocLen];
}
MultiByteToWideChar(codepage, 0, mbcs2Convert, -1, _wideCharStr, len);
}
else
_wideCharStr[0] = 0;
return _wideCharStr;
}
// "mstart" and "mend" are pointers to indexes in mbcs2Convert,
// which are converted to the corresponding indexes in the returned wchar_t string.
const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, UINT codepage, int *mstart, int *mend)
{
if (!_wideCharStr)
{
_wideCharStr = new wchar_t[initSize];
_wideCharAllocLen = initSize;
}
int len = MultiByteToWideChar(codepage, 0, mbcs2Convert, -1, _wideCharStr, 0);
if (len > 0)
{
if (len > int(_wideCharAllocLen))
{
delete [] _wideCharStr;
_wideCharAllocLen = len;
_wideCharStr = new wchar_t[_wideCharAllocLen];
}
MultiByteToWideChar(codepage, 0, mbcs2Convert, -1, _wideCharStr, len);
*mstart = MultiByteToWideChar(codepage, 0, mbcs2Convert, *mstart, _wideCharStr, 0);
*mend = MultiByteToWideChar(codepage, 0, mbcs2Convert, *mend, _wideCharStr, 0);
}
else
{
_wideCharStr[0] = 0;
*mstart = 0;
*mend = 0;
}
return _wideCharStr;
}
const char * WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, UINT codepage)
{
if (!_multiByteStr)
{
_multiByteStr = new char[initSize];
_multiByteAllocLen = initSize;
}
int len = WideCharToMultiByte(codepage, 0, wcharStr2Convert, -1, _multiByteStr, 0, NULL, NULL);
if (len > 0)
{
if (len > int(_multiByteAllocLen))
{
delete [] _multiByteStr;
_multiByteAllocLen = len;
_multiByteStr = new char[_multiByteAllocLen];
}
WideCharToMultiByte(codepage, 0, wcharStr2Convert, -1, _multiByteStr, len, NULL, NULL);
}
else
_multiByteStr[0] = 0;
return _multiByteStr;
}
const char * WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, UINT codepage, long *mstart, long *mend)
{
if (!_multiByteStr)
{
_multiByteStr = new char[initSize];
_multiByteAllocLen = initSize;
}
int len = WideCharToMultiByte(codepage, 0, wcharStr2Convert, -1, _multiByteStr, 0, NULL, NULL);
if (len > 0)
{
if (len > int(_multiByteAllocLen))
{
delete [] _multiByteStr;
_multiByteAllocLen = len;
_multiByteStr = new char[_multiByteAllocLen];
}
WideCharToMultiByte(codepage, 0, wcharStr2Convert, -1, _multiByteStr, len, NULL, NULL);
*mstart = WideCharToMultiByte(codepage, 0, wcharStr2Convert, *mstart, _multiByteStr, 0, NULL, NULL);
*mend = WideCharToMultiByte(codepage, 0, wcharStr2Convert, *mend, _multiByteStr, 0, NULL, NULL);
}
else
_multiByteStr[0] = 0;
return _multiByteStr;
}
std::wstring string2wstring(const std::string & rString, UINT codepage)
{
int len = MultiByteToWideChar(codepage, 0, rString.c_str(), -1, NULL, 0);
if(len > 0)
{
std::vector<wchar_t> vw(len);
MultiByteToWideChar(codepage, 0, rString.c_str(), -1, &vw[0], len);
return &vw[0];
}
else
return L"";
}
std::string wstring2string(const std::wstring & rwString, UINT codepage)
{
int len = WideCharToMultiByte(codepage, 0, rwString.c_str(), -1, NULL, 0, NULL, NULL);
if(len > 0)
{
std::vector<char> vw(len);
WideCharToMultiByte(codepage, 0, rwString.c_str(), -1, &vw[0], len, NULL, NULL);
return &vw[0];
}
else
return "";
}

View File

@ -0,0 +1,136 @@
//this file is part of notepad++
//Copyright (C)2003 Don HO ( donho@altern.org )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#ifndef M30_IDE_COMMUN_H
#define M30_IDE_COMMUN_H
#include <windows.h>
#include <string>
#include <vector>
#include <time.h>
#include <Shlobj.h>
#ifdef UNICODE
#include <wchar.h>
#endif
#define CP_ANSI_LATIN_1 1252
#define CP_BIG5 950
#ifdef UNICODE
#define NppMainEntry wWinMain
#define generic_strtol wcstol
#define generic_strncpy wcsncpy
#define generic_stricmp wcsicmp
#define generic_strncmp wcsncmp
#define generic_strnicmp wcsnicmp
#define generic_strncat wcsncat
#define generic_strchr wcschr
#define generic_atoi _wtoi
#define generic_itoa _itow
#define generic_atof _wtof
#define generic_strtok wcstok
#define generic_strftime wcsftime
#define generic_fprintf fwprintf
#define generic_sscanf swscanf
#define generic_fopen _wfopen
#define generic_fgets fgetws
#define generic_stat _wstat
#define generic_string wstring
#define COPYDATA_FILENAMES COPYDATA_FILENAMESW
#else
#define NppMainEntry WinMain
#define generic_strtol strtol
#define generic_strncpy strncpy
#define generic_stricmp stricmp
#define generic_strncmp strncmp
#define generic_strnicmp strnicmp
#define generic_strncat strncat
#define generic_strchr strchr
#define generic_atoi atoi
#define generic_itoa itoa
#define generic_atof atof
#define generic_strtok strtok
#define generic_strftime strftime
#define generic_fprintf fprintf
#define generic_sscanf sscanf
#define generic_fopen fopen
#define generic_fgets fgets
#define generic_stat _stat
#define generic_string string
#define COPYDATA_FILENAMES COPYDATA_FILENAMESA
#endif
void folderBrowser(HWND parent, int outputCtrlID, const TCHAR *defaultStr = NULL);
// Set a call back with the handle after init to set the path.
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/callbackfunctions/browsecallbackproc.asp
static int __stdcall BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM, LPARAM pData)
{
if (uMsg == BFFM_INITIALIZED)
::SendMessage(hwnd, BFFM_SETSELECTION, TRUE, pData);
return 0;
};
void systemMessage(const TCHAR *title);
//DWORD ShortToLongPathName(LPCTSTR lpszShortPath, LPTSTR lpszLongPath, DWORD cchBuffer);
void printInt(int int2print);
void printStr(const TCHAR *str2print);
void writeLog(const TCHAR *logFileName, const char *log2write);
int filter(unsigned int code, struct _EXCEPTION_POINTERS *ep);
int getCpFromStringValue(const char * encodingStr);
std::generic_string purgeMenuItemString(const TCHAR * menuItemStr, bool keepAmpersand = false);
std::vector<std::generic_string> tokenizeString(const std::generic_string & tokenString, const char delim);
void ClientRectToScreenRect(HWND hWnd, RECT* rect);
void ScreenRectToClientRect(HWND hWnd, RECT* rect);
std::wstring string2wstring(const std::string & rString, UINT codepage);
std::string wstring2string(const std::wstring & rwString, UINT codepage);
class WcharMbcsConvertor {
public:
static WcharMbcsConvertor * getInstance() {return _pSelf;};
static void destroyInstance() {delete _pSelf;};
const wchar_t * char2wchar(const char* mbStr, UINT codepage);
const wchar_t * char2wchar(const char * mbcs2Convert, UINT codepage, int *mstart, int *mend);
const char * wchar2char(const wchar_t* wcStr, UINT codepage);
const char * wchar2char(const wchar_t * wcStr, UINT codepage, long *mstart, long *mend);
protected:
WcharMbcsConvertor() : _multiByteStr(NULL), _wideCharStr(NULL), _multiByteAllocLen(0), _wideCharAllocLen(0), initSize(1024) {
};
~WcharMbcsConvertor() {
if (_multiByteStr)
delete [] _multiByteStr;
if (_wideCharStr)
delete [] _wideCharStr;
};
static WcharMbcsConvertor * _pSelf;
const int initSize;
char *_multiByteStr;
size_t _multiByteAllocLen;
wchar_t *_wideCharStr;
size_t _wideCharAllocLen;
};
#endif //M30_IDE_COMMUN_H

View File

@ -0,0 +1,82 @@
#include "MiniDumper.h"
//#include "Common.h"
#include <shlwapi.h>
LPCTSTR msgTitle = TEXT("Notepad++ crash analysis");
MiniDumper::MiniDumper()
{
}
bool MiniDumper::writeDump(EXCEPTION_POINTERS * pExceptionInfo)
{
TCHAR szDumpPath[MAX_PATH];
TCHAR szScratch[MAX_PATH];
LPCTSTR szResult = NULL;
bool retval = false;
HMODULE hDll = ::LoadLibrary( TEXT("DBGHELP.DLL") ); //that wont work on older windows version than XP, #care :)
if (hDll)
{
MINIDUMPWRITEDUMP pDump = (MINIDUMPWRITEDUMP)::GetProcAddress( hDll, "MiniDumpWriteDump" );
if (pDump)
{
//lstrcpy(szDumpPath, TEXT("C:\\N++RECOV\\NppDump.dmp"));
::GetModuleFileName(NULL, szDumpPath, MAX_PATH);
::PathRemoveFileSpec(szDumpPath);
lstrcat(szDumpPath, TEXT("\\NppDump.dmp"));
// ask the user if they want to save a dump file
int msgret = ::MessageBox(NULL, TEXT("Do you want to save a dump file?\r\nDoing so can aid in developing Notepad++."), msgTitle, MB_YESNO);
if (msgret == IDYES)
{
// create the file
HANDLE hFile = ::CreateFile( szDumpPath, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, NULL );
if (hFile!=INVALID_HANDLE_VALUE)
{
_MINIDUMP_EXCEPTION_INFORMATION ExInfo;
ExInfo.ThreadId = ::GetCurrentThreadId();
ExInfo.ExceptionPointers = pExceptionInfo;
ExInfo.ClientPointers = NULL;
// write the dump
BOOL bOK = pDump( GetCurrentProcess(), GetCurrentProcessId(), hFile, MiniDumpNormal, &ExInfo, NULL, NULL );
if (bOK)
{
wsprintf( szScratch, TEXT("Saved dump file to '%s'"), szDumpPath );
szResult = szScratch;
retval = true;
}
else
{
wsprintf( szScratch, TEXT("Failed to save dump file to '%s' (error %d)"), szDumpPath, GetLastError() );
szResult = szScratch;
}
::CloseHandle(hFile);
}
else
{
wsprintf( szScratch, TEXT("Failed to create dump file '%s' (error %d)"), szDumpPath, GetLastError() );
szResult = szScratch;
}
}
}
else
{
szResult = TEXT("The debugging DLL is outdated,\r\nfind a recent copy of dbghelp.dll and install it.");
}
}
else
{
szResult = TEXT("Unable to load the debugging DLL,\r\nfind a recent copy of dbghelp.dll and install it.");
}
if (szResult)
::MessageBox(NULL, szResult, msgTitle, MB_OK);
return retval;
}

View File

@ -0,0 +1,22 @@
//Adapted from http://www.codeproject.com/KB/debug/postmortemdebug_standalone1.aspx#_Reading_a_Minidump_with%20Visual%20Stud
//Modified for use by Npp
#ifndef MDUMP_H
#define MDUMP_H
#include <windows.h>
#include "dbghelp.h"
// based on dbghelp.h
typedef BOOL (WINAPI *MINIDUMPWRITEDUMP)(HANDLE hProcess, DWORD dwPid, HANDLE hFile, MINIDUMP_TYPE DumpType,
const PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,
const PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,
const PMINIDUMP_CALLBACK_INFORMATION CallbackParam
);
class MiniDumper {
public:
MiniDumper();
bool writeDump(EXCEPTION_POINTERS * pExceptionInfo);
};
#endif //MDUMP_H

View File

@ -0,0 +1,49 @@
//This code was retrieved from
//http://www.thunderguy.com/semicolon/2002/08/15/visual-c-exception-handling/3/
//(Visual C++ exception handling)
//By Bennett
//Formatting Slightly modified for N++
#include "Win32Exception.h"
#include "eh.h"
Win32Exception::Win32Exception(EXCEPTION_POINTERS * info) {
_location = info->ExceptionRecord->ExceptionAddress;
_code = info->ExceptionRecord->ExceptionCode;
_info = info;
switch (_code) {
case EXCEPTION_ACCESS_VIOLATION:
_event = "Access violation";
break;
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
case EXCEPTION_INT_DIVIDE_BY_ZERO:
_event = "Division by zero";
break;
default:
_event = "Unlisted exception";
}
}
void Win32Exception::installHandler() {
_set_se_translator(Win32Exception::translate);
}
void Win32Exception::removeHandler() {
_set_se_translator(NULL);
}
void Win32Exception::translate(unsigned code, EXCEPTION_POINTERS * info) {
// Windows guarantees that *(info->ExceptionRecord) is valid
switch (code) {
case EXCEPTION_ACCESS_VIOLATION:
throw Win32AccessViolation(info);
break;
default:
throw Win32Exception(info);
}
}
Win32AccessViolation::Win32AccessViolation(EXCEPTION_POINTERS * info) : Win32Exception(info) {
_isWrite = info->ExceptionRecord->ExceptionInformation[0] == 1;
_badAddress = reinterpret_cast<ExceptionAddress>(info->ExceptionRecord->ExceptionInformation[1]);
}

View File

@ -0,0 +1,46 @@
//This code was retrieved from
//http://www.thunderguy.com/semicolon/2002/08/15/visual-c-exception-handling/3/
//(Visual C++ exception handling)
//By Bennett
//Formatting Slightly modified for N++
#include "windows.h"
#include <exception>
typedef const void* ExceptionAddress; // OK on Win32 platform
class Win32Exception : public std::exception
{
public:
static void installHandler();
static void removeHandler();
virtual const char* what() const throw() { return _event; };
ExceptionAddress where() const { return _location; };
unsigned int code() const { return _code; };
EXCEPTION_POINTERS* info() const { return _info; };
protected:
Win32Exception(EXCEPTION_POINTERS * info); //Constructor only accessible by exception handler
static void translate(unsigned code, EXCEPTION_POINTERS * info);
private:
const char * _event;
ExceptionAddress _location;
unsigned int _code;
EXCEPTION_POINTERS * _info;
};
class Win32AccessViolation: public Win32Exception
{
public:
bool isWrite() const { return _isWrite; };
ExceptionAddress badAddress() const { return _badAddress; };
private:
Win32AccessViolation(EXCEPTION_POINTERS * info);
bool _isWrite;
ExceptionAddress _badAddress;
friend void Win32Exception::translate(unsigned code, EXCEPTION_POINTERS* info);
};

View File

@ -0,0 +1,92 @@
//this file is part of notepad++
//Copyright (C)2003 Don HO ( donho@altern.org )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#ifndef FILENAME_STRING_SPLITTER_H
#define FILENAME_STRING_SPLITTER_H
typedef std::vector<std::generic_string> stringVector;
class FileNameStringSplitter
{
public :
FileNameStringSplitter(const TCHAR *fileNameStr) {
//if (!fileNameStr) return;
TCHAR *pStr = NULL;
bool isInsideQuotes = false;
TCHAR str[MAX_PATH];
int i = 0;
bool fini = false;
for (pStr = (TCHAR *)fileNameStr ; !fini ; )
{
switch (*pStr)
{
case '"' :
if (isInsideQuotes)
{
str[i] = '\0';
if (str[0])
_fileNames.push_back(std::generic_string(str));
i = 0;
}
isInsideQuotes = !isInsideQuotes;
pStr++;
break;
case ' ' :
if (isInsideQuotes)
{
str[i] = *pStr;
i++;
}
else
{
str[i] = '\0';
if (str[0])
_fileNames.push_back(std::generic_string(str));
i = 0;
}
pStr++;
break;
case '\0' :
str[i] = *pStr;
if (str[0])
_fileNames.push_back(std::generic_string(str));
fini = true;
break;
default :
str[i] = *pStr;
i++; pStr++;
break;
}
}
};
const TCHAR * getFileName(int index) const {
return _fileNames[index].c_str();
};
int size() const {
return int(_fileNames.size());
};
private :
stringVector _fileNames;
};
#endif //FILENAME_STRING_SPLITTER_H

View File

@ -0,0 +1,428 @@
//this file is part of notepad++
//Copyright (C)2003 Don HO ( donho@altern.org )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#ifndef NOTEPAD_PLUS_MSGS_H
#define NOTEPAD_PLUS_MSGS_H
//#include "menuCmdID.h"
enum LangType {L_TXT, L_PHP , L_C, L_CPP, L_CS, L_OBJC, L_JAVA, L_RC,\
L_HTML, L_XML, L_MAKEFILE, L_PASCAL, L_BATCH, L_INI, L_NFO, L_USER,\
L_ASP, L_SQL, L_VB, L_JS, L_CSS, L_PERL, L_PYTHON, L_LUA,\
L_TEX, L_FORTRAN, L_BASH, L_FLASH, L_NSIS, L_TCL, L_LISP, L_SCHEME,\
L_ASM, L_DIFF, L_PROPS, L_PS, L_RUBY, L_SMALLTALK, L_VHDL, L_KIX, L_AU3,\
L_CAML, L_ADA, L_VERILOG, L_MATLAB, L_HASKELL, L_INNO, L_SEARCHRESULT,\
L_CMAKE, L_YAML,\
// The end of enumated language type, so it should be always at the end
L_EXTERNAL};
enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV_S2003, WV_XPX64, WV_VISTA};
//#include "deprecatedSymbols.h"
//Here you can find how to use these messages : http://notepad-plus.sourceforge.net/uk/plugins-HOWTO.php
#define NPPMSG (WM_USER + 1000)
#define NPPM_GETCURRENTSCINTILLA (NPPMSG + 4)
#define NPPM_GETCURRENTLANGTYPE (NPPMSG + 5)
#define NPPM_SETCURRENTLANGTYPE (NPPMSG + 6)
#define NPPM_GETNBOPENFILES (NPPMSG + 7)
#define ALL_OPEN_FILES 0
#define PRIMARY_VIEW 1
#define SECOND_VIEW 2
#define NPPM_GETOPENFILENAMES (NPPMSG + 8)
#define NPPM_MODELESSDIALOG (NPPMSG + 12)
#define MODELESSDIALOGADD 0
#define MODELESSDIALOGREMOVE 1
#define NPPM_GETNBSESSIONFILES (NPPMSG + 13)
#define NPPM_GETSESSIONFILES (NPPMSG + 14)
#define NPPM_SAVESESSION (NPPMSG + 15)
#define NPPM_SAVECURRENTSESSION (NPPMSG + 16)
struct sessionInfo {
TCHAR* sessionFilePathName;
int nbFile;
TCHAR** files;
};
#define NPPM_GETOPENFILENAMESPRIMARY (NPPMSG + 17)
#define NPPM_GETOPENFILENAMESSECOND (NPPMSG + 18)
#define NPPM_CREATESCINTILLAHANDLE (NPPMSG + 20)
#define NPPM_DESTROYSCINTILLAHANDLE (NPPMSG + 21)
#define NPPM_GETNBUSERLANG (NPPMSG + 22)
#define NPPM_GETCURRENTDOCINDEX (NPPMSG + 23)
#define MAIN_VIEW 0
#define SUB_VIEW 1
#define NPPM_SETSTATUSBAR (NPPMSG + 24)
#define STATUSBAR_DOC_TYPE 0
#define STATUSBAR_DOC_SIZE 1
#define STATUSBAR_CUR_POS 2
#define STATUSBAR_EOF_FORMAT 3
#define STATUSBAR_UNICODE_TYPE 4
#define STATUSBAR_TYPING_MODE 5
#define NPPM_GETMENUHANDLE (NPPMSG + 25)
#define NPPPLUGINMENU 0
#define NPPM_ENCODESCI (NPPMSG + 26)
//ascii file to unicode
//int NPPM_ENCODESCI(MAIN_VIEW/SUB_VIEW, 0)
//return new unicodeMode
#define NPPM_DECODESCI (NPPMSG + 27)
//unicode file to ascii
//int NPPM_DECODESCI(MAIN_VIEW/SUB_VIEW, 0)
//return old unicodeMode
#define NPPM_ACTIVATEDOC (NPPMSG + 28)
//void NPPM_ACTIVATEDOC(int view, int index2Activate)
#define NPPM_LAUNCHFINDINFILESDLG (NPPMSG + 29)
//void NPPM_LAUNCHFINDINFILESDLG(TCHAR * dir2Search, TCHAR * filtre)
#define NPPM_DMMSHOW (NPPMSG + 30)
#define NPPM_DMMHIDE (NPPMSG + 31)
#define NPPM_DMMUPDATEDISPINFO (NPPMSG + 32)
//void NPPM_DMMxxx(0, tTbData->hClient)
#define NPPM_DMMREGASDCKDLG (NPPMSG + 33)
//void NPPM_DMMREGASDCKDLG(0, &tTbData)
#define NPPM_LOADSESSION (NPPMSG + 34)
//void NPPM_LOADSESSION(0, const TCHAR* file name)
#define NPPM_DMMVIEWOTHERTAB (NPPMSG + 35)
//void WM_DMM_VIEWOTHERTAB(0, tTbData->pszName)
#define NPPM_RELOADFILE (NPPMSG + 36)
//BOOL NPPM_RELOADFILE(BOOL withAlert, TCHAR *filePathName2Reload)
#define NPPM_SWITCHTOFILE (NPPMSG + 37)
//BOOL NPPM_SWITCHTOFILE(0, TCHAR *filePathName2switch)
#define NPPM_SAVECURRENTFILE (NPPMSG + 38)
//BOOL WM_SWITCHTOFILE(0, 0)
#define NPPM_SAVEALLFILES (NPPMSG + 39)
//BOOL NPPM_SAVEALLFILES(0, 0)
#define NPPM_SETMENUITEMCHECK (NPPMSG + 40)
//void WM_PIMENU_CHECK(UINT funcItem[X]._cmdID, TRUE/FALSE)
#define NPPM_ADDTOOLBARICON (NPPMSG + 41)
//void WM_ADDTOOLBARICON(UINT funcItem[X]._cmdID, toolbarIcons icon)
struct toolbarIcons {
HBITMAP hToolbarBmp;
HICON hToolbarIcon;
};
#define NPPM_GETWINDOWSVERSION (NPPMSG + 42)
//winVer NPPM_GETWINDOWSVERSION(0, 0)
#define NPPM_DMMGETPLUGINHWNDBYNAME (NPPMSG + 43)
//HWND WM_DMM_GETPLUGINHWNDBYNAME(const TCHAR *windowName, const TCHAR *moduleName)
// if moduleName is NULL, then return value is NULL
// if windowName is NULL, then the first found window handle which matches with the moduleName will be returned
#define NPPM_MAKECURRENTBUFFERDIRTY (NPPMSG + 44)
//BOOL NPPM_MAKECURRENTBUFFERDIRTY(0, 0)
#define NPPM_GETENABLETHEMETEXTUREFUNC (NPPMSG + 45)
//BOOL NPPM_GETENABLETHEMETEXTUREFUNC(0, 0)
#define NPPM_GETPLUGINSCONFIGDIR (NPPMSG + 46)
//void NPPM_GETPLUGINSCONFIGDIR(int strLen, TCHAR *str)
#define NPPM_MSGTOPLUGIN (NPPMSG + 47)
//BOOL NPPM_MSGTOPLUGIN(TCHAR *destModuleName, CommunicationInfo *info)
// return value is TRUE when the message arrive to the destination plugins.
// if destModule or info is NULL, then return value is FALSE
struct CommunicationInfo {
long internalMsg;
const TCHAR * srcModuleName;
void * info; // defined by plugin
};
#define NPPM_MENUCOMMAND (NPPMSG + 48)
//void NPPM_MENUCOMMAND(0, int cmdID)
// uncomment //#include "menuCmdID.h"
// in the beginning of this file then use the command symbols defined in "menuCmdID.h" file
// to access all the Notepad++ menu command items
#define NPPM_TRIGGERTABBARCONTEXTMENU (NPPMSG + 49)
//void NPPM_TRIGGERTABBARCONTEXTMENU(int view, int index2Activate)
#define NPPM_GETNPPVERSION (NPPMSG + 50)
// int NPPM_GETNPPVERSION(0, 0)
// return version
// ex : v4.6
// HIWORD(version) == 4
// LOWORD(version) == 6
#define NPPM_HIDETABBAR (NPPMSG + 51)
// BOOL NPPM_HIDETABBAR(0, BOOL hideOrNot)
// if hideOrNot is set as TRUE then tab bar will be hidden
// otherwise it'll be shown.
// return value : the old status value
#define NPPM_ISTABBARHIDDEN (NPPMSG + 52)
// BOOL NPPM_ISTABBARHIDDEN(0, 0)
// returned value : TRUE if tab bar is hidden, otherwise FALSE
#define NPPM_GETPOSFROMBUFFERID (NPPMSG + 57)
// INT NPPM_GETPOSFROMBUFFERID(INT bufferID, 0)
// Return VIEW|INDEX from a buffer ID. -1 if the bufferID non existing
//
// VIEW takes 2 highest bits and INDEX (0 based) takes the rest (30 bits)
// Here's the values for the view :
// MAIN_VIEW 0
// SUB_VIEW 1
#define NPPM_GETFULLPATHFROMBUFFERID (NPPMSG + 58)
// INT NPPM_GETFULLPATHFROMBUFFERID(INT bufferID, TCHAR *fullFilePath)
// Get full path file name from a bufferID.
// Return -1 if the bufferID non existing, otherwise the number of TCHAR copied/to copy
// User should call it with fullFilePath be NULL to get the number of TCHAR (not including the nul character),
// allocate fullFilePath with the return values + 1, then call it again to get full path file name
#define NPPM_GETBUFFERIDFROMPOS (NPPMSG + 59)
//wParam: Position of document
//lParam: View to use, 0 = Main, 1 = Secondary
//Returns 0 if invalid
#define NPPM_GETCURRENTBUFFERID (NPPMSG + 60)
//Returns active Buffer
#define NPPM_RELOADBUFFERID (NPPMSG + 61)
//Reloads Buffer
//wParam: Buffer to reload
//lParam: 0 if no alert, else alert
#define NPPM_GETBUFFERLANGTYPE (NPPMSG + 64)
//wParam: BufferID to get LangType from
//lParam: 0
//Returns as int, see LangType. -1 on error
#define NPPM_SETBUFFERLANGTYPE (NPPMSG + 65)
//wParam: BufferID to set LangType of
//lParam: LangType
//Returns TRUE on success, FALSE otherwise
//use int, see LangType for possible values
//L_USER and L_EXTERNAL are not supported
#define NPPM_GETBUFFERENCODING (NPPMSG + 66)
//wParam: BufferID to get encoding from
//lParam: 0
//returns as int, see UniMode. -1 on error
#define NPPM_SETBUFFERENCODING (NPPMSG + 67)
//wParam: BufferID to set encoding of
//lParam: format
//Returns TRUE on success, FALSE otherwise
//use int, see UniMode
//Can only be done on new, unedited files
#define NPPM_GETBUFFERFORMAT (NPPMSG + 68)
//wParam: BufferID to get format from
//lParam: 0
//returns as int, see formatType. -1 on error
#define NPPM_SETBUFFERFORMAT (NPPMSG + 69)
//wParam: BufferID to set format of
//lParam: format
//Returns TRUE on success, FALSE otherwise
//use int, see formatType
/*
#define NPPM_ADDREBAR (NPPMSG + 57)
// BOOL NPPM_ADDREBAR(0, REBARBANDINFO *)
// Returns assigned ID in wID value of struct pointer
#define NPPM_UPDATEREBAR (NPPMSG + 58)
// BOOL NPPM_ADDREBAR(INT ID, REBARBANDINFO *)
//Use ID assigned with NPPM_ADDREBAR
#define NPPM_REMOVEREBAR (NPPMSG + 59)
// BOOL NPPM_ADDREBAR(INT ID, 0)
//Use ID assigned with NPPM_ADDREBAR
*/
#define NPPM_HIDETOOLBAR (NPPMSG + 70)
// BOOL NPPM_HIDETOOLBAR(0, BOOL hideOrNot)
// if hideOrNot is set as TRUE then tool bar will be hidden
// otherwise it'll be shown.
// return value : the old status value
#define NPPM_ISTOOLBARHIDDEN (NPPMSG + 71)
// BOOL NPPM_ISTOOLBARHIDDEN(0, 0)
// returned value : TRUE if tool bar is hidden, otherwise FALSE
#define NPPM_HIDEMENU (NPPMSG + 72)
// BOOL NPPM_HIDEMENU(0, BOOL hideOrNot)
// if hideOrNot is set as TRUE then menu will be hidden
// otherwise it'll be shown.
// return value : the old status value
#define NPPM_ISMENUHIDDEN (NPPMSG + 73)
// BOOL NPPM_ISMENUHIDDEN(0, 0)
// returned value : TRUE if menu is hidden, otherwise FALSE
#define NPPM_HIDESTATUSBAR (NPPMSG + 74)
// BOOL NPPM_HIDESTATUSBAR(0, BOOL hideOrNot)
// if hideOrNot is set as TRUE then STATUSBAR will be hidden
// otherwise it'll be shown.
// return value : the old status value
#define NPPM_ISSTATUSBARHIDDEN (NPPMSG + 75)
// BOOL NPPM_ISSTATUSBARHIDDEN(0, 0)
// returned value : TRUE if STATUSBAR is hidden, otherwise FALSE
#define NPPM_GETSHORTCUTBYCMDID (NPPMSG + 76)
// BOOL NPPM_GETSHORTCUTBYCMDID(int cmdID, ShortcutKey *sk)
// get your plugin command current mapped shortcut into sk via cmdID
// You may need it after getting NPPN_READY notification
// returned value : TRUE if this function call is successful and shorcut is enable, otherwise FALSE
#define NPPM_DOOPEN (NPPMSG + 77)
// BOOL NPPM_DOOPEN(0, const TCHAR *fullPathName2Open)
// fullPathName2Open indicates the full file path name to be opened.
// The return value is TRUE (1) if the operation is successful, otherwise FALSE (0).
#define RUNCOMMAND_USER (WM_USER + 3000)
#define NPPM_GETFULLCURRENTPATH (RUNCOMMAND_USER + FULL_CURRENT_PATH)
#define NPPM_GETCURRENTDIRECTORY (RUNCOMMAND_USER + CURRENT_DIRECTORY)
#define NPPM_GETFILENAME (RUNCOMMAND_USER + FILE_NAME)
#define NPPM_GETNAMEPART (RUNCOMMAND_USER + NAME_PART)
#define NPPM_GETEXTPART (RUNCOMMAND_USER + EXT_PART)
#define NPPM_GETCURRENTWORD (RUNCOMMAND_USER + CURRENT_WORD)
#define NPPM_GETNPPDIRECTORY (RUNCOMMAND_USER + NPP_DIRECTORY)
// BOOL NPPM_GETXXXXXXXXXXXXXXXX(size_t strLen, TCHAR *str)
// where str is the allocated TCHAR array,
// strLen is the allocated array size
// The return value is TRUE when get generic_string operation success
// Otherwise (allocated array size is too small) FALSE
#define NPPM_GETCURRENTLINE (RUNCOMMAND_USER + CURRENT_LINE)
// INT NPPM_GETCURRENTLINE(0, 0)
// return the caret current position line
#define NPPM_GETCURRENTCOLUMN (RUNCOMMAND_USER + CURRENT_COLUMN)
// INT NPPM_GETCURRENTCOLUMN(0, 0)
// return the caret current position column
#define VAR_NOT_RECOGNIZED 0
#define FULL_CURRENT_PATH 1
#define CURRENT_DIRECTORY 2
#define FILE_NAME 3
#define NAME_PART 4
#define EXT_PART 5
#define CURRENT_WORD 6
#define NPP_DIRECTORY 7
#define CURRENT_LINE 8
#define CURRENT_COLUMN 9
// Notification code
#define NPPN_FIRST 1000
#define NPPN_READY (NPPN_FIRST + 1) // To notify plugins that all the procedures of launchment of notepad++ are done.
//scnNotification->nmhdr.code = NPPN_READY;
//scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = 0;
#define NPPN_TBMODIFICATION (NPPN_FIRST + 2) // To notify plugins that toolbar icons can be registered
//scnNotification->nmhdr.code = NPPN_TB_MODIFICATION;
//scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = 0;
#define NPPN_FILEBEFORECLOSE (NPPN_FIRST + 3) // To notify plugins that the current file is about to be closed
//scnNotification->nmhdr.code = NPPN_FILEBEFORECLOSE;
//scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = BufferID;
#define NPPN_FILEOPENED (NPPN_FIRST + 4) // To notify plugins that the current file is just opened
//scnNotification->nmhdr.code = NPPN_FILEOPENED;
//scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = BufferID;
#define NPPN_FILECLOSED (NPPN_FIRST + 5) // To notify plugins that the current file is just closed
//scnNotification->nmhdr.code = NPPN_FILECLOSED;
//scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = BufferID;
#define NPPN_FILEBEFOREOPEN (NPPN_FIRST + 6) // To notify plugins that the current file is about to be opened
//scnNotification->nmhdr.code = NPPN_FILEBEFOREOPEN;
//scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = BufferID;
#define NPPN_FILEBEFORESAVE (NPPN_FIRST + 7) // To notify plugins that the current file is about to be saved
//scnNotification->nmhdr.code = NPPN_FILEBEFOREOPEN;
//scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = BufferID;
#define NPPN_FILESAVED (NPPN_FIRST + 8) // To notify plugins that the current file is just saved
//scnNotification->nmhdr.code = NPPN_FILECLOSED;
//scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = BufferID;
#define NPPN_SHUTDOWN (NPPN_FIRST + 9) // To notify plugins that Notepad++ is about to be shutdowned.
//scnNotification->nmhdr.code = NPPN_SHUTDOWN;
//scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = 0;
#define NPPN_BUFFERACTIVATED (NPPN_FIRST + 10) // To notify plugins that a buffer was activated (put to foreground).
//scnNotification->nmhdr.code = NPPN_BUFFERACTIVATED;
//scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = activatedBufferID;
#define NPPN_LANGCHANGED (NPPN_FIRST + 11) // To notify plugins that the language in the current doc is just changed.
//scnNotification->nmhdr.code = NPPN_LANGCHANGED;
//scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = currentBufferID;
#define NPPN_WORDSTYLESUPDATED (NPPN_FIRST + 12) // To notify plugins that user initiated a WordStyleDlg change.
//scnNotification->nmhdr.code = NPPN_WORDSTYLESUPDATED;
//scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = currentBufferID;
#define NPPN_SHORTCUTREMAPPED (NPPN_FIRST + 13) // To notify plugins that plugin command shortcut is remapped.
//scnNotification->nmhdr.code = NPPN_SHORTCUTSREMAPPED;
//scnNotification->nmhdr.hwndFrom = ShortcutKeyStructurePointer;
//scnNotification->nmhdr.idFrom = cmdID;
//where ShortcutKeyStructurePointer is pointer of struct ShortcutKey:
//struct ShortcutKey {
// bool _isCtrl;
// bool _isAlt;
// bool _isShift;
// UCHAR _key;
//};
#define NPPN_FILEBEFORELOAD (NPPN_FIRST + 14) // To notify plugins that the current file is about to be loaded
//scnNotification->nmhdr.code = NPPN_FILEBEFOREOPEN;
//scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = NULL;
#define NPPN_FILELOADFAILED (NPPN_FIRST + 15) // To notify plugins that file open operation failed
//scnNotification->nmhdr.code = NPPN_FILEOPENFAILED;
//scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = BufferID;
#endif //NOTEPAD_PLUS_MSGS_H

View File

@ -0,0 +1,69 @@
//this file is part of notepad++
//Copyright (C)2003 Don HO ( donho@altern.org )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#ifndef PLUGININTERFACE_H
#define PLUGININTERFACE_H
#include <windows.h>
#include "Scintilla.h"
#include "Notepad_plus_msgs.h"
const int nbChar = 64;
typedef const TCHAR * (__cdecl * PFUNCGETNAME)();
struct NppData {
HWND _nppHandle;
HWND _scintillaMainHandle;
HWND _scintillaSecondHandle;
};
typedef void (__cdecl * PFUNCSETINFO)(NppData);
typedef void (__cdecl * PFUNCPLUGINCMD)();
typedef void (__cdecl * PBENOTIFIED)(SCNotification *);
typedef LRESULT (__cdecl * PMESSAGEPROC)(UINT Message, WPARAM wParam, LPARAM lParam);
struct ShortcutKey {
bool _isCtrl;
bool _isAlt;
bool _isShift;
UCHAR _key;
};
struct FuncItem {
TCHAR _itemName[nbChar];
PFUNCPLUGINCMD _pFunc;
int _cmdID;
bool _init2Check;
ShortcutKey *_pShKey;
};
typedef FuncItem * (__cdecl * PFUNCGETFUNCSARRAY)(int *);
// You should implement (or define an empty function body) those functions which are called by Notepad++ plugin manager
extern "C" __declspec(dllexport) void setInfo(NppData);
extern "C" __declspec(dllexport) const TCHAR * getName();
extern "C" __declspec(dllexport) FuncItem * getFuncsArray(int *);
extern "C" __declspec(dllexport) void beNotified(SCNotification *);
extern "C" __declspec(dllexport) LRESULT messageProc(UINT Message, WPARAM wParam, LPARAM lParam);
#ifdef UNICODE
extern "C" __declspec(dllexport) BOOL isUnicode();
#endif //UNICODE
#endif //PLUGININTERFACE_H

View File

@ -0,0 +1,301 @@
//this file is part of notepad++
//Copyright (C)2003 Don HO ( donho@altern.org )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include <shlwapi.h>
#include "PluginsManager.h"
const TCHAR * USERMSG = TEXT("This plugin is not compatible with current version of Notepad++.\n\n\
Do you want to remove this plugin from plugins directory to prevent this message from the next launch time?");
bool PluginsManager::loadPlugins(const TCHAR *dir)
{
if (_isDisabled)
return false;
vector<generic_string> dllNames;
vector<generic_string> dll2Remove;
const TCHAR *pNppPath = (NppParameters::getInstance())->getNppPath();
generic_string pluginsFullPathFilter = (dir && dir[0])?dir:pNppPath;
pluginsFullPathFilter += TEXT("\\plugins\\*.dll");
WIN32_FIND_DATA foundData;
HANDLE hFindFile = ::FindFirstFile(pluginsFullPathFilter.c_str(), &foundData);
if (hFindFile != INVALID_HANDLE_VALUE)
{
generic_string plugins1stFullPath = (dir && dir[0])?dir:pNppPath;
plugins1stFullPath += TEXT("\\plugins\\");
plugins1stFullPath += foundData.cFileName;
dllNames.push_back(plugins1stFullPath);
while (::FindNextFile(hFindFile, &foundData))
{
generic_string fullPath = (dir && dir[0])?dir:pNppPath;
fullPath += TEXT("\\plugins\\");
fullPath += foundData.cFileName;
dllNames.push_back(fullPath);
}
::FindClose(hFindFile);
size_t i = 0;
for ( ; i < dllNames.size() ; i++)
{
PluginInfo *pi = new PluginInfo;
try {
TCHAR tmpStr[MAX_PATH];
lstrcpy(tmpStr, dllNames[i].c_str());
lstrcpy(pi->_moduleName, PathFindFileName(tmpStr));
pi->_hLib = ::LoadLibrary(dllNames[i].c_str());
if (!pi->_hLib)
throw generic_string(TEXT("Load Library is failed.\nMake \"Runtime Library\" setting of this project as \"Multi-threaded(/MT)\" may cure this problem."));
pi->_pFuncIsUnicode = (PFUNCISUNICODE)GetProcAddress(pi->_hLib, "isUnicode");
#ifdef UNICODE
if (!pi->_pFuncIsUnicode || !pi->_pFuncIsUnicode())
throw generic_string(TEXT("This ANSI plugin is not compatible with your Unicode Notepad++."));
#else
if (pi->_pFuncIsUnicode)
throw generic_string(TEXT("This Unicode plugin is not compatible with your ANSI mode Notepad++."));
#endif
pi->_pFuncSetInfo = (PFUNCSETINFO)GetProcAddress(pi->_hLib, "setInfo");
if (!pi->_pFuncSetInfo)
throw generic_string(TEXT("Missing \"setInfo\" function"));
pi->_pFuncGetName = (PFUNCGETNAME)GetProcAddress(pi->_hLib, "getName");
if (!pi->_pFuncGetName)
throw generic_string(TEXT("Missing \"getName\" function"));
pi->_pBeNotified = (PBENOTIFIED)GetProcAddress(pi->_hLib, "beNotified");
if (!pi->_pBeNotified)
throw generic_string(TEXT("Missing \"beNotified\" function"));
pi->_pMessageProc = (PMESSAGEPROC)GetProcAddress(pi->_hLib, "messageProc");
if (!pi->_pMessageProc)
throw generic_string(TEXT("Missing \"messageProc\" function"));
pi->_pFuncSetInfo(_nppData);
pi->_pFuncGetFuncsArray = (PFUNCGETFUNCSARRAY)GetProcAddress(pi->_hLib, "getFuncsArray");
if (!pi->_pFuncGetFuncsArray)
throw generic_string(TEXT("Missing \"getFuncsArray\" function"));
pi->_funcItems = pi->_pFuncGetFuncsArray(&pi->_nbFuncItem);
if ((!pi->_funcItems) || (pi->_nbFuncItem <= 0))
throw generic_string(TEXT("Missing \"FuncItems\" array, or the nb of Function Item is not set correctly"));
pi->_pluginMenu = ::CreateMenu();
GetLexerCountFn GetLexerCount = (GetLexerCountFn)::GetProcAddress(pi->_hLib, "GetLexerCount");
// it's a lexer plugin
if (GetLexerCount)
{
GetLexerNameFn GetLexerName = (GetLexerNameFn)::GetProcAddress(pi->_hLib, "GetLexerName");
if (!GetLexerName)
throw generic_string(TEXT("Loading GetLexerName function failed."));
GetLexerStatusTextFn GetLexerStatusText = (GetLexerStatusTextFn)::GetProcAddress(pi->_hLib, "GetLexerStatusText");
if (!GetLexerStatusText)
throw generic_string(TEXT("Loading GetLexerStatusText function failed."));
// Assign a buffer for the lexer name.
char lexName[MAX_EXTERNAL_LEXER_NAME_LEN];
lexName[0] = '\0';
TCHAR lexDesc[MAX_EXTERNAL_LEXER_DESC_LEN];
lstrcpy(lexDesc, TEXT(""));
int numLexers = GetLexerCount();
NppParameters * nppParams = NppParameters::getInstance();
ExternalLangContainer *containers[30];
#ifdef UNICODE
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
#endif
for (int x = 0; x < numLexers; x++)
{
GetLexerName(x, lexName, MAX_EXTERNAL_LEXER_NAME_LEN);
GetLexerStatusText(x, lexDesc, MAX_EXTERNAL_LEXER_DESC_LEN);
#ifdef UNICODE
const TCHAR *pLexerName = wmc->char2wchar(lexName, CP_ACP);
#else
const TCHAR *pLexerName = lexName;
#endif
if (!nppParams->isExistingExternalLangName(pLexerName) && nppParams->ExternalLangHasRoom())
containers[x] = new ExternalLangContainer(pLexerName, lexDesc);
else
containers[x] = NULL;
}
TCHAR xmlPath[MAX_PATH];
lstrcpy(xmlPath, nppParams->getNppPath());
PathAppend(xmlPath, TEXT("plugins\\Config"));
PathAppend(xmlPath, pi->_moduleName);
PathRemoveExtension(xmlPath);
PathAddExtension(xmlPath, TEXT(".xml"));
if (!PathFileExists(xmlPath))
{
lstrcpyn( xmlPath, TEXT("\0"), MAX_PATH );
lstrcpy( xmlPath, nppParams->getAppDataNppDir() );
PathAppend(xmlPath, TEXT("plugins\\Config"));
PathAppend( xmlPath, pi->_moduleName );
PathRemoveExtension( xmlPath );
PathAddExtension( xmlPath, TEXT(".xml") );
if (! PathFileExists( xmlPath ) )
{
throw generic_string(generic_string(xmlPath) + TEXT(" is missing."));
}
}
TiXmlDocument *_pXmlDoc = new TiXmlDocument(xmlPath);
if (!_pXmlDoc->LoadFile())
{
delete _pXmlDoc;
_pXmlDoc = NULL;
throw generic_string(generic_string(xmlPath) + TEXT(" failed to load."));
}
for (int x = 0; x < numLexers; x++) // postpone adding in case the xml is missing/corrupt
if (containers[x] != NULL)
nppParams->addExternalLangToEnd(containers[x]);
nppParams->getExternalLexerFromXmlTree(_pXmlDoc);
nppParams->getExternalLexerDoc()->push_back(_pXmlDoc);
#ifdef UNICODE
const char *pDllName = wmc->wchar2char(dllNames[i].c_str(), CP_ACP);
#else
const char *pDllName = dllNames[i].c_str();
#endif
::SendMessage(_nppData._scintillaMainHandle, SCI_LOADLEXERLIBRARY, 0, (LPARAM)pDllName);
}
_pluginInfos.push_back(pi);
}
catch(generic_string s)
{
s += TEXT("\n\n");
s += USERMSG;
if (::MessageBox(NULL, s.c_str(), dllNames[i].c_str(), MB_YESNO) == IDYES)
{
dll2Remove.push_back(dllNames[i]);
}
delete pi;
}
catch(...)
{
generic_string msg = TEXT("Fail loaded");
msg += TEXT("\n\n");
msg += USERMSG;
if (::MessageBox(NULL, msg.c_str(), dllNames[i].c_str(), MB_YESNO) == IDYES)
{
dll2Remove.push_back(dllNames[i]);
}
delete pi;
}
}
}
for (size_t j = 0 ; j < dll2Remove.size() ; j++)
::DeleteFile(dll2Remove[j].c_str());
return true;
}
// return true if cmdID found and its shortcut is enable
// false otherwise
bool PluginsManager::getShortcutByCmdID(int cmdID, ShortcutKey *sk)
{
if (cmdID == 0 || !sk)
return false;
const vector<PluginCmdShortcut> & pluginCmdSCList = (NppParameters::getInstance())->getPluginCommandList();
for (size_t i = 0 ; i < pluginCmdSCList.size() ; i++)
{
if (pluginCmdSCList[i].getID() == cmdID)
{
const KeyCombo & kc = pluginCmdSCList[i].getKeyCombo();
if (kc._key == 0x00)
return false;
sk->_isAlt = kc._isAlt;
sk->_isCtrl = kc._isCtrl;
sk->_isShift = kc._isShift;
sk->_key = kc._key;
return true;
}
}
return false;
}
void PluginsManager::setMenu(HMENU hMenu, const TCHAR *menuName)
{
if (hasPlugins())
{
vector<PluginCmdShortcut> & pluginCmdSCList = (NppParameters::getInstance())->getPluginCommandList();
const TCHAR *nom_menu = (menuName && menuName[0])?menuName:TEXT("Plugins");
_hPluginsMenu = ::CreateMenu();
::InsertMenu(hMenu, 9, MF_BYPOSITION | MF_POPUP, (UINT_PTR)_hPluginsMenu, nom_menu);
for (size_t i = 0 ; i < _pluginInfos.size() ; i++)
{
::InsertMenu(_hPluginsMenu, i, MF_BYPOSITION | MF_POPUP, (UINT_PTR)_pluginInfos[i]->_pluginMenu, _pluginInfos[i]->_pFuncGetName());
for (int j = 0 ; j < _pluginInfos[i]->_nbFuncItem ; j++)
{
if (_pluginInfos[i]->_funcItems[j]._pFunc == NULL)
{
::InsertMenu(_pluginInfos[i]->_pluginMenu, j, MF_BYPOSITION | MF_SEPARATOR, 0, TEXT(""));
continue;
}
_pluginsCommands.push_back(PluginCommand(_pluginInfos[i]->_moduleName, j, _pluginInfos[i]->_funcItems[j]._pFunc));
int cmdID = ID_PLUGINS_CMD + (_pluginsCommands.size() - 1);
_pluginInfos[i]->_funcItems[j]._cmdID = cmdID;
generic_string itemName = _pluginInfos[i]->_funcItems[j]._itemName;
if (_pluginInfos[i]->_funcItems[j]._pShKey)
{
ShortcutKey & sKey = *(_pluginInfos[i]->_funcItems[j]._pShKey);
PluginCmdShortcut pcs(Shortcut(itemName.c_str(), sKey._isCtrl, sKey._isAlt, sKey._isShift, sKey._key), cmdID, _pluginInfos[i]->_moduleName, j);
pluginCmdSCList.push_back(pcs);
itemName += TEXT("\t");
itemName += pcs.toString();
}
else
{ //no ShortcutKey is provided, add an disabled shortcut (so it can still be mapped, Paramaters class can still index any changes and the toolbar wont funk out
PluginCmdShortcut pcs(Shortcut(itemName.c_str(), false, false, false, 0x00), cmdID, _pluginInfos[i]->_moduleName, j); //VK_NULL and everything disabled, the menu name is left alone
pluginCmdSCList.push_back(pcs);
}
::InsertMenu(_pluginInfos[i]->_pluginMenu, j, MF_BYPOSITION, cmdID, itemName.c_str());
if (_pluginInfos[i]->_funcItems[j]._init2Check)
::CheckMenuItem(_hPluginsMenu, cmdID, MF_BYCOMMAND | MF_CHECKED);
}
}
}
}

View File

@ -0,0 +1,155 @@
//this file is part of notepad++
//Copyright (C)2003 Don HO ( donho@altern.org )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#ifndef PLUGINSMANAGER_H
#define PLUGINSMANAGER_H
#include "resource.h"
#include "Parameters.h"
#include "PluginInterface.h"
typedef BOOL (__cdecl * PFUNCISUNICODE)();
struct PluginCommand {
TCHAR _pluginName[64];
int _funcID;
PFUNCPLUGINCMD _pFunc;
PluginCommand(const TCHAR *pluginName, int funcID, PFUNCPLUGINCMD pFunc): _funcID(funcID), _pFunc(pFunc){
lstrcpy(_pluginName, pluginName);
};
};
struct PluginInfo {
PluginInfo() :_hLib(NULL), _pluginMenu(NULL), _pFuncSetInfo(NULL),\
_pFuncGetFuncsArray(NULL), _pFuncGetName(NULL), _funcItems(NULL),\
_nbFuncItem(0){};
~PluginInfo(){
if (_pluginMenu)
::DestroyMenu(_pluginMenu);
if (_hLib)
::FreeLibrary(_hLib);
};
HINSTANCE _hLib;
HMENU _pluginMenu;
PFUNCSETINFO _pFuncSetInfo;
PFUNCGETNAME _pFuncGetName;
PBENOTIFIED _pBeNotified;
PFUNCGETFUNCSARRAY _pFuncGetFuncsArray;
PMESSAGEPROC _pMessageProc;
PFUNCISUNICODE _pFuncIsUnicode;
FuncItem *_funcItems;
int _nbFuncItem;
TCHAR _moduleName[64];
};
class PluginsManager {
public:
PluginsManager() : _hPluginsMenu(NULL), _isDisabled(false) {};
~PluginsManager() {
for (size_t i = 0 ; i < _pluginInfos.size() ; i++)
delete _pluginInfos[i];
if (_hPluginsMenu)
DestroyMenu(_hPluginsMenu);
};
void init(const NppData & nppData) {
_nppData = nppData;
};
bool loadPlugins(const TCHAR *dir = NULL);
void runPluginCommand(size_t i) {
if (i < _pluginsCommands.size())
if (_pluginsCommands[i]._pFunc != NULL)
_pluginsCommands[i]._pFunc();
};
void runPluginCommand(const TCHAR *pluginName, int commandID) {
for (size_t i = 0 ; i < _pluginsCommands.size() ; i++)
{
if (!generic_stricmp(_pluginsCommands[i]._pluginName, pluginName))
{
if (_pluginsCommands[i]._funcID == commandID)
_pluginsCommands[i]._pFunc();
}
}
};
void setMenu(HMENU hMenu, const TCHAR *menuName);
bool getShortcutByCmdID(int cmdID, ShortcutKey *sk);
void notify(SCNotification *notification) {
for (size_t i = 0 ; i < _pluginInfos.size() ; i++)
{
// To avoid the plugin change the data in SCNotification
// Each notification to pass to a plugin is a copy of SCNotification instance
SCNotification scNotif = *notification;
_pluginInfos[i]->_pBeNotified(&scNotif);
}
};
void relayNppMessages(UINT Message, WPARAM wParam, LPARAM lParam) {
for (size_t i = 0 ; i < _pluginInfos.size() ; i++)
{
_pluginInfos[i]->_pMessageProc(Message, wParam, lParam);
}
};
bool relayPluginMessages(UINT Message, WPARAM wParam, LPARAM lParam) {
const TCHAR * moduleName = (const TCHAR *)wParam;
if (!moduleName || !moduleName[0] || !lParam)
return false;
for (size_t i = 0 ; i < _pluginInfos.size() ; i++)
{
if (generic_stricmp(_pluginInfos[i]->_moduleName, moduleName) == 0)
{
_pluginInfos[i]->_pMessageProc(Message, wParam, lParam);
return true;
}
}
return false;
};
HMENU getMenuHandle() {
return _hPluginsMenu;
};
void disable() {_isDisabled = true;};
bool hasPlugins(){return (_pluginInfos.size()!= 0);};
private:
NppData _nppData;
HMENU _hPluginsMenu;
vector<PluginInfo *> _pluginInfos;
vector<PluginCommand> _pluginsCommands;
bool _isDisabled;
};
#define EXT_LEXER_DECL __stdcall
// External Lexer function definitions...
typedef int (EXT_LEXER_DECL *GetLexerCountFn)();
typedef void (EXT_LEXER_DECL *GetLexerNameFn)(unsigned int Index, char *name, int buflength);
typedef void (EXT_LEXER_DECL *GetLexerStatusTextFn)(unsigned int Index, TCHAR *desc, int buflength);
#endif //PLUGINSMANAGER_H

View File

@ -0,0 +1,68 @@
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#define NOTEPADPLUS_USER (WM_USER + 1000)
#define WM_GETCURRENTSCINTILLA (NOTEPADPLUS_USER + 4)
#define WM_GETCURRENTLANGTYPE (NOTEPADPLUS_USER + 5)
#define WM_SETCURRENTLANGTYPE (NOTEPADPLUS_USER + 6)
#define WM_NBOPENFILES (NOTEPADPLUS_USER + 7)
#define WM_GETOPENFILENAMES (NOTEPADPLUS_USER + 8)
#define WM_MODELESSDIALOG (NOTEPADPLUS_USER + 12)
#define WM_NBSESSIONFILES (NOTEPADPLUS_USER + 13)
#define WM_GETSESSIONFILES (NOTEPADPLUS_USER + 14)
#define WM_SAVESESSION (NOTEPADPLUS_USER + 15)
#define WM_SAVECURRENTSESSION (NOTEPADPLUS_USER + 16)
#define WM_GETOPENFILENAMES_PRIMARY (NOTEPADPLUS_USER + 17)
#define WM_GETOPENFILENAMES_SECOND (NOTEPADPLUS_USER + 18)
#define WM_CREATESCINTILLAHANDLE (NOTEPADPLUS_USER + 20)
#define WM_DESTROYSCINTILLAHANDLE (NOTEPADPLUS_USER + 21)
#define WM_GETNBUSERLANG (NOTEPADPLUS_USER + 22)
#define WM_GETCURRENTDOCINDEX (NOTEPADPLUS_USER + 23)
#define WM_SETSTATUSBAR (NOTEPADPLUS_USER + 24)
#define WM_GETMENUHANDLE (NOTEPADPLUS_USER + 25)
#define WM_ENCODE_SCI (NOTEPADPLUS_USER + 26)
#define WM_DECODE_SCI (NOTEPADPLUS_USER + 27)
#define WM_ACTIVATE_DOC (NOTEPADPLUS_USER + 28)
#define WM_LAUNCH_FINDINFILESDLG (NOTEPADPLUS_USER + 29)
#define WM_DMM_SHOW (NOTEPADPLUS_USER + 30)
#define WM_DMM_HIDE (NOTEPADPLUS_USER + 31)
#define WM_DMM_UPDATEDISPINFO (NOTEPADPLUS_USER + 32)
#define WM_DMM_REGASDCKDLG (NOTEPADPLUS_USER + 33)
#define WM_LOADSESSION (NOTEPADPLUS_USER + 34)
#define WM_DMM_VIEWOTHERTAB (NOTEPADPLUS_USER + 35)
#define WM_RELOADFILE (NOTEPADPLUS_USER + 36)
#define WM_SWITCHTOFILE (NOTEPADPLUS_USER + 37)
#define WM_SAVECURRENTFILE (NOTEPADPLUS_USER + 38)
#define WM_SAVEALLFILES (NOTEPADPLUS_USER + 39)
#define WM_PIMENU_CHECK (NOTEPADPLUS_USER + 40)
#define WM_ADDTOOLBARICON (NOTEPADPLUS_USER + 41)
#define WM_GETWINDOWSVERSION (NOTEPADPLUS_USER + 42)
#define WM_DMM_GETPLUGINHWNDBYNAME (NOTEPADPLUS_USER + 43)
#define RUNCOMMAND_USER_ (WM_USER + 3000)
#define WM_GET_FULLCURRENTPATH (RUNCOMMAND_USER_ + FULL_CURRENT_PATH)
#define WM_GET_CURRENTDIRECTORY (RUNCOMMAND_USER_ + CURRENT_DIRECTORY)
#define WM_GET_FILENAME (RUNCOMMAND_USER_ + FILE_NAME)
#define WM_GET_NAMEPART (RUNCOMMAND_USER_ + NAME_PART)
#define WM_GET_EXTPART (RUNCOMMAND_USER_ + EXT_PART)
#define WM_GET_CURRENTWORD (RUNCOMMAND_USER_ + CURRENT_WORD)
#define WM_GET_NPPDIRECTORY (RUNCOMMAND_USER_ + NPP_DIRECTORY)

View File

@ -0,0 +1,301 @@
//this file is part of notepad++
//Copyright (C)2003 Don HO ( donho@altern.org )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "process.h"
BOOL Process::run()
{
BOOL result = TRUE;
// stdout & stderr pipes for process to write
HANDLE hPipeOutW = NULL;
HANDLE hPipeErrW = NULL;
HANDLE hListenerStdOutThread = NULL;
HANDLE hListenerStdErrThread = NULL;
HANDLE hWaitForProcessEndThread = NULL;
HANDLE hListenerEvent[2];
hListenerEvent[0] = NULL;
hListenerEvent[1] = NULL;
SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE }; // inheritable handle
try {
// Create stdout pipe
if (!::CreatePipe(&_hPipeOutR, &hPipeOutW, &sa, 0))
error(TEXT("CreatePipe"), result, 1000);
// Create stderr pipe
if (!::CreatePipe(&_hPipeErrR, &hPipeErrW, &sa, 0))
error(TEXT("CreatePipe"), result, 1001);
STARTUPINFO startup;
PROCESS_INFORMATION procinfo;
::ZeroMemory(&startup, sizeof(startup));
startup.cb = sizeof(startup);
startup.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
startup.wShowWindow = (_type == WIN32_PROG)?SW_SHOW:SW_HIDE; // hidden console window
startup.hStdInput = NULL; // not used
startup.hStdOutput = hPipeOutW;
startup.hStdError = hPipeErrW;
generic_string cmd = TEXT("\"");
cmd += _command;
cmd += TEXT("\"");
if (_args[0])
{
cmd += TEXT(" ");
cmd += _args;
}
BOOL started = ::CreateProcess(NULL, // command is part of input generic_string
(TCHAR *)cmd.c_str(), // (writeable) command generic_string
NULL, // process security
NULL, // thread security
TRUE, // inherit handles flag
(_type == WIN32_PROG)?NULL:CREATE_SUSPENDED, // flags
NULL, // inherit environment
_curDir, // inherit directory
&startup, // STARTUPINFO
&procinfo); // PROCESS_INFORMATION
_hProcess = procinfo.hProcess;
_hProcessThread = procinfo.hThread;
if(!started)
error(TEXT("CreateProcess"), result, 1002);
if (_type == CONSOLE_PROG)
{
hListenerEvent[0] = ::CreateEvent(NULL, FALSE, FALSE, TEXT("listenerEvent"));
if(!hListenerEvent[0])
error(TEXT("CreateEvent"), result, 1003);
hListenerEvent[1] = ::CreateEvent(NULL, FALSE, FALSE, TEXT("listenerStdErrEvent"));
if(!hListenerEvent[1])
error(TEXT("CreateEvent"), result, 1004);
// The process is running so we set this to FALSE
_bProcessEnd = FALSE;
hWaitForProcessEndThread = ::CreateThread(NULL, 0, staticWaitForProcessEnd, this, 0, NULL);
if (!hWaitForProcessEndThread)
error(TEXT("CreateThread"), result, 1005);
hListenerStdOutThread = ::CreateThread(NULL, 0, staticListenerStdOut, this, 0, NULL);
if (!hListenerStdOutThread)
error(TEXT("CreateThread"), result, 1006);
hListenerStdErrThread = ::CreateThread(NULL, 0, staticListenerStdErr, this, 0, NULL);
if (!hListenerStdErrThread)
error(TEXT("CreateThread"), result, 1007);
// We wait until the process is over
// TO DO: This should be a bit secured in case something happen and the
// _bProcessEnd variable never gets set to TRUE... (by checking process
// state as well for instance to see if it is still running...)
while (!_bProcessEnd)
{
MSG msg;
while( ::PeekMessage( &msg, NULL, 0, 0, PM_REMOVE))
{
if( msg.message == WM_QUIT)
{
::PostQuitMessage(0);
// We do not exit but simply break in order to close
// handles properly
_bProcessEnd = TRUE;
break;
}
else
{
::TranslateMessage( &msg);
::DispatchMessage( &msg);
}
}
}
}
} catch (int coderr){
TCHAR str[10];
wsprintf(str, TEXT("%d"), coderr);
::MessageBox(NULL, str, TEXT("Exception :"), MB_OK);
}
// on va fermer toutes les handles
if (hPipeOutW)
::CloseHandle(hPipeOutW);
if (hPipeErrW)
::CloseHandle(hPipeErrW);
if (_hPipeOutR)
::CloseHandle(_hPipeOutR);
if (_hPipeErrR)
::CloseHandle(_hPipeErrR);
if (hListenerStdOutThread)
::CloseHandle(hListenerStdOutThread);
if (hListenerStdErrThread)
::CloseHandle(hListenerStdErrThread);
if (hWaitForProcessEndThread)
::CloseHandle(hWaitForProcessEndThread);
if (hListenerEvent[0])
::CloseHandle(hListenerEvent[0]);
if (hListenerEvent[1])
::CloseHandle(hListenerEvent[1]);
return result;
}
#define MAX_LINE_LENGTH 1024
void Process::listenerStdOut()
{
//BOOL Result = 0;
//DWORD size = 0;
DWORD bytesAvail = 0;
BOOL result = 0;
HANDLE hListenerEvent = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, TEXT("listenerEvent"));
//FILE *fp = NULL;
int taille = 0;
TCHAR bufferOut[MAX_LINE_LENGTH + 1];
//TCHAR bufferErr[MAX_LINE_LENGTH + 1];
int nExitCode = STILL_ACTIVE;
DWORD outbytesRead;
::ResumeThread(_hProcessThread);
while (true)
{ // got data
memset(bufferOut,0x00,MAX_LINE_LENGTH + 1);
//memset(bufferErr,0x00,MAX_LINE_LENGTH + 1);
taille = sizeof(bufferOut) - sizeof(TCHAR);
Sleep(50);
if (!::PeekNamedPipe(_hPipeOutR, bufferOut, taille, &outbytesRead, &bytesAvail, NULL))
{
bytesAvail = 0;
break;
}
if(outbytesRead)
{
result = :: ReadFile(_hPipeOutR, bufferOut, taille, &outbytesRead, NULL);
if ((!result) && (outbytesRead == 0))
break;
}
//outbytesRead = lstrlen(bufferOut);
bufferOut[outbytesRead] = '\0';
generic_string s;
s.assign(bufferOut);
_stdoutStr += s;
if (::GetExitCodeProcess(_hProcess, (unsigned long*)&nExitCode))
{
if (nExitCode != STILL_ACTIVE)
break; // EOF condition
}
//else
//break;
}
_exitCode = nExitCode;
if(!::SetEvent(hListenerEvent))
{
systemMessage(TEXT("Thread listenerStdOut"));
}
}
void Process::listenerStdErr()
{
//BOOL Result = 0;
//DWORD size = 0;
DWORD bytesAvail = 0;
BOOL result = 0;
HANDLE hListenerEvent = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, TEXT("listenerStdErrEvent"));
int taille = 0;
//TCHAR bufferOut[MAX_LINE_LENGTH + 1];
TCHAR bufferErr[MAX_LINE_LENGTH + 1];
int nExitCode = STILL_ACTIVE;
DWORD errbytesRead;
::ResumeThread(_hProcessThread);
while (true)
{ // got data
memset(bufferErr, 0x00, MAX_LINE_LENGTH + 1);
taille = sizeof(bufferErr) - sizeof(TCHAR);
Sleep(50);
if (!::PeekNamedPipe(_hPipeErrR, bufferErr, taille, &errbytesRead, &bytesAvail, NULL))
{
bytesAvail = 0;
break;
}
if(errbytesRead)
{
result = :: ReadFile(_hPipeErrR, bufferErr, taille, &errbytesRead, NULL);
if ((!result) && (errbytesRead == 0))
break;
}
//outbytesRead = lstrlen(bufferOut);
bufferErr[errbytesRead] = '\0';
generic_string s;
s.assign(bufferErr);
_stderrStr += s;
if (::GetExitCodeProcess(_hProcess, (unsigned long*)&nExitCode))
{
if (nExitCode != STILL_ACTIVE)
break; // EOF condition
}
}
if(!::SetEvent(hListenerEvent))
{
systemMessage(TEXT("Thread stdout listener"));
}
}
void Process::waitForProcessEnd()
{
HANDLE hListenerEvent[2];
hListenerEvent[0] = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, TEXT("listenerEvent"));
hListenerEvent[1] = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, TEXT("listenerStdErrEvent"));
::WaitForSingleObject(_hProcess, INFINITE);
::WaitForMultipleObjects(2, hListenerEvent, TRUE, INFINITE);
_bProcessEnd = TRUE;
}
void Process::error(const TCHAR *txt2display, BOOL & returnCode, int errCode)
{
systemMessage(txt2display);
returnCode = FALSE;
throw int(errCode);
}

View File

@ -0,0 +1,111 @@
//this file is part of notepad++
//Copyright (C)2003 Don HO ( donho@altern.org )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#ifndef PROCESSUS_H
#define PROCESSUS_H
#include <windows.h>
#include <string>
#include "Common.h"
using namespace std;
enum progType {WIN32_PROG, CONSOLE_PROG};
class Process
{
public:
Process(progType pt = WIN32_PROG) : _type(pt) {};
Process(const TCHAR *cmd, const TCHAR *args, const TCHAR *cDir, progType pt = WIN32_PROG)
: _type(pt), _stdoutStr(TEXT("")), _stderrStr(TEXT("")), _hPipeOutR(NULL),
_hPipeErrR(NULL), _hProcess(NULL), _hProcessThread(NULL) {
lstrcpy(_command, cmd);
lstrcpy(_args, args);
lstrcpy(_curDir, cDir);
//_pid = id;
_bProcessEnd = TRUE;
};
BOOL run();
const TCHAR * getStdout() const {
return _stdoutStr.c_str();
};
const TCHAR * getStderr() const {
return _stderrStr.c_str();
};
int getExitCode() const {
return _exitCode;
};
bool hasStdout() {
return (_stdoutStr.compare(TEXT("")) != 0);
};
bool hasStderr() {
return (_stderrStr.compare(TEXT("")) != 0);
};
protected:
progType _type;
// LES ENTREES
TCHAR _command[MAX_PATH];
TCHAR _args[MAX_PATH];
TCHAR _curDir[MAX_PATH];
// LES SORTIES
generic_string _stdoutStr;
generic_string _stderrStr;
int _exitCode;
// LES HANDLES
HANDLE _hPipeOutR;
HANDLE _hPipeErrR;
HANDLE _hProcess;
HANDLE _hProcessThread;
BOOL _bProcessEnd;
//UINT _pid; // process ID assigned by caller
static DWORD WINAPI staticListenerStdOut(void * myself){
((Process *)myself)->listenerStdOut();
return 0;
};
static DWORD WINAPI staticListenerStdErr(void * myself) {
((Process *)myself)->listenerStdErr();
return 0;
};
static DWORD WINAPI staticWaitForProcessEnd(void * myself) {
((Process *)myself)->waitForProcessEnd();
return 0;
};
void listenerStdOut();
void listenerStdErr();
void waitForProcessEnd();
void error(const TCHAR *txt2display, BOOL & returnCode, int errCode);
};
#endif //PROCESSUS_H

View File

@ -0,0 +1,243 @@
//this file is part of notepad++
//Copyright (C)2003 Don HO ( donho@altern.org )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "process.h"
#include "SysMsg.h"
BOOL Process::run()
{
BOOL result = TRUE;
// stdout & stderr pipes for process to write
HANDLE hPipeOutW = NULL;
HANDLE hPipeErrW = NULL;
HANDLE hListenerStdOutThread = NULL;
HANDLE hListenerStdErrThread = NULL;
HANDLE hListenerEvent[2];
hListenerEvent[0] = NULL;
hListenerEvent[1] = NULL;
SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE }; // inheritable handle
try {
// Create stdout pipe
if (!::CreatePipe(&_hPipeOutR, &hPipeOutW, &sa, 0))
error("CreatePipe", result, 1000);
// Create stderr pipe
if (!::CreatePipe(&_hPipeErrR, &hPipeErrW, &sa, 0))
error("CreatePipe", result, 1001);
STARTUPINFO startup;
PROCESS_INFORMATION procinfo;
::ZeroMemory(&startup, sizeof(startup));
startup.cb = sizeof(startup);
startup.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
startup.wShowWindow = SW_HIDE; // hidden console window
startup.hStdInput = NULL; // not used
startup.hStdOutput = hPipeOutW;
startup.hStdError = hPipeErrW;
BOOL started = ::CreateProcess(NULL, // command is part of input string
_command, // (writeable) command string
NULL, // process security
NULL, // thread security
TRUE, // inherit handles flag
CREATE_SUSPENDED, // flags
NULL, // inherit environment
_curDir, // inherit directory
&startup, // STARTUPINFO
&procinfo); // PROCESS_INFORMATION
_hProcess = procinfo.hProcess;
_hProcessThread = procinfo.hThread;
if(!started)
error("CreateProcess", result, 1002);
hListenerEvent[0] = ::CreateEvent(NULL, FALSE, FALSE, "listenerEvent");
if(!hListenerEvent[0])
error("CreateEvent", result, 1003);
hListenerEvent[1] = ::CreateEvent(NULL, FALSE, FALSE, "listenerStdErrEvent");
if(!hListenerEvent[1])
error("CreateEvent", result, 1004);
hListenerStdOutThread = ::CreateThread(NULL, 0, staticListenerStdOut, this, 0, NULL);
if (!hListenerStdOutThread)
error("CreateThread", result, 1005);
hListenerStdErrThread = ::CreateThread(NULL, 0, staticListenerStdErr, this, 0, NULL);
if (!hListenerStdErrThread)
error("CreateThread", result, 1006);
::WaitForSingleObject(_hProcess, INFINITE);
::WaitForMultipleObjects(2, hListenerEvent, TRUE, INFINITE);
} catch (int coderr){}
// on va fermer toutes les handles
if (hPipeOutW)
::CloseHandle(hPipeOutW);
if (hPipeErrW)
::CloseHandle(hPipeErrW);
if (_hPipeOutR)
::CloseHandle(_hPipeOutR);
if (_hPipeErrR)
::CloseHandle(_hPipeErrR);
if (hListenerStdOutThread)
::CloseHandle(hListenerStdOutThread);
if (hListenerStdErrThread)
::CloseHandle(hListenerStdErrThread);
if (hListenerEvent[0])
::CloseHandle(hListenerEvent[0]);
if (hListenerEvent[1])
::CloseHandle(hListenerEvent[1]);
return result;
}
#define MAX_LINE_LENGTH 1024
void Process::listenerStdOut()
{
BOOL Result = 0;
DWORD size = 0;
DWORD bytesAvail = 0;
BOOL result = 0;
HANDLE hListenerEvent = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, "listenerEvent");
//FILE *fp = NULL;
int taille = 0;
TCHAR bufferOut[MAX_LINE_LENGTH + 1];
//TCHAR bufferErr[MAX_LINE_LENGTH + 1];
int nExitCode = STILL_ACTIVE;
DWORD outbytesRead;
::ResumeThread(_hProcessThread);
while (true)
{ // got data
memset(bufferOut,0x00,MAX_LINE_LENGTH + 1);
//memset(bufferErr,0x00,MAX_LINE_LENGTH + 1);
taille = sizeof(bufferOut) - sizeof(TCHAR);
Sleep(50);
if (!::PeekNamedPipe(_hPipeOutR, bufferOut, taille, &outbytesRead, &bytesAvail, NULL))
{
bytesAvail = 0;
break;
}
if(outbytesRead)
{
result = :: ReadFile(_hPipeOutR, bufferOut, taille, &outbytesRead, NULL);
if ((!result) && (outbytesRead == 0))
break;
}
//outbytesRead = strlen(bufferOut);
bufferOut[outbytesRead] = '\0';
string s;
s.assign(bufferOut);
_stdoutStr += s;
if (::GetExitCodeProcess(_hProcess, (unsigned long*)&nExitCode))
{
if (nExitCode != STILL_ACTIVE)
break; // EOF condition
}
//else
//break;
}
_exitCode = nExitCode;
if(!::SetEvent(hListenerEvent))
{
systemMessage("Thread listenerStdOut");
}
}
void Process::listenerStdErr()
{
BOOL Result = 0;
DWORD size = 0;
DWORD bytesAvail = 0;
BOOL result = 0;
HANDLE hListenerEvent = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, "listenerStdErrEvent");
int taille = 0;
//TCHAR bufferOut[MAX_LINE_LENGTH + 1];
TCHAR bufferErr[MAX_LINE_LENGTH + 1];
int nExitCode = STILL_ACTIVE;
DWORD errbytesRead;
::ResumeThread(_hProcessThread);
while (true)
{ // got data
memset(bufferErr, 0x00, MAX_LINE_LENGTH + 1);
taille = sizeof(bufferErr) - sizeof(TCHAR);
Sleep(50);
if (!::PeekNamedPipe(_hPipeErrR, bufferErr, taille, &errbytesRead, &bytesAvail, NULL))
{
bytesAvail = 0;
break;
}
if(errbytesRead)
{
result = :: ReadFile(_hPipeErrR, bufferErr, taille, &errbytesRead, NULL);
if ((!result) && (errbytesRead == 0))
break;
}
//outbytesRead = strlen(bufferOut);
bufferErr[errbytesRead] = '\0';
string s;
s.assign(bufferErr);
_stderrStr += s;
if (::GetExitCodeProcess(_hProcess, (unsigned long*)&nExitCode))
{
if (nExitCode != STILL_ACTIVE)
break; // EOF condition
}
//else
//break;
}
//_exitCode = nExitCode;
if(!::SetEvent(hListenerEvent))
{
systemMessage("Thread stdout listener");
}
}
void Process::error(const char *txt2display, BOOL & returnCode, int errCode)
{
systemMessage(txt2display);
returnCode = FALSE;
throw int(errCode);
}

View File

@ -0,0 +1,92 @@
//this file is part of notepad++
//Copyright (C)2003 Don HO ( donho@altern.org )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#ifndef PROCESSUS_H
#define PROCESSUS_H
#include <windows.h>
#include <string>
using namespace std;
class Process
{
public:
Process() {};
Process(const char *cmd, const char *cDir/*, unsigned int id = 0*/)
: _stdoutStr(""), _stderrStr(""), _hPipeOutR(NULL),
_hPipeErrR(NULL), _hProcess(NULL), _hProcessThread(NULL) {
strcpy(_command, cmd);
strcpy(_curDir, cDir);
//_pid = id;
};
BOOL run();
const char * getStdout() const {
return _stdoutStr.c_str();
};
const char * getStderr() const {
return _stderrStr.c_str();
};
int getExitCode() const {
return _exitCode;
};
bool hasStdout() {
return _stdoutStr.compare("");
};
bool hasStderr() {
return _stderrStr.compare("");
};
protected:
// LES ENTREES
char _command[256];
char _curDir[256];
// LES SORTIES
string _stdoutStr;
string _stderrStr;
int _exitCode;
// LES HANDLES
HANDLE _hPipeOutR;
HANDLE _hPipeErrR;
HANDLE _hProcess;
HANDLE _hProcessThread;
//UINT _pid; // process ID assigned by caller
static DWORD WINAPI staticListenerStdOut(void * myself){
((Process *)myself)->listenerStdOut();
return 0;
};
static DWORD WINAPI staticListenerStdErr(void * myself) {
((Process *)myself)->listenerStdErr();
return 0;
};
void listenerStdOut();
void listenerStdErr();
void error(const char *txt2display, BOOL & returnCode, int errCode);
};
#endif //PROCESSUS_H

View File

@ -0,0 +1,85 @@
//this file is part of notepad++
//Copyright (C)2003 Don HO ( donho@altern.org )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#ifndef PROCESS_THREAD_H
#define PROCESS_THREAD_H
#include "process.h"
class ProcessThread
{
public :
ProcessThread(const char *appName, const char *cmd, const char *cDir, HWND hwnd) : _hwnd(hwnd) {
strcpy(_appName, appName);
strcpy(_command, cmd);
strcpy(_curDir, cDir);
};
BOOL run(){
HANDLE hEvent = ::CreateEvent(NULL, FALSE, FALSE, "localVarProcessEvent");
_hProcessThread = ::CreateThread(NULL, 0, staticLauncher, this, 0, NULL);
::WaitForSingleObject(hEvent, INFINITE);
::CloseHandle(hEvent);
return TRUE;
};
protected :
// ENTREES
char _appName[256];
char _command[256];
char _curDir[256];
HWND _hwnd;
HANDLE _hProcessThread;
static DWORD WINAPI staticLauncher(void *myself) {
((ProcessThread *)myself)->launch();
return TRUE;
};
bool launch() {
HANDLE hEvent = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, "localVarProcessEvent");
HWND hwnd = _hwnd;
char appName[256];
strcpy(appName, _appName);
HANDLE hMyself = _hProcessThread;
Process process(_command, _curDir);
if(!::SetEvent(hEvent))
{
systemMessage("Thread launcher");
}
process.run();
int code = process.getExitCode();
char codeStr[256];
sprintf(codeStr, "%s : %0.4X", appName, code);
::MessageBox(hwnd, (char *)process.getStdout(), codeStr, MB_OK);
if (process.hasStderr())
::MessageBox(hwnd, (char *)process.getStderr(), codeStr, MB_OK);
::CloseHandle(hMyself);
return true;
};
};
#endif PROCESS_THREAD_H

View File

@ -0,0 +1,388 @@
/*
this file is part of notepad++
Copyright (C)2003 Don HO ( donho@altern.org )
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <windows.h>
#include "regExtDlg.h"
#include "resource.h"
#include "Common.h"
const TCHAR *nppName = TEXT("Notepad++_file");
const TCHAR *nppBackup = TEXT("Notepad++_backup");
const TCHAR *nppDoc = TEXT("Notepad++ Document");
const int nbSupportedLang = 9;
const int nbExtMax = 10;
const int extNameMax = 18;
TCHAR defExtArray[nbSupportedLang][nbExtMax][extNameMax] = {
{TEXT("Notepad"), TEXT(".txt"), TEXT(".log"), TEXT(".ini")},
{TEXT("c, c++, objc"), TEXT(".h"), TEXT(".hpp"), TEXT(".hxx"), TEXT(".c"), TEXT(".cpp"), TEXT(".cxx"), TEXT(".cc"), TEXT(".m")},
{TEXT("java, c#, pascal"), TEXT(".java"), TEXT(".cs"), TEXT(".pas"), TEXT(".inc")},
{TEXT("web(html) script"), TEXT(".html"), TEXT(".htm"), TEXT(".php"), TEXT(".phtml"), TEXT(".js"), TEXT(".jsp"), TEXT(".asp"), TEXT(".css"), TEXT(".xml")},
{TEXT("public script"), TEXT(".sh"), TEXT(".bsh"), TEXT(".nsi"), TEXT(".nsh"), TEXT(".lua"), TEXT(".pl"), TEXT(".pm"), TEXT(".py")},
{TEXT("property script"), TEXT(".rc"), TEXT(".as"), TEXT(".mx"), TEXT(".vb"), TEXT(".vbs")},
{TEXT("fortran, TeX, SQL"), TEXT(".f"), TEXT(".for"), TEXT(".f90"), TEXT(".f95"), TEXT(".f2k"), TEXT(".tex"), TEXT(".sql")},
{TEXT("misc"), TEXT(".nfo"), TEXT(".mak")},
{TEXT("customize")}
};
void RegExtDlg::doDialog(bool isRTL)
{
if (isRTL)
{
DLGTEMPLATE *pMyDlgTemplate = NULL;
HGLOBAL hMyDlgTemplate = makeRTLResource(IDD_REGEXT_BOX, &pMyDlgTemplate);
::DialogBoxIndirectParam(_hInst, pMyDlgTemplate, _hParent, (DLGPROC)dlgProc, (LPARAM)this);
::GlobalFree(hMyDlgTemplate);
}
else
::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_REGEXT_BOX), _hParent, (DLGPROC)dlgProc, (LPARAM)this);
};
BOOL CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam)
{
switch (Message)
{
case WM_INITDIALOG :
{
getRegisteredExts();
getDefSupportedExts();
//goToCenter();
::EnableWindow(::GetDlgItem(_hSelf, IDC_ADDFROMLANGEXT_BUTTON), false);
::EnableWindow(::GetDlgItem(_hSelf, IDC_REMOVEEXT_BUTTON), false);
::SendDlgItemMessage(_hSelf, IDC_CUSTOMEXT_EDIT, EM_SETLIMITTEXT, extNameMax-1, 0);
return TRUE;
}
case WM_DRAWITEM :
{
HICON hIcon = ::LoadIcon(_hInst, MAKEINTRESOURCE(IDI_DELETE_ICON));
DRAWITEMSTRUCT *pdis = (DRAWITEMSTRUCT *)lParam;
::DrawIcon(pdis->hDC, 0, 0, hIcon);
return TRUE;
}
case WM_COMMAND :
{
switch (wParam)
{
case IDC_ADDFROMLANGEXT_BUTTON :
{
writeNppPath();
TCHAR ext2Add[extNameMax] = TEXT("");
if (!_isCustomize)
{
int index2Add = ::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_GETCURSEL, 0, 0);
::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_GETTEXT, index2Add, (LPARAM)ext2Add);
addExt(ext2Add);
::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_DELETESTRING, index2Add, 0);
}
else
{
::SendDlgItemMessage(_hSelf, IDC_CUSTOMEXT_EDIT, WM_GETTEXT, extNameMax, (LPARAM)ext2Add);
int i = ::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_FINDSTRINGEXACT, 0, (LPARAM)ext2Add);
if (i != LB_ERR)
return TRUE;
addExt(ext2Add);
::SendDlgItemMessage(_hSelf, IDC_CUSTOMEXT_EDIT, WM_SETTEXT, 0, (LPARAM)TEXT(""));
}
::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_ADDSTRING, 0, (LPARAM)ext2Add);
::EnableWindow(::GetDlgItem(_hSelf, IDC_ADDFROMLANGEXT_BUTTON), false);
return TRUE;
}
case IDC_REMOVEEXT_BUTTON :
{
TCHAR ext2Sup[extNameMax] = TEXT("");
int index2Sup = ::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_GETCURSEL, 0, 0);
::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_GETTEXT, index2Sup, (LPARAM)ext2Sup);
if (deleteExts(ext2Sup))
::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_DELETESTRING, index2Sup, 0);
int langIndex = ::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANG_LIST, LB_GETCURSEL, 0, 0);
::EnableWindow(::GetDlgItem(_hSelf, IDC_REMOVEEXT_BUTTON), false);
if (langIndex != LB_ERR)
{
for (int i = 1 ; i < nbExtMax ; i++)
{
if (!generic_stricmp(ext2Sup, defExtArray[langIndex][i]))
{
::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_ADDSTRING, 0, (LPARAM)ext2Sup);
return TRUE;
}
}
}
return TRUE;
}
case IDCANCEL :
::EndDialog(_hSelf, 0);
return TRUE;
}
if (HIWORD(wParam) == EN_CHANGE)
{
TCHAR text[extNameMax] = TEXT("");
::SendDlgItemMessage(_hSelf, IDC_CUSTOMEXT_EDIT, WM_GETTEXT, extNameMax, (LPARAM)text);
if ((lstrlen(text) == 1) && (text[0] != '.'))
{
text[1] = text[0];
text[0] = '.';
text[2] = '\0';
::SendDlgItemMessage(_hSelf, IDC_CUSTOMEXT_EDIT, WM_SETTEXT, 0, (LPARAM)text);
::SendDlgItemMessage(_hSelf, IDC_CUSTOMEXT_EDIT, EM_SETSEL, 2, 2);
}
::EnableWindow(::GetDlgItem(_hSelf, IDC_ADDFROMLANGEXT_BUTTON), (lstrlen(text) > 1));
return TRUE;
}
if (HIWORD(wParam) == LBN_SELCHANGE)
{
int i = ::SendDlgItemMessage(_hSelf, LOWORD(wParam), LB_GETCURSEL, 0, 0);
if (LOWORD(wParam) == IDC_REGEXT_LANG_LIST)
{
if (i != LB_ERR)
{
TCHAR itemName[32];
::SendDlgItemMessage(_hSelf, LOWORD(wParam), LB_GETTEXT, i, (LPARAM)itemName);
if (!generic_stricmp(defExtArray[nbSupportedLang-1][0], itemName))
{
::ShowWindow(::GetDlgItem(_hSelf, IDC_REGEXT_LANGEXT_LIST), SW_HIDE);
::ShowWindow(::GetDlgItem(_hSelf, IDC_CUSTOMEXT_EDIT), SW_SHOW);
_isCustomize = true;
}
else
{
if (_isCustomize)
{
::ShowWindow(::GetDlgItem(_hSelf, IDC_REGEXT_LANGEXT_LIST), SW_SHOW);
::ShowWindow(::GetDlgItem(_hSelf, IDC_CUSTOMEXT_EDIT), SW_HIDE);
_isCustomize = false;
}
int count = ::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_GETCOUNT, 0, 0);
for (count -= 1 ; count >= 0 ; count--)
::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_DELETESTRING, count, 0);
for (int j = 1 ; j < nbExtMax ; j++)
if (lstrcmp(TEXT(""), defExtArray[i][j]))
{
int index = ::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_FINDSTRINGEXACT, 0, (LPARAM)defExtArray[i][j]);
if (index == -1)
::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_ADDSTRING, 0, (LPARAM)defExtArray[i][j]);
}
}
::EnableWindow(::GetDlgItem(_hSelf, IDC_ADDFROMLANGEXT_BUTTON), false);
}
}
else if (LOWORD(wParam) == IDC_REGEXT_LANGEXT_LIST)
{
if (i != LB_ERR)
::EnableWindow(::GetDlgItem(_hSelf, IDC_ADDFROMLANGEXT_BUTTON), true);
}
else if (LOWORD(wParam) == IDC_REGEXT_REGISTEREDEXTS_LIST)
{
if (i != LB_ERR)
::EnableWindow(::GetDlgItem(_hSelf, IDC_REMOVEEXT_BUTTON), true);
}
}
}
default :
return FALSE;
}
//return FALSE;
}
void RegExtDlg::getRegisteredExts()
{
int nbRegisteredKey = getNbSubKey(HKEY_CLASSES_ROOT);
for (int i = 0 ; i < nbRegisteredKey ; i++)
{
TCHAR extName[extNameLen];
//FILETIME fileTime;
int extNameActualLen = extNameLen;
int res = ::RegEnumKeyEx(HKEY_CLASSES_ROOT, i, extName, (LPDWORD)&extNameActualLen, NULL, NULL, NULL, NULL);
if ((res == ERROR_SUCCESS) && (extName[0] == '.'))
{
//TCHAR valName[extNameLen];
TCHAR valData[extNameLen];
int valDataLen = extNameLen * sizeof(TCHAR);
int valType;
HKEY hKey2Check;
extNameActualLen = extNameLen;
::RegOpenKeyEx(HKEY_CLASSES_ROOT, extName, 0, KEY_ALL_ACCESS, &hKey2Check);
::RegQueryValueEx(hKey2Check, TEXT(""), NULL, (LPDWORD)&valType, (LPBYTE)valData, (LPDWORD)&valDataLen);
//::RegEnumValue(hKey2Check, 0, valName, (LPDWORD)&extNameActualLen, NULL, (LPDWORD)&valType, (LPBYTE)valData, (LPDWORD)&valDataLen);
if ((valType == REG_SZ) && (!lstrcmp(valData, nppName)))
::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_ADDSTRING, 0, (LPARAM)extName);
::RegCloseKey(hKey2Check);
}
}
}
void RegExtDlg::getDefSupportedExts()
{
for (int i = 0 ; i < nbSupportedLang ; i++)
::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANG_LIST, LB_ADDSTRING, 0, (LPARAM)defExtArray[i][0]);
}
void RegExtDlg::addExt(TCHAR *ext)
{
HKEY hKey;
DWORD dwDisp;
long nRet;
nRet = ::RegCreateKeyEx(HKEY_CLASSES_ROOT,
ext,
0,
NULL,
0,
KEY_ALL_ACCESS,
NULL,
&hKey,
&dwDisp);
if (nRet == ERROR_SUCCESS)
{
TCHAR valData[MAX_PATH];
int valDataLen = MAX_PATH * sizeof(TCHAR);
if (dwDisp == REG_OPENED_EXISTING_KEY)
{
int res = ::RegQueryValueEx(hKey, TEXT(""), NULL, NULL, (LPBYTE)valData, (LPDWORD)&valDataLen);
if (res == ERROR_SUCCESS)
::RegSetValueEx(hKey, nppBackup, 0, REG_SZ, (LPBYTE)valData, valDataLen);
}
::RegSetValueEx(hKey, NULL, 0, REG_SZ, (LPBYTE)nppName, (lstrlen(nppName)+1)*sizeof(TCHAR));
::RegCloseKey(hKey);
}
}
bool RegExtDlg::deleteExts(const TCHAR *ext2Delete)
{
HKEY hKey;
::RegOpenKeyEx(HKEY_CLASSES_ROOT, ext2Delete, 0, KEY_ALL_ACCESS, &hKey);
int nbValue = getNbSubValue(hKey);
int nbSubkey = getNbSubKey(hKey);
if ((nbValue <= 1) && (!nbSubkey))
{
TCHAR subKey[32] = TEXT("\\");
lstrcat(subKey, ext2Delete);
::RegDeleteKey(HKEY_CLASSES_ROOT, subKey);
}
else
{
TCHAR valData[extNameLen];
int valDataLen = extNameLen*sizeof(TCHAR);
int valType;
int res = ::RegQueryValueEx(hKey, nppBackup, NULL, (LPDWORD)&valType, (LPBYTE)valData, (LPDWORD)&valDataLen);
if (res == ERROR_SUCCESS)
{
::RegSetValueEx(hKey, NULL, 0, valType, (LPBYTE)valData, valDataLen);
::RegDeleteValue(hKey, nppBackup);
}
else
::RegDeleteValue(hKey, NULL);
}
return true;
}
void RegExtDlg::writeNppPath()
{
HKEY hKey, hRootKey;
DWORD dwDisp;
long nRet;
TCHAR regStr[MAX_PATH] = TEXT("");
lstrcat(lstrcat(regStr, nppName), TEXT("\\shell\\open\\command"));
nRet = ::RegCreateKeyEx(
HKEY_CLASSES_ROOT,
regStr,
0,
NULL,
0,
KEY_ALL_ACCESS,
NULL,
&hKey,
&dwDisp);
if (nRet == ERROR_SUCCESS)
{
//if (dwDisp == REG_CREATED_NEW_KEY)
{
// Write the value for new document
::RegOpenKeyEx(HKEY_CLASSES_ROOT, nppName, 0, KEY_ALL_ACCESS, &hRootKey);
::RegSetValueEx(hRootKey, NULL, 0, REG_SZ, (LPBYTE)nppDoc, (lstrlen(nppDoc)+1)*sizeof(TCHAR));
RegCloseKey(hRootKey);
TCHAR nppPath[MAX_PATH];
::GetModuleFileName(_hInst, nppPath, MAX_PATH);
TCHAR nppPathParam[256] = TEXT("\"");
lstrcat(lstrcat(nppPathParam, nppPath), TEXT("\" \"%1\""));
::RegSetValueEx(hKey, NULL, 0, REG_SZ, (LPBYTE)nppPathParam, (lstrlen(nppPathParam)+1)*sizeof(TCHAR));
}
RegCloseKey(hKey);
}
//Set default icon value
lstrcpy(regStr, nppName);
lstrcat(regStr, TEXT("\\DefaultIcon"));
nRet = ::RegCreateKeyEx(
HKEY_CLASSES_ROOT,
regStr,
0,
NULL,
0,
KEY_ALL_ACCESS,
NULL,
&hKey,
&dwDisp);
if (nRet == ERROR_SUCCESS)
{
//if (dwDisp == REG_CREATED_NEW_KEY)
{
TCHAR nppPath[MAX_PATH];
::GetModuleFileName(_hInst, nppPath, MAX_PATH);
TCHAR nppPathParam[256] = TEXT("\"");
lstrcat(lstrcat(nppPathParam, nppPath), TEXT("\",0"));
::RegSetValueEx(hKey, NULL, 0, REG_SZ, (LPBYTE)nppPathParam, (lstrlen(nppPathParam)+1)*sizeof(TCHAR));
}
RegCloseKey(hKey);
}
}

View File

@ -0,0 +1,60 @@
/*
this file is part of notepad++
Copyright (C)2003 Don HO ( donho@altern.org )
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef REG_EXT_DLG_H
#define REG_EXT_DLG_H
#include "StaticDialog.h"
#include "regExtDlgRc.h"
const int extNameLen = 32;
class RegExtDlg : public StaticDialog
{
public :
RegExtDlg() : _isCustomize(false){};
~RegExtDlg(){};
void doDialog(bool isRTL = false);
private :
bool _isCustomize;
BOOL CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam);
void getRegisteredExts();
void getDefSupportedExts();
void addExt(TCHAR *ext);
bool deleteExts(const TCHAR *ext2Delete);
void writeNppPath();
int getNbSubKey(HKEY hKey) const {
int nbSubKey;
long result = ::RegQueryInfoKey(hKey, NULL, NULL, NULL, (LPDWORD)&nbSubKey, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
return (result == ERROR_SUCCESS)?nbSubKey:0;
};
int getNbSubValue(HKEY hKey) const {
int nbSubValue;
long result = ::RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, NULL, NULL, (LPDWORD)&nbSubValue, NULL, NULL, NULL, NULL);
return (result == ERROR_SUCCESS)?nbSubValue:0;
};
};
#endif //REG_EXT_DLG_H

View File

@ -0,0 +1,39 @@
/*
this file is part of notepad++
Copyright (C)2003 Don HO ( donho@altern.org )
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <windows.h>
#include "regExtDlgRc.h"
IDD_REGEXT_BOX DIALOGEX 0, 0, 370, 180
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1
BEGIN
LISTBOX IDC_REGEXT_LANGEXT_LIST,141,31,29,122,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP
LISTBOX IDC_REGEXT_REGISTEREDEXTS_LIST,211,30,48,123,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "->",IDC_ADDFROMLANGEXT_BUTTON,178,87,26,14
EDITTEXT IDC_CUSTOMEXT_EDIT,141,87,30,14,ES_AUTOHSCROLL | NOT WS_VISIBLE
PUSHBUTTON "->",IDC_REMOVEEXT_BUTTON,266,86,26,14
CONTROL "",IDC_POUPELLE_STATIC,"Static",SS_OWNERDRAW,301,82,20,20
LTEXT "Supported exts :",IDC_SUPPORTEDEXTS_STATIC,73,18,77,8
LTEXT "Registered exts :",IDC_REGISTEREDEXTS_STATIC,212,18,72,8
LISTBOX IDC_REGEXT_LANG_LIST,73,31,63,122,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP
END

View File

@ -0,0 +1,35 @@
/*
this file is part of notepad++
Copyright (C)2003 Don HO ( donho@altern.org )
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef REGEXTDLGRC_H
#define REGEXTDLGRC_H
#define IDD_REGEXT_BOX 4000
#define IDC_REGEXT_LANG_LIST (IDD_REGEXT_BOX + 1)
#define IDC_REGEXT_LANGEXT_LIST (IDD_REGEXT_BOX + 2)
#define IDC_REGEXT_REGISTEREDEXTS_LIST (IDD_REGEXT_BOX + 3)
#define IDC_ADDFROMLANGEXT_BUTTON (IDD_REGEXT_BOX + 4)
#define IDI_POUPELLE_ICON (IDD_REGEXT_BOX + 5)
#define IDC_CUSTOMEXT_EDIT (IDD_REGEXT_BOX + 6)
#define IDC_REMOVEEXT_BUTTON (IDD_REGEXT_BOX + 7)
#define IDC_POUPELLE_STATIC (IDD_REGEXT_BOX + 8)
#define IDC_SUPPORTEDEXTS_STATIC (IDD_REGEXT_BOX + 9)
#define IDC_REGISTEREDEXTS_STATIC (IDD_REGEXT_BOX + 10)
#endif //REGEXTDLGRC_H

View File

@ -0,0 +1,112 @@
//Copyright (C)2003 Don HO ( donho@altern.org )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#ifndef _CRC16_H_
#define _CRC16_H_
#include <assert.h>
class CRC16_ISO_3309
{
public :
CRC16_ISO_3309(unsigned short polynom = 0x1021, unsigned short initVal = 0xFFFF)
:_polynom(polynom), _initVal(initVal) {};
~CRC16_ISO_3309(){};
void set(unsigned short polynom, unsigned short initVal) {
_polynom = polynom;
_initVal = initVal;
};
unsigned short calculate(unsigned char *data, unsigned short count)
{
unsigned short fcs = _initVal;
unsigned short d, i, k;
for (i=0; i<count; i++)
{
d = *data++ << 8;
for (k=0; k<8; k++)
{
if ((fcs ^ d) & 0x8000)
fcs = (fcs << 1) ^ _polynom;
else
fcs = (fcs << 1);
d <<= 1;
}
}
return(fcs);
}
private :
unsigned short _polynom;
unsigned short _initVal;
};
const bool bits8 = true;
const bool bits16 = false;
class CRC16 : public CRC16_ISO_3309
{
public:
CRC16(){};
~CRC16(){};
unsigned short calculate(const unsigned char *data, unsigned short count)
{
assert(data != NULL);
assert(count != 0);
//unsigned short wordResult;
unsigned char *pBuffer = new unsigned char[count];
// Reverse all bits of the byte then copy the result byte by byte in the array
for (int i = 0 ; i < count ; i++)
pBuffer[i] = reverseByte<unsigned char>(data[i]);
// calculate CRC : by default polynom = 0x1021, init val = 0xFFFF)
unsigned short wordResult = CRC16_ISO_3309::calculate(pBuffer, count);
// Reverse the WORD bits
wordResult = reverseByte<unsigned short>(wordResult);
// XOR FFFF
wordResult ^= 0xFFFF;
// Invert MSB/LSB
wordResult = wordResult << 8 | wordResult >> 8 ;
delete [] pBuffer;
return wordResult;
};
private:
template <class IntType>
IntType reverseByte(IntType val2Reverses)
{
IntType reversedValue = 0;
long mask = 1;
int nBits = sizeof(val2Reverses) * 8;
for (int i = 0 ; i < nBits ; i++)
if ((mask << i) & val2Reverses)
reversedValue += (mask << (nBits - 1 - i));
return reversedValue;
};
};
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,839 @@
//this file is part of notepad++
//Copyright (C)2003 Don HO ( donho@altern.org )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#ifndef NOTEPAD_PLUS_H
#define NOTEPAD_PLUS_H
#include <window.h>
#include "Window.h"
#include "ScintillaEditView.h"
#include "ToolBar.h"
#include "ImageListSet.h"
#include "DocTabView.h"
#include "StaticDialog.h"
#include "SplitterContainer.h"
#include "FindReplaceDlg.h"
#include "AboutDlg.h"
#include "RunDlg.h"
#include "UserDefineDialog.h"
#include "StatusBar.h"
#include "Parameters.h"
#include "lastRecentFileList.h"
#include "GoToLineDlg.h"
#include "columnEditor.h"
#include "WordStyleDlg.h"
//#include "constant.h"
#include "trayIconControler.h"
#include "ContextMenu.h"
#include "PluginsManager.h"
#include "Notepad_plus_msgs.h"
#include "preferenceDlg.h"
#include "WindowsDlg.h"
#include "RunMacroDlg.h"
#include "DockingManager.h"
#include "Process.h"
#include "AutoCompletion.h"
#include "Buffer.h"
#include "SmartHighlighter.h"
#define MENU 0x01
#define TOOLBAR 0x02
enum FileTransferMode {
TransferClone = 0x01,
TransferMove = 0x02
};
enum WindowStatus { //bitwise mask
WindowMainActive = 0x01,
WindowSubActive = 0x02,
WindowBothActive = 0x03, //little helper shortcut
WindowUserActive = 0x04,
WindowMask = 0x07
};
/*
//Plugins rely on #define's
enum Views {
MAIN_VIEW = 0x00,
SUB_VIEW = 0x01
};
*/
struct TaskListInfo;
static TiXmlNodeA * searchDlgNode(TiXmlNodeA *node, const char *dlgTagName);
struct iconLocator {
int listIndex;
int iconIndex;
std::generic_string iconLocation;
iconLocator(int iList, int iIcon, const std::generic_string iconLoc)
: listIndex(iList), iconIndex(iIcon), iconLocation(iconLoc){};
};
struct VisibleGUIConf {
bool isPostIt;
bool isFullScreen;
//Used by both views
bool isMenuShown;
//bool isToolbarShown; //toolbar forcefully hidden by hiding rebar
DWORD_PTR preStyle;
//used by postit only
bool isTabbarShown;
bool isAlwaysOnTop;
bool isStatusbarShown;
//used by fullscreen only
WINDOWPLACEMENT _winPlace;
VisibleGUIConf() : isPostIt(false), isFullScreen(false),
isAlwaysOnTop(false), isMenuShown(true), isTabbarShown(true),
isStatusbarShown(true), preStyle(WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN)
{
_winPlace.length = 0;
};
};
class FileDialog;
class Notepad_plus : public Window {
enum comment_mode {cm_comment, cm_uncomment, cm_toggle};
public:
Notepad_plus();
virtual inline ~Notepad_plus();
void init(HINSTANCE, HWND, const TCHAR *cmdLine, CmdLineParams *cmdLineParams);
inline void killAllChildren();
virtual inline void destroy();
static const TCHAR * Notepad_plus::getClassName() {
return _className;
};
void setTitle();
void getTaskListInfo(TaskListInfo *tli);
// For filtering the modeless Dialog message
inline bool isDlgsMsg(MSG *msg, bool unicodeSupported) const {
for (size_t i = 0; i < _hModelessDlgs.size(); i++)
{
if (unicodeSupported?(::IsDialogMessageW(_hModelessDlgs[i], msg)):(::IsDialogMessageA(_hModelessDlgs[i], msg)))
return true;
}
return false;
};
// fileOperations
//The doXXX functions apply to a single buffer and dont need to worry about views, with the excpetion of doClose, since closing one view doesnt have to mean the document is gone
BufferID doOpen(const TCHAR *fileName, bool isReadOnly = false);
bool doReload(BufferID id, bool alert = true);
bool doSave(BufferID, const TCHAR * filename, bool isSaveCopy = false);
void doClose(BufferID, int whichOne);
//bool doDelete(const TCHAR *fileName) const {return ::DeleteFile(fileName) != 0;};
inline void fileNew();
void fileOpen();
inline bool fileReload();
bool fileClose(BufferID id = BUFFER_INVALID, int curView = -1); //use curView to override view to close from
bool fileCloseAll();
bool fileCloseAllButCurrent();
bool fileSave(BufferID id = BUFFER_INVALID);
bool fileSaveAll();
bool fileSaveAs(BufferID id = BUFFER_INVALID, bool isSaveCopy = false);
bool fileDelete(BufferID id = BUFFER_INVALID, int curView = -1);
bool fileRename(BufferID id = BUFFER_INVALID, int curView = -1);
bool addBufferToView(BufferID id, int whichOne);
bool moveBuffer(BufferID id, int whereTo); //assumes whereFrom is otherView(whereTo)
bool switchToFile(BufferID buffer); //find buffer in active view then in other view.
// end fileOperations
bool isFileSession(const TCHAR * filename);
void filePrint(bool showDialog);
bool saveScintillaParams(bool whichOne);
inline bool saveGUIParams();
inline void saveDockingParams();
inline void saveUserDefineLangs();
inline void saveShortcuts();
inline void saveSession(const Session & session);
inline void saveFindHistory();
void getCurrentOpenedFiles(Session & session);
bool fileLoadSession(const TCHAR *fn = NULL);
const TCHAR * fileSaveSession(size_t nbFile, TCHAR ** fileNames, const TCHAR *sessionFile2save);
const TCHAR * fileSaveSession(size_t nbFile = 0, TCHAR ** fileNames = NULL);
bool changeDlgLang(HWND hDlg, const char *dlgTagName, char *title = NULL);
void changeFindReplaceDlgLang();
void changeConfigLang();
void changeUserDefineLang();
void changeMenuLang(generic_string & pluginsTrans, generic_string & windowTrans);
void changeLangTabContextMenu();
void changeLangTabDrapContextMenu();
void changePrefereceDlgLang();
void changeShortcutLang();
void changeShortcutmapperLang(ShortcutMapper * sm);
const TCHAR * getNativeTip(int btnID);
void changeToolBarIcons();
bool doBlockComment(comment_mode currCommentMode);
bool doStreamComment();
inline void doTrimTrailing();
inline HACCEL getAccTable() const{
return _accelerator.getAccTable();
};
bool addCurrentMacro();
inline void loadLastSession();
bool loadSession(Session & session);
winVer getWinVersion() const {return _winVersion;};
bool emergency(generic_string emergencySavedDir);
void notifyBufferChanged(Buffer * buffer, int mask);
bool findInFiles();
bool replaceInFiles();
void setFindReplaceFolderFilter(const TCHAR *dir, const TCHAR *filters);
static HWND gNppHWND; //static handle to Notepad++ window, NULL if non-existant
private:
static const TCHAR _className[32];
TCHAR _nppPath[MAX_PATH];
Window *_pMainWindow;
DockingManager _dockingManager;
AutoCompletion _autoCompleteMain;
AutoCompletion _autoCompleteSub; //each Scintilla has its own autoComplete
SmartHighlighter _smartHighlighter;
TiXmlNode *_toolIcons;
TiXmlNodeA *_nativeLangA;
int _nativeLangEncoding;
DocTabView _mainDocTab;
DocTabView _subDocTab;
DocTabView *_pDocTab;
DocTabView *_pNonDocTab;
ScintillaEditView _subEditView;
ScintillaEditView _mainEditView;
ScintillaEditView _invisibleEditView; //for searches
ScintillaEditView _fileEditView; //for FileManager
ScintillaEditView *_pEditView;
ScintillaEditView *_pNonEditView;
SplitterContainer *_pMainSplitter;
SplitterContainer _subSplitter;
ContextMenu _tabPopupMenu, _tabPopupDropMenu;
ToolBar _toolBar;
IconList _docTabIconList;
StatusBar _statusBar;
bool _toReduceTabBar;
ReBar _rebarTop;
ReBar _rebarBottom;
// Dialog
FindReplaceDlg _findReplaceDlg;
FindIncrementDlg _incrementFindDlg;
AboutDlg _aboutDlg;
RunDlg _runDlg;
GoToLineDlg _goToLineDlg;
ColumnEditorDlg _colEditorDlg;
WordStyleDlg _configStyleDlg;
PreferenceDlg _preference;
// a handle list of all the Notepad++ dialogs
vector<HWND> _hModelessDlgs;
LastRecentFileList _lastRecentFileList;
vector<iconLocator> _customIconVect;
WindowsMenu _windowsMenu;
HMENU _mainMenuHandle;
HMENU _menuLang;
HMENU _menuLangCompact;
bool _sysMenuEntering;
// For FullScreen/PostIt features
VisibleGUIConf _beforeSpecialView;
void fullScreenToggle();
void postItToggle();
// Keystroke macro recording and playback
Macro _macro;
bool _recordingMacro;
RunMacroDlg _runMacroDlg;
// For hotspot
bool _linkTriggered;
bool _isDocModifing;
bool _isHotspotDblClicked;
//For Dynamic selection highlight
CharacterRange _prevSelectedRange;
struct ActivateAppInfo {
bool _isActivated;
int _x;
int _y;
ActivateAppInfo() : _isActivated(false), _x(0), _y(0){};
} _activeAppInf;
//Synchronized Scolling
struct SyncInfo {
int _line;
int _column;
bool _isSynScollV;
bool _isSynScollH;
SyncInfo():_line(0), _column(0), _isSynScollV(false), _isSynScollH(false){};
bool doSync() const {return (_isSynScollV || _isSynScollH); };
} _syncInfo;
bool _isUDDocked;
trayIconControler *_pTrayIco;
int _zoomOriginalValue;
Accelerator _accelerator;
ScintillaAccelerator _scintaccelerator;
PluginsManager _pluginsManager;
bool _isRTL;
winVer _winVersion;
bool _isFileOpening;
class ScintillaCtrls {
public :
//ScintillaCtrls();
void init(HINSTANCE hInst, HWND hNpp) {
_hInst = hInst;
_hParent = hNpp;
};
HWND createSintilla(HWND hParent) {
_hParent = hParent;
ScintillaEditView *scint = new ScintillaEditView;
scint->init(_hInst, _hParent);
_scintVector.push_back(scint);
return scint->getHSelf();
};
bool destroyScintilla(HWND handle2Destroy) {
for (size_t i = 0 ; i < _scintVector.size() ; i++)
{
if (_scintVector[i]->getHSelf() == handle2Destroy)
{
_scintVector[i]->destroy();
delete _scintVector[i];
vector<ScintillaEditView *>::iterator it2delete = _scintVector.begin()+ i;
_scintVector.erase(it2delete);
return true;
}
}
return false;
};
void destroy() {
for (size_t i = 0 ; i < _scintVector.size() ; i++)
{
_scintVector[i]->destroy();
delete _scintVector[i];
}
};
private:
vector<ScintillaEditView *> _scintVector;
HINSTANCE _hInst;
HWND _hParent;
} _scintillaCtrls4Plugins;
vector<pair<int, int> > _hideLinesMarks;
static LRESULT CALLBACK Notepad_plus_Proc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);
LRESULT runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);
BOOL notify(SCNotification *notification);
void specialCmd(int id, int param);
void command(int id);
//Document management
UCHAR _mainWindowStatus; //For 2 views and user dialog if docked
int _activeView;
//User dialog docking
void dockUserDlg();
void undockUserDlg();
//View visibility
void showView(int whichOne);
bool viewVisible(int whichOne);
void hideView(int whichOne);
void hideCurrentView();
bool bothActive() { return (_mainWindowStatus & WindowBothActive) == WindowBothActive; };
bool reloadLang();
bool loadStyles();
int currentView(){
return _activeView;
};
int otherView(){
return (_activeView == MAIN_VIEW?SUB_VIEW:MAIN_VIEW);
};
int otherFromView(int whichOne){
return (whichOne == MAIN_VIEW?SUB_VIEW:MAIN_VIEW);
};
bool canHideView(int whichOne); //true if view can safely be hidden (no open docs etc)
int switchEditViewTo(int gid); //activate other view (set focus etc)
void docGotoAnotherEditView(FileTransferMode mode); //TransferMode
void docOpenInNewInstance(FileTransferMode mode, int x = 0, int y = 0);
void loadBufferIntoView(BufferID id, int whichOne, bool dontClose = false); //Doesnt _activate_ the buffer
void removeBufferFromView(BufferID id, int whichOne); //Activates alternative of possible, or creates clean document if not clean already
bool activateBuffer(BufferID id, int whichOne); //activate buffer in that view if found
void notifyBufferActivated(BufferID bufid, int view);
void performPostReload(int whichOne);
//END: Document management
int doSaveOrNot(const TCHAR *fn) {
TCHAR pattern[64] = TEXT("Save file \"%s\" ?");
TCHAR phrase[512];
wsprintf(phrase, pattern, fn);
return doActionOrNot(TEXT("Save"), phrase, MB_YESNOCANCEL | MB_ICONQUESTION | MB_APPLMODAL);
};
int doReloadOrNot(const TCHAR *fn, bool dirty) {
TCHAR* pattern = TEXT("%s\r\rThis file has been modified by another program.\rDo you want to reload it%s?");
TCHAR* lose_info_str = dirty ? TEXT(" and lose the changes made in Notepad++") : TEXT("");
TCHAR phrase[512];
wsprintf(phrase, pattern, fn, lose_info_str);
int icon = dirty ? MB_ICONEXCLAMATION : MB_ICONQUESTION;
return doActionOrNot(TEXT("Reload"), phrase, MB_YESNO | MB_APPLMODAL | icon);
};
int doCloseOrNot(const TCHAR *fn) {
TCHAR pattern[128] = TEXT("The file \"%s\" doesn't exist anymore.\rKeep this file in editor?");
TCHAR phrase[512];
wsprintf(phrase, pattern, fn);
return doActionOrNot(TEXT("Keep non existing file"), phrase, MB_YESNO | MB_ICONQUESTION | MB_APPLMODAL);
};
int doDeleteOrNot(const TCHAR *fn) {
TCHAR pattern[128] = TEXT("The file \"%s\"\rwill be deleted from your disk and this document will be closed.\rContinue?");
TCHAR phrase[512];
wsprintf(phrase, pattern, fn);
return doActionOrNot(TEXT("Delete file"), phrase, MB_YESNO | MB_ICONQUESTION | MB_APPLMODAL);
};
int doActionOrNot(const TCHAR *title, const TCHAR *displayText, int type) {
return ::MessageBox(_hSelf, displayText, title, type);
};
void enableMenu(int cmdID, bool doEnable) const {
int flag = doEnable?MF_ENABLED | MF_BYCOMMAND:MF_DISABLED | MF_GRAYED | MF_BYCOMMAND;
::EnableMenuItem(_mainMenuHandle, cmdID, flag);
}
void enableCommand(int cmdID, bool doEnable, int which) const;
void checkClipboard();
void checkDocState();
void checkUndoState();
void checkMacroState();
void checkSyncState();
void dropFiles(HDROP hdrop);
void checkModifiedDocument();
void getMainClientRect(RECT & rc) const;
void dynamicCheckMenuAndTB() const;
void enableConvertMenuItems(formatType f) const {
enableCommand(IDM_FORMAT_TODOS, (f != WIN_FORMAT), MENU);
enableCommand(IDM_FORMAT_TOUNIX, (f != UNIX_FORMAT), MENU);
enableCommand(IDM_FORMAT_TOMAC, (f != MAC_FORMAT), MENU);
};
void checkUnicodeMenuItems(UniMode um) const;
generic_string getLangDesc(LangType langType, bool shortDesc = false);
void setLangStatus(LangType langType){
_statusBar.setText(getLangDesc(langType).c_str(), STATUSBAR_DOC_TYPE);
};
void setDisplayFormat(formatType f) {
std::generic_string str;
switch (f)
{
case MAC_FORMAT :
str = TEXT("MAC");
break;
case UNIX_FORMAT :
str = TEXT("UNIX");
break;
default :
str = TEXT("Dos\\Windows");
}
_statusBar.setText(str.c_str(), STATUSBAR_EOF_FORMAT);
};
void setUniModeText(UniMode um)
{
TCHAR *uniModeText;
switch (um)
{
case uniUTF8:
uniModeText = TEXT("UTF-8"); break;
case uni16BE:
uniModeText = TEXT("UCS-2 Big Endian"); break;
case uni16LE:
uniModeText = TEXT("UCS-2 little Endian"); break;
case uniCookie:
uniModeText = TEXT("ANSI as UTF-8"); break;
default :
uniModeText = TEXT("ANSI");
}
_statusBar.setText(uniModeText, STATUSBAR_UNICODE_TYPE);
};
void checkLangsMenu(int id) const ;
void setLanguage(int id, LangType langType);
enum LangType menuID2LangType(int cmdID);
int getFolderMarginStyle() const {
if (::GetMenuState(_mainMenuHandle, IDM_VIEW_FOLDERMAGIN_SIMPLE, MF_BYCOMMAND) == MF_CHECKED)
return IDM_VIEW_FOLDERMAGIN_SIMPLE;
if (::GetMenuState(_mainMenuHandle, IDM_VIEW_FOLDERMAGIN_ARROW, MF_BYCOMMAND) == MF_CHECKED)
return IDM_VIEW_FOLDERMAGIN_ARROW;
if (::GetMenuState(_mainMenuHandle, IDM_VIEW_FOLDERMAGIN_CIRCLE, MF_BYCOMMAND) == MF_CHECKED)
return IDM_VIEW_FOLDERMAGIN_CIRCLE;
if (::GetMenuState(_mainMenuHandle, IDM_VIEW_FOLDERMAGIN_BOX, MF_BYCOMMAND) == MF_CHECKED)
return IDM_VIEW_FOLDERMAGIN_BOX;
return 0;
};
void checkFolderMarginStyleMenu(int id2Check) const {
::CheckMenuRadioItem(_mainMenuHandle, IDM_VIEW_FOLDERMAGIN_SIMPLE, IDM_VIEW_FOLDERMAGIN_BOX, id2Check, MF_BYCOMMAND);
};
int getFolderMaginStyleIDFrom(folderStyle fStyle) const {
switch (fStyle)
{
case FOLDER_STYLE_SIMPLE : return IDM_VIEW_FOLDERMAGIN_SIMPLE;
case FOLDER_STYLE_ARROW : return IDM_VIEW_FOLDERMAGIN_ARROW;
case FOLDER_STYLE_CIRCLE : return IDM_VIEW_FOLDERMAGIN_CIRCLE;
case FOLDER_STYLE_BOX : return IDM_VIEW_FOLDERMAGIN_BOX;
default : return FOLDER_TYPE;
}
//return
};
void checkMenuItem(int itemID, bool willBeChecked) const {
::CheckMenuItem(_mainMenuHandle, itemID, MF_BYCOMMAND | (willBeChecked?MF_CHECKED:MF_UNCHECKED));
};
void charAdded(TCHAR chAdded);
void MaintainIndentation(TCHAR ch);
void addHotSpot(bool docIsModifing = false);
void bookmarkAdd(int lineno) const {
if (lineno == -1)
lineno = _pEditView->getCurrentLineNumber();
if (!bookmarkPresent(lineno))
_pEditView->execute(SCI_MARKERADD, lineno, MARK_BOOKMARK);
};
void bookmarkDelete(int lineno) const {
if (lineno == -1)
lineno = _pEditView->getCurrentLineNumber();
if ( bookmarkPresent(lineno))
_pEditView->execute(SCI_MARKERDELETE, lineno, MARK_BOOKMARK);
};
bool bookmarkPresent(int lineno) const {
if (lineno == -1)
lineno = _pEditView->getCurrentLineNumber();
LRESULT state = _pEditView->execute(SCI_MARKERGET, lineno);
return ((state & (1 << MARK_BOOKMARK)) != 0);
};
void bookmarkToggle(int lineno) const {
if (lineno == -1)
lineno = _pEditView->getCurrentLineNumber();
if (bookmarkPresent(lineno))
bookmarkDelete(lineno);
else
bookmarkAdd(lineno);
};
void bookmarkNext(bool forwardScan);
void bookmarkClearAll() const {
_pEditView->execute(SCI_MARKERDELETEALL, MARK_BOOKMARK);
};
void copyMarkedLines() {
int lastLine = _pEditView->lastZeroBasedLineNumber();
generic_string globalStr = TEXT("");
for (int i = lastLine ; i >= 0 ; i--)
{
if (bookmarkPresent(i))
{
generic_string currentStr = getMarkedLine(i) + globalStr;
globalStr = currentStr;
}
}
str2Cliboard(globalStr.c_str());
};
void cutMarkedLines() {
int lastLine = _pEditView->lastZeroBasedLineNumber();
generic_string globalStr = TEXT("");
_pEditView->execute(SCI_BEGINUNDOACTION);
for (int i = lastLine ; i >= 0 ; i--)
{
if (bookmarkPresent(i))
{
generic_string currentStr = getMarkedLine(i) + globalStr;
globalStr = currentStr;
deleteMarkedline(i);
}
}
_pEditView->execute(SCI_ENDUNDOACTION);
str2Cliboard(globalStr.c_str());
};
void deleteMarkedLines() {
int lastLine = _pEditView->lastZeroBasedLineNumber();
_pEditView->execute(SCI_BEGINUNDOACTION);
for (int i = lastLine ; i >= 0 ; i--)
{
if (bookmarkPresent(i))
deleteMarkedline(i);
}
_pEditView->execute(SCI_ENDUNDOACTION);
};
void pasteToMarkedLines() {
int clipFormat;
#ifdef UNICODE
clipFormat = CF_UNICODETEXT;
#else
clipFormat = CF_TEXT;
#endif
BOOL canPaste = ::IsClipboardFormatAvailable(clipFormat);
if (!canPaste)
return;
int lastLine = _pEditView->lastZeroBasedLineNumber();
::OpenClipboard(_hSelf);
HANDLE clipboardData = ::GetClipboardData(clipFormat);
int len = ::GlobalSize(clipboardData);
LPVOID clipboardDataPtr = ::GlobalLock(clipboardData);
generic_string clipboardStr = (const TCHAR *)clipboardDataPtr;
::GlobalUnlock(clipboardData);
::CloseClipboard();
_pEditView->execute(SCI_BEGINUNDOACTION);
for (int i = lastLine ; i >= 0 ; i--)
{
if (bookmarkPresent(i))
{
replaceMarkedline(i, clipboardStr.c_str());
}
}
_pEditView->execute(SCI_ENDUNDOACTION);
};
void deleteMarkedline(int ln) {
int lineLen = _pEditView->execute(SCI_LINELENGTH, ln);
int lineBegin = _pEditView->execute(SCI_POSITIONFROMLINE, ln);
bookmarkDelete(ln);
TCHAR emptyString[2] = TEXT("");
_pEditView->replaceTarget(emptyString, lineBegin, lineBegin + lineLen);
};
void replaceMarkedline(int ln, const TCHAR *str) {
int lineBegin = _pEditView->execute(SCI_POSITIONFROMLINE, ln);
int lineEnd = _pEditView->execute(SCI_GETLINEENDPOSITION, ln);
_pEditView->replaceTarget(str, lineBegin, lineEnd);
};
generic_string getMarkedLine(int ln) {
int lineLen = _pEditView->execute(SCI_LINELENGTH, ln);
int lineBegin = _pEditView->execute(SCI_POSITIONFROMLINE, ln);
TCHAR * buf = new TCHAR[lineLen+1];
_pEditView->getGenericText(buf, lineBegin, lineBegin + lineLen);
generic_string line = buf;
delete [] buf;
return line;
};
void findMatchingBracePos(int & braceAtCaret, int & braceOpposite);
void braceMatch();
void activateNextDoc(bool direction);
void activateDoc(int pos);
void updateStatusBar();
void showAutoComp();
void autoCompFromCurrentFile(bool autoInsert = true);
void showFunctionComp();
void changeStyleCtrlsLang(HWND hDlg, int *idArray, const char **translatedText);
bool replaceAllFiles();
bool findInOpenedFiles();
bool findInCurrentFile();
bool matchInList(const TCHAR *fileName, const vector<generic_string> & patterns);
void getMatchedFileNames(const TCHAR *dir, const vector<generic_string> & patterns, vector<generic_string> & fileNames, bool isRecursive, bool isInHiddenDir);
void doSynScorll(HWND hW);
void setWorkingDir(TCHAR *dir) {
NppParameters * params = NppParameters::getInstance();
if (params->getNppGUI()._openSaveDir == dir_last)
return;
if (params->getNppGUI()._openSaveDir == dir_userDef)
{
params->setWorkingDir(NULL);
}
else if (dir && PathIsDirectory(dir))
{
params->setWorkingDir(dir);
}
}
bool str2Cliboard(const TCHAR *str2cpy);
bool bin2Cliboard(const UCHAR *uchar2cpy, size_t length);
bool getIntegralDockingData(tTbData & dockData, int & iCont, bool & isVisible);
int getLangFromMenuName(const TCHAR * langName) {
int id = 0;
const int menuSize = 64;
TCHAR menuLangName[menuSize];
for ( int i = IDM_LANG_C; i <= IDM_LANG_USER; i++ )
if ( ::GetMenuString( _mainMenuHandle, i, menuLangName, menuSize, MF_BYCOMMAND ) )
if ( !lstrcmp( langName, menuLangName ) )
{
id = i;
break;
}
if ( id == 0 )
{
for ( int i = IDM_LANG_USER + 1; i <= IDM_LANG_USER_LIMIT; i++ )
if ( ::GetMenuString( _mainMenuHandle, i, menuLangName, menuSize, MF_BYCOMMAND ) )
if ( !lstrcmp( langName, menuLangName ) )
{
id = i;
break;
}
}
return id;
};
generic_string getLangFromMenu(const Buffer * buf) {
int id;
const TCHAR * userLangName;
TCHAR menuLangName[32];
id = (NppParameters::getInstance())->langTypeToCommandID( buf->getLangType() );
if ( ( id != IDM_LANG_USER ) || !( buf->isUserDefineLangExt() ) )
{
( ::GetMenuString( _mainMenuHandle, id, menuLangName, sizeof( menuLangName ), MF_BYCOMMAND ) );
userLangName = (TCHAR *)menuLangName;
}
else
{
userLangName = buf->getUserDefineLangName();
}
return userLangName;
};
void setFileOpenSaveDlgFilters(FileDialog & fDlg);
void markSelectedTextInc(bool enable);
Style * getStyleFromName(const TCHAR *styleName) {
StyleArray & stylers = (NppParameters::getInstance())->getMiscStylerArray();
int i = stylers.getStylerIndexByName(styleName);
Style * st = NULL;
if (i != -1)
{
Style & style = stylers.getStyler(i);
st = &style;
}
return st;
};
bool dumpFiles(const TCHAR * outdir, const TCHAR * fileprefix = TEXT("")); //helper func
void drawTabbarColoursFromStylerArray();
void loadCommandlineParams(const TCHAR * commandLine, CmdLineParams * pCmdParams);
bool noOpenedDoc() const {
if (_mainDocTab.isVisible() && _subDocTab.isVisible())
return false;
if (_pDocTab->nbItem() == 1)
{
BufferID buffer = _pDocTab->getBufferByIndex(0);
Buffer * buf = MainFileManager->getBufferByID(buffer);
if (!buf->isDirty() && buf->isUntitled())
return true;
}
return false;
};
};
#endif //NOTEPAD_PLUS_H

View File

@ -0,0 +1,622 @@
/*
this file is part of notepad++
Copyright (C)2003 Don HO ( donho@altern.org )
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <windows.h>
#include "resource.h"
#include "menuCmdID.h"
VS_VERSION_INFO VERSIONINFO
FILEVERSION VERSION_DIGITALVALUE
PRODUCTVERSION VERSION_DIGITALVALUE
FILEFLAGSMASK 0x3fL
FILEFLAGS 0
FILEOS VOS_NT_WINDOWS32
FILETYPE VFT_APP
FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "Don HO don.h@free.fr\0"
VALUE "FileDescription", "Notepad++ : a free (GNU) source code editor\0"
VALUE "FileVersion", VERSION_VALUE
VALUE "InternalName", "npp.exe\0"
VALUE "LegalCopyright", "Copyleft 1998-2006 by Don HO\0"
VALUE "OriginalFilename", "Notepad++.exe\0"
VALUE "ProductName", "Notepad++\0"
VALUE "ProductVersion", VERSION_VALUE
END
END
END
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_M30ICON ICON "icons\\npp.ico"
IDI_NEW_OFF_ICON ICON "icons\\new_off.ico"
IDI_OPEN_OFF_ICON ICON "icons\\open_off.ico"
IDI_SAVE_OFF_ICON ICON "icons\\save_off.ico"
IDI_SAVEALL_OFF_ICON ICON "icons\\saveall_off.ico"
IDI_CLOSE_OFF_ICON ICON "icons\\supp_off.ico"
IDI_CLOSEALL_OFF_ICON ICON "icons\\suppall_off.ico"
IDI_CUT_OFF_ICON ICON "icons\\cut_off.ico"
IDI_COPY_OFF_ICON ICON "icons\\dupli_off.ico"
IDI_PASTE_OFF_ICON ICON "icons\\paste_off.ico"
IDI_UNDO_OFF_ICON ICON "icons\\undo_off.ico"
IDI_REDO_OFF_ICON ICON "icons\\redo_off.ico"
IDI_FIND_OFF_ICON ICON "icons\\find_off.ico"
IDI_REPLACE_OFF_ICON ICON "icons\\findrep_off.ico"
IDI_ZOOMIN_OFF_ICON ICON "icons\\zoomIn_off.ico"
IDI_ZOOMOUT_OFF_ICON ICON "icons\\zoomOut_off.ico"
IDI_VIEW_UD_DLG_OFF_ICON ICON "icons\\userDefineDlg_off.ico"
IDI_VIEW_ALL_CHAR_OFF_ICON ICON "icons\\allChars_off.ico"
IDI_VIEW_INDENT_OFF_ICON ICON "icons\\indentGuide_off.ico"
IDI_VIEW_WRAP_OFF_ICON ICON "icons\\wrap_off.ico"
IDI_PRINT_OFF_ICON ICON "icons\\imprim_off.ico"
IDI_NEW_ON_ICON ICON "icons\\new_on.ico"
IDI_OPEN_ON_ICON ICON "icons\\open_on.ico"
IDI_SAVE_ON_ICON ICON "icons\\save_on.ico"
IDI_SAVEALL_ON_ICON ICON "icons\\saveall_on.ico"
IDI_CLOSE_ON_ICON ICON "icons\\supp_on.ico"
IDI_CLOSEALL_ON_ICON ICON "icons\\suppall_on.ico"
IDI_CUT_ON_ICON ICON "icons\\cut_on.ico"
IDI_COPY_ON_ICON ICON "icons\\dupli_on.ico"
IDI_PASTE_ON_ICON ICON "icons\\paste_on.ico"
IDI_UNDO_ON_ICON ICON "icons\\undo_on.ico"
IDI_REDO_ON_ICON ICON "icons\\redo_on.ico"
IDI_FIND_ON_ICON ICON "icons\\find_on.ico"
IDI_REPLACE_ON_ICON ICON "icons\\findrep_on.ico"
IDI_ZOOMIN_ON_ICON ICON "icons\\zoomIn_on.ico"
IDI_ZOOMOUT_ON_ICON ICON "icons\\zoomOut_on.ico"
IDI_VIEW_UD_DLG_ON_ICON ICON "icons\\userDefineDlg_on.ico"
IDI_VIEW_ALL_CHAR_ON_ICON ICON "icons\\allChars_on.ico"
IDI_VIEW_INDENT_ON_ICON ICON "icons\\indentGuide_on.ico"
IDI_VIEW_WRAP_ON_ICON ICON "icons\\wrap_on.ico"
IDI_PRINT_ON_ICON ICON "icons\\imprim_on.ico"
IDI_SAVE_DISABLE_ICON ICON "icons\\save_dis.ico"
IDI_SAVEALL_DISABLE_ICON ICON "icons\\saveall_dis.ico"
IDI_CUT_DISABLE_ICON ICON "icons\\cut_dis.ico"
IDI_COPY_DISABLE_ICON ICON "icons\\dupli_dis.ico"
IDI_PASTE_DISABLE_ICON ICON "icons\\paste_dis.ico"
IDI_UNDO_DISABLE_ICON ICON "icons\\undo_dis.ico"
IDI_REDO_DISABLE_ICON ICON "icons\\redo_dis.ico"
//
IDI_SAVED_ICON ICON "icons\\saved.ico"
IDI_UNSAVED_ICON ICON "icons\\unsaved.ico"
IDI_READONLY_ICON ICON "icons\\readonly.ico"
IDI_DELETE_ICON ICON "icons\\delete.ico"
IDI_FIND_RESULT_ICON ICON "icons\\findResult.ico"
IDC_DRAG_TAB CURSOR "cursors\\drag.cur"
IDC_DRAG_INTERDIT_TAB CURSOR "cursors\\drag_interdit.cur"
IDC_DRAG_PLUS_TAB CURSOR "cursors\\drag_plus.cur"
IDC_DRAG_OUT_TAB CURSOR "cursors\\drag_out.cur"
IDR_FILENEW BITMAP "icons\\newFile.bmp"
IDR_FILEOPEN BITMAP "icons\\openFile.bmp"
IDR_FILESAVE BITMAP "icons\\saveFile.bmp"
IDR_SAVEALL BITMAP "icons\\saveAll.bmp"
IDR_CLOSEFILE BITMAP "icons\\closeFile.bmp"
IDR_CLOSEALL BITMAP "icons\\closeAll.bmp"
IDR_FIND BITMAP "icons\\find.bmp"
IDR_REPLACE BITMAP "icons\\findReplace.bmp"
IDR_ZOOMIN BITMAP "icons\\zoomIn.bmp"
IDR_ZOOMOUT BITMAP "icons\\zoomOut.bmp"
IDR_WRAP BITMAP "icons\\wrap.bmp"
IDR_INVISIBLECHAR BITMAP "icons\\invisibleChar.bmp"
IDR_INDENTGUIDE BITMAP "icons\\indentGuide.bmp"
IDR_SHOWPANNEL BITMAP "icons\\showPannel.bmp"
IDR_STARTRECORD BITMAP "icons\\startRecord.bmp"
IDR_STOPRECORD BITMAP "icons\\stopRecord.bmp"
IDR_PLAYRECORD BITMAP "icons\\playRecord.bmp"
IDR_M_PLAYRECORD BITMAP "icons\\playRecord_m.bmp"
IDR_SAVERECORD BITMAP "icons\\saveRecord.bmp"
IDR_CUT BITMAP "icons\\cut.bmp"
IDR_COPY BITMAP "icons\\copy.bmp"
IDR_PASTE BITMAP "icons\\paste.bmp"
IDR_UNDO BITMAP "icons\\undo.bmp"
IDR_REDO BITMAP "icons\\redo.bmp"
IDR_SYNCV BITMAP "icons\\syncV.bmp"
IDR_SYNCH BITMAP "icons\\syncH.bmp"
IDR_PRINT BITMAP "icons\\print.bmp"
IDR_CLOSETAB BITMAP "icons\\closeTabButton.bmp"
IDR_CLOSETAB_INACT BITMAP "icons\\closeTabButton_inact.bmp"
IDR_CLOSETAB_HOVER BITMAP "icons\\closeTabButton_hover.bmp"
IDR_CLOSETAB_PUSH BITMAP "icons\\closeTabButton_push.bmp"
IDI_STARTRECORD_OFF_ICON ICON "icons\\startrecord_off.ico"
IDI_STARTRECORD_ON_ICON ICON "icons\\startrecord_on.ico"
IDI_STARTRECORD_DISABLE_ICON ICON "icons\\startrecord_dis.ico"
IDI_STOPRECORD_OFF_ICON ICON "icons\\stoprecord_off.ico"
IDI_STOPRECORD_ON_ICON ICON "icons\\stoprecord_on.ico"
IDI_STOPRECORD_DISABLE_ICON ICON "icons\\stoprecord_dis.ico"
IDI_PLAYRECORD_OFF_ICON ICON "icons\\playrecord_off.ico"
IDI_PLAYRECORD_ON_ICON ICON "icons\\playrecord_on.ico"
IDI_PLAYRECORD_DISABLE_ICON ICON "icons\\playrecord_dis.ico"
IDI_SAVERECORD_OFF_ICON ICON "icons\\saverecord_off.ico"
IDI_SAVERECORD_ON_ICON ICON "icons\\saverecord_on.ico"
IDI_SAVERECORD_DISABLE_ICON ICON "icons\\saverecord_dis.ico"
IDI_SYNCV_OFF_ICON ICON "icons\\syncV_off.ico"
IDI_SYNCV_ON_ICON ICON "icons\\syncV_on.ico"
IDI_SYNCV_DISABLE_ICON ICON "icons\\syncV_dis.ico"
IDI_SYNCH_OFF_ICON ICON "icons\\syncH_off.ico"
IDI_SYNCH_ON_ICON ICON "icons\\syncH_on.ico"
IDI_SYNCH_DISABLE_ICON ICON "icons\\syncH_dis.ico"
// multi run macro
IDI_MMPLAY_DIS_ICON ICON "icons\\playrecord_m_dis.ico"
IDI_MMPLAY_OFF_ICON ICON "icons\\playrecord_m_off.ico"
IDI_MMPLAY_ON_ICON ICON "icons\\playrecord_m_on.ico"
IDR_M30_MENU MENU
BEGIN
POPUP "&File"
BEGIN
MENUITEM "&New", IDM_FILE_NEW
MENUITEM "&Open...", IDM_FILE_OPEN
MENUITEM "Re&load from Disk", IDM_FILE_RELOAD
MENUITEM "&Save", IDM_FILE_SAVE
MENUITEM "Save &As...", IDM_FILE_SAVEAS
MENUITEM "Save a Copy As...", IDM_FILE_SAVECOPYAS
MENUITEM "Sav&e All", IDM_FILE_SAVEALL
MENUITEM "Rename...", IDM_FILE_RENAME
MENUITEM "&Close", IDM_FILE_CLOSE
MENUITEM "Cl&ose All", IDM_FILE_CLOSEALL
MENUITEM "Close All but Active Document", IDM_FILE_CLOSEALL_BUT_CURRENT
MENUITEM "Delete from Disk", IDM_FILE_DELETE
MENUITEM SEPARATOR
MENUITEM "Load Session...", IDM_FILE_LOADSESSION
MENUITEM "Save Session...", IDM_FILE_SAVESESSION
MENUITEM SEPARATOR
MENUITEM "Print...", IDM_FILE_PRINT
MENUITEM "Print Now!", IDM_FILE_PRINTNOW
MENUITEM SEPARATOR
MENUITEM "E&xit", IDM_FILE_EXIT
END
POPUP "&Edit"
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 "Select A&ll", IDM_EDIT_SELECTALL
MENUITEM SEPARATOR
POPUP "Copy to clipboard"
BEGIN
MENUITEM "Current full file path to Clipboard", IDM_EDIT_FULLPATHTOCLIP
MENUITEM "Current file name to Clipboard", IDM_EDIT_FILENAMETOCLIP
MENUITEM "Current dir path to Clipboard", IDM_EDIT_CURRENTDIRTOCLIP
END
POPUP "Indent"
BEGIN
MENUITEM "Increase Line Indent", IDM_EDIT_INS_TAB
MENUITEM "Decrease Line Indent", IDM_EDIT_RMV_TAB
END
POPUP "Convert case"
BEGIN
MENUITEM "to &UPPERCASE", IDM_EDIT_UPPERCASE
MENUITEM "to &lowercase", IDM_EDIT_LOWERCASE
END
POPUP "Line operations"
BEGIN
MENUITEM "Duplicate current line", IDM_EDIT_DUP_LINE
MENUITEM "Split lines", IDM_EDIT_SPLIT_LINES
MENUITEM "Join lines", IDM_EDIT_JOIN_LINES
MENUITEM "Move Up current line", IDM_EDIT_LINE_UP
MENUITEM "Move Down current line", IDM_EDIT_LINE_DOWN
END
POPUP "Comment/Uncomment"
BEGIN
MENUITEM "Toggle block comment", IDM_EDIT_BLOCK_COMMENT
MENUITEM "Block comment", IDM_EDIT_BLOCK_COMMENT_SET
MENUITEM "Block uncomment", IDM_EDIT_BLOCK_UNCOMMENT
MENUITEM "Stream comment", IDM_EDIT_STREAM_COMMENT
END
POPUP "Auto-completion"
BEGIN
MENUITEM "Function completion", IDM_EDIT_AUTOCOMPLETE
MENUITEM "Word completion", IDM_EDIT_AUTOCOMPLETE_CURRENTFILE
MENUITEM "Function parameters hint", IDM_EDIT_FUNCCALLTIP
END
MENUITEM "Trim Trailing Space", IDM_EDIT_TRIMTRAILING
MENUITEM SEPARATOR
MENUITEM "Column Editor...", IDM_EDIT_COLUMNMODE
MENUITEM SEPARATOR
MENUITEM "Set Read Only", IDM_EDIT_SETREADONLY
MENUITEM "Clear Read Only Flag", IDM_EDIT_CLEARREADONLY
//MENUITEM SEPARATOR
END
POPUP "&Search"
BEGIN
MENUITEM "&Find...", IDM_SEARCH_FIND
MENUITEM "Find in files...", IDM_SEARCH_FINDINFILES
MENUITEM "Find &Next", IDM_SEARCH_FINDNEXT
MENUITEM "Find &Previous", IDM_SEARCH_FINDPREV
MENUITEM "Find (volatile) Next", IDM_SEARCH_VOLATILE_FINDNEXT
MENUITEM "Find (volatile) Previous", IDM_SEARCH_VOLATILE_FINDPREV
MENUITEM "&Replace...", IDM_SEARCH_REPLACE
MENUITEM "&Incremental Search...", IDM_SEARCH_FINDINCREMENT
MENUITEM "&Go to...", IDM_SEARCH_GOTOLINE
MENUITEM "Go to matching brace", IDM_SEARCH_GOTOMATCHINGBRACE
MENUITEM SEPARATOR
POPUP "Mark all"
BEGIN
MENUITEM "Using 1st style", IDM_SEARCH_MARKALLEXT1
MENUITEM "Using 2nd style", IDM_SEARCH_MARKALLEXT2
MENUITEM "Using 3rd style", IDM_SEARCH_MARKALLEXT3
MENUITEM "Using 4th style", IDM_SEARCH_MARKALLEXT4
MENUITEM "Using 5th style", IDM_SEARCH_MARKALLEXT5
END
POPUP "Unmark all"
BEGIN
MENUITEM "Clear 1st style", IDM_SEARCH_UNMARKALLEXT1
MENUITEM "Clear 2nd style", IDM_SEARCH_UNMARKALLEXT2
MENUITEM "Clear 3rd style", IDM_SEARCH_UNMARKALLEXT3
MENUITEM "Clear 4th style", IDM_SEARCH_UNMARKALLEXT4
MENUITEM "Clear 5th style", IDM_SEARCH_UNMARKALLEXT5
MENUITEM "Clear all styles", IDM_SEARCH_CLEARALLMARKS
END
MENUITEM SEPARATOR
MENUITEM "Toggle Bookmark" , IDM_SEARCH_TOGGLE_BOOKMARK
MENUITEM "Next Bookmark", IDM_SEARCH_NEXT_BOOKMARK
MENUITEM "Previous Bookmark", IDM_SEARCH_PREV_BOOKMARK
MENUITEM "Clear all Bookmarks", IDM_SEARCH_CLEAR_BOOKMARKS
MENUITEM "Cut bookmarked lines", IDM_SEARCH_CUTMARKEDLINES
MENUITEM "Copy bookmarked lines", IDM_SEARCH_COPYMARKEDLINES
MENUITEM "Paste to (Replace) bookmarked lines", IDM_SEARCH_PASTEMARKEDLINES
MENUITEM "Delete bookmarked lines", IDM_SEARCH_DELETEMARKEDLINES
END
POPUP "&View"
BEGIN
MENUITEM "Always on top", IDM_VIEW_ALWAYSONTOP
MENUITEM "Toggle Full Screen Mode", IDM_VIEW_FULLSCREENTOGGLE
MENUITEM "Post-it", IDM_VIEW_POSTIT
MENUITEM SEPARATOR
POPUP "Show Symbol"
BEGIN
MENUITEM "Show White Space and TAB", IDM_VIEW_TAB_SPACE
MENUITEM "Show End Of Line", IDM_VIEW_EOL
MENUITEM "Show all characters", IDM_VIEW_ALL_CHARACTERS
MENUITEM SEPARATOR
MENUITEM "Show Indent guide", IDM_VIEW_INDENT_GUIDE
MENUITEM "Show wrap symbol", IDM_VIEW_WRAP_SYMBOL
END
POPUP "Zoom"
BEGIN
MENUITEM "Zoom &in", IDM_VIEW_ZOOMIN
MENUITEM "Zoom &out", IDM_VIEW_ZOOMOUT
MENUITEM "Restore default zoom", IDM_VIEW_ZOOMRESTORE
END
POPUP "Move/Clone current document"
BEGIN
MENUITEM "Move to other view", IDM_VIEW_GOTO_ANOTHER_VIEW
MENUITEM "Clone to other view", IDM_VIEW_CLONE_TO_ANOTHER_VIEW
MENUITEM "Move to new instance", IDM_VIEW_GOTO_NEW_INSTANCE
MENUITEM "Open in new instance", IDM_VIEW_LOAD_IN_NEW_INSTANCE
END
MENUITEM "Word wrap", IDM_VIEW_WRAP
MENUITEM "Focus on other view", IDM_VIEW_SWITCHTO_OTHER_VIEW
MENUITEM "Hide lines", IDM_VIEW_HIDELINES
MENUITEM "User Define Dialog...", IDM_VIEW_USER_DLG
MENUITEM SEPARATOR
MENUITEM "Fold all", IDM_VIEW_TOGGLE_FOLDALL
MENUITEM "Unfold all", IDM_VIEW_TOGGLE_UNFOLDALL
MENUITEM "Collapse current level", IDM_VIEW_FOLD_CURRENT
MENUITEM "Uncollapse current level", IDM_VIEW_UNFOLD_CURRENT
POPUP "Collapse level"
BEGIN
MENUITEM "1" , IDM_VIEW_FOLD_1
MENUITEM "2", IDM_VIEW_FOLD_2
MENUITEM "3", IDM_VIEW_FOLD_3
MENUITEM "4", IDM_VIEW_FOLD_4
MENUITEM "5" , IDM_VIEW_FOLD_5
MENUITEM "6", IDM_VIEW_FOLD_6
MENUITEM "7", IDM_VIEW_FOLD_7
MENUITEM "8", IDM_VIEW_FOLD_8
END
POPUP "Uncollapse level"
BEGIN
MENUITEM "1" , IDM_VIEW_UNFOLD_1
MENUITEM "2", IDM_VIEW_UNFOLD_2
MENUITEM "3", IDM_VIEW_UNFOLD_3
MENUITEM "4", IDM_VIEW_UNFOLD_4
MENUITEM "5" , IDM_VIEW_UNFOLD_5
MENUITEM "6", IDM_VIEW_UNFOLD_6
MENUITEM "7", IDM_VIEW_UNFOLD_7
MENUITEM "8", IDM_VIEW_UNFOLD_8
END
MENUITEM SEPARATOR
MENUITEM "Synchronize Vertical Scrolling", IDM_VIEW_SYNSCROLLV
MENUITEM "Synchronize Horizontal Scrolling", IDM_VIEW_SYNSCROLLH
MENUITEM SEPARATOR
MENUITEM "Text Direction RTL", IDM_EDIT_RTL
MENUITEM "Text Direction LTR", IDM_EDIT_LTR
END
POPUP "For&mat"
BEGIN
MENUITEM "Convert to Windows Format", IDM_FORMAT_TODOS
MENUITEM "Convert to UNIX Format", IDM_FORMAT_TOUNIX
MENUITEM "Convert to Mac Format", IDM_FORMAT_TOMAC
MENUITEM SEPARATOR
MENUITEM "Encode in ANSI", IDM_FORMAT_ANSI
MENUITEM "Encode in UTF-8 without BOM", IDM_FORMAT_AS_UTF_8
MENUITEM "Encode in UTF-8", IDM_FORMAT_UTF_8
MENUITEM "Encode in UCS-2 Big Endian", IDM_FORMAT_UCS_2BE
MENUITEM "Encode in UCS-2 Little Endian", IDM_FORMAT_UCS_2LE
MENUITEM SEPARATOR
MENUITEM "Convert to ANSI", IDM_FORMAT_CONV2_ANSI
MENUITEM "Convert to UTF-8 without BOM", IDM_FORMAT_CONV2_AS_UTF_8
MENUITEM "Convert to UTF-8", IDM_FORMAT_CONV2_UTF_8
MENUITEM "Convert to UCS-2 Big Endian", IDM_FORMAT_CONV2_UCS_2BE
MENUITEM "Convert to UCS-2 Little Endian", IDM_FORMAT_CONV2_UCS_2LE
END
POPUP "&Language"
BEGIN
MENUITEM "Ada", IDM_LANG_ADA
MENUITEM "ASP", IDM_LANG_ASP
MENUITEM "Assembly", IDM_LANG_ASM
MENUITEM "AutoIt", IDM_LANG_AU3
MENUITEM "Batch", IDM_LANG_BATCH
MENUITEM "C", IDM_LANG_C
MENUITEM "C#", IDM_LANG_CS
MENUITEM "C++", IDM_LANG_CPP
MENUITEM "Caml", IDM_LANG_CAML
MENUITEM "Cmake", IDM_LANG_CMAKE
MENUITEM "CSS", IDM_LANG_CSS
MENUITEM "Diff", IDM_LANG_DIFF
MENUITEM "Flash actionscript", IDM_LANG_FLASH
MENUITEM "Fortran", IDM_LANG_FORTRAN
MENUITEM "Haskell", IDM_LANG_HASKELL
MENUITEM "HTML", IDM_LANG_HTML
MENUITEM "INNO", IDM_LANG_INNO
MENUITEM "Java", IDM_LANG_JAVA
MENUITEM "Javascript", IDM_LANG_JS
MENUITEM "KIXtart", IDM_LANG_KIX
MENUITEM "LISP", IDM_LANG_LISP
MENUITEM "Lua", IDM_LANG_LUA
MENUITEM "Makefile", IDM_LANG_MAKEFILE
MENUITEM "Matlab", IDM_LANG_MATLAB
MENUITEM "MS INI file", IDM_LANG_INI
MENUITEM "MS-DOS Style", IDM_LANG_ASCII
MENUITEM "Normal Text", IDM_LANG_TEXT
MENUITEM "NSIS", IDM_LANG_NSIS
MENUITEM "Objective-C", IDM_LANG_OBJC
MENUITEM "Pascal", IDM_LANG_PASCAL
MENUITEM "Perl", IDM_LANG_PERL
MENUITEM "PHP", IDM_LANG_PHP
MENUITEM "Postscript", IDM_LANG_PS
MENUITEM "Properties", IDM_LANG_PROPS
MENUITEM "Python", IDM_LANG_PYTHON
MENUITEM "rc resource file", IDM_LANG_RC
MENUITEM "Ruby", IDM_LANG_RUBY
MENUITEM "Shell", IDM_LANG_SH
MENUITEM "Scheme", IDM_LANG_SCHEME
MENUITEM "Smalltalk", IDM_LANG_SMALLTALK
MENUITEM "SQL", IDM_LANG_SQL
MENUITEM "TCL", IDM_LANG_TCL
MENUITEM "TeX", IDM_LANG_TEX
MENUITEM "VB", IDM_LANG_VB
MENUITEM "VHDL", IDM_LANG_VHDL
MENUITEM "Verilog", IDM_LANG_VERILOG
MENUITEM "XML", IDM_LANG_XML
MENUITEM "YAML", IDM_LANG_YAML
MENUITEM SEPARATOR
MENUITEM "User Defined", IDM_LANG_USER
END
POPUP "&Language"
BEGIN
POPUP "A"
BEGIN
MENUITEM "Ada", IDM_LANG_ADA
MENUITEM "ASP", IDM_LANG_ASP
MENUITEM "Assembly", IDM_LANG_ASM
MENUITEM "AutoIt", IDM_LANG_AU3
END
MENUITEM "Batch", IDM_LANG_BATCH
POPUP "C"
BEGIN
MENUITEM "C", IDM_LANG_C
MENUITEM "C#", IDM_LANG_CS
MENUITEM "C++", IDM_LANG_CPP
MENUITEM "Caml", IDM_LANG_CAML
MENUITEM "Cmake", IDM_LANG_CMAKE
MENUITEM "CSS", IDM_LANG_CSS
END
MENUITEM "Diff", IDM_LANG_DIFF
POPUP "F"
BEGIN
MENUITEM "Flash actionscript", IDM_LANG_FLASH
MENUITEM "Fortran", IDM_LANG_FORTRAN
END
POPUP "H"
BEGIN
MENUITEM "Haskell", IDM_LANG_HASKELL
MENUITEM "HTML", IDM_LANG_HTML
END
MENUITEM "INNO", IDM_LANG_INNO
POPUP "J"
BEGIN
MENUITEM "Java", IDM_LANG_JAVA
MENUITEM "Javascript", IDM_LANG_JS
END
MENUITEM "KIXtart", IDM_LANG_KIX
POPUP "L"
BEGIN
MENUITEM "LISP", IDM_LANG_LISP
MENUITEM "Lua", IDM_LANG_LUA
END
POPUP "M"
BEGIN
MENUITEM "Makefile", IDM_LANG_MAKEFILE
MENUITEM "Matlab", IDM_LANG_MATLAB
MENUITEM "MS INI file", IDM_LANG_INI
MENUITEM "MS-DOS Style", IDM_LANG_ASCII
END
POPUP "N"
BEGIN
MENUITEM "Normal Text", IDM_LANG_TEXT
MENUITEM "NSIS", IDM_LANG_NSIS
END
MENUITEM "Objective-C", IDM_LANG_OBJC
POPUP "P"
BEGIN
MENUITEM "Pascal", IDM_LANG_PASCAL
MENUITEM "Perl", IDM_LANG_PERL
MENUITEM "PHP", IDM_LANG_PHP
MENUITEM "Postscript", IDM_LANG_PS
MENUITEM "Properties", IDM_LANG_PROPS
MENUITEM "Python", IDM_LANG_PYTHON
END
POPUP "R"
BEGIN
MENUITEM "rc resource file", IDM_LANG_RC
MENUITEM "Ruby", IDM_LANG_RUBY
END
POPUP "S"
BEGIN
MENUITEM "Shell", IDM_LANG_SH
MENUITEM "Scheme", IDM_LANG_SCHEME
MENUITEM "Smalltalk", IDM_LANG_SMALLTALK
MENUITEM "SQL", IDM_LANG_SQL
END
POPUP "T"
BEGIN
MENUITEM "TCL", IDM_LANG_TCL
MENUITEM "TeX", IDM_LANG_TEX
END
POPUP "V"
BEGIN
MENUITEM "VB", IDM_LANG_VB
MENUITEM "VHDL", IDM_LANG_VHDL
MENUITEM "Verilog", IDM_LANG_VERILOG
END
MENUITEM "XML", IDM_LANG_XML
MENUITEM "YAML", IDM_LANG_YAML
MENUITEM SEPARATOR
MENUITEM "User Defined", IDM_LANG_USER
END
POPUP "Se&ttings"
BEGIN
MENUITEM "Preferences...", IDM_SETTING_PREFERECE
MENUITEM "Styler Configurator...", IDM_LANGSTYLE_CONFIG_DLG
MENUITEM "Shortcut Mapper...", IDM_SETTING_SHORTCUT_MAPPER
END
POPUP "Macro"
BEGIN
MENUITEM "Start Re&cording", IDM_MACRO_STARTRECORDINGMACRO
MENUITEM "S&top Recording", IDM_MACRO_STOPRECORDINGMACRO
MENUITEM "&Playback", IDM_MACRO_PLAYBACKRECORDEDMACRO
MENUITEM "&Save current recorded macro...", IDM_MACRO_SAVECURRENTMACRO
MENUITEM "&Run a macro multiple times...", IDM_MACRO_RUNMULTIMACRODLG
END
POPUP "Run"
BEGIN
MENUITEM "&Run...", IDM_EXECUTE
END
POPUP "&?"
BEGIN
MENUITEM "Help content", IDM_HELP
MENUITEM SEPARATOR
MENUITEM "Notepad++ Home", IDM_HOMESWEETHOME
MENUITEM "Notepad++ Project Page", IDM_PROJECTPAGE
MENUITEM "Online help", IDM_ONLINEHELP
MENUITEM "Wiki FAQ", IDM_WIKIFAQ
MENUITEM "Forum", IDM_FORUM
MENUITEM "Get more plugins", IDM_PLUGINSHOME
MENUITEM SEPARATOR
MENUITEM "Update Notepad++", IDM_UPDATE_NPP
MENUITEM "About Notepad++", IDM_ABOUT
END
MENUITEM "X", IDM_FILE_CLOSE, HELP
END
IDD_ABOUTBOX DIALOGEX 0, 0, 271, 240
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_BORDER | WS_SYSMENU
FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1
BEGIN
LTEXT NOTEPAD_PLUS_VERSION, IDC_STATIC,50,16,65,11
LTEXT UNICODE_ANSI_MODE, IDC_STATIC,120,16,65,11
GROUPBOX "GNU General Public Licence",IDC_STATIC,19,75,231,131,BS_CENTER
DEFPUSHBUTTON "Ok",IDOK,106,215,50,14,BS_FLAT,WS_EX_STATICEDGE
LTEXT "Author :",IDC_STATIC,21,41,31,8
LTEXT "Don HO",IDC_AUTHOR_NAME,78,41,25,8
LTEXT "Home Page :",IDC_STATIC,21,54,47,8
LTEXT "http://notepad-plus.sourceforge.net/",IDC_HOME_ADDR,78,54,126,8
EDITTEXT IDC_LICENCE_EDIT,31,99,209,96,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | NOT WS_BORDER | WS_VSCROLL
EDITTEXT IDC_BUILD_DATETIME,150,2,150,10, ES_READONLY | NOT WS_BORDER
CONTROL "",IDI_M30ICON,"Static",SS_OWNERDRAW,21,10,20,20
END
IDD_GOLINE DIALOGEX 26, 41, 261, 88
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_TOOLWINDOW | WS_EX_WINDOWEDGE
CAPTION "Go To..."
FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x0
BEGIN
CONTROL "&Line",IDC_RADIO_GOTOLINE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,5,9,80,10
CONTROL "&Offset",IDC_RADIO_GOTOOFFSET,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,98,9,80,10
LTEXT "You are here :",ID_URHERE_STATIC,5,34,95,8,NOT WS_GROUP
LTEXT "0123456789",ID_CURRLINE,100,34,45,8,NOT WS_GROUP
LTEXT "You want to &go :",ID_UGO_STATIC,5,51,95,8
EDITTEXT ID_GOLINE_EDIT,98,49,71,12,ES_NUMBER
LTEXT "You can't go further than :",ID_NOMORETHAN_STATIC,5,68,92,8,NOT WS_GROUP
LTEXT "0123456789",ID_LASTLINE,100,68,45,8,NOT WS_GROUP
DEFPUSHBUTTON "Go !",IDOK,181,48,70,14,BS_NOTIFY
PUSHBUTTON "I'm going nowhere",IDCANCEL,181,66,70,14,BS_NOTIFY
END
IDD_VALUE_DLG DIALOGEX 0, 0, 74, 17
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
EXSTYLE WS_EX_TOOLWINDOW
FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1
BEGIN
LTEXT "STATIC :",IDC_VALUE_STATIC,6,4,45,8
EDITTEXT IDC_VALUE_EDIT,49,2,18,14,ES_NUMBER,WS_EX_DLGMODALFRAME
END
// xp style
1 RT_MANIFEST "notepad++.exe.manifest"

File diff suppressed because it is too large Load Diff

1418
PowerEditor/src/Parameters.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,306 @@
//this file is part of Notepad++
//Copyright (C)2008 Harry Bruin <harrybharry@users.sourceforge.net>
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "AutoCompletion.h"
#include "Notepad_plus_msgs.h"
#include <algorithm>
static bool isInList(generic_string word, const vector<generic_string> & wordArray)
{
for (size_t i = 0 ; i < wordArray.size() ; i++)
if (wordArray[i] == word)
return true;
return false;
};
AutoCompletion::AutoCompletion(ScintillaEditView * pEditView) : _funcCompletionActive(false), _pEditView(pEditView), _funcCalltip(pEditView),
_curLang(L_TXT), _XmlFile(TEXT("")), _activeCompletion(CompletionNone),
_pXmlKeyword(NULL), _ignoreCase(true), _keyWords(TEXT(""))
{
//Do not load any language yet
}
bool AutoCompletion::showAutoComplete() {
if (!_funcCompletionActive)
return false;
int curPos = int(_pEditView->execute(SCI_GETCURRENTPOS));
int line = _pEditView->getCurrentLineNumber();
int startLinePos = int(_pEditView->execute(SCI_POSITIONFROMLINE, line ));
int startWordPos = startLinePos;
int len = curPos-startLinePos;
char * lineBuffer = new char[len+1];
_pEditView->getText(lineBuffer, startLinePos, curPos);
int offset = len-1;
int nrChars = 0;
char c;
while (offset>=0)
{
c = lineBuffer[offset];
if (isalnum(c) || c == '_') {
nrChars++;
} else {
break;
}
offset--;
}
startWordPos = curPos-nrChars;
_pEditView->execute(SCI_AUTOCSETSEPARATOR, WPARAM('\n'));
_pEditView->execute(SCI_AUTOCSETIGNORECASE, _ignoreCase);
_pEditView->showAutoComletion(curPos - startWordPos, _keyWords.c_str());
_activeCompletion = CompletionAuto;
return true;
}
bool AutoCompletion::showWordComplete(bool autoInsert)
{
int curPos = int(_pEditView->execute(SCI_GETCURRENTPOS));
int startPos = int(_pEditView->execute(SCI_WORDSTARTPOSITION, curPos, true));
if (curPos == startPos)
return false;
const size_t bufSize = 256;
size_t len = (curPos > startPos)?(curPos - startPos):(startPos - curPos);
if (len >= bufSize)
return false;
TCHAR beginChars[bufSize];
_pEditView->getGenericText(beginChars, startPos, curPos);
generic_string expr(TEXT("\\<"));
expr += beginChars;
expr += TEXT("[^ \\t.,;:\"()=<>'+!\\[\\]]*");
int docLength = int(_pEditView->execute(SCI_GETLENGTH));
int flags = SCFIND_WORDSTART | SCFIND_MATCHCASE | SCFIND_REGEXP | SCFIND_POSIX;
_pEditView->execute(SCI_SETSEARCHFLAGS, flags);
vector<generic_string> wordArray;
int posFind = _pEditView->searchInTarget(expr.c_str(), 0, docLength);
while (posFind != -1)
{
int wordStart = int(_pEditView->execute(SCI_GETTARGETSTART));
int wordEnd = int(_pEditView->execute(SCI_GETTARGETEND));
size_t foundTextLen = wordEnd - wordStart;
if (foundTextLen < bufSize)
{
TCHAR w[bufSize];
_pEditView->getGenericText(w, wordStart, wordEnd);
if (lstrcmp(w, beginChars))
if (!isInList(w, wordArray))
wordArray.push_back(w);
}
posFind = _pEditView->searchInTarget(expr.c_str(), wordEnd, docLength);
}
if (wordArray.size() == 0) return false;
if (wordArray.size() == 1 && autoInsert)
{
_pEditView->replaceTargetRegExMode(wordArray[0].c_str(), startPos, curPos);
_pEditView->execute(SCI_GOTOPOS, startPos + wordArray[0].length());
return true;
}
sort(wordArray.begin(), wordArray.end());
generic_string words(TEXT(""));
for (size_t i = 0 ; i < wordArray.size() ; i++)
{
words += wordArray[i];
if (i != wordArray.size()-1)
words += TEXT(" ");
}
// UNICODE TO DO
_pEditView->execute(SCI_AUTOCSETSEPARATOR, WPARAM(' '));
_pEditView->execute(SCI_AUTOCSETIGNORECASE, _ignoreCase);
_pEditView->showAutoComletion(curPos - startPos, words.c_str());
_activeCompletion = CompletionWord;
return true;
}
bool AutoCompletion::showFunctionComplete() {
if (!_funcCompletionActive)
return false;
if (_funcCalltip.updateCalltip(0, true)) {
_activeCompletion = CompletionFunc;
return true;
}
return false;
}
void AutoCompletion::update(int character)
{
const NppGUI & nppGUI = NppParameters::getInstance()->getNppGUI();
if (!_funcCompletionActive && nppGUI._autocStatus == nppGUI.autoc_func)
return;
if (nppGUI._funcParams || _funcCalltip.isVisible()) {
if (_funcCalltip.updateCalltip(character)) { //calltip visible because triggered by autocomplete, set mode
_activeCompletion = CompletionFunc;
return; //only return in case of success, else autocomplete
}
}
if (!character)
return;
//If autocomplete already active, let Scintilla handle it
if (_pEditView->execute(SCI_AUTOCACTIVE) != 0)
return;
const int wordSize = 64;
TCHAR s[wordSize];
_pEditView->getWordToCurrentPos(s, wordSize);
if (lstrlen(s) >= int(nppGUI._autocFromLen))
{
if (nppGUI._autocStatus == nppGUI.autoc_word)
showWordComplete(false);
else if (nppGUI._autocStatus == nppGUI.autoc_func)
showAutoComplete();
}
}
void AutoCompletion::callTipClick(int direction) {
if (!_funcCompletionActive)
return;
if (direction == 1) {
_funcCalltip.showPrevOverload();
} else if (direction == 2) {
_funcCalltip.showNextOverload();
}
}
bool AutoCompletion::setLanguage(LangType language) {
if (_curLang == language)
return true;
_curLang = language;
TCHAR path[MAX_PATH];
::GetModuleFileName(NULL, path, MAX_PATH);
PathRemoveFileSpec(path);
lstrcat(path, TEXT("\\plugins\\APIs\\"));
lstrcat(path, getApiFileName());
lstrcat(path, TEXT(".xml"));
_XmlFile = TiXmlDocument(path);
_funcCompletionActive = _XmlFile.LoadFile();
TiXmlNode * pAutoNode = NULL;
if (_funcCompletionActive) {
_funcCompletionActive = false; //safety
TiXmlNode * pNode = _XmlFile.FirstChild(TEXT("NotepadPlus"));
if (!pNode)
return false;
pAutoNode = pNode = pNode->FirstChildElement(TEXT("AutoComplete"));
if (!pNode)
return false;
pNode = pNode->FirstChildElement(TEXT("KeyWord"));
if (!pNode)
return false;
_pXmlKeyword = reinterpret_cast<TiXmlElement *>(pNode);
if (!_pXmlKeyword)
return false;
_funcCompletionActive = true;
}
if(_funcCompletionActive) { //try setting up environment
//setup defaults
_ignoreCase = true;
_funcCalltip._start = '(';
_funcCalltip._stop = ')';
_funcCalltip._param = ',';
_funcCalltip._terminal = ';';
_funcCalltip._ignoreCase = true;
TiXmlElement * pElem = pAutoNode->FirstChildElement(TEXT("Environment"));
if (pElem) {
const TCHAR * val = 0;
val = pElem->Attribute(TEXT("ignoreCase"));
if (val && !lstrcmp(val, TEXT("no"))) {
_ignoreCase = false;
_funcCalltip._ignoreCase = false;
}
val = pElem->Attribute(TEXT("startFunc"));
if (val && val[0])
_funcCalltip._start = val[0];
val = pElem->Attribute(TEXT("stopFunc"));
if (val && val[0])
_funcCalltip._stop = val[0];
val = pElem->Attribute(TEXT("paramSeparator"));
if (val && val[0])
_funcCalltip._param = val[0];
val = pElem->Attribute(TEXT("terminal"));
if (val && val[0])
_funcCalltip._terminal = val[0];
}
}
if (_funcCompletionActive) {
_funcCalltip.setLanguageXML(_pXmlKeyword);
} else {
_funcCalltip.setLanguageXML(NULL);
}
_keyWords = TEXT("");
if (_funcCompletionActive) { //Cache the keywords
//Iterate through all keywords
TiXmlElement *funcNode = _pXmlKeyword;
const TCHAR * name = NULL;
for (; funcNode; funcNode = funcNode->NextSiblingElement(TEXT("KeyWord")) ) {
name = funcNode->Attribute(TEXT("name"));
if (!name) //malformed node
continue;
_keyWords.append(name);
_keyWords.append(TEXT("\n"));
}
}
return _funcCompletionActive;
}
const TCHAR * AutoCompletion::getApiFileName() {
if (_curLang == L_USER)
{
Buffer * currentBuf = _pEditView->getCurrentBuffer();
if (currentBuf->isUserDefineLangExt())
{
return currentBuf->getUserDefineLangName();
}
}
if (_curLang >= L_EXTERNAL && _curLang < NppParameters::getInstance()->L_END)
return NppParameters::getInstance()->getELCFromIndex(_curLang - L_EXTERNAL)._name;
return ScintillaEditView::langNames[_curLang].lexerName;
}

View File

@ -0,0 +1,57 @@
//this file is part of Notepad++
//Copyright (C)2008 Harry Bruin <harrybharry@users.sourceforge.net>
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#ifndef AUTOCOMPLETION_H
#define AUTOCOMPLETION_H
#include "ScintillaEditView.h"
#include "FunctionCallTip.h"
#include "tinyxml.h"
class AutoCompletion {
public:
enum ActiveCompletion {CompletionNone = 0, CompletionAuto, CompletionWord, CompletionFunc};
AutoCompletion(ScintillaEditView * pEditView);
bool setLanguage(LangType language);
//AutoComplete from the list
bool showAutoComplete();
//WordCompletion from the current file
bool showWordComplete(bool autoInsert); //autoInsert true if completion should fill in the word on a single match
//Parameter display from the list
bool showFunctionComplete();
void update(int character);
void callTipClick(int direction);
private:
bool _funcCompletionActive;
ScintillaEditView * _pEditView;
LangType _curLang;
TiXmlDocument _XmlFile;
TiXmlElement * _pXmlKeyword;
ActiveCompletion _activeCompletion;
bool _ignoreCase;
std::generic_string _keyWords;
FunctionCallTip _funcCalltip;
const TCHAR * getApiFileName();
};
#endif //AUTOCOMPLETION_H

View File

@ -0,0 +1,723 @@
#include "Buffer.h"
#include <shlwapi.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "Scintilla.h"
#include "Parameters.h"
#include "Notepad_plus.h"
#include "ScintillaEditView.h"
FileManager * FileManager::_pSelf = new FileManager();
const int blockSize = 128 * 1024 + 4;
// Ordre important!! Ne le changes pas!
//SC_EOL_CRLF (0), SC_EOL_CR (1), or SC_EOL_LF (2).
const int CR = 0x0D;
const int LF = 0x0A;
static bool isInList(const TCHAR *token, const TCHAR *list) {
if ((!token) || (!list))
return false;
TCHAR word[64];
int i = 0;
int j = 0;
for (; i <= int(lstrlen(list)) ; i++)
{
if ((list[i] == ' ')||(list[i] == '\0'))
{
if (j != 0)
{
word[j] = '\0';
j = 0;
if (!generic_stricmp(token, word))
return true;
}
}
else
{
word[j] = list[i];
j++;
}
}
return false;
};
void Buffer::determinateFormat(const char *data) {
_format = WIN_FORMAT;
size_t len = strlen(data);
for (size_t i = 0 ; i < len ; i++)
{
if (data[i] == CR)
{
if (data[i+1] == LF)
{
_format = WIN_FORMAT;
break;
}
else
{
_format = MAC_FORMAT;
break;
}
}
if (data[i] == LF)
{
_format = UNIX_FORMAT;
break;
}
}
doNotify(BufferChangeFormat);
return;
};
long Buffer::_recentTagCtr = 0;
void Buffer::updateTimeStamp() {
struct _stat buf;
time_t timeStamp = (generic_stat(_fullPathName, &buf)==0)?buf.st_mtime:0;
if (timeStamp != _timeStamp) {
_timeStamp = timeStamp;
doNotify(BufferChangeTimestamp);
}
};
// Set full path file name in buffer object,
// and determinate its language by its extension.
// If the ext is not in the list, the defaultLang passed as argument will be set.
void Buffer::setFileName(const TCHAR *fn, LangType defaultLang)
{
NppParameters *pNppParamInst = NppParameters::getInstance();
if (!lstrcmpi(fn, _fullPathName)) {
updateTimeStamp();
doNotify(BufferChangeTimestamp);
return;
}
lstrcpy(_fullPathName, fn);
_fileName = PathFindFileName(_fullPathName);
// for _lang
LangType newLang = defaultLang;
TCHAR *ext = PathFindExtension(_fullPathName);
if (*ext == '.') { //extension found
ext += 1;
// Define User Lang firstly
const TCHAR *langName = NULL;
if ((langName = pNppParamInst->getUserDefinedLangNameFromExt(ext)))
{
newLang = L_USER;
lstrcpy(_userLangExt, langName);
}
else // if it's not user lang, then check if it's supported lang
{
_userLangExt[0] = '\0';
newLang = getLangFromExt(ext);
}
}
if (newLang == defaultLang || newLang == L_TXT) //language can probably be refined
{
if ((!generic_stricmp(_fileName, TEXT("makefile"))) || (!generic_stricmp(_fileName, TEXT("GNUmakefile"))))
newLang = L_MAKEFILE;
else if (!generic_stricmp(_fileName, TEXT("CmakeLists.txt")))
newLang = L_CMAKE;
else if ((!generic_stricmp(_fileName, TEXT("SConstruct"))) || (!generic_stricmp(_fileName, TEXT("SConscript"))))
newLang = L_PYTHON;
}
updateTimeStamp();
if (newLang != _lang || _lang == L_USER) {
_lang = newLang;
doNotify(BufferChangeFilename | BufferChangeLanguage | BufferChangeTimestamp);
return;
}
doNotify(BufferChangeFilename | BufferChangeTimestamp);
}
bool Buffer::checkFileState() { //returns true if the status has been changed (it can change into DOC_REGULAR too). false otherwise
struct _stat buf;
if (_currentStatus == DOC_UNNAMED) //unsaved document cannot change by environment
return false;
if (_currentStatus != DOC_DELETED && !PathFileExists(_fullPathName)) //document has been deleted
{
_currentStatus = DOC_DELETED;
_isFileReadOnly = false;
_isDirty = true; //dirty sicne no match with filesystem
_timeStamp = 0;
doNotify(BufferChangeStatus | BufferChangeReadonly | BufferChangeTimestamp);
return true;
}
if (_currentStatus == DOC_DELETED && PathFileExists(_fullPathName))
{ //document has returned from its grave
if (!generic_stat(_fullPathName, &buf))
{
_isFileReadOnly = (bool)(!(buf.st_mode & _S_IWRITE));
_currentStatus = DOC_MODIFIED;
_timeStamp = buf.st_mtime;
doNotify(BufferChangeStatus | BufferChangeReadonly | BufferChangeTimestamp);
return true;
}
}
if (!generic_stat(_fullPathName, &buf))
{
int mask = 0; //status always 'changes', even if from modified to modified
bool isFileReadOnly = (bool)(!(buf.st_mode & _S_IWRITE));
if (isFileReadOnly != _isFileReadOnly) {
_isFileReadOnly = isFileReadOnly;
mask |= BufferChangeReadonly;
}
if (_timeStamp != buf.st_mtime) {
_timeStamp = buf.st_mtime;
mask |= BufferChangeTimestamp;
_currentStatus = DOC_MODIFIED;
mask |= BufferChangeStatus; //status always 'changes', even if from modified to modified
}
if (mask != 0) {
doNotify(mask);
return true;
}
return false;
}
return false;
}
void Buffer::setPosition(const Position & pos, ScintillaEditView * identifier) {
int index = indexOfReference(identifier);
if (index == -1)
return;
_positions[index] = pos;
}
Position & Buffer::getPosition(ScintillaEditView * identifier) {
int index = indexOfReference(identifier);
return _positions.at(index);
}
void Buffer::setHeaderLineState(const std::vector<HeaderLineState> & folds, ScintillaEditView * identifier) {
int index = indexOfReference(identifier);
if (index == -1)
return;
//deep copy
std::vector<HeaderLineState> & local = _foldStates[index];
local.clear();
size_t size = folds.size();
for(size_t i = 0; i < size; i++) {
local.push_back(folds[i]);
}
}
std::vector<HeaderLineState> & Buffer::getHeaderLineState(ScintillaEditView * identifier) {
int index = indexOfReference(identifier);
return _foldStates.at(index);
}
LangType Buffer::getLangFromExt(const TCHAR *ext)
{
NppParameters *pNppParam = NppParameters::getInstance();
int i = pNppParam->getNbLang();
i--;
while (i >= 0)
{
Lang *l = pNppParam->getLangFromIndex(i--);
const TCHAR *defList = l->getDefaultExtList();
const TCHAR *userList = NULL;
LexerStylerArray &lsa = pNppParam->getLStylerArray();
const TCHAR *lName = l->getLangName();
LexerStyler *pLS = lsa.getLexerStylerByName(lName);
if (pLS)
userList = pLS->getLexerUserExt();
std::generic_string list(TEXT(""));
if (defList)
list += defList;
if (userList)
{
list += TEXT(" ");
list += userList;
}
if (isInList(ext, list.c_str()))
return l->getLangID();
}
return L_TXT;
}
Lang * Buffer::getCurrentLang() const {
NppParameters *pNppParam = NppParameters::getInstance();
int i = 0;
Lang *l = pNppParam->getLangFromIndex(i++);
while (l)
{
if (l->_langID == _lang)
return l;
l = pNppParam->getLangFromIndex(i++);
}
return NULL;
};
int Buffer::indexOfReference(ScintillaEditView * identifier) const {
int size = (int)_referees.size();
for(int i = 0; i < size; i++) {
if (_referees[i] == identifier)
return i;
}
return -1; //not found
}
int Buffer::addReference(ScintillaEditView * identifier) {
if (indexOfReference(identifier) != -1)
return _references;
_referees.push_back(identifier);
_positions.push_back(Position());
_foldStates.push_back(std::vector<HeaderLineState>());
_references++;
return _references;
}
int Buffer::removeReference(ScintillaEditView * identifier) {
int indexToPop = indexOfReference(identifier);
if (indexToPop == -1)
return _references;
_referees.erase(_referees.begin() + indexToPop);
_positions.erase(_positions.begin() + indexToPop);
_foldStates.erase(_foldStates.begin() + indexToPop);
_references--;
return _references;
}
void Buffer::setHideLineChanged(bool isHide, int location) {
//First run through all docs without removing markers
for(int i = 0; i < _references; i++) {
_referees.at(i)->notifyMarkers(this, isHide, location, false);//(i == _references-1));
}
if (!isHide) { //no deleting if hiding lines
//Then all docs to remove markers.
for(int i = 0; i < _references; i++) {
_referees.at(i)->notifyMarkers(this, isHide, location, true);
}
}
}
void Buffer::setDeferredReload() { //triggers a reload on the next Document access
_isDirty = false; //when reloading, just set to false, since it sohuld be marked as clean
_needReloading = true;
doNotify(BufferChangeDirty);
}
/*
pair<size_t, bool> Buffer::getLineUndoState(size_t currentLine) const
{
for (size_t i = 0 ; i < _linesUndoState.size() ; i++)
{
if (_linesUndoState[i].first == currentLine)
return _linesUndoState[i].second;
}
return pair<size_t, bool>(0, false);
}
void Buffer::setLineUndoState(size_t currentLine, size_t undoLevel, bool isSaved)
{
bool found = false;
for (size_t i = 0 ; i < _linesUndoState.size() ; i++)
{
if (_linesUndoState[i].first == currentLine)
{
_linesUndoState[i].second.first = undoLevel;
_linesUndoState[i].second.second = isSaved;
}
}
if (!found)
{
_linesUndoState.push_back(pair<size_t, pair<size_t, bool> >(currentLine, pair<size_t, bool>(undoLevel, false)));
}
}
*/
//filemanager
void FileManager::init(Notepad_plus * pNotepadPlus, ScintillaEditView * pscratchTilla)
{
_pNotepadPlus = pNotepadPlus;
_pscratchTilla = pscratchTilla;
_pscratchTilla->execute(SCI_SETUNDOCOLLECTION, false); //dont store any undo information
_scratchDocDefault = (Document)_pscratchTilla->execute(SCI_GETDOCPOINTER);
_pscratchTilla->execute(SCI_ADDREFDOCUMENT, 0, _scratchDocDefault);
}
void FileManager::checkFilesystemChanges() {
for(size_t i = 0; i < _nrBufs; i++) {
if (_buffers[i]->checkFileState()){} //something has changed. Triggers update automatically
}
}
int FileManager::getBufferIndexByID(BufferID id) {
for(size_t i = 0; i < _nrBufs; i++) {
if (_buffers[i]->_id == id)
return (int)i;
}
return -1;
}
Buffer * FileManager::getBufferByIndex(int index) {
return _buffers.at(index);
}
void FileManager::beNotifiedOfBufferChange(Buffer * theBuf, int mask) {
_pNotepadPlus->notifyBufferChanged(theBuf, mask);
};
void FileManager::addBufferReference(BufferID buffer, ScintillaEditView * identifier) {
Buffer * buf = getBufferByID(buffer);
buf->addReference(identifier);
}
void FileManager::closeBuffer(BufferID id, ScintillaEditView * identifier) {
int index = getBufferIndexByID(id);
Buffer * buf = getBufferByIndex(index);
int oldRefs = buf->_references;
int refs = buf->removeReference(identifier);
if (!refs) { //buffer can be deallocated
_pscratchTilla->execute(SCI_RELEASEDOCUMENT, 0, buf->_doc); //release for FileManager, Document is now gone
_buffers.erase(_buffers.begin() + index);
delete buf;
_nrBufs--;
}
}
BufferID FileManager::loadFile(const TCHAR * filename, Document doc) {
bool ownDoc = false;
if (doc == NULL)
{
doc = (Document)_pscratchTilla->execute(SCI_CREATEDOCUMENT);
ownDoc = true;
}
TCHAR fullpath[MAX_PATH];
::GetFullPathName(filename, MAX_PATH, fullpath, NULL);
::GetLongPathName(fullpath, fullpath, MAX_PATH);
Utf8_16_Read UnicodeConvertor; //declare here so we can get information after loading is done
bool res = loadFileData(doc, fullpath, &UnicodeConvertor, L_TXT);
if (res)
{
Buffer * newBuf = new Buffer(this, _nextBufferID, doc, DOC_REGULAR, fullpath);
BufferID id = (BufferID) newBuf;
newBuf->_id = id;
_buffers.push_back(newBuf);
_nrBufs++;
Buffer * buf = _buffers.at(_nrBufs - 1);
// 3 formats : WIN_FORMAT, UNIX_FORMAT and MAC_FORMAT
if (UnicodeConvertor.getNewBuf())
{
buf->determinateFormat(UnicodeConvertor.getNewBuf());
}
else
{
buf->determinateFormat("");
}
UniMode encoding = UnicodeConvertor.getEncoding();
if (encoding == uni7Bit)
{
NppParameters *pNppParamInst = NppParameters::getInstance();
const NewDocDefaultSettings & ndds = (pNppParamInst->getNppGUI()).getNewDocDefaultSettings();
if (ndds._openAnsiAsUtf8)
{
encoding = uniCookie;
}
else
{
encoding = uni8Bit;
}
}
buf->setUnicodeMode(encoding);
//determine buffer properties
BufferID retval = _nextBufferID++;
return id;
} else { //failed loading, release document
if (ownDoc)
_pscratchTilla->execute(SCI_RELEASEDOCUMENT, 0, doc); //Failure, so release document
return BUFFER_INVALID;
}
}
bool FileManager::reloadBuffer(BufferID id) {
Buffer * buf = getBufferByID(id);
Document doc = buf->getDocument();
Utf8_16_Read UnicodeConvertor;
buf->_canNotify = false; //disable notify during file load, we dont want dirty to be triggered
bool res = loadFileData(doc, buf->getFullPathName(), &UnicodeConvertor, buf->getLangType());
buf->_canNotify = true;
if (res) {
if (UnicodeConvertor.getNewBuf()) {
buf->determinateFormat(UnicodeConvertor.getNewBuf());
} else {
buf->determinateFormat("");
}
buf->setUnicodeMode(UnicodeConvertor.getEncoding());
// buf->setNeedsLexing(true);
}
return res;
}
bool FileManager::reloadBufferDeferred(BufferID id) {
Buffer * buf = getBufferByID(id);
buf->setDeferredReload();
return true;
}
bool FileManager::deleteFile(BufferID id)
{
Buffer * buf = getBufferByID(id);
const TCHAR *fileNamePath = buf->getFullPathName();
if (!PathFileExists(fileNamePath))
return false;
return ::DeleteFile(fileNamePath) != 0;
}
bool FileManager::moveFile(BufferID id, const TCHAR * newFileName)
{
Buffer * buf = getBufferByID(id);
const TCHAR *fileNamePath = buf->getFullPathName();
if (!PathFileExists(fileNamePath))
return false;
if (::MoveFile(fileNamePath, newFileName) == 0)
return false;
buf->setFileName(newFileName);
return true;
}
bool FileManager::saveBuffer(BufferID id, const TCHAR * filename, bool isCopy) {
Buffer * buffer = getBufferByID(id);
bool isHidden = false;
bool isSys = false;
DWORD attrib;
TCHAR fullpath[MAX_PATH];
::GetFullPathName(filename, MAX_PATH, fullpath, NULL);
::GetLongPathName(fullpath, fullpath, MAX_PATH);
if (PathFileExists(fullpath))
{
attrib = ::GetFileAttributes(fullpath);
if (attrib != INVALID_FILE_ATTRIBUTES)
{
isHidden = (attrib & FILE_ATTRIBUTE_HIDDEN) != 0;
if (isHidden)
::SetFileAttributes(filename, attrib & ~FILE_ATTRIBUTE_HIDDEN);
isSys = (attrib & FILE_ATTRIBUTE_SYSTEM) != 0;
if (isSys)
::SetFileAttributes(filename, attrib & ~FILE_ATTRIBUTE_SYSTEM);
}
}
UniMode mode = buffer->getUnicodeMode();
if (mode == uniCookie)
mode = uni8Bit; //set the mode to ANSI to prevent converter from adding BOM and performing conversions, Scintilla's data can be copied directly
Utf8_16_Write UnicodeConvertor;
UnicodeConvertor.setEncoding(mode);
FILE *fp = UnicodeConvertor.fopen(fullpath, TEXT("wb"));
if (fp)
{
_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, buffer->_doc); //generate new document
char data[blockSize + 1];
int lengthDoc = _pscratchTilla->getCurrentDocLen();
for (int i = 0; i < lengthDoc; i += blockSize)
{
int grabSize = lengthDoc - i;
if (grabSize > blockSize)
grabSize = blockSize;
_pscratchTilla->getText(data, i, i + grabSize);
UnicodeConvertor.fwrite(data, grabSize);
}
UnicodeConvertor.fclose();
if (isHidden)
::SetFileAttributes(fullpath, attrib | FILE_ATTRIBUTE_HIDDEN);
if (isSys)
::SetFileAttributes(fullpath, attrib | FILE_ATTRIBUTE_SYSTEM);
if (isCopy) {
_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, _scratchDocDefault);
return true; //all done
}
buffer->setFileName(fullpath);
buffer->setDirty(false);
buffer->setStatus(DOC_REGULAR);
buffer->checkFileState();
_pscratchTilla->execute(SCI_SETSAVEPOINT);
//_pscratchTilla->markSavedLines();
_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, _scratchDocDefault);
return true;
}
return false;
}
BufferID FileManager::newEmptyDocument()
{
TCHAR newTitle[10];
lstrcpy(newTitle, UNTITLED_STR);
wsprintf(newTitle+4, TEXT("%d"), _nextNewNumber);
_nextNewNumber++;
Document doc = (Document)_pscratchTilla->execute(SCI_CREATEDOCUMENT); //this already sets a reference for filemanager
Buffer * newBuf = new Buffer(this, _nextBufferID, doc, DOC_UNNAMED, newTitle);
BufferID id = (BufferID)newBuf;
newBuf->_id = id;
_buffers.push_back(newBuf);
_nrBufs++;
BufferID retval = _nextBufferID++;
return id;
}
BufferID FileManager::bufferFromDocument(Document doc, bool dontIncrease, bool dontRef)
{
TCHAR newTitle[10];
lstrcpy(newTitle, UNTITLED_STR);
wsprintf(newTitle+4, TEXT("%d"), _nextNewNumber);
if (!dontRef)
_pscratchTilla->execute(SCI_ADDREFDOCUMENT, 0, doc); //set reference for FileManager
Buffer * newBuf = new Buffer(this, _nextBufferID, doc, DOC_UNNAMED, newTitle);
BufferID id = (BufferID)newBuf;
newBuf->_id = id;
_buffers.push_back(newBuf);
_nrBufs++;
BufferID retval = _nextBufferID;
if (!dontIncrease)
_nextBufferID++;
return id;
}
bool FileManager::loadFileData(Document doc, const TCHAR * filename, Utf8_16_Read * UnicodeConvertor, LangType language)
{
const int blockSize = 128 * 1024; //128 kB
char data[blockSize];
FILE *fp = generic_fopen(filename, TEXT("rb"));
if (!fp)
return false;
//Setup scratchtilla for new filedata
_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, doc);
bool ro = _pscratchTilla->execute(SCI_GETREADONLY) != 0;
if (ro) {
_pscratchTilla->execute(SCI_SETREADONLY, false);
}
_pscratchTilla->execute(SCI_CLEARALL);
if (language < L_EXTERNAL) {
_pscratchTilla->execute(SCI_SETLEXER, ScintillaEditView::langNames[language].lexerID);
} else {
int id = language - L_EXTERNAL;
TCHAR * name = NppParameters::getInstance()->getELCFromIndex(id)._name;
#ifdef UNICODE
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
const char *pName = wmc->wchar2char(name, CP_ACP);
#else
const char *pName = name;
#endif
_pscratchTilla->execute(SCI_SETLEXERLANGUAGE, 0, (LPARAM)pName);
}
bool success = true;
__try {
size_t lenFile = 0;
size_t lenConvert = 0; //just in case conversion results in 0, but file not empty
do {
lenFile = fread(data, 1, blockSize, fp);
lenConvert = UnicodeConvertor->convert(data, lenFile);
_pscratchTilla->execute(SCI_APPENDTEXT, lenConvert, (LPARAM)(UnicodeConvertor->getNewBuf()));
} while (lenFile > 0);
} __except(filter(GetExceptionCode(), GetExceptionInformation())) {
printStr(TEXT("File is too big to be opened by Notepad++"));
success = false;
}
fclose(fp);
_pscratchTilla->execute(SCI_EMPTYUNDOBUFFER);
_pscratchTilla->execute(SCI_SETSAVEPOINT);
if (ro) {
_pscratchTilla->execute(SCI_SETREADONLY, true);
}
_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, _scratchDocDefault);
return success;
}
BufferID FileManager::getBufferFromName(const TCHAR * name) {
TCHAR fullpath[MAX_PATH];
::GetFullPathName(name, MAX_PATH, fullpath, NULL);
::GetLongPathName(fullpath, fullpath, MAX_PATH);
for(size_t i = 0; i < _buffers.size(); i++) {
if (!lstrcmpi(name, _buffers.at(i)->getFullPathName()))
return _buffers.at(i)->getID();
}
return BUFFER_INVALID;
}
BufferID FileManager::getBufferFromDocument(Document doc) {
for(size_t i = 0; i < _nrBufs; i++) {
if (_buffers[i]->_doc == doc)
return _buffers[i]->_id;
}
return BUFFER_INVALID;
}
bool FileManager::createEmptyFile(const TCHAR * path) {
FILE * file = generic_fopen(path, TEXT("wb"));
if (!file)
return false;
fclose(file);
return true;
}
int FileManager::getFileNameFromBuffer(BufferID id, TCHAR * fn2copy) {
if (getBufferIndexByID(id) == -1)
return -1;
Buffer * buf = getBufferByID(id);
if (fn2copy)
lstrcpy(fn2copy, buf->getFullPathName());
return lstrlen(buf->getFullPathName());
}
int FileManager::docLength(Buffer * buffer) const
{
_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, buffer->_doc);
int docLen = _pscratchTilla->getCurrentDocLen();
_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, _scratchDocDefault);
return docLen;
}

View File

@ -0,0 +1,386 @@
//this file is part of notepad++
//Copyright (C)2003 Don HO < donho@altern.org >
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#ifndef BUFFER_H
#define BUFFER_H
#include "Utf8_16.h"
class Buffer;
typedef Buffer * BufferID; //each buffer has unique ID by which it can be retrieved
#define BUFFER_INVALID (BufferID)0
typedef sptr_t Document;
enum DocFileStatus{
DOC_REGULAR = 0x01, //should not be combined with anything
DOC_UNNAMED = 0x02, //not saved (new ##)
DOC_DELETED = 0x04, //doesnt exist in environment anymore, but not DOC_UNNAMED
DOC_MODIFIED = 0x08 //File in environment has changed
};
enum BufferStatusInfo {
BufferChangeLanguage = 0x001, //Language was altered
BufferChangeDirty = 0x002, //Buffer has changed dirty state
BufferChangeFormat = 0x004, //EOL type was changed
BufferChangeUnicode = 0x008, //Unicode type was changed
BufferChangeReadonly = 0x010, //Readonly state was changed, can be both file and user
BufferChangeStatus = 0x020, //Filesystem Status has changed
BufferChangeTimestamp = 0x040, //Timestamp was changed
BufferChangeFilename = 0x080, //Filename was changed
BufferChangeRecentTag = 0x100, //Recent tag has changed
BufferChangeLexing = 0x200, //Document needs lexing
BufferChangeMask = 0x3FF //Mask: covers all changes
};
struct HeaderLineState {
HeaderLineState() : _headerLineNumber(0), _isExpanded(true){};
HeaderLineState(int lineNumber, bool isExpanded) : _headerLineNumber(lineNumber), _isExpanded(isExpanded){};
int _headerLineNumber;
bool _isExpanded;
};
const int userLangNameMax = 16;
const TCHAR UNTITLED_STR[] = TEXT("new ");
//File manager class maintains all buffers
class Buffer;
class FileManager {
public:
void init(Notepad_plus * pNotepadPlus, ScintillaEditView * pscratchTilla);
//void activateBuffer(int index);
void checkFilesystemChanges();
int getNrBuffers() { return _nrBufs; };
int getBufferIndexByID(BufferID id);
Buffer * getBufferByIndex(int index); //generates exception if index is invalid
Buffer * getBufferByID(BufferID id) {return (Buffer*)id;}
void beNotifiedOfBufferChange(Buffer * theBuf, int mask);
void closeBuffer(BufferID, ScintillaEditView * identifer); //called by Notepad++
void addBufferReference(BufferID id, ScintillaEditView * identifer); //called by Scintilla etc indirectly
BufferID loadFile(const TCHAR * filename, Document doc = NULL); //ID == BUFFER_INVALID on failure. If Doc == NULL, a new file is created, otherwise data is loaded in given document
BufferID newEmptyDocument();
//create Buffer from existing Scintilla, used from new Scintillas. If dontIncrease = true, then the new document number isnt increased afterwards.
//usefull for temporary but neccesary docs
//If dontRef = false, then no extra reference is added for the doc. Its the responsibility of the caller to do so
BufferID bufferFromDocument(Document doc, bool dontIncrease = false, bool dontRef = false);
BufferID getBufferFromName(const TCHAR * name);
BufferID getBufferFromDocument(Document doc);
bool reloadBuffer(BufferID id);
bool reloadBufferDeferred(BufferID id);
bool saveBuffer(BufferID id, const TCHAR * filename, bool isCopy = false);
bool deleteFile(BufferID id);
bool moveFile(BufferID id, const TCHAR * newFilename);
bool createEmptyFile(const TCHAR * path);
static FileManager * getInstance() {return _pSelf;};
void destroyInstance() { delete _pSelf; };
void increaseDocNr() {_nextNewNumber++;};
int getFileNameFromBuffer(BufferID id, TCHAR * fn2copy);
int docLength(Buffer * buffer) const;
private:
FileManager() : _nextNewNumber(1), _nextBufferID(0), _pNotepadPlus(NULL), _nrBufs(0), _pscratchTilla(NULL){};
~FileManager(){};
static FileManager *_pSelf;
Notepad_plus * _pNotepadPlus;
ScintillaEditView * _pscratchTilla;
Document _scratchDocDefault;
int _nextNewNumber;
std::vector<Buffer *> _buffers;
BufferID _nextBufferID;
size_t _nrBufs;
bool loadFileData(Document doc, const TCHAR * filename, Utf8_16_Read * UnicodeConvertor, LangType language);
};
#define MainFileManager FileManager::getInstance()
class Buffer
{
friend class FileManager;
public :
//Loading a document:
//constructor with ID.
//Set a reference (pointer to a container mostly, like DocTabView or ScintillaEditView)
//Set the position manually if needed
//Load the document into Scintilla/add to TabBar
//The entire lifetime if the buffer, the Document has reference count of _atleast_ one
//Destructor makes sure its purged
Buffer(FileManager * pManager, BufferID id, Document doc, DocFileStatus type, const TCHAR *fileName) //type must be either DOC_REGULAR or DOC_UNNAMED
: _pManager(pManager), _id(id), _isDirty(false), _doc(doc), _isFileReadOnly(false), _isUserReadOnly(false), _recentTag(-1), _references(0),
_canNotify(false), _timeStamp(0), _needReloading(false)
{
NppParameters *pNppParamInst = NppParameters::getInstance();
const NewDocDefaultSettings & ndds = (pNppParamInst->getNppGUI()).getNewDocDefaultSettings();
_format = ndds._format;
_unicodeMode = ndds._encoding;
_userLangExt[0] = 0;
_fullPathName[0] = 0;
_fileName = NULL;
setFileName(fileName, ndds._lang);
updateTimeStamp();
checkFileState();
_currentStatus = type;
_isDirty = false;
_needLexer = false; //new buffers do not need lexing, Scintilla takes care of that
_canNotify = true;
};
LangType getLangFromExt(const TCHAR *ext);
// this method 1. copies the file name
// 2. determinates the language from the ext of file name
// 3. gets the last modified time
void setFileName(const TCHAR *fn, LangType defaultLang = L_TXT);
const TCHAR * getFullPathName() const {
return _fullPathName;
};
const TCHAR * getFileName() const { return _fileName; };
BufferID getID() const {
return _id;
};
void increaseRecentTag() {
_recentTag = ++_recentTagCtr;
doNotify(BufferChangeRecentTag);
};
long getRecentTag() const {
return _recentTag;
};
bool checkFileState();
bool isDirty() const {
return _isDirty;
};
bool isReadOnly() const {
return (_isUserReadOnly || _isFileReadOnly);
};
bool isUntitled() const {
return (_currentStatus == DOC_UNNAMED);
};
bool getFileReadOnly() const {
return _isFileReadOnly;
};
void setFileReadOnly(bool ro) {
_isFileReadOnly = ro;
doNotify(BufferChangeReadonly);
};
bool getUserReadOnly() const {
return _isUserReadOnly;
};
void setUserReadOnly(bool ro) {
_isUserReadOnly = ro;
doNotify(BufferChangeReadonly);
};
formatType getFormat() const {
return _format;
};
void setFormat(formatType format) {
_format = format;
doNotify(BufferChangeFormat);
};
LangType getLangType() const {
return _lang;
};
void setLangType(LangType lang, const TCHAR * userLangName = TEXT("")) {
if (lang == _lang && lang != L_USER)
return;
_lang = lang;
if (_lang == L_USER) {
lstrcpy(_userLangExt, userLangName);
}
_needLexer = true; //change of lang means lexern eeds updating
doNotify(BufferChangeLanguage|BufferChangeLexing);
};
UniMode getUnicodeMode() const {
return _unicodeMode;
};
void setUnicodeMode(UniMode mode) {
_unicodeMode = mode;
//_isDirty = true; //set to dirty if change unicode mode
doNotify(BufferChangeUnicode | BufferChangeDirty);
};
DocFileStatus getStatus() const {
return _currentStatus;
};
Document getDocument() {
return _doc;
};
void setDirty(bool dirty) {
_isDirty = dirty;
doNotify(BufferChangeDirty);
};
void setPosition(const Position & pos, ScintillaEditView * identifier);
Position & getPosition(ScintillaEditView * identifier);
void setHeaderLineState(const std::vector<HeaderLineState> & folds, ScintillaEditView * identifier);
std::vector<HeaderLineState> & getHeaderLineState(ScintillaEditView * identifier);
void determinateFormat(const char *data);
bool isUserDefineLangExt() const {
return (_userLangExt[0] != '\0');
};
const TCHAR * getUserDefineLangName() const {
return _userLangExt;
};
const TCHAR * getCommentLineSymbol() const {
Lang *l = getCurrentLang();
if (!l)
return NULL;
return l->_pCommentLineSymbol;
};
const TCHAR * getCommentStart() const {
Lang *l = getCurrentLang();
if (!l)
return NULL;
return l->_pCommentStart;
};
const TCHAR * getCommentEnd() const {
Lang *l = getCurrentLang();
if (!l)
return NULL;
return l->_pCommentEnd;
};
bool getNeedsLexing() const {
return _needLexer;
};
void setNeedsLexing(bool lex) {
_needLexer = lex;
doNotify(BufferChangeLexing);
};
//these two return reference count after operation
int addReference(ScintillaEditView * identifier); //if ID not registered, creates a new Position for that ID and new foldstate
int removeReference(ScintillaEditView * identifier); //reduces reference. If zero, Document is purged
void setHideLineChanged(bool isHide, int location);
void setDeferredReload();
bool getNeedReload() {
return _needReloading;
}
void setNeedReload(bool reload) {
_needReloading = reload;
}
/*
pair<size_t, bool> getLineUndoState(size_t currentLine) const;
void setLineUndoState(size_t currentLine, size_t undoLevel, bool isSaved = false);
*/
int docLength() const {
return _pManager->docLength(_id);
};
private :
FileManager * _pManager;
bool _canNotify;
int _references; //if no references file inaccessible, can be closed
BufferID _id;
//document properties
Document _doc; //invariable
LangType _lang;
TCHAR _userLangExt[userLangNameMax]; // it's useful if only (_lang == L_USER)
bool _isDirty;
formatType _format;
UniMode _unicodeMode;
bool _isUserReadOnly;
bool _needLexer; //initially true
//these properties have to be duplicated because of multiple references
//All the vectors must have the same size at all times
vector< ScintillaEditView * > _referees;
vector< Position > _positions;
vector< vector<HeaderLineState> > _foldStates;
//vector< pair<size_t, pair<size_t, bool> > > _linesUndoState;
//Environment properties
DocFileStatus _currentStatus;
time_t _timeStamp; // 0 if it's a new doc
bool _isFileReadOnly;
TCHAR _fullPathName[MAX_PATH];
TCHAR * _fileName; //points to filename part in _fullPathName
bool _needReloading; //True if Buffer needs to be reloaded on activation
long _recentTag;
static long _recentTagCtr;
void updateTimeStamp();
Lang * getCurrentLang() const;
int indexOfReference(ScintillaEditView * identifier) const;
void setStatus(DocFileStatus status) {
_currentStatus = status;
doNotify(BufferChangeStatus);
}
void doNotify(int mask) {
if (_canNotify)
_pManager->beNotifiedOfBufferChange(this, mask);
};
};
#endif //BUFFER_H

View File

@ -0,0 +1,146 @@
//this file is part of notepad++
//Copyright (C)2003 Don HO ( donho@altern.org )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "DocTabView.h"
#ifndef _WIN32_IE
#define _WIN32_IE 0x0600
#endif //_WIN32_IE
#include <commctrl.h>
#include <shlwapi.h>
bool DocTabView::_hideTabBarStatus = false;
void DocTabView::addBuffer(BufferID buffer) {
if (buffer == BUFFER_INVALID) //valid only
return;
if (this->getIndexByBuffer(buffer) != -1) //no duplicates
return;
Buffer * buf = MainFileManager->getBufferByID(buffer);
TCITEM tie;
tie.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM;
int index = -1;
if (_hasImgLst)
index = 0;
tie.iImage = index;
tie.pszText = (TCHAR *)buf->getFileName();
tie.lParam = (LPARAM)buffer;
::SendMessage(_hSelf, TCM_INSERTITEM, _nbItem++, reinterpret_cast<LPARAM>(&tie));
bufferUpdated(buf, BufferChangeMask);
::SendMessage(_hParent, WM_SIZE, 0, 0);
}
void DocTabView::closeBuffer(BufferID buffer) {
int indexToClose = getIndexByBuffer(buffer);
deletItemAt(indexToClose);
::SendMessage(_hParent, WM_SIZE, 0, 0);
}
bool DocTabView::activateBuffer(BufferID buffer) {
int indexToActivate = getIndexByBuffer(buffer);
if (indexToActivate == -1)
return false; //cannot activate
activateAt(indexToActivate);
return true;
}
BufferID DocTabView::activeBuffer() {
int index = getCurrentTabIndex();
return (BufferID)getBufferByIndex(index);
}
BufferID DocTabView::findBufferByName(const TCHAR * fullfilename) { //-1 if not found, something else otherwise
TCITEM tie;
tie.lParam = -1;
tie.mask = TCIF_PARAM;
for(size_t i = 0; i < _nbItem; i++) {
::SendMessage(_hSelf, TCM_GETITEM, i, reinterpret_cast<LPARAM>(&tie));
BufferID id = (BufferID)tie.lParam;
Buffer * buf = MainFileManager->getBufferByID(id);
if (!lstrcmp(fullfilename, buf->getFullPathName())) {
return id;
}
}
return BUFFER_INVALID;
}
int DocTabView::getIndexByBuffer(BufferID id) {
TCITEM tie;
tie.lParam = -1;
tie.mask = TCIF_PARAM;
for(int i = 0; i < (int)_nbItem; i++) {
::SendMessage(_hSelf, TCM_GETITEM, i, reinterpret_cast<LPARAM>(&tie));
if ((BufferID)tie.lParam == id)
return i;
}
return -1;
}
BufferID DocTabView::getBufferByIndex(int index) {
TCITEM tie;
tie.lParam = -1;
tie.mask = TCIF_PARAM;
::SendMessage(_hSelf, TCM_GETITEM, index, reinterpret_cast<LPARAM>(&tie));
return (BufferID)tie.lParam;
}
void DocTabView::bufferUpdated(Buffer * buffer, int mask) {
int index = getIndexByBuffer(buffer->getID());
if (index == -1)
return;
TCITEM tie;
tie.lParam = -1;
tie.mask = 0;
if (mask & BufferChangeReadonly || mask & BufferChangeDirty) {
tie.mask |= TCIF_IMAGE;
tie.iImage = buffer->isDirty()?UNSAVED_IMG_INDEX:SAVED_IMG_INDEX;
if (buffer->isReadOnly()) {
tie.iImage = REDONLY_IMG_INDEX;
}
}
if (mask & BufferChangeFilename) {
tie.mask |= TCIF_TEXT;
tie.pszText = (TCHAR *)buffer->getFileName();
}
::SendMessage(_hSelf, TCM_SETITEM, index, reinterpret_cast<LPARAM>(&tie));
::SendMessage(_hParent, WM_SIZE, 0, 0);
}
void DocTabView::setBuffer(int index, BufferID id) {
if (index < 0 || index >= (int)_nbItem)
return;
TCITEM tie;
tie.lParam = (LPARAM)id;
tie.mask = TCIF_PARAM;
::SendMessage(_hSelf, TCM_SETITEM, index, reinterpret_cast<LPARAM>(&tie));
bufferUpdated(MainFileManager->getBufferByID(id), BufferChangeMask); //update tab, everything has changed
::SendMessage(_hParent, WM_SIZE, 0, 0);
}

View File

@ -0,0 +1,92 @@
//this file is part of notepad++
//Copyright (C)2003 Don HO ( donho@altern.org )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#ifndef DOCTABVIEW_H
#define DOCTABVIEW_H
#include "TabBar.h"
#include "ScintillaEditView.h"
#include "ImageListSet.h"
const int SAVED_IMG_INDEX = 0;
const int UNSAVED_IMG_INDEX = 1;
const int REDONLY_IMG_INDEX = 2;
class DocTabView : public TabBarPlus
{
public :
DocTabView():TabBarPlus(), _pView(NULL) {};
virtual ~DocTabView(){};
virtual void destroy() {
TabBarPlus::destroy();
};
void init(HINSTANCE hInst, HWND parent, ScintillaEditView * pView, IconList *pIconList = NULL)
{
TabBarPlus::init(hInst, parent);
_pView = pView;
if (pIconList)
TabBar::setImageList(pIconList->getHandle());
return;
};
void addBuffer(BufferID buffer);
void closeBuffer(BufferID buffer);
void bufferUpdated(Buffer * buffer, int mask);
bool activateBuffer(BufferID buffer);
BufferID activeBuffer();
BufferID findBufferByName(const TCHAR * fullfilename); //-1 if not found, something else otherwise
int getIndexByBuffer(BufferID id);
BufferID getBufferByIndex(int index);
void setBuffer(int index, BufferID id);
static bool setHideTabBarStatus(bool hideOrNot) {
bool temp = _hideTabBarStatus;
_hideTabBarStatus = hideOrNot;
return temp;
};
static bool getHideTabBarStatus() {
return _hideTabBarStatus;
};
virtual void reSizeTo(RECT & rc) {
if (_hideTabBarStatus)
{
RECT rcTmp = rc;
TabBar::reSizeTo(rcTmp);
_pView->reSizeTo(rc);
}
else
{
TabBar::reSizeTo(rc);
_pView->reSizeTo(rc);
}
};
private :
ScintillaEditView *_pView;
static bool _hideTabBarStatus;
};
#endif //DOCTABVIEW_H

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,594 @@
//this file is part of notepad++
//Copyright (C)2003 Don HO <donho@altern.org>
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#ifndef FIND_REPLACE_DLG_H
#define FIND_REPLACE_DLG_H
#include "StaticDialog.h"
#include "FindReplaceDlg_rc.h"
#include "Buffer.h"
#include "ScintillaEditView.h"
#include "StatusBar.h"
#include "DockingDlgInterface.h"
#define FIND_RECURSIVE 1
#define FIND_INHIDDENDIR 2
#define FINDREPLACE_MAXLENGTH 2048
enum DIALOG_TYPE {FIND_DLG, REPLACE_DLG, FINDINFILES_DLG};
#define DIR_DOWN true
#define DIR_UP false
//#define FIND_REPLACE_STR_MAX 256
enum InWhat{ALL_OPEN_DOCS, FILES_IN_DIR, CURRENT_DOC};
struct FoundInfo {
FoundInfo(int start, int end, const TCHAR *fullPath)
: _start(start), _end(end), _fullPath(fullPath) {};
int _start;
int _end;
std::generic_string _fullPath;
};
struct TargetRange {
int targetStart;
int targetEnd;
};
enum SearchType { FindNormal, FindExtended, FindRegex };
enum ProcessOperation { ProcessFindAll, ProcessReplaceAll, ProcessCountAll, ProcessMarkAll, ProcessMarkAll_2, ProcessMarkAll_IncSearch, ProcessMarkAllExt };
struct FindOption {
bool _isWholeWord;
bool _isMatchCase;
bool _isWrapAround;
bool _whichDirection;
bool _isIncremental;
SearchType _searchType;
FindOption() :_isWholeWord(true), _isMatchCase(true), _searchType(FindNormal),\
_isWrapAround(true), _whichDirection(DIR_DOWN), _isIncremental(false){};
};
//This class contains generic search functions as static functions for easy access
class Searching {
public:
static int convertExtendedToString(const TCHAR * query, TCHAR * result, int length);
static TargetRange t;
static int buildSearchFlags(FindOption * option) {
return (option->_isWholeWord ? SCFIND_WHOLEWORD : 0) |
(option->_isMatchCase ? SCFIND_MATCHCASE : 0) |
(option->_searchType == FindRegex ? SCFIND_REGEXP|SCFIND_POSIX : 0);
};
static void displaySectionCentered(int posStart, int posEnd, ScintillaEditView * pEditView, bool isDownwards = true);
private:
static bool readBase(const TCHAR * str, int * value, int base, int size);
};
//Finder: Dockable window that contains search results
class Finder : public DockingDlgInterface {
friend class FindReplaceDlg;
public:
Finder() : DockingDlgInterface(IDD_FINDRESULT), _pMainFoundInfos(&_foundInfos1), _pMainMarkings(&_markings1) {
_MarkingsStruct._length = 0;
_MarkingsStruct._markings = NULL;
};
~Finder() {
_scintView.destroy();
}
void init(HINSTANCE hInst, HWND hPere, ScintillaEditView **ppEditView) {
DockingDlgInterface::init(hInst, hPere);
_ppEditView = ppEditView;
};
void addSearchLine(const TCHAR *searchName) {
generic_string str = TEXT("Search \"");
str += searchName;
str += TEXT("\"\r\n");
setFinderReadOnly(false);
_scintView.addGenericText(str.c_str());
setFinderReadOnly(true);
_lastSearchHeaderPos = _scintView.execute(SCI_GETCURRENTPOS) - 2;
_pMainFoundInfos->push_back(EmptyFoundInfo);
_pMainMarkings->push_back(EmptySearchResultMarking);
};
void addFileNameTitle(const TCHAR * fileName) {
generic_string str = TEXT(" ");
str += fileName;
str += TEXT("\r\n");
setFinderReadOnly(false);
_scintView.addGenericText(str.c_str());
setFinderReadOnly(true);
_lastFileHeaderPos = _scintView.execute(SCI_GETCURRENTPOS) - 2;
_pMainFoundInfos->push_back(EmptyFoundInfo);
_pMainMarkings->push_back(EmptySearchResultMarking);
};
void addFileHitCount(int count) {
TCHAR text[20];
wsprintf(text, TEXT(" (%i hits)"), count);
setFinderReadOnly(false);
_scintView.insertGenericTextFrom(_lastFileHeaderPos, text);
setFinderReadOnly(true);
nFoundFiles++;
};
void addSearchHitCount(int count) {
TCHAR text[50];
wsprintf(text, TEXT(" (%i hits in %i files)"), count, nFoundFiles);
setFinderReadOnly(false);
_scintView.insertGenericTextFrom(_lastSearchHeaderPos, text);
setFinderReadOnly(true);
};
void add(FoundInfo fi, SearchResultMarking mi, const TCHAR* foundline, int lineNb) {
_pMainFoundInfos->push_back(fi);
std::generic_string str = TEXT("\tLine ");
TCHAR lnb[16];
wsprintf(lnb, TEXT("%d"), lineNb);
str += lnb;
str += TEXT(": ");
mi._start += str.length();
mi._end += str.length();
str += foundline;
if (str.length() >= SC_SEARCHRESULT_LINEBUFFERMAXLENGTH)
{
const TCHAR * endOfLongLine = TEXT("...\r\n");
str = str.substr(0, SC_SEARCHRESULT_LINEBUFFERMAXLENGTH - lstrlen(endOfLongLine) - 1);
str += endOfLongLine;
}
setFinderReadOnly(false);
_scintView.addGenericText(str.c_str(), &mi._start, &mi._end);
setFinderReadOnly(true);
_pMainMarkings->push_back(mi);
};
void setFinderStyle();
void removeAll() {
_pMainFoundInfos->clear();
_pMainMarkings->clear();
setFinderReadOnly(false);
_scintView.execute(SCI_CLEARALL);
setFinderReadOnly(true);
};
void beginNewFilesSearch() {
_scintView.execute(SCI_SETLEXER, SCLEX_NULL);
_scintView.execute(SCI_SETCURRENTPOS, 0);
_pMainFoundInfos = _pMainFoundInfos == &_foundInfos1 ? &_foundInfos2 : &_foundInfos1;
_pMainMarkings = _pMainMarkings == &_markings1 ? &_markings2 : &_markings1;
nFoundFiles = 0;
// fold all old searches (1st level only)
_scintView.collapse(searchHeaderLevel - SC_FOLDLEVELBASE, fold_collapse);
};
void finishFilesSearch(int count) {
std::vector<FoundInfo>* _pOldFoundInfos;
std::vector<SearchResultMarking>* _pOldMarkings;
_pOldFoundInfos = _pMainFoundInfos == &_foundInfos1 ? &_foundInfos2 : &_foundInfos1;
_pOldMarkings = _pMainMarkings == &_markings1 ? &_markings2 : &_markings1;
_pOldFoundInfos->insert(_pOldFoundInfos->begin(), _pMainFoundInfos->begin(), _pMainFoundInfos->end());
_pOldMarkings->insert(_pOldMarkings->begin(), _pMainMarkings->begin(), _pMainMarkings->end());
_pMainFoundInfos->clear();
_pMainMarkings->clear();
_pMainFoundInfos = _pOldFoundInfos;
_pMainMarkings = _pOldMarkings;
_MarkingsStruct._length = _pMainMarkings->size();
_MarkingsStruct._markings = &((*_pMainMarkings)[0]);
addSearchHitCount(count);
_scintView.execute(SCI_SETSEL, 0, 0);
_scintView.execute(SCI_SETLEXER, SCLEX_SEARCHRESULT);
};
void gotoNextFoundResult(int direction);
void GotoFoundLine();
void DeleteResult();
protected :
virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
bool notify(SCNotification *notification);
private:
enum { searchHeaderLevel = SC_FOLDLEVELBASE + 1, fileHeaderLevel, resultLevel };
ScintillaEditView **_ppEditView;
std::vector<FoundInfo> _foundInfos1;
std::vector<FoundInfo> _foundInfos2;
std::vector<FoundInfo>* _pMainFoundInfos;
std::vector<SearchResultMarking> _markings1;
std::vector<SearchResultMarking> _markings2;
std::vector<SearchResultMarking>* _pMainMarkings;
SearchResultMarkings _MarkingsStruct;
ScintillaEditView _scintView;
unsigned int nFoundFiles;
int _lastFileHeaderPos;
int _lastSearchHeaderPos;
void setFinderReadOnly(bool isReadOnly) {
_scintView.execute(SCI_SETREADONLY, isReadOnly);
};
static FoundInfo EmptyFoundInfo;
static SearchResultMarking EmptySearchResultMarking;
};
//FindReplaceDialog: standard find/replace window
class FindReplaceDlg : public StaticDialog
{
friend class FindIncrementDlg;
public :
FindReplaceDlg() : StaticDialog(), _pFinder(NULL), _isRTL(false), _isRecursive(true),_isInHiddenDir(false),\
_fileNameLenMax(1024) {
_uniFileName = new char[(_fileNameLenMax + 3) * 2];
_winVer = (NppParameters::getInstance())->getWinVersion();
};
~FindReplaceDlg() {
_tab.destroy();
if (_pFinder)
delete _pFinder;
delete [] _uniFileName;
};
void init(HINSTANCE hInst, HWND hPere, ScintillaEditView **ppEditView) {
Window::init(hInst, hPere);
if (!ppEditView)
throw int(9900);
_ppEditView = ppEditView;
};
virtual void create(int dialogID, bool isRTL = false);
void initOptionsFromDlg() {
_options._isWholeWord = isCheckedOrNot(IDWHOLEWORD);
_options._isMatchCase = isCheckedOrNot(IDMATCHCASE);
_options._searchType = isCheckedOrNot(IDREGEXP)?FindRegex:isCheckedOrNot(IDEXTENDED)?FindExtended:FindNormal;
_options._isWrapAround = isCheckedOrNot(IDWRAP);
_isInSelection = isCheckedOrNot(IDC_IN_SELECTION_CHECK);
// Set Direction : Down by default
_options._whichDirection = DIR_DOWN;
::SendMessage(::GetDlgItem(_hSelf, IDDIRECTIONDOWN), BM_SETCHECK, BST_CHECKED, 0);
_doPurge = isCheckedOrNot(IDC_PURGE_CHECK);
_doMarkLine = isCheckedOrNot(IDC_MARKLINE_CHECK);
_doStyleFoundToken = isCheckedOrNot(IDC_STYLEFOUND_CHECK);
::EnableWindow(::GetDlgItem(_hSelf, IDCMARKALL), (_doMarkLine || _doStyleFoundToken));
};
void doDialog(DIALOG_TYPE whichType, bool isRTL = false) {
if (!isCreated())
{
create(IDD_FIND_REPLACE_DLG, isRTL);
_isRTL = isRTL;
}
if (whichType == FINDINFILES_DLG)
enableFindInFilesFunc();
else
enableReplaceFunc(whichType == REPLACE_DLG);
::SetFocus(::GetDlgItem(_hSelf, IDFINDWHAT));
display();
};
bool processFindNext(const TCHAR *txt2find, FindOption *options = NULL);
bool processReplace(const TCHAR *txt2find, const TCHAR *txt2replace, FindOption *options = NULL);
int markAll(const TCHAR *txt2find, int styleID);
int markAll2(const TCHAR *str2find);
int markAllInc(const TCHAR *str2find, FindOption *opt);
int processAll(ProcessOperation op, const TCHAR *txt2find, const TCHAR *txt2replace, bool isEntire = false, const TCHAR *fileName = NULL, FindOption *opt = NULL, int colourStyleID = -1);
int processRange(ProcessOperation op, const TCHAR *txt2find, const TCHAR *txt2replace, int startRange, int endRange, const TCHAR *fileName = NULL, FindOption *opt = NULL, int colourStyleID = -1);
void replaceAllInOpenedDocs();
void findAllIn(InWhat op);
void setSearchText(TCHAR * txt2find) {
HWND hCombo = ::GetDlgItem(_hSelf, IDFINDWHAT);
if (txt2find && txt2find[0])
{
// We got a valid search string
::SendMessage(hCombo, CB_SETCURSEL, -1, 0); // remove selection - to allow using down arrow to get to last searched word
::SetDlgItemText(_hSelf, IDFINDWHAT, txt2find);
}
::SendMessage(hCombo, CB_SETEDITSEL, 0, MAKELPARAM(0, -1)); // select all text - fast edit
}
void gotoNextFoundResult(int direction = 0) {if (_pFinder) _pFinder->gotoNextFoundResult(direction);};
void putFindResult(int result) {
_findAllResult = result;
};
const TCHAR * getDir2Search() const {return _directory.c_str();};
void getPatterns(vector<generic_string> & patternVect);
void launchFindInFilesDlg() {
doDialog(FINDINFILES_DLG);
};
void setFindInFilesDirFilter(const TCHAR *dir, const TCHAR *filters) {
if (dir)
{
_directory = dir;
::SetDlgItemText(_hSelf, IDD_FINDINFILES_DIR_COMBO, dir);
}
if (filters)
{
_filters = filters;
::SetDlgItemText(_hSelf, IDD_FINDINFILES_FILTERS_COMBO, filters);
}
};
generic_string getText2search() const {
return getTextFromCombo(::GetDlgItem(_hSelf, IDFINDWHAT));
};
const generic_string & getFilters() const {return _filters;};
const generic_string & getDirectory() const {return _directory;};
const FindOption & getCurrentOptions() const {return _options;};
bool isRecursive() const { return _isRecursive; };
bool isInHiddenDir() const { return _isInHiddenDir; };
void saveFindHistory();
void changeTabName(DIALOG_TYPE index, const TCHAR *name2change) {
TCITEM tie;
tie.mask = TCIF_TEXT;
tie.pszText = (TCHAR *)name2change;
TabCtrl_SetItem(_tab.getHSelf(), index, &tie);
}
void beginNewFilesSearch()
{
_pFinder->beginNewFilesSearch();
bool isUnicode = (*_ppEditView)->getCurrentBuffer()->getUnicodeMode() != uni8Bit;
_pFinder->addSearchLine(getText2search().c_str());
}
void finishFilesSearch(int count)
{
_pFinder->finishFilesSearch(count);
}
void focusOnFinder() {
// Show finder and set focus
if (_pFinder)
{
::SendMessage(_hParent, NPPM_DMMSHOW, 0, (LPARAM)_pFinder->getHSelf());
_pFinder->_scintView.getFocus();
}
};
HWND getHFindResults() {
if (_pFinder)
return _pFinder->_scintView.getHSelf();
return NULL;
}
void updateFinderScintilla() {
if (_pFinder && _pFinder->isCreated() && _pFinder->isVisible())
{
_pFinder->setFinderStyle();
}
};
protected :
virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
void addText2Combo(const TCHAR * txt2add, HWND comboID, bool isUTF8 = false);
generic_string getTextFromCombo(HWND hCombo, bool isUnicode = false) const;
static LONG originalFinderProc;
// Window procedure for the finder
static LRESULT FAR PASCAL finderProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if (message == WM_KEYDOWN && (wParam == VK_DELETE || wParam == VK_RETURN))
{
ScintillaEditView *pScint = (ScintillaEditView *)(::GetWindowLongPtr(hwnd, GWL_USERDATA));
Finder *pFinder = (Finder *)(::GetWindowLongPtr(pScint->getHParent(), GWL_USERDATA));
if (wParam == VK_RETURN)
pFinder->GotoFoundLine();
else // VK_DELETE
pFinder->DeleteResult();
return 0;
}
else
// Call default (original) window procedure
return CallWindowProc((WNDPROC) originalFinderProc, hwnd, message, wParam, lParam);
}
private :
DIALOG_TYPE _currentStatus;
FindOption _options;
bool _doPurge;
bool _doMarkLine;
bool _doStyleFoundToken;
bool _isInSelection;
RECT _findClosePos, _replaceClosePos, _findInFilesClosePos;
ScintillaEditView **_ppEditView;
Finder *_pFinder;
bool _isRTL;
int _findAllResult;
TCHAR _findAllResultStr[1024];
generic_string _filters;
generic_string _directory;
bool _isRecursive;
bool _isInHiddenDir;
int _fileNameLenMax;
char *_uniFileName;
TabBar _tab;
winVer _winVer;
void enableReplaceFunc(bool isEnable);
void enableFindInFilesControls(bool isEnable = true);
void enableFindInFilesFunc() {
enableFindInFilesControls();
_currentStatus = FINDINFILES_DLG;
gotoCorrectTab();
::MoveWindow(::GetDlgItem(_hSelf, IDCANCEL), _findInFilesClosePos.left, _findInFilesClosePos.top, _findInFilesClosePos.right, _findInFilesClosePos.bottom, TRUE);
TCHAR label[MAX_PATH];
_tab.getCurrentTitle(label, MAX_PATH);
::SetWindowText(_hSelf, label);
setDefaultButton(IDD_FINDINFILES_FIND_BUTTON);
};
//////////////////
void setDefaultButton(int nID)
{
#if 0
// There is a problem when you:
// 1. open the find dialog
// 2. press the "close" buttom
// 3. open it again
// 4. search for a non existing text
// 5. when the "Can't find the text:" messagebox appears, hit "OK"
// 6. now, the "Close" button looks like the default button. (but it only looks like that)
// if you hit "Enter" the "Find" button will be "pressed".
// I thought this code might fix this but it doesn't
// See: http://msdn.microsoft.com/en-us/library/ms645413(VS.85).aspx
HWND pButton;
DWORD dwDefInfo = SendMessage(_hSelf, DM_GETDEFID, 0, 0L);
if (HIWORD(dwDefInfo) == DC_HASDEFID && (int)LOWORD(dwDefInfo) != nID)
{
// Reset 'DefButton' style
pButton = GetDlgItem(_hSelf, (int)LOWORD(dwDefInfo));
if (pButton)
SendMessage(pButton, BM_SETSTYLE, LOWORD(BS_PUSHBUTTON | BS_RIGHT ), MAKELPARAM(TRUE, 0));
}
SendMessage(_hSelf, DM_SETDEFID, (WPARAM)nID, 0L);
pButton = GetDlgItem(_hSelf, nID);
if (pButton)
{
SendMessage(pButton, BM_SETSTYLE, LOWORD(BS_DEFPUSHBUTTON), MAKELPARAM(TRUE, 0));
}
#endif
SendMessage(_hSelf, DM_SETDEFID, (WPARAM)nID, 0L);
}
////////////////////////
void gotoCorrectTab() {
int currentIndex = _tab.getCurrentTabIndex();
if (currentIndex != _currentStatus)
_tab.activateAt(_currentStatus);
};
bool isCheckedOrNot(int checkControlID) const {
return (BST_CHECKED == ::SendMessage(::GetDlgItem(_hSelf, checkControlID), BM_GETCHECK, 0, 0));
};
void updateCombos();
void updateCombo(int comboID) {
bool isUnicode = (*_ppEditView)->getCurrentBuffer()->getUnicodeMode() != uni8Bit;
HWND hCombo = ::GetDlgItem(_hSelf, comboID);
addText2Combo(getTextFromCombo(hCombo, isUnicode).c_str(), hCombo, isUnicode);
};
void fillFindHistory();
void fillComboHistory(int id, int count, generic_string **pStrings);
void saveComboHistory(int id, int maxcount, int& oldcount, generic_string **pStrings);
};
//FindIncrementDlg: incremental search dialog, docked in rebar
class FindIncrementDlg : public StaticDialog
{
public :
FindIncrementDlg() : _pFRDlg(NULL), _pRebar(NULL) {};
void init(HINSTANCE hInst, HWND hPere, FindReplaceDlg *pFRDlg, bool isRTL = false) {
Window::init(hInst, hPere);
if (!pFRDlg)
throw int(9910);
_pFRDlg = pFRDlg;
create(IDD_INCREMENT_FIND, isRTL);
_isRTL = isRTL;
};
virtual void destroy();
virtual void display(bool toShow = true) const;
void setSearchText(const TCHAR * txt2find, bool isUTF8 = false) {
_doSearchFromBegin = false;
#ifdef UNICODE
::SendDlgItemMessage(_hSelf, IDC_INCFINDTEXT, WM_SETTEXT, 0, (LPARAM)txt2find);
#else
if (!isUTF8)
{
::SendDlgItemMessage(_hSelf, IDC_INCFINDTEXT, WM_SETTEXT, 0, (LPARAM)txt2find);
return;
}
const int wideBufferSize = 256;
WCHAR wchars[wideBufferSize];
::MultiByteToWideChar(CP_UTF8, 0, txt2find, -1, wchars, wideBufferSize);
winVer winVersion = NppParameters::getInstance()->getWinVersion();
if (winVersion <= WV_ME) {
//Cannot simply take txt2find since its UTF8
char ansiBuffer[wideBufferSize]; //Assuming no more than 2 bytes for each wchar (SBCS or DBCS, no UTF8 and sorts)
::WideCharToMultiByte(CP_ACP, 0, wchars, -1, ansiBuffer, wideBufferSize, NULL, NULL);
::SendDlgItemMessageA(_hSelf, IDC_INCFINDTEXT, WM_SETTEXT, 0, (LPARAM)ansiBuffer);
} else {
::SendDlgItemMessageW(_hSelf, IDC_INCFINDTEXT, WM_SETTEXT, 0, (LPARAM)wchars);
}
#endif
}
void addToRebar(ReBar * rebar);
private :
bool _isRTL;
FindReplaceDlg *_pFRDlg;
ReBar * _pRebar;
REBARBANDINFO _rbBand;
bool _doSearchFromBegin;
virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
void markSelectedTextInc(bool enable, FindOption *opt = NULL);
};
#endif //FIND_REPLACE_DLG_H

View File

@ -0,0 +1,100 @@
/*
this file is part of notepad++
Copyright (C)2003 Don HO <donho@altern.org >
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef FIND_REPLACE_DLG_RC
#define FIND_REPLACE_DLG_RC
#include <windows.h>
#include "FindReplaceDlg_rc.h"
IDD_FIND_REPLACE_DLG DIALOGEX 36, 44, 317, 182
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_TOOLWINDOW
CAPTION "Replace"
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
RTEXT "&Find what :",IDFINDWHAT_STATIC,6,22,75,8
COMBOBOX IDFINDWHAT,83,20,125,150,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_TABSTOP
RTEXT "Rep&lace with :",ID_STATICTEXT_REPLACE,6,40,75,8
COMBOBOX IDREPLACEWITH,83,38,125,50,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_TABSTOP
CONTROL "&Mark Line",IDC_MARKLINE_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,40,88,10
CONTROL "Style found to&ken",IDC_STYLEFOUND_CHECK,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,13,52,100,15
GROUPBOX "",IDC_FINDALL_STATIC,6,31,204,54
CONTROL "Purge for each search",IDC_PURGE_CHECK,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,13,66,99,16
PUSHBUTTON "Find &All",IDCMARKALL,146,38,59,14
GROUPBOX "",IDC_REPLACEINSELECTION,141,50,170,23
CONTROL "In select&ion",IDC_IN_SELECTION_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,146,58,59,10
PUSHBUTTON "Clear",IDC_CLEAR_ALL,146,71,59,11
RTEXT "Filter&s :",IDD_FINDINFILES_FILTERS_STATIC,27,58,53,8
COMBOBOX IDD_FINDINFILES_FILTERS_COMBO,83,56,125,150,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_TABSTOP
RTEXT "Dir&ectory :",IDD_FINDINFILES_DIR_STATIC,7,76,40,8
COMBOBOX IDD_FINDINFILES_DIR_COMBO,49,74,141,150,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_TABSTOP
PUSHBUTTON "...",IDD_FINDINFILES_BROWSE_BUTTON,193,74,15,13
CONTROL "In all su&b-folders",IDD_FINDINFILES_RECURSIVE_CHECK, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,218,73,94,15
CONTROL "In &hidden folders",IDD_FINDINFILES_INHIDDENDIR_CHECK, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,218,87,94,15
CONTROL "Match &whole word only",IDWHOLEWORD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,88,140,15
CONTROL "Match &case",IDMATCHCASE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,100,140,15
CONTROL "Wra&p around",IDWRAP,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,6,112,110,15
GROUPBOX "Search mode",IDC_MODE_STATIC,6,126,138,48
CONTROL "&Normal",IDNORMAL,"Button",BS_AUTORADIOBUTTON | WS_GROUP,12,138,126,10
CONTROL "E&xtended (\\n, \\r, \\t, \\0, \\x...)",IDEXTENDED, "Button",BS_AUTORADIOBUTTON,12,150,126,10
CONTROL "Re&gular expression",IDREGEXP,"Button",BS_AUTORADIOBUTTON,12,162,126,10
CONTROL "&Up",IDDIRECTIONUP,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,155,138,45,12
CONTROL "&Down",IDDIRECTIONDOWN,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,155,150,45,12
GROUPBOX "Direction",IDC_DIR_STATIC,150,126,60,48,WS_GROUP
PUSHBUTTON "Find Next",IDOK,217,20,90,14,WS_GROUP
PUSHBUTTON "Coun&t",IDCCOUNTALL,217,38,90,14
PUSHBUTTON "Find all in all &opened documents",IDC_FINDALL_OPENEDFILES,217,56,90,21,BS_MULTILINE
PUSHBUTTON "Find all in current document",IDC_FINDALL_CURRENTFILE,217,80,90,21,BS_MULTILINE
PUSHBUTTON "&Replace",IDREPLACE,217,38,90,14
PUSHBUTTON "Replace &All",IDREPLACEALL,217,56,90,14
PUSHBUTTON "Replace all in all &opened documents",IDC_REPLACE_OPENEDFILES,217,74,90,21,BS_MULTILINE
PUSHBUTTON "Find All",IDD_FINDINFILES_FIND_BUTTON,217,20,90,14,WS_GROUP
PUSHBUTTON "&Replace in files",IDD_FINDINFILES_REPLACEINFILES,217,38,90,14
PUSHBUTTON "Close",IDCANCEL,217,98,90,14
GROUPBOX "",IDC_TRANSPARENT_GRPBOX,222,126,85,48
CONTROL "Transparenc&y",IDC_TRANSPARENT_CHECK,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,218,126,80,10
CONTROL "On lose focus",IDC_TRANSPARENT_LOSSFOCUS_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,232,138,70,10
CONTROL "Always",IDC_TRANSPARENT_ALWAYS_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,232,150,70,10
CONTROL "",IDC_PERCENTAGE_SLIDER,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | NOT WS_VISIBLE | WS_TABSTOP,235,161,53,10
END
IDD_INCREMENT_FIND DIALOGEX 0, 0, 400, 20
STYLE DS_SYSMODAL | DS_CONTROL | DS_FIXEDSYS | WS_CHILD | WS_CLIPCHILDREN
//EXSTYLE WS_EX_TRANSPARENT
FONT 8, TEXT("MS Shell Dlg")
BEGIN
PUSHBUTTON "X",IDCANCEL,2,3,16,14
RTEXT "Find :",IDC_INCSTATIC,20,6,25,12
EDITTEXT IDC_INCFINDTEXT,45,4,175,12,ES_AUTOHSCROLL | ES_WANTRETURN | NOT WS_BORDER,WS_EX_STATICEDGE
PUSHBUTTON "<",IDC_INCFINDPREVOK,223,3,16,14
DEFPUSHBUTTON ">",IDC_INCFINDNXTOK,243,3,16,14
CONTROL "Highlight all", IDC_INCFINDHILITEALL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,270,5,65,12
CONTROL "Match case", IDC_INCFINDMATCHCASE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,335,5,60,12
END
IDD_FINDRESULT DIALOGEX 26, 41, 223, 67
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_TOOLWINDOW | WS_EX_WINDOWEDGE
CAPTION "Find result"
FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x0
BEGIN
DEFPUSHBUTTON ">",IDC_INCFINDNXTOK,243,0,16,14, NOT WS_VISIBLE
END
#endif //FIND_REPLACE_DLG_RC

View File

@ -0,0 +1,74 @@
#define IDD_FIND_REPLACE_DLG 1600
#define IDFINDWHAT 1601
#define IDREPLACEWITH 1602
#define IDWHOLEWORD 1603
#define IDMATCHCASE 1604
#define IDC_MODE_STATIC 1624
#define IDNORMAL 1625
#define IDEXTENDED 1626
#define IDREGEXP 1605
#define IDWRAP 1606
#define IDUNSLASH 1607
#define IDREPLACE 1608
#define IDREPLACEALL 1609
#define IDREPLACEINSEL 1610
#define ID_STATICTEXT_REPLACE 1611
#define IDDIRECTIONUP 1612
#define IDDIRECTIONDOWN 1613
#define IDCCOUNTALL 1614
#define IDCMARKALL 1615
#define IDC_MARKLINE_CHECK 1616
#define IDC_STYLEFOUND_CHECK 1617
#define IDC_PURGE_CHECK 1618
#define IDC_FINDALL_STATIC 1619
#define IDFINDWHAT_STATIC 1620
#define IDC_DIR_STATIC 1621
#define IDC_PERCENTAGE_SLIDER 1622
#define IDC_TRANSPARENT_GRPBOX 1623
#define IDC_FIND_IN_STATIC 1628
//#define IDC_CURRENT_FILE_RADIO 1629
//#define IDC_OPENED_FILES_RADIO 1630
//#define IDC_FILES_RADIO 1631
#define IDC_IN_SELECTION_CHECK 1632
#define IDC_CLEAR_ALL 1633
#define IDC_REPLACEINSELECTION 1634
#define IDC_REPLACE_OPENEDFILES 1635
#define IDC_FINDALL_OPENEDFILES 1636
//#define IDC_FINDINFILES 1637
#define IDC_FINDINFILES_LAUNCH 1638
#define IDC_GETCURRENTDOCTYPE 1639
#define IDC_FINDALL_CURRENTFILE 1641
//#define IDSWITCH 1640
#define IDD_FINDINFILES_DLG 1650
#define IDD_FINDINFILES_BROWSE_BUTTON 1651
#define IDD_FINDINFILES_FILTERS_COMBO 1652
#define IDD_FINDINFILES_DIR_COMBO 1653
#define IDD_FINDINFILES_FILTERS_STATIC 1654
#define IDD_FINDINFILES_DIR_STATIC 1655
#define IDD_FINDINFILES_FIND_BUTTON 1656
#define IDD_FINDINFILES_GOBACK_BUTTON 1657
#define IDD_FINDINFILES_RECURSIVE_CHECK 1658
#define IDD_FINDINFILES_INHIDDENDIR_CHECK 1659
#define IDD_FINDINFILES_REPLACEINFILES 1660
#define IDD_FINDRESULT 1670
#define IDD_INCREMENT_FIND 1680
#define IDC_INCSTATIC 1681
#define IDC_INCFINDTEXT 1682
#define IDC_INCFINDPREVOK 1683
#define IDC_INCFINDNXTOK 1684
#define IDC_INCFINDMATCHCASE 1685
#define IDC_INCFINDHILITEALL 1686
#define IDC_TRANSPARENT_CHECK 1686
#define IDC_TRANSPARENT_LOSSFOCUS_RADIO 1687
#define IDC_TRANSPARENT_ALWAYS_RADIO 1688

View File

@ -0,0 +1,416 @@
//this file is part of Notepad++
//Copyright (C)2008 Harry Bruin <harrybharry@users.sourceforge.net>
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "FunctionCallTip.h"
struct Token {
TCHAR * token;
int length;
bool isIdentifier;
Token(TCHAR * tok, int len, bool isID) : token(tok), length(len), isIdentifier(isID) {};
};
struct FunctionValues {
int lastIdentifier;
int lastFunctionIdentifier;
int param;
int scopeLevel;
FunctionValues() : lastIdentifier(-1), lastFunctionIdentifier(-1), param(0), scopeLevel(-1) {};
};
inline bool lower(TCHAR c) {
return (c >= 'a' && c <= 'z');
}
inline bool match(TCHAR c1, TCHAR c2) {
if (c1 == c2) return true;
if (lower(c1))
return ((c1-32) == c2);
if (lower(c2))
return ((c2-32) == c1);
return false;
}
//test string case insensitive ala Scintilla
//0 if equal, <0 of before, >0 if after (name1 that is)
int testNameNoCase(const TCHAR * name1, const TCHAR * name2, int len = -1) {
if (len == -1) {
len = 1024; //magic value, but it probably fails way before it reaches this
}
int i = 0;
while(match(name1[i], name2[i])) {
if (name1[i] == 0 || i == len) {
return 0; //equal
}
i++;
}
int subs1 = lower(name1[i])?32:0;
int subs2 = lower(name2[i])?32:0;
return ( (name1[i]-subs1) - (name2[i]-subs2) );
}
void FunctionCallTip::setLanguageXML(TiXmlElement * pXmlKeyword) {
if (isVisible())
close();
_pXmlKeyword = pXmlKeyword;
}
bool FunctionCallTip::updateCalltip(int ch, bool needShown) {
if (!needShown && ch != _start && !isVisible()) //must be already visible
return false;
_curPos = _pEditView->execute(SCI_GETCURRENTPOS);
//recalculate everything
if (!getCursorFunction()) { //cannot display calltip (anymore)
close();
return false;
}
showCalltip();
return true;
}
void FunctionCallTip::showNextOverload() {
if (!isVisible())
return;
_currentOverload = (_currentOverload+1) % _currentNrOverloads;
showCalltip();
}
void FunctionCallTip::showPrevOverload() {
if (!isVisible())
return;
_currentOverload = _currentOverload > 0?(_currentOverload-1) : _currentNrOverloads-1;
showCalltip();
}
void FunctionCallTip::close() {
if (!isVisible()) {
return;
}
_pEditView->execute(SCI_CALLTIPCANCEL);
_currentOverload = 0;
}
bool FunctionCallTip::getCursorFunction() {
int line = _pEditView->execute(SCI_LINEFROMPOSITION, _curPos);
int startpos = _pEditView->execute(SCI_POSITIONFROMLINE, line);
int endpos = _pEditView->execute(SCI_GETLINEENDPOSITION, line);
int len = endpos - startpos + 3; //also take CRLF in account, even if not there
int offset = _curPos - startpos; //offset is cursor location, only stuff before cursor has influence
const int maxLen = 128;
if ((offset < 2) || (len >= maxLen))
{
reset();
return false; //cannot be a func, need name and separator
}
TCHAR lineData[maxLen] = TEXT("");
_pEditView->getLine(line, lineData, len);
//line aquired, find the functionname
//first split line into tokens to parse
//token is identifier or some expression, whitespace is ignored
std::vector< Token > tokenVector;
int tokenLen = 0;
TCHAR ch;
for (int i = 0; i < offset; i++) { //we dont care about stuff after the offset
//tokenVector.push_back(pair(lineData+i, len));
ch = lineData[i];
if (ch >= 'A' && ch <= 'Z' || ch >= 'a' && ch <= 'z' || ch >= '0' && ch <= '9' || ch == '_') { //part of identifier
tokenLen = 0;
TCHAR * begin = lineData+i;
while ( (ch >= 'A' && ch <= 'Z' || ch >= 'a' && ch <= 'z' || ch >= '0' && ch <= '9' || ch == '_') && i < offset) {
tokenLen++;
i++;
ch = lineData[i];
}
tokenVector.push_back(Token(begin, tokenLen, true));
i--; //correct overshooting of while loop
} else {
if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r') { //whitespace
//do nothing
} else {
tokenLen = 1;
tokenVector.push_back(Token(lineData+i, tokenLen, false));
}
}
}
size_t vsize = tokenVector.size();
//mind nested funcs, like |blblb a (x, b(), c);|
//therefore, use stack
std::vector<FunctionValues> valueVec;
FunctionValues curValue, newValue;
int scopeLevel = 0;
for (size_t i = 0; i < vsize; i++) {
Token & curToken = tokenVector.at(i);
if (curToken.isIdentifier) {
curValue.lastIdentifier = i;
} else {
if (curToken.token[0] == _start) {
scopeLevel++;
newValue = curValue;
valueVec.push_back(newValue); //store the current settings, so when this new function doesnt happen to be the 'real' one, we can restore everything
curValue.scopeLevel = scopeLevel;
if (i > 0 && curValue.lastIdentifier == i-1) { //identifier must be right before (, else we have some expression like "( x + y() )"
curValue.lastFunctionIdentifier = curValue.lastIdentifier;
curValue.param = 0;
} else { //some expression
curValue.lastFunctionIdentifier = -1;
}
} else if (curToken.token[0] == _param && curValue.lastFunctionIdentifier > -1) {
curValue.param++;
} else if (curToken.token[0] == _stop) {
if (scopeLevel) //scope cannot go below -1
scopeLevel--;
if (valueVec.size() > 0) { //only pop level if scope was of actual function
curValue = valueVec.back();
valueVec.pop_back();
} else {
//invalidate curValue
curValue = FunctionValues();
}
} else if (curToken.token[0] == _terminal) {
//invalidate everything
valueVec.clear();
curValue = FunctionValues();
}
}
}
bool res = false;
if (curValue.lastFunctionIdentifier == -1) { //not in direct function. Start popping the stack untill we empty it, or a func IS found
while(curValue.lastFunctionIdentifier == -1 && valueVec.size() > 0) {
curValue = valueVec.back();
valueVec.pop_back();
}
}
if (curValue.lastFunctionIdentifier > -1) {
Token funcToken = tokenVector.at(curValue.lastFunctionIdentifier);
funcToken.token[funcToken.length] = 0;
_currentParam = curValue.param;
bool same = false;
if (_funcName) {
if(_ignoreCase)
same = testNameNoCase(_funcName, funcToken.token, lstrlen(_funcName)) == 0;
else
same = generic_strncmp(_funcName, funcToken.token, lstrlen(_funcName)) == 0;
}
if (!same) { //check if we need to reload data
if (_funcName) {
delete [] _funcName;
}
_funcName = new TCHAR[funcToken.length+1];
lstrcpy(_funcName, funcToken.token);
res = loadFunction();
} else {
res = true;
}
}
return res;
}
/*
Find function in XML structure and parse it
*/
bool FunctionCallTip::loadFunction() {
reset(); //set everything back to 0
//The functions should be ordered, but linear search because we cant access like array
_curFunction = NULL;
//Iterate through all keywords and find the correct function keyword
TiXmlElement *funcNode = _pXmlKeyword;
const TCHAR * name = NULL;
for (; funcNode; funcNode = funcNode->NextSiblingElement(TEXT("KeyWord")) ) {
name = funcNode->Attribute(TEXT("name"));
if (!name) //malformed node
continue;
int compVal = 0;
if (_ignoreCase)
compVal = testNameNoCase(name, _funcName); //lstrcmpi doesnt work in this case
else
compVal = lstrcmp(name, _funcName);
if (!compVal) { //found it?
const TCHAR * val = funcNode->Attribute(TEXT("func"));
if (val)
{
if (!lstrcmp(val, TEXT("yes"))) {
//what we've been looking for
_curFunction = funcNode;
break;
} else {
//name matches, but not a function, abort the entire procedure
return false;
}
}
} else if (compVal > 0) { //too far, abort
return false;
}
}
//Nothing found
if (!_curFunction)
return false;
stringVec paramVec;
TiXmlElement *overloadNode = _curFunction->FirstChildElement(TEXT("Overload"));
TiXmlElement *paramNode = NULL;
for (; overloadNode ; overloadNode = overloadNode->NextSiblingElement(TEXT("Overload")) ) {
const TCHAR * retVal = overloadNode->Attribute(TEXT("retVal"));
if (!retVal)
continue; //malformed node
_retVals.push_back(retVal);
const TCHAR * description = overloadNode->Attribute(TEXT("descr"));
if (description)
_descriptions.push_back(description);
else
_descriptions.push_back(TEXT("")); //"no description available"
paramNode = overloadNode->FirstChildElement(TEXT("Param"));
for (; paramNode ; paramNode = paramNode->NextSiblingElement(TEXT("Param")) ) {
const TCHAR * param = paramNode->Attribute(TEXT("name"));
if (!param)
continue; //malformed node
paramVec.push_back(param);
}
_overloads.push_back(paramVec);
paramVec.clear();
_currentNrOverloads++;
}
_currentNrOverloads = (int)_overloads.size();
if (_currentNrOverloads == 0) //malformed node
return false;
return true;
}
void FunctionCallTip::showCalltip() {
if (_currentNrOverloads == 0) {
//ASSERT
return;
}
//Check if the current overload still holds. If the current param exceeds amounti n overload, see if another one fits better (enough params)
stringVec & params = _overloads.at(_currentOverload);
size_t psize = params.size()+1, osize;
if ((size_t)_currentParam >= psize) {
osize = _overloads.size();
for(size_t i = 0; i < osize; i++) {
psize = _overloads.at(i).size()+1;
if ((size_t)_currentParam < psize) {
_currentOverload = i;
break;
}
}
}
const TCHAR * curRetValText = _retVals.at(_currentOverload);
const TCHAR * curDescriptionText = _descriptions.at(_currentOverload);
bool hasDescr = true;
if (!curDescriptionText[0])
hasDescr = false;
int bytesNeeded = lstrlen(curRetValText) + lstrlen(_funcName) + 5;//'retval funcName (params)\0'
if (hasDescr)
bytesNeeded += lstrlen(curDescriptionText);
size_t nrParams = params.size();
for(size_t i = 0; i < nrParams; i++) {
bytesNeeded += lstrlen(params.at(i)) + 2; //'param, '
}
if (_currentNrOverloads > 1) {
bytesNeeded += 24; // /\00001 of 00003\/
}
const int maxLen = 512;
if (bytesNeeded >= maxLen)
return;
TCHAR textBuffer[maxLen];
textBuffer[0] = 0;
if (_currentNrOverloads > 1) {
wsprintf(textBuffer, TEXT("\001%u of %u\002"), _currentOverload+1, _currentNrOverloads);
}
lstrcat(textBuffer, curRetValText);
lstrcat(textBuffer, TEXT(" "));
lstrcat(textBuffer, _funcName);
lstrcat(textBuffer, TEXT(" ("));
int highlightstart = 0;
int highlightend = 0;
for(size_t i = 0; i < nrParams; i++) {
if (i == _currentParam) {
highlightstart = lstrlen(textBuffer);
highlightend = highlightstart + lstrlen(params.at(i));
}
lstrcat(textBuffer, params.at(i));
if (i < nrParams-1)
lstrcat(textBuffer, TEXT(", "));
}
lstrcat(textBuffer, TEXT(")"));
if (hasDescr) {
lstrcat(textBuffer, TEXT("\n"));
lstrcat(textBuffer, curDescriptionText);
}
if (isVisible())
_pEditView->execute(SCI_CALLTIPCANCEL);
else
_startPos = _curPos;
_pEditView->showCallTip(_startPos, textBuffer);
if (highlightstart != highlightend) {
_pEditView->execute(SCI_CALLTIPSETHLT, highlightstart, highlightend);
}
}
void FunctionCallTip::reset() {
_currentOverload = 0;
_currentParam = 0;
//_curPos = 0;
_startPos = 0;
_overloads.clear();
_currentNrOverloads = 0;
_retVals.clear();
_descriptions.clear();
}
void FunctionCallTip::cleanup() {
reset();
if (_funcName)
delete [] _funcName;
_funcName = 0;
_pEditView = NULL;
}

View File

@ -0,0 +1,71 @@
//this file is part of Notepad++
//Copyright (C)2008 Harry Bruin <harrybharry@users.sourceforge.net>
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#ifndef FUNCTIONCALLTIP_H
#define FUNCTIONCALLTIP_H
#include "ScintillaEditView.h"
typedef std::vector<const TCHAR *> stringVec;
class FunctionCallTip {
friend class AutoCompletion;
public:
FunctionCallTip(ScintillaEditView * pEditView) : _pEditView(pEditView), _pXmlKeyword(NULL), _curPos(0), _startPos(0),
_curFunction(NULL), _currentNrOverloads(0), _currentOverload(0),
_currentParam(0), _funcName(NULL),
_start('('), _stop(')'), _param(','), _terminal(';'), _ignoreCase(true)
{};
~FunctionCallTip() {/* cleanup(); */};
void setLanguageXML(TiXmlElement * pXmlKeyword); //set calltip keyword node
bool updateCalltip(int ch, bool needShown = false); //Ch is character typed, or 0 if another event occured. NeedShown is true if calltip should be attempted to displayed. Return true if calltip was made visible
void showNextOverload(); //show next overlaoded parameters
void showPrevOverload(); //show prev overlaoded parameters
bool isVisible() { return _pEditView?_pEditView->execute(SCI_CALLTIPACTIVE) == TRUE:false; }; //true if calltip visible
void close(); //Close calltip if visible
private:
ScintillaEditView * _pEditView; //Scintilla to display calltip in
TiXmlElement * _pXmlKeyword; //current keyword node (first one)
int _curPos; //cursor position
int _startPos; //display start position
TiXmlElement * _curFunction; //current function element
//cache some XML values n stuff
TCHAR * _funcName; //name of function
stringVec _retVals; //vector of overload return values/types
vector<stringVec> _overloads; //vector of overload params (=vector)
stringVec _descriptions; //vecotr of function descriptions
int _currentNrOverloads; //current amount of overloads
int _currentOverload; //current chosen overload
int _currentParam; //current highlighted param
TCHAR _start;
TCHAR _stop;
TCHAR _param;
TCHAR _terminal;
bool _ignoreCase;
bool getCursorFunction(); //retrieve data about function at cursor. Returns true if a function was found. Calls loaddata if needed
bool loadFunction(); //returns true if the function can be found
void showCalltip(); //display calltip based on current variables
void reset(); //reset all vars in case function is invalidated
void cleanup(); //delete any leftovers
};
#endif// FUNCTIONCALLTIP_H

View File

@ -0,0 +1,104 @@
//this file is part of notepad++
//Copyright (C)2003 Don HO ( donho@altern.org )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "GoToLineDlg.h"
BOOL CALLBACK GoToLineDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG :
{
::SendDlgItemMessage(_hSelf, IDC_RADIO_GOTOLINE, BM_SETCHECK, TRUE, 0);
goToCenter();
return TRUE;
}
case WM_COMMAND :
{
switch (wParam)
{
case IDCANCEL : // Close
display(false);
cleanLineEdit();
return TRUE;
case IDOK :
{
int line = getLine();
if (line != -1)
{
display(false);
cleanLineEdit();
if (_mode == go2line) {
(*_ppEditView)->execute(SCI_ENSUREVISIBLE, line-1);
(*_ppEditView)->execute(SCI_GOTOLINE, line-1);
} else {
int sci_line = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, line);
(*_ppEditView)->execute(SCI_ENSUREVISIBLE, sci_line);
(*_ppEditView)->execute(SCI_GOTOPOS, line);
}
}
(*_ppEditView)->getFocus();
return TRUE;
}
case IDC_RADIO_GOTOLINE :
case IDC_RADIO_GOTOOFFSET :
{
bool isLine, isOffset;
if (wParam == IDC_RADIO_GOTOLINE)
{
isLine = true;
isOffset = false;
_mode = go2line;
}
else
{
isLine = false;
isOffset = true;
_mode = go2offsset;
}
::SendDlgItemMessage(_hSelf, IDC_RADIO_GOTOLINE, BM_SETCHECK, isLine, 0);
::SendDlgItemMessage(_hSelf, IDC_RADIO_GOTOOFFSET, BM_SETCHECK, isOffset, 0);
updateLinesNumbers();
return TRUE;
}
default :
{
switch (HIWORD(wParam))
{
case EN_SETFOCUS :
case BN_SETFOCUS :
updateLinesNumbers();
return TRUE;
default :
return TRUE;
}
break;
}
}
}
default :
return FALSE;
}
return FALSE;
}

View File

@ -0,0 +1,93 @@
//this file is part of notepad++
//Copyright (C)2003 Don HO ( donho@altern.org )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#ifndef GOTILINE_DLG_H
#define GOTILINE_DLG_H
#include "StaticDialog.h"
#include "..\resource.h"
#include "ScintillaEditView.h"
class GoToLineDlg : public StaticDialog
{
public :
GoToLineDlg() : StaticDialog(), _mode(go2line) {};
void init(HINSTANCE hInst, HWND hPere, ScintillaEditView **ppEditView) {
Window::init(hInst, hPere);
if (!ppEditView)
throw int(9900);
_ppEditView = ppEditView;
};
virtual void create(int dialogID, bool isRTL = false) {
StaticDialog::create(dialogID, isRTL);
};
void doDialog(bool isRTL = false) {
if (!isCreated())
create(IDD_GOLINE, isRTL);
display();
};
virtual void display(bool toShow = true) const {
Window::display(toShow);
if (toShow)
::SetFocus(::GetDlgItem(_hSelf, ID_GOLINE_EDIT));
};
protected :
enum mode {go2line, go2offsset};
mode _mode;
virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
private :
ScintillaEditView **_ppEditView;
void updateLinesNumbers() const {
unsigned int current = 0;
unsigned int limit = 0;
if (_mode == go2line)
{
current = (unsigned int)((*_ppEditView)->getCurrentLineNumber() + 1);
limit = (unsigned int)((*_ppEditView)->execute(SCI_GETLINECOUNT));
}
else
{
current = (unsigned int)(*_ppEditView)->execute(SCI_GETCURRENTPOS);
limit = (unsigned int)((*_ppEditView)->getCurrentDocLen() - 1);
}
::SetDlgItemInt(_hSelf, ID_CURRLINE, current, FALSE);
::SetDlgItemInt(_hSelf, ID_LASTLINE, limit, FALSE);
};
void cleanLineEdit() const {
::SetDlgItemText(_hSelf, ID_GOLINE_EDIT, TEXT(""));
};
int getLine() const {
BOOL isSuccessful;
int line = ::GetDlgItemInt(_hSelf, ID_GOLINE_EDIT, &isSuccessful, FALSE);
return (isSuccessful?line:-1);
};
};
#endif //GOTILINE_DLG_H

View File

@ -0,0 +1,502 @@
//this file is part of notepad++
//Copyright (C)2003 Don HO ( donho@altern.org )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "Printer.h"
void replaceStr(generic_string & str, generic_string str2BeReplaced, generic_string replacement)
{
size_t pos = str.find(str2BeReplaced);
if (pos != str.npos)
str.replace(pos, str2BeReplaced.length(), replacement);
}
void Printer::init(HINSTANCE hInst, HWND hwnd, ScintillaEditView *pSEView, bool showDialog, int startPos, int endPos)
{
_pSEView = pSEView;
_startPos = startPos;
_endPos = endPos;
_pdlg.lStructSize = sizeof(PRINTDLG);
_pdlg.hwndOwner = hwnd;
_pdlg.hInstance = hInst;
_pdlg.Flags = PD_USEDEVMODECOPIES | PD_ALLPAGES | PD_RETURNDC;
_pdlg.nFromPage = 1;
_pdlg.nToPage = 1;
_pdlg.nMinPage = 1;
_pdlg.nMaxPage = 0xffffU; // We do not know how many pages in the
// document until the printer is selected and the paper size is known.
_pdlg.nCopies = 1;
_pdlg.hDC = 0;
_pdlg.hDevMode = NULL;
_pdlg.hDevNames = NULL;
_pdlg.lCustData = 0;
_pdlg.lpfnPrintHook = NULL;
_pdlg.lpfnSetupHook = NULL;
_pdlg.lpPrintTemplateName = NULL;
_pdlg.lpSetupTemplateName = NULL;
_pdlg.hPrintTemplate = NULL;
_pdlg.hSetupTemplate = NULL;
// See if a range has been selected
_pdlg.Flags |= (_startPos != _endPos)?PD_SELECTION:PD_NOSELECTION;
if (!showDialog)
{
// Don't display dialog box, just use the default printer and options
_pdlg.Flags |= PD_RETURNDEFAULT;
}
}
size_t Printer::doPrint(bool justDoIt)
{/*
if (!::PrintDlg(&_pdlg))
return 0;
*/
const NppGUI & nppGUI = (NppParameters::getInstance())->getNppGUI();
POINT ptPage;
POINT ptDpi;
RECT rectMargins;
RECT rectPhysMargins;
RECT userMargins;
// Get printer resolution
ptDpi.x = GetDeviceCaps(_pdlg.hDC, LOGPIXELSX); // dpi in X direction
ptDpi.y = GetDeviceCaps(_pdlg.hDC, LOGPIXELSY); // dpi in Y direction
// Start by getting the physical page size (in device units).
ptPage.x = GetDeviceCaps(_pdlg.hDC, PHYSICALWIDTH); // device units
ptPage.y = GetDeviceCaps(_pdlg.hDC, PHYSICALHEIGHT); // device units
// Get the dimensions of the unprintable
// part of the page (in device units).
rectPhysMargins.left = GetDeviceCaps(_pdlg.hDC, PHYSICALOFFSETX);
rectPhysMargins.top = GetDeviceCaps(_pdlg.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(_pdlg.hDC, HORZRES) // printable width
- rectPhysMargins.left; // left unprintable margin
rectPhysMargins.bottom = ptPage.y // total paper height
- GetDeviceCaps(_pdlg.hDC, VERTRES) // printable height
- rectPhysMargins.top; // right unprintable margin
if (nppGUI._printSettings.isUserMargePresent())
{
userMargins.left = MulDiv(nppGUI._printSettings._marge.left*100, ptDpi.x, 2540);
userMargins.top = MulDiv(nppGUI._printSettings._marge.top*100, ptDpi.y, 2540);
userMargins.right = MulDiv(nppGUI._printSettings._marge.right*100, ptDpi.x, 2540);
userMargins.bottom = MulDiv(nppGUI._printSettings._marge.bottom*100, ptDpi.y, 2540);
rectMargins.left = max(rectPhysMargins.left, userMargins.left);
rectMargins.top = max(rectPhysMargins.top, userMargins.top);
rectMargins.right = max(rectPhysMargins.right, userMargins.right);
rectMargins.bottom = max(rectPhysMargins.bottom, userMargins.bottom);
}
else
{
rectMargins.left = rectPhysMargins.left;
rectMargins.top = rectPhysMargins.top;
rectMargins.right = rectPhysMargins.right;
rectMargins.bottom = rectPhysMargins.bottom;
}
// Convert device coordinates into logical coordinates
DPtoLP(_pdlg.hDC, (LPPOINT)&rectMargins, 2);
DPtoLP(_pdlg.hDC, (LPPOINT)&rectPhysMargins, 2);
// Convert page size to logical units and we're done!
DPtoLP(_pdlg.hDC, &ptPage, 1);
TEXTMETRIC tm;
int fontSize = nppGUI._printSettings._headerFontSize?nppGUI._printSettings._headerFontSize:9;
int fontWeight = nppGUI._printSettings._headerFontStyle & FONTSTYLE_BOLD?FW_BOLD:FW_NORMAL;
int isFontItalic = nppGUI._printSettings._headerFontStyle & FONTSTYLE_ITALIC?TRUE:FALSE;
const TCHAR *fontFace = (nppGUI._printSettings._headerFontName != TEXT(""))?nppGUI._printSettings._headerFontName.c_str():TEXT("Arial");
int headerLineHeight = ::MulDiv(fontSize, ptDpi.y, 72);
//TCHAR toto[10];
//::MessageBox(NULL, itoa(nppGUI._printSettings._headerFontStyle, toto, 10), TEXT("header"), MB_OK);
HFONT fontHeader = ::CreateFont(headerLineHeight,
0, 0, 0,
fontWeight,
isFontItalic,
FALSE,
0, 0, 0,
0, 0, 0,
fontFace);
::SelectObject(_pdlg.hDC, fontHeader);
::GetTextMetrics(_pdlg.hDC, &tm);
headerLineHeight = tm.tmHeight + tm.tmExternalLeading;
fontSize = nppGUI._printSettings._footerFontSize?nppGUI._printSettings._footerFontSize:9;
fontWeight = nppGUI._printSettings._footerFontStyle & FONTSTYLE_BOLD?FW_BOLD:FW_NORMAL;
isFontItalic = nppGUI._printSettings._footerFontStyle & FONTSTYLE_ITALIC?TRUE:FALSE;
fontFace = (nppGUI._printSettings._footerFontName != TEXT(""))?nppGUI._printSettings._footerFontName.c_str():TEXT("Arial");
//::MessageBox(NULL, itoa(nppGUI._printSettings._footerFontStyle, , 10), TEXT("footer"), MB_OK);
int footerLineHeight = ::MulDiv(fontSize, ptDpi.y, 72);
HFONT fontFooter = ::CreateFont(footerLineHeight,
0, 0, 0,
fontWeight,
isFontItalic,
FALSE,
0, 0, 0,
0, 0, 0,
fontFace);
::SelectObject(_pdlg.hDC, fontFooter);
::GetTextMetrics(_pdlg.hDC, &tm);
footerLineHeight = tm.tmHeight + tm.tmExternalLeading;
::GetTextMetrics(_pdlg.hDC, &tm);
int printMarge = tm.tmHeight + tm.tmExternalLeading;
printMarge = printMarge + printMarge / 2;
DOCINFO docInfo;
docInfo.cbSize = sizeof(DOCINFO);
docInfo.lpszDocName = _pSEView->getCurrentBuffer()->getFullPathName();
docInfo.lpszOutput = NULL;
if (::StartDoc(_pdlg.hDC, &docInfo) < 0)
{
MessageBox(NULL, TEXT("Can not start printer document."), 0, MB_OK);
return 0;
}
// By default, we will print all the document
long lengthPrinted = 0;
long lengthDoc = _pSEView->getCurrentDocLen();
long lengthDocMax = lengthDoc;
// In the case that the print dialog was launched and that there's a range of selection
// We print the range of selection
if ((!(_pdlg.Flags & PD_RETURNDEFAULT)) && (_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;
}
RangeToFormat frPrint;
frPrint.hdc = _pdlg.hDC;
frPrint.hdcTarget = _pdlg.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 += printMarge;
frPrint.rc.bottom -= printMarge;
frPrint.rc.left += printMarge;
frPrint.rc.right -= printMarge;
const int headerSize = 256;
TCHAR headerL[headerSize] = TEXT("");
TCHAR headerM[headerSize] = TEXT("");
TCHAR headerR[headerSize] = TEXT("");
TCHAR footerL[headerSize] = TEXT("");
TCHAR footerM[headerSize] = TEXT("");
TCHAR footerR[headerSize] = TEXT("");
const TCHAR shortDateVar[] = TEXT("$(SHORT_DATE)");
const TCHAR longDateVar[] = TEXT("$(LONG_DATE)");
const TCHAR timeVar[] = TEXT("$(TIME)");
const int bufferSize = 64;
TCHAR shortDate[bufferSize];
TCHAR longDate[bufferSize];
TCHAR time[bufferSize];
SYSTEMTIME st;
::GetLocalTime(&st);
::GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, shortDate, bufferSize);
::GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, longDate, bufferSize);
::GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, NULL, time, bufferSize);
if (nppGUI._printSettings.isHeaderPresent())
{
frPrint.rc.top += headerLineHeight + headerLineHeight / 2;
generic_string headerLeftPart = nppGUI._printSettings._headerLeft;
if (headerLeftPart != TEXT(""))
{
replaceStr(headerLeftPart, shortDateVar, shortDate);
replaceStr(headerLeftPart, longDateVar, longDate);
replaceStr(headerLeftPart, timeVar, time);
expandNppEnvironmentStrs(headerLeftPart.c_str(), headerL, headerSize, _pdlg.hwndOwner);
}
generic_string headerMiddlePart = nppGUI._printSettings._headerMiddle;
if (headerMiddlePart != TEXT(""))
{
replaceStr(headerMiddlePart, shortDateVar, shortDate);
replaceStr(headerMiddlePart, longDateVar, longDate);
replaceStr(headerMiddlePart, timeVar, time);
expandNppEnvironmentStrs(headerMiddlePart.c_str(), headerM, headerSize, _pdlg.hwndOwner);
}
generic_string headerRightPart = nppGUI._printSettings._headerRight;
if (headerRightPart != TEXT(""))
{
replaceStr(headerRightPart, shortDateVar, shortDate);
replaceStr(headerRightPart, longDateVar, longDate);
replaceStr(headerRightPart, timeVar, time);
expandNppEnvironmentStrs(headerRightPart.c_str(), headerR, headerSize, _pdlg.hwndOwner);
}
}
if (nppGUI._printSettings.isFooterPresent())
{
frPrint.rc.bottom -= footerLineHeight + footerLineHeight / 2;
generic_string footerLeftPart = nppGUI._printSettings._footerLeft;
if (footerLeftPart != TEXT(""))
{
replaceStr(footerLeftPart, shortDateVar, shortDate);
replaceStr(footerLeftPart, longDateVar, longDate);
replaceStr(footerLeftPart, timeVar, time);
expandNppEnvironmentStrs(footerLeftPart.c_str(), footerL, headerSize, _pdlg.hwndOwner);
}
generic_string footerMiddlePart = nppGUI._printSettings._footerMiddle;
if (footerMiddlePart != TEXT(""))
{
replaceStr(footerMiddlePart, shortDateVar, shortDate);
replaceStr(footerMiddlePart, longDateVar, longDate);
replaceStr(footerMiddlePart, timeVar, time);
expandNppEnvironmentStrs(footerMiddlePart.c_str(), footerM, headerSize, _pdlg.hwndOwner);
}
generic_string footerRightPart = nppGUI._printSettings._footerRight;
if (footerRightPart != TEXT(""))
{
replaceStr(footerRightPart, shortDateVar, shortDate);
replaceStr(footerRightPart, longDateVar, longDate);
replaceStr(footerRightPart, timeVar, time);
expandNppEnvironmentStrs(footerRightPart.c_str(), footerR, headerSize, _pdlg.hwndOwner);
}
}
bool isShown = _pSEView->hasMarginShowed(ScintillaEditView::_SC_MARGE_LINENUMBER);
if (!nppGUI._printSettings._printLineNumber)
_pSEView->showMargin(ScintillaEditView::_SC_MARGE_LINENUMBER, false);
size_t pageNum = 1;
bool printPage;
const TCHAR pageVar[] = TEXT("$(CURRENT_PRINTING_PAGE)");
while (lengthPrinted < lengthDoc)
{
printPage = (!(_pdlg.Flags & PD_PAGENUMS) ||
(pageNum >= _pdlg.nFromPage) && (pageNum <= _pdlg.nToPage));
if (!justDoIt)
printPage = false;
TCHAR pageString[32];
wsprintf(pageString, TEXT("%0d"), pageNum);
if (printPage)
{
::StartPage(_pdlg.hDC);
if (nppGUI._printSettings.isHeaderPresent())
{
::SelectObject(_pdlg.hDC, fontHeader);
::SetTextColor(_pdlg.hDC, RGB(0, 0, 0));
::SetBkColor(_pdlg.hDC, RGB(255, 255, 255));
UINT oldTASettings = ::SetTextAlign(_pdlg.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;
SIZE size;
// Left part
if (headerL[0] != '\0')
{
generic_string headerLeft(headerL);
size_t pos = headerLeft.find(pageVar);
if (pos != headerLeft.npos)
headerLeft.replace(pos, lstrlen(pageVar), pageString);
::ExtTextOut(_pdlg.hDC, frPrint.rc.left + 5, frPrint.rc.top - headerLineHeight / 2,
ETO_OPAQUE, &rcw, headerLeft.c_str(), static_cast<int>(headerLeft.length()), NULL);
}
// Middle part
if (headerM != '\0')
{
generic_string headerMiddle(headerM);
size_t pos = headerMiddle.find(pageVar);
if (pos != headerMiddle.npos)
headerMiddle.replace(pos, lstrlen(pageVar), pageString);
::GetTextExtentPoint32(_pdlg.hDC, headerMiddle.c_str(), static_cast<int>(headerMiddle.length()), &size);
::ExtTextOut(_pdlg.hDC, ((frPrint.rc.right - frPrint.rc.left)/2 + frPrint.rc.left) - (size.cx/2), frPrint.rc.top - headerLineHeight / 2,
ETO_CLIPPED, &rcw, headerMiddle.c_str(), static_cast<int>(headerMiddle.length()), NULL);
}
// Right part
if (headerR != '\0')
{
generic_string headerRight(headerR);
size_t pos = headerRight.find(pageVar);
if (pos != headerRight.npos)
headerRight.replace(pos, lstrlen(pageVar), pageString);
::GetTextExtentPoint32(_pdlg.hDC, headerRight.c_str(), static_cast<int>(headerRight.length()), &size);
::ExtTextOut(_pdlg.hDC, frPrint.rc.right - size.cx, frPrint.rc.top - headerLineHeight / 2,
ETO_CLIPPED, &rcw, headerRight.c_str(), static_cast<int>(headerRight.length()), NULL);
}
::SetTextAlign(_pdlg.hDC, oldTASettings);
HPEN pen = ::CreatePen(0, 1, 0x00000000);
HPEN penOld = static_cast<HPEN>(::SelectObject(_pdlg.hDC, pen));
::MoveToEx(_pdlg.hDC, frPrint.rc.left, frPrint.rc.top - headerLineHeight / 4, NULL);
::LineTo(_pdlg.hDC, frPrint.rc.right, frPrint.rc.top - headerLineHeight / 4);
::SelectObject(_pdlg.hDC, penOld);
::DeleteObject(pen);
}
}
frPrint.chrg.cpMin = lengthPrinted;
frPrint.chrg.cpMax = lengthDoc;
_pSEView->execute(SCI_SETPRINTCOLOURMODE, nppGUI._printSettings._printOption);
lengthPrinted = long(_pSEView->execute(SCI_FORMATRANGE, printPage, reinterpret_cast<LPARAM>(&frPrint)));
if (printPage)
{
if (nppGUI._printSettings.isFooterPresent())
{
::SelectObject(_pdlg.hDC, fontFooter);
::SetTextColor(_pdlg.hDC, RGB(0, 0, 0));
::SetBkColor(_pdlg.hDC, RGB(255, 255, 255));
UINT oldta = ::SetTextAlign(_pdlg.hDC, TA_TOP);
RECT rcw = {frPrint.rc.left, frPrint.rc.bottom + footerLineHeight / 2,
frPrint.rc.right, frPrint.rc.bottom + footerLineHeight + footerLineHeight / 2};
SIZE size;
// Left part
if (footerL[0] != '\0')
{
generic_string footerLeft(footerL);
size_t pos = footerLeft.find(pageVar);
if (pos != footerLeft.npos)
footerLeft.replace(pos, lstrlen(pageVar), pageString);
::ExtTextOut(_pdlg.hDC, frPrint.rc.left + 5, frPrint.rc.bottom + footerLineHeight / 2,
ETO_OPAQUE, &rcw, footerLeft.c_str(), static_cast<int>(footerLeft.length()), NULL);
}
// Middle part
if (footerM[0] != '\0')
{
generic_string footerMiddle(footerM);
size_t pos = footerMiddle.find(pageVar);
if (pos != footerMiddle.npos)
footerMiddle.replace(pos, lstrlen(pageVar), pageString);
::GetTextExtentPoint32(_pdlg.hDC, footerMiddle.c_str(), static_cast<int>(footerMiddle.length()), &size);
::ExtTextOut(_pdlg.hDC, ((frPrint.rc.right - frPrint.rc.left)/2 + frPrint.rc.left) - (size.cx/2), frPrint.rc.bottom + footerLineHeight / 2,
ETO_CLIPPED, &rcw, footerMiddle.c_str(), static_cast<int>(footerMiddle.length()), NULL);
}
// Right part
if (footerR[0] != '\0')
{
generic_string footerRight(footerR);
size_t pos = footerRight.find(pageVar);
if (pos != footerRight.npos)
footerRight.replace(pos, lstrlen(pageVar), pageString);
::GetTextExtentPoint32(_pdlg.hDC, footerRight.c_str(), static_cast<int>(footerRight.length()), &size);
::ExtTextOut(_pdlg.hDC, frPrint.rc.right - size.cx, frPrint.rc.bottom + footerLineHeight / 2,
ETO_CLIPPED, &rcw, footerRight.c_str(), static_cast<int>(footerRight.length()), NULL);
}
::SetTextAlign(_pdlg.hDC, oldta);
HPEN pen = ::CreatePen(0, 1, 0x00000000);
HPEN penOld = static_cast<HPEN>(::SelectObject(_pdlg.hDC, pen));
::MoveToEx(_pdlg.hDC, frPrint.rc.left, frPrint.rc.bottom + footerLineHeight / 4, NULL);
::LineTo(_pdlg.hDC, frPrint.rc.right, frPrint.rc.bottom + footerLineHeight / 4);
::SelectObject(_pdlg.hDC, penOld);
::DeleteObject(pen);
}
::EndPage(_pdlg.hDC);
}
pageNum++;
if ((_pdlg.Flags & PD_PAGENUMS) && (pageNum > _pdlg.nToPage))
break;
}
//TCHAR toto[10];
//::MessageBox(NULL, itoa(pageNum, toto, 10), TEXT("page total"), MB_OK);
if (!nppGUI._printSettings._printLineNumber)
_pSEView->showMargin(ScintillaEditView::_SC_MARGE_LINENUMBER, isShown);
_pSEView->execute(SCI_FORMATRANGE, FALSE, 0);
::EndDoc(_pdlg.hDC);
::DeleteDC(_pdlg.hDC);
if (fontHeader)
::DeleteObject(fontHeader);
if (fontFooter)
::DeleteObject(fontFooter);
return (pageNum - 1);
}

View File

@ -0,0 +1,55 @@
//this file is part of notepad++
//Copyright (C)2003 Don HO ( donho@altern.org )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#ifndef PRINTER_H
#define PRINTER_H
#include <windows.h>
#include "ScintillaEditView.h"
#include "RunDlg.h"
#include "Parameters.h"
struct RangeToFormat {
HDC hdc;
HDC hdcTarget;
RECT rc;
RECT rcPage;
CharacterRange chrg;
};
class Printer
{
public :
Printer(){};
void init(HINSTANCE hInst, HWND hwnd, ScintillaEditView *pSEView, bool showDialog, int startPos, int endPos);
size_t Printer::doPrint() {
if (!::PrintDlg(&_pdlg))
return 0;
return doPrint(true);
};
size_t doPrint(bool justDoIt);
private :
PRINTDLG _pdlg;
ScintillaEditView *_pSEView;
size_t _startPos;
size_t _endPos;
size_t _nbPageTotal;
};
#endif //PRINTER_H

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,821 @@
//this file is part of notepad++
//Copyright (C)2003 Don HO ( donho@altern.org )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#ifndef SCINTILLA_EDIT_VIEW_H
#define SCINTILLA_EDIT_VIEW_H
#include <vector>
#include "Window.h"
#include "Scintilla.h"
#include "ScintillaRef.h"
#include "SciLexer.h"
#include "Buffer.h"
#include "colors.h"
#include "UserDefineDialog.h"
#include "xpm_icons.h"
#include "resource.h"
#ifndef WM_MOUSEWHEEL
#define WM_MOUSEWHEEL 0x020A
#endif //WM_MOUSEWHEEL
#ifndef WM_MOUSEHWHEEL
#define WM_MOUSEHWHEEL 0x020E
#endif //WM_MOUSEHWHEEL
#ifndef WM_APPCOMMAND
#define WM_APPCOMMAND 0x0319
#define APPCOMMAND_BROWSER_BACKWARD 1
#define APPCOMMAND_BROWSER_FORWARD 2
#define FAPPCOMMAND_MASK 0xF000
#define GET_APPCOMMAND_LPARAM(lParam) ((short)(HIWORD(lParam) & ~FAPPCOMMAND_MASK))
#endif //WM_APPCOMMAND
class NppParameters;
#define NB_WORD_LIST 4
#define WORD_LIST_LEN 256
typedef int (* SCINTILLA_FUNC) (void*, int, int, int);
typedef void * SCINTILLA_PTR;
#define WM_DOCK_USERDEFINE_DLG (SCINTILLA_USER + 1)
#define WM_UNDOCK_USERDEFINE_DLG (SCINTILLA_USER + 2)
#define WM_CLOSE_USERDEFINE_DLG (SCINTILLA_USER + 3)
#define WM_REMOVE_USERLANG (SCINTILLA_USER + 4)
#define WM_RENAME_USERLANG (SCINTILLA_USER + 5)
#define WM_REPLACEALL_INOPENEDDOC (SCINTILLA_USER + 6)
#define WM_FINDALL_INOPENEDDOC (SCINTILLA_USER + 7)
#define WM_DOOPEN (SCINTILLA_USER + 8)
#define WM_FINDINFILES (SCINTILLA_USER + 9)
#define WM_REPLACEINFILES (SCINTILLA_USER + 10)
#define WM_FINDALL_INCURRENTDOC (SCINTILLA_USER + 11)
const int NB_FOLDER_STATE = 7;
// Codepage
const int CP_CHINESE_TRADITIONAL = 950;
const int CP_CHINESE_SIMPLIFIED = 936;
const int CP_JAPANESE = 932;
const int CP_KOREAN = 949;
const int CP_GREEK = 1253;
//wordList
#define LIST_NONE 0
#define LIST_0 1
#define LIST_1 2
#define LIST_2 4
#define LIST_3 8
#define LIST_4 16
#define LIST_5 32
#define LIST_6 64
const bool fold_uncollapse = true;
const bool fold_collapse = false;
const bool UPPERCASE = true;
const bool LOWERCASE = false;
typedef vector<pair<int, int> > ColumnModeInfo;
const UCHAR MASK_FORMAT = 0x03;
const UCHAR MASK_ZERO_LEADING = 0x04;
const UCHAR BASE_10 = 0x00; // Dec
const UCHAR BASE_16 = 0x01; // Hex
const UCHAR BASE_08 = 0x02; // Oct
const UCHAR BASE_02 = 0x03; // Bin
const int MARK_BOOKMARK = 24;
const int MARK_HIDELINESBEGIN = 23;
const int MARK_HIDELINESEND = 22;
//const int MARK_LINEMODIFIEDUNSAVED = 21;
//const int MARK_LINEMODIFIEDSAVED = 20;
// 24 - 16 reserved for Notepad++ internal used
// 15 - 0 are free to use for plugins
static int getNbChiffre(int aNum, int base)
{
int nbChiffre = 1;
int diviseur = base;
for (;;)
{
int result = aNum / diviseur;
if (!result)
break;
else
{
diviseur *= base;
nbChiffre++;
}
}
if ((base == 16) && (nbChiffre % 2 != 0))
nbChiffre += 1;
return nbChiffre;
};
TCHAR * int2str(TCHAR *str, int strLen, int number, int base, int nbChiffre, bool isZeroLeading);
typedef LRESULT (WINAPI *CallWindowProcFunc) (WNDPROC,HWND,UINT,WPARAM,LPARAM);
struct LanguageName {
const TCHAR * lexerName;
const TCHAR * shortName;
const TCHAR * longName;
LangType LangID;
int lexerID;
};
class ScintillaEditView : public Window
{
friend class Notepad_plus;
friend class Finder;
public:
ScintillaEditView()
: Window(), _pScintillaFunc(NULL),_pScintillaPtr(NULL),
_folderStyle(FOLDER_STYLE_BOX), _lineNumbersShown(false), _wrapRestoreNeeded(false)
{
++_refCount;
};
virtual ~ScintillaEditView()
{
--_refCount;
if ((!_refCount)&&(_hLib))
{
::FreeLibrary(_hLib);
}
};
virtual void destroy()
{
::DestroyWindow(_hSelf);
_hSelf = NULL;
};
virtual void init(HINSTANCE hInst, HWND hPere);
LRESULT execute(UINT Msg, WPARAM wParam=0, LPARAM lParam=0) const {
return _pScintillaFunc(_pScintillaPtr, static_cast<int>(Msg), static_cast<int>(wParam), static_cast<int>(lParam));
};
void activateBuffer(BufferID buffer);
void getText(char *dest, int start, int end) const;
void getGenericText(TCHAR *dest, int start, int end) const;
void getGenericText(TCHAR *dest, int start, int end, int *mstart, int *mend) const;
void insertGenericTextFrom(int position, const TCHAR *text2insert) const;
void replaceSelWith(const char * replaceText);
int getSelectedTextCount() {
CharacterRange range = getSelection();
return (range.cpMax - range.cpMin);
};
char * getSelectedText(char * txt, int size, bool expand = true);
TCHAR * getGenericSelectedText(TCHAR * txt, int size, bool expand = true);
int searchInTarget(const TCHAR * Text2Find, int fromPos, int toPos) const;
void appandGenericText(const TCHAR * text2Append) const;
void addGenericText(const TCHAR * text2Append) const;
void addGenericText(const TCHAR * text2Append, long *mstart, long *mend) const;
int replaceTarget(const TCHAR * str2replace, int fromTargetPos = -1, int toTargetPos = -1) const;
int replaceTargetRegExMode(const TCHAR * re, int fromTargetPos = -1, int toTargetPos = -1) const;
void showAutoComletion(int lenEntered, const TCHAR * list);
void showCallTip(int startPos, const TCHAR * def);
void getLine(int lineNumber, TCHAR * line, int lineBufferLen);
void addText(int length, const char *buf);
void saveCurrentPos();
void restoreCurrentPos();
void saveCurrentFold();
void restoreCurrentFold();
int getCurrentDocLen() const {
return int(execute(SCI_GETLENGTH));
};
CharacterRange getSelection() const {
CharacterRange crange;
crange.cpMin = long(execute(SCI_GETSELECTIONSTART));
crange.cpMax = long(execute(SCI_GETSELECTIONEND));
return crange;
};
void getWordToCurrentPos(TCHAR * str, int strLen) const {
int caretPos = execute(SCI_GETCURRENTPOS);
int startPos = static_cast<int>(execute(SCI_WORDSTARTPOSITION, caretPos, true));
str[0] = '\0';
if ((caretPos - startPos) < strLen)
getGenericText(str, startPos, caretPos);
};
void doUserDefineDlg(bool willBeShown = true, bool isRTL = false) {
_userDefineDlg.doDialog(willBeShown, isRTL);
};
static UserDefineDialog * getUserDefineDlg() {return &_userDefineDlg;};
void setCaretColorWidth(int color, int width = 1) const {
execute(SCI_SETCARETFORE, color);
execute(SCI_SETCARETWIDTH, width);
};
void beSwitched() {
_userDefineDlg.setScintilla(this);
};
//Marge member and method
static const int _SC_MARGE_LINENUMBER;
static const int _SC_MARGE_SYBOLE;
static const int _SC_MARGE_FOLDER;
//static const int _SC_MARGE_MODIFMARKER;
void showMargin(int whichMarge, bool willBeShowed = true) {
if (whichMarge == _SC_MARGE_LINENUMBER)
showLineNumbersMargin(willBeShowed);
else
{
int width = 3;
if (whichMarge == _SC_MARGE_SYBOLE || whichMarge == _SC_MARGE_FOLDER)
width = 14;
execute(SCI_SETMARGINWIDTHN, whichMarge, willBeShowed?width:0);
}
};
bool hasMarginShowed(int witchMarge) {
return (execute(SCI_GETMARGINWIDTHN, witchMarge, 0) != 0);
};
void marginClick(int position, int modifiers);
void setMakerStyle(folderStyle style) {
if (_folderStyle == style)
return;
_folderStyle = style;
for (int i = 0 ; i < NB_FOLDER_STATE ; i++)
defineMarker(_markersArray[FOLDER_TYPE][i], _markersArray[style][i], white, grey);
};
folderStyle getFolderStyle() {return _folderStyle;};
void showWSAndTab(bool willBeShowed = true) {
execute(SCI_SETVIEWWS, willBeShowed?SCWS_VISIBLEALWAYS:SCWS_INVISIBLE);
};
void showEOL(bool willBeShowed = true) {
execute(SCI_SETVIEWEOL, willBeShowed);
};
bool isEolVisible() {
return (execute(SCI_GETVIEWEOL) != 0);
};
void showInvisibleChars(bool willBeShowed = true) {
showWSAndTab(willBeShowed);
showEOL(willBeShowed);
};
bool isInvisibleCharsShown() {
return (execute(SCI_GETVIEWWS) != 0);
};
void showIndentGuideLine(bool willBeShowed = true) {
execute(SCI_SETINDENTATIONGUIDES, (WPARAM)willBeShowed);
};
bool isShownIndentGuide() const {
return (execute(SCI_GETINDENTATIONGUIDES) != 0);
};
void wrap(bool willBeWrapped = true) {
execute(SCI_SETWRAPMODE, (WPARAM)willBeWrapped);
};
bool isWrap() const {
return (execute(SCI_GETWRAPMODE) == SC_WRAP_WORD);
};
bool isWrapSymbolVisible() const {
return (execute(SCI_GETWRAPVISUALFLAGS) != SC_WRAPVISUALFLAG_NONE);
};
void showWrapSymbol(bool willBeShown = true) {
execute(SCI_SETWRAPVISUALFLAGSLOCATION, SC_WRAPVISUALFLAGLOC_END_BY_TEXT);
execute(SCI_SETWRAPVISUALFLAGS, willBeShown?SC_WRAPVISUALFLAG_END:SC_WRAPVISUALFLAG_NONE);
};
long getCurrentLineNumber()const {
return long(execute(SCI_LINEFROMPOSITION, execute(SCI_GETCURRENTPOS)));
};
long lastZeroBasedLineNumber() const {
int endPos = execute(SCI_GETLENGTH);
return execute(SCI_LINEFROMPOSITION, endPos);
};
long getCurrentXOffset()const{
return long(execute(SCI_GETXOFFSET));
};
void setCurrentXOffset(long xOffset){
execute(SCI_SETXOFFSET,xOffset);
};
void scroll(int column, int line){
execute(SCI_LINESCROLL, column, line);
};
long getCurrentPointX()const{
return long (execute(SCI_POINTXFROMPOSITION, 0, execute(SCI_GETCURRENTPOS)));
};
long getCurrentPointY()const{
return long (execute(SCI_POINTYFROMPOSITION, 0, execute(SCI_GETCURRENTPOS)));
};
long getTextHeight()const{
return long(execute(SCI_TEXTHEIGHT));
};
void gotoLine(int line){
if (line < execute(SCI_GETLINECOUNT))
execute(SCI_GOTOLINE,line);
};
long getCurrentColumnNumber() const {
return long(execute(SCI_GETCOLUMN, execute(SCI_GETCURRENTPOS)));
};
long getSelectedByteNumber() const {
long start = long(execute(SCI_GETSELECTIONSTART));
long end = long(execute(SCI_GETSELECTIONEND));
return (start < end)?end-start:start-end;
};
long getLineLength(int line) const {
return long(execute(SCI_GETLINEENDPOSITION, line) - execute(SCI_POSITIONFROMLINE, line));
};
long getLineIndent(int line) const {
return long(execute(SCI_GETLINEINDENTATION, line));
};
void setLineIndent(int line, int indent) const;
void showLineNumbersMargin(bool show){
if (show == _lineNumbersShown) return;
_lineNumbersShown = show;
if (show)
{
updateLineNumberWidth();
}
else
{
execute(SCI_SETMARGINWIDTHN, _SC_MARGE_LINENUMBER, 0);
}
}
void updateLineNumberWidth() {
if (_lineNumbersShown)
{
int linesVisible = (int) execute(SCI_LINESONSCREEN);
if (linesVisible)
{
int firstVisibleLineVis = (int) execute(SCI_GETFIRSTVISIBLELINE);
int lastVisibleLineVis = linesVisible + firstVisibleLineVis + 1;
int i = 0;
while (lastVisibleLineVis)
{
lastVisibleLineVis /= 10;
i++;
}
i = max(i, 3);
{
int pixelWidth = int(8 + i * execute(SCI_TEXTWIDTH, STYLE_LINENUMBER, (LPARAM)"8"));
execute(SCI_SETMARGINWIDTHN, _SC_MARGE_LINENUMBER, pixelWidth);
}
}
}
};
void setCurrentLineHiLiting(bool isHiliting, COLORREF bgColor) const {
execute(SCI_SETCARETLINEVISIBLE, isHiliting);
if (!isHiliting)
return;
execute(SCI_SETCARETLINEBACK, bgColor);
};
bool isCurrentLineHiLiting() const {
return (execute(SCI_GETCARETLINEVISIBLE) != 0);
};
void performGlobalStyles();
void expand(int &line, bool doExpand, bool force = false, int visLevels = 0, int level = -1);
void currentLineUp() const {
int currentLine = getCurrentLineNumber();
if (currentLine != 0)
{
execute(SCI_BEGINUNDOACTION);
currentLine--;
execute(SCI_LINETRANSPOSE);
execute(SCI_GOTOLINE, currentLine);
execute(SCI_ENDUNDOACTION);
}
};
void currentLineDown() const {
int currentLine = getCurrentLineNumber();
if (currentLine != (execute(SCI_GETLINECOUNT) - 1))
{
execute(SCI_BEGINUNDOACTION);
currentLine++;
execute(SCI_GOTOLINE, currentLine);
execute(SCI_LINETRANSPOSE);
execute(SCI_ENDUNDOACTION);
}
};
void convertSelectedTextTo(bool Case);
void convertSelectedTextToLowerCase() {
// if system is w2k or xp
if ((NppParameters::getInstance())->isTransparentAvailable())
convertSelectedTextTo(LOWERCASE);
else
execute(SCI_LOWERCASE);
};
void convertSelectedTextToUpperCase() {
// if system is w2k or xp
if ((NppParameters::getInstance())->isTransparentAvailable())
convertSelectedTextTo(UPPERCASE);
else
execute(SCI_UPPERCASE);
};
void collapse(int level2Collapse, bool mode);
void foldAll(bool mode);
void foldCurrentPos(bool mode);
int getCodepage() const {return _codepage;};
NppParameters * getParameter() {
return _pParameter;
};
ColumnModeInfo getColumnModeSelectInfo();
void columnReplace(ColumnModeInfo & cmi, const TCHAR *str);
void columnReplace(ColumnModeInfo & cmi, int initial, int incr, UCHAR format);
void foldChanged(int line, int levelNow, int levelPrev);
void clearIndicator(int indicatorNumber) {
int docStart = 0;
int docEnd = getCurrentDocLen();
execute(SCI_SETINDICATORCURRENT, indicatorNumber);
execute(SCI_INDICATORCLEARRANGE, docStart, docEnd-docStart);
};
static LanguageName ScintillaEditView::langNames[L_EXTERNAL+1];
void bufferUpdated(Buffer * buffer, int mask);
BufferID getCurrentBufferID() { return _currentBufferID; };
Buffer * getCurrentBuffer() { return _currentBuffer; };
void styleChange();
void hideLines();
bool markerMarginClick(int lineNumber); //true if it did something
void notifyMarkers(Buffer * buf, bool isHide, int location, bool del);
void runMarkers(bool doHide, int searchStart, bool endOfDoc, bool doDelete);
bool isSelecting() const {
static CharacterRange previousSelRange = getSelection();
CharacterRange currentSelRange = getSelection();
if (currentSelRange.cpMin == currentSelRange.cpMax)
{
previousSelRange = currentSelRange;
return false;
}
if ((previousSelRange.cpMin == currentSelRange.cpMin) || (previousSelRange.cpMax == currentSelRange.cpMax))
{
previousSelRange = currentSelRange;
return true;
}
previousSelRange = currentSelRange;
return false;
};
void setHiLiteResultWords(const TCHAR *keywords);
/*
pair<size_t, bool> getLineUndoState(size_t currentLine) {
Buffer * buf = getCurrentBuffer();
return buf->getLineUndoState(currentLine);
};
void setLineUndoState(size_t currentLine, size_t undoLevel, bool isSaved = false) {
Buffer * buf = getCurrentBuffer();
buf->setLineUndoState(currentLine, undoLevel, isSaved);
};
void markSavedLines() {
for (int i = 0 ; i <= lastZeroBasedLineNumber() ; i++)
{
if ((execute(SCI_MARKERGET, i) & (1 << MARK_LINEMODIFIEDUNSAVED)) != 0)
{
execute(SCI_MARKERDELETE, i, MARK_LINEMODIFIEDUNSAVED);
execute(SCI_MARKERADD, i, MARK_LINEMODIFIEDSAVED);
//pair<size_t, bool> st = getLineUndoState(i);
setLineUndoState(i, 0, true);
}
}
};
*/
protected:
static HINSTANCE _hLib;
static int _refCount;
static UserDefineDialog _userDefineDlg;
static const int _markersArray[][NB_FOLDER_STATE];
static LRESULT CALLBACK scintillaStatic_Proc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) {
ScintillaEditView *pScint = (ScintillaEditView *)(::GetWindowLongPtr(hwnd, GWL_USERDATA));
//
if (Message == WM_MOUSEWHEEL || Message == WM_MOUSEHWHEEL)
{
POINT pt;
POINTS pts = MAKEPOINTS(lParam);
POINTSTOPOINT(pt, pts);
HWND hwndOnMouse = WindowFromPoint(pt);
ScintillaEditView *pScintillaOnMouse = (ScintillaEditView *)(::GetWindowLongPtr(hwndOnMouse, GWL_USERDATA));
if (pScintillaOnMouse != pScint)
return ::SendMessage(hwndOnMouse, Message, wParam, lParam);
}
if (pScint)
return (pScint->scintillaNew_Proc(hwnd, Message, wParam, lParam));
else
return ::DefWindowProc(hwnd, Message, wParam, lParam);
//
};
LRESULT scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);
SCINTILLA_FUNC _pScintillaFunc;
SCINTILLA_PTR _pScintillaPtr;
static WNDPROC _scintillaDefaultProc;
CallWindowProcFunc _callWindowProc;
BufferID attachDefaultDoc();
//Store the current buffer so it can be retrieved later
BufferID _currentBufferID;
Buffer * _currentBuffer;
folderStyle _folderStyle;
NppParameters *_pParameter;
int _codepage;
int _oemCodepage;
bool _lineNumbersShown;
bool _wrapRestoreNeeded;
//Lexers and Styling
void defineDocType(LangType typeDoc); //setup stylers for active document
void restyleBuffer();
const char * getCompleteKeywordList(std::basic_string<char> & kwl, LangType langType, int keywordIndex);
void setKeywords(LangType langType, const char *keywords, int index);
void setLexer(int lexerID, LangType langType, int whichList);
inline void makeStyle(LangType langType, const TCHAR **keywordArray = NULL);
void setStyle(Style styleToSet); //NOT by reference (style edited)
void setSpecialStyle(Style & styleToSet); //by reference
void setSpecialIndicator(Style & styleToSet) {
execute(SCI_INDICSETFORE, styleToSet._styleID, styleToSet._bgColor);
};
//Complex lexers (same lexer, different language)
void setXmlLexer(LangType type);
void setCppLexer(LangType type);
void setObjCLexer(LangType type);
void setUserLexer(const TCHAR *userLangName = NULL);
void setExternalLexer(LangType typeDoc);
void setEmbeddedJSLexer();
void setPhpEmbeddedLexer();
void setEmbeddedAspLexer();
//Simple lexers
void setCssLexer() {
setLexer(SCLEX_CSS, L_CSS, LIST_0 | LIST_1);
};
void setLuaLexer() {
setLexer(SCLEX_LUA, L_LUA, LIST_0 | LIST_1 | LIST_2 | LIST_3);
};
void setMakefileLexer() {
execute(SCI_SETLEXER, SCLEX_MAKEFILE);
makeStyle(L_MAKEFILE);
};
void setIniLexer() {
execute(SCI_SETLEXER, SCLEX_PROPERTIES);
execute(SCI_STYLESETEOLFILLED, SCE_PROPS_SECTION, true);
makeStyle(L_INI);
};
void setSqlLexer() {
setLexer(SCLEX_SQL, L_SQL, LIST_0);
};
void setBashLexer() {
setLexer(SCLEX_BASH, L_BASH, LIST_0);
};
void setVBLexer() {
setLexer(SCLEX_VB, L_VB, LIST_0);
};
void setPascalLexer() {
setLexer(SCLEX_PASCAL, L_PASCAL, LIST_0);
};
void setPerlLexer() {
setLexer(SCLEX_PERL, L_PERL, LIST_0);
};
void setPythonLexer() {
setLexer(SCLEX_PYTHON, L_PYTHON, LIST_0);
};
void setBatchLexer() {
setLexer(SCLEX_BATCH, L_BATCH, LIST_0);
};
void setTeXLexer() {
for (int i = 0 ; i < 4 ; i++)
execute(SCI_SETKEYWORDS, i, reinterpret_cast<LPARAM>(TEXT("")));
setLexer(SCLEX_TEX, L_TEX, 0);
};
void setNsisLexer() {
setLexer(SCLEX_NSIS, L_NSIS, LIST_0 | LIST_1 | LIST_2 | LIST_3);
};
void setFortranLexer() {
setLexer(SCLEX_F77, L_FORTRAN, LIST_0 | LIST_1 | LIST_2);
};
void setLispLexer(){
setLexer(SCLEX_LISP, L_LISP, LIST_0);
};
void setSchemeLexer(){
setLexer(SCLEX_LISP, L_SCHEME, LIST_0);
};
void setAsmLexer(){
setLexer(SCLEX_ASM, L_ASM, LIST_0 | LIST_1 | LIST_2 | LIST_3 | LIST_4 | LIST_5);
};
void setDiffLexer(){
setLexer(SCLEX_DIFF, L_DIFF, LIST_NONE);
};
void setPropsLexer(){
setLexer(SCLEX_PROPERTIES, L_PROPS, LIST_NONE);
};
void setPostscriptLexer(){
setLexer(SCLEX_PS, L_PS, LIST_0 | LIST_1 | LIST_2 | LIST_3);
};
void setRubyLexer(){
setLexer(SCLEX_RUBY, L_RUBY, LIST_0);
execute(SCI_STYLESETEOLFILLED, SCE_RB_POD, true);
};
void setSmalltalkLexer(){
setLexer(SCLEX_SMALLTALK, L_SMALLTALK, LIST_0);
};
void setVhdlLexer(){
setLexer(SCLEX_VHDL, L_VHDL, LIST_0 | LIST_1 | LIST_2 | LIST_3 | LIST_4 | LIST_5 | LIST_6);
};
void setKixLexer(){
setLexer(SCLEX_KIX, L_KIX, LIST_0 | LIST_1 | LIST_2);
};
void setAutoItLexer(){
setLexer(SCLEX_AU3, L_AU3, LIST_0 | LIST_1 | LIST_2 | LIST_3 | LIST_4 | LIST_5 | LIST_6);
};
void setCamlLexer(){
setLexer(SCLEX_CAML, L_CAML, LIST_0 | LIST_1 | LIST_2);
};
void setAdaLexer(){
setLexer(SCLEX_ADA, L_ADA, LIST_0);
};
void setVerilogLexer(){
setLexer(SCLEX_VERILOG, L_VERILOG, LIST_0 | LIST_1);
};
void setMatlabLexer(){
setLexer(SCLEX_MATLAB, L_MATLAB, LIST_0);
};
void setHaskellLexer(){
setLexer(SCLEX_HASKELL, L_HASKELL, LIST_0);
};
void setInnoLexer() {
setLexer(SCLEX_INNOSETUP, L_INNO, LIST_0 | LIST_1 | LIST_2 | LIST_3 | LIST_4 | LIST_5);
};
void setCmakeLexer() {
setLexer(SCLEX_CMAKE, L_CMAKE, LIST_0 | LIST_1 | LIST_2);
};
void setYamlLexer() {
setLexer(SCLEX_YAML, L_YAML, LIST_0);
};
void setSearchResultLexer() {
execute(SCI_STYLESETEOLFILLED, SCE_SEARCHRESULT_FILE_HEADER, true);
execute(SCI_STYLESETEOLFILLED, SCE_SEARCHRESULT_SEARCH_HEADER, true);
setLexer(SCLEX_SEARCHRESULT, L_SEARCHRESULT, 0);
};
bool isNeededFolderMarge(LangType typeDoc) const {
switch (typeDoc)
{
case L_NFO:
case L_BATCH:
case L_TXT:
case L_MAKEFILE:
case L_SQL:
case L_ASM:
//case L_TEX:
case L_HASKELL:
case L_PROPS:
case L_SMALLTALK:
case L_KIX:
case L_ADA:
return false;
default:
return true;
}
};
//END: Lexers and Styling
void defineMarker(int marker, int markerType, COLORREF fore, COLORREF back) {
execute(SCI_MARKERDEFINE, marker, markerType);
execute(SCI_MARKERSETFORE, marker, fore);
execute(SCI_MARKERSETBACK, marker, back);
};
bool isCJK() const {
return ((_codepage == CP_CHINESE_TRADITIONAL) || (_codepage == CP_CHINESE_SIMPLIFIED) ||
(_codepage == CP_JAPANESE) || (_codepage == CP_KOREAN) || (_codepage == CP_GREEK));
};
int codepage2CharSet() const {
switch (_codepage)
{
case CP_CHINESE_TRADITIONAL : return SC_CHARSET_CHINESEBIG5;
case CP_CHINESE_SIMPLIFIED : return SC_CHARSET_GB2312;
case CP_KOREAN : return SC_CHARSET_HANGUL;
case CP_JAPANESE : return SC_CHARSET_SHIFTJIS;
case CP_GREEK : return SC_CHARSET_GREEK;
default : return 0;
}
};
bool expandWordSelection();
};
#endif //SCINTILLA_EDIT_VIEW_H

View File

@ -0,0 +1,6 @@
#ifndef SCINTILLA_REF_H
#define SCINTILLA_REF_H
enum folderStyle {FOLDER_TYPE, FOLDER_STYLE_SIMPLE, FOLDER_STYLE_ARROW, FOLDER_STYLE_CIRCLE, FOLDER_STYLE_BOX};
#endif //SCINTILLA_REF_H

View File

@ -0,0 +1,177 @@
//this file is part of notepad++
//Copyright (C)2003 Harry <harrybharry@users.sourceforge.net>
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "SmartHighlighter.h"
//#include "Parameters.h"
#define MAXLINEHIGHLIGHT 400 //prevent highlighter from doing too much work when a lot is visible
SmartHighlighter::SmartHighlighter(FindReplaceDlg * pFRDlg)
: _pFRDlg(pFRDlg)
{
//Nothing to do
}
void SmartHighlighter::highlightView(ScintillaEditView * pHighlightView)
{
//Get selection
CharacterRange range = pHighlightView->getSelection();
//Clear marks
pHighlightView->clearIndicator(SCE_UNIVERSAL_FOUND_STYLE_2);
//If nothing selected, dont mark anything
if (range.cpMin == range.cpMax)
{
return;
}
int textlen = range.cpMax - range.cpMin + 1;
char * text2Find = new char[textlen];
pHighlightView->getSelectedText(text2Find, textlen, false); //do not expand selection (false)
bool valid = true;
//The word has to consist if wordChars only, and the characters before and after something else
if (!isQualifiedWord(text2Find))
valid = false;
else
{
UCHAR c = (UCHAR)pHighlightView->execute(SCI_GETCHARAT, range.cpMax);
if (c)
{
if (isWordChar(char(c)))
valid = false;
}
c = (UCHAR)pHighlightView->execute(SCI_GETCHARAT, range.cpMin-1);
if (c)
{
if (isWordChar(char(c)))
valid = false;
}
}
if (!valid) {
delete [] text2Find;
return;
}
// save target locations for other search functions
int originalStartPos = (int)pHighlightView->execute(SCI_GETTARGETSTART);
int originalEndPos = (int)pHighlightView->execute(SCI_GETTARGETEND);
// Get the range of text visible and highlight everything in it
int firstLine = (int)pHighlightView->execute(SCI_GETFIRSTVISIBLELINE);
int nrLines = min((int)pHighlightView->execute(SCI_LINESONSCREEN), MAXLINEHIGHLIGHT ) + 1;
int lastLine = firstLine+nrLines;
int startPos = 0;//(int)pHighlightView->execute(SCI_POSITIONFROMLINE, firstLine);
int endPos = 0;//(int)pHighlightView->execute(SCI_POSITIONFROMLINE, lastLine);
//if (endPos == -1) { //past EOF
// endPos = (int)pHighlightView->getCurrentDocLen() - 1;
//}
int currentLine = firstLine;
int prevDocLineChecked = -1; //invalid start
FindOption fo;
fo._isMatchCase = false;
fo._isWholeWord = true;
const TCHAR * searchText = NULL;
#ifdef UNICODE
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
unsigned int cp = pHighlightView->execute(SCI_GETCODEPAGE);
const TCHAR * text2FindW = wmc->char2wchar(text2Find, cp);
searchText = text2FindW;
#else
searchText = text2Find;
#endif
for(; currentLine < lastLine; currentLine++) {
int docLine = (int)pHighlightView->execute(SCI_DOCLINEFROMVISIBLE, currentLine);
if (docLine == prevDocLineChecked)
continue; //still on same line (wordwrap)
prevDocLineChecked = docLine;
startPos = (int)pHighlightView->execute(SCI_POSITIONFROMLINE, docLine);
endPos = (int)pHighlightView->execute(SCI_POSITIONFROMLINE, docLine+1);
if (endPos == -1) { //past EOF
endPos = (int)pHighlightView->getCurrentDocLen() - 1;
_pFRDlg->processRange(ProcessMarkAll_2, searchText, NULL, startPos, endPos, NULL, &fo);
break;
} else {
_pFRDlg->processRange(ProcessMarkAll_2, searchText, NULL, startPos, endPos, NULL, &fo);
}
}
// restore the original targets to avoid conflicts with the search/replace functions
pHighlightView->execute(SCI_SETTARGETSTART, originalStartPos);
pHighlightView->execute(SCI_SETTARGETEND, originalEndPos);
}
bool SmartHighlighter::isQualifiedWord(const char *str) const
{
for (size_t i = 0 ; i < strlen(str) ; i++)
{
if (!isWordChar(str[i]))
return false;
}
return true;
};
bool SmartHighlighter::isWordChar(char ch) const
{
if ((UCHAR)ch < 0x20)
return false;
switch(ch)
{
case ' ':
case ' ':
case '\n':
case '\r':
case '.':
case ',':
case '?':
case ';':
case ':':
case '!':
case '(':
case ')':
case '[':
case ']':
case '+':
case '-':
case '*':
case '/':
case '#':
case '@':
case '^':
case '%':
case '$':
case '"':
case '\'':
case '~':
case '&':
case '{':
case '}':
case '|':
case '=':
case '<':
case '>':
case '\\':
return false;
}
return true;
};

View File

@ -0,0 +1,35 @@
//this file is part of notepad++
//Copyright (C)2003 Harry <harrybharry@users.sourceforge.net>
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#ifndef SMARTHIGHLIGHTER_H
#define SMARTHIGHLIGHTER_H
#include "ScintillaEditView.h"
#include "FindReplaceDlg.h"
class SmartHighlighter {
public:
SmartHighlighter(FindReplaceDlg * pFRDlg);
void highlightView(ScintillaEditView * pHighlightView);
private:
FindReplaceDlg * _pFRDlg;
bool isQualifiedWord(const char *str) const;
bool isWordChar(char ch) const;
};
#endif //SMARTHIGHLIGHTER_H

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,505 @@
/*
this file is part of Notepad++
Copyright (C)2003 Don HO <donho@altern.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef USER_DEFINE_H
#define USER_DEFINE_H
#include <string>
#include <shlwapi.h>
#include "UserDefineResource.h"
#include "ControlsTab.h"
#include "ColourPicker.h"
#include "UserDefineLangReference.h"
//#include "Parameters.h"
#ifdef __GNUC__
static int min(int a, int b) {
return (a<b)?a:b;
};
static int max(int a, int b) {
return (a>b)?a:b;
};
#endif //__GNUC__
class ScintillaEditView;
class UserLangContainer;
struct Style;
#define WL_LEN_MAX 1024
#define BOLD_MASK 1
#define ITALIC_MASK 2
const int nbWordList = 4;
const int nbBlockColor = 5;
const int nbBoolean = 5;
const bool DOCK = true;
const bool UNDOCK = false;
const int maxNbGroup = 10;
const int KWL_FOLDER_OPEN_INDEX = 1;
const int KWL_FOLDER_CLOSE_INDEX = 2;
const int KWL_OPERATOR_INDEX = 3;
const int KWL_COMMENT_INDEX = 4;
const int KWL_KW1_INDEX = 5;
const int KWL_KW2_INDEX = 6;
const int KWL_KW3_INDEX = 7;
const int KWL_KW4_INDEX = 8;
const int KWL_DELIM_INDEX = 0;
const int STYLE_DEFAULT_INDEX = 0;
const int STYLE_BLOCK_OPEN_INDEX = 1;
const int STYLE_BLOCK_CLOSE_INDEX = 2;
const int STYLE_WORD1_INDEX = 3;
const int STYLE_WORD2_INDEX = 4;
const int STYLE_WORD3_INDEX = 5;
const int STYLE_WORD4_INDEX = 6;
const int STYLE_COMMENT_INDEX = 7;
const int STYLE_COMMENTLINE_INDEX = 8;
const int STYLE_NUMBER_INDEX = 9;
const int STYLE_OPERATOR_INDEX = 10;
const int STYLE_DELIM2_INDEX = 11;
const int STYLE_DELIM3_INDEX = 12;
class SharedParametersDialog : public StaticDialog
{
public:
SharedParametersDialog() {};
SharedParametersDialog(int nbGroup) : _nbGroup(nbGroup) {};
virtual void updateDlg() = 0;
protected :
//Shared data
static UserLangContainer *_pUserLang;
static ScintillaEditView *_pScintilla;
//data for per object
int _nbGroup;
ColourPicker *_pFgColour[maxNbGroup];
ColourPicker *_pBgColour[maxNbGroup];
int _fgStatic[maxNbGroup];
int _bgStatic[maxNbGroup];
int _fontSizeCombo[maxNbGroup];
int _fontNameCombo[maxNbGroup];
BOOL CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam);
void initControls();
void styleUpdate(const Style & style, ColourPicker *pFgColourPicker, ColourPicker *pBgColourPicker,
int fontComboId, int fontSizeComboId, int boldCheckId, int italicCheckId, int underlineCheckId);
bool setPropertyByCheck(HWND hwnd, WPARAM id, bool & bool2set);
virtual void setKeywords2List(int ctrlID) = 0;
virtual int getGroupIndexFromCombo(int ctrlID, bool & isFontSize) const = 0;
virtual int getStylerIndexFromCP(HWND hWnd, bool & isFG, ColourPicker **ppCP) const = 0;
virtual int getGroupeIndexFromCheck(int ctrlID, int & fontStyleMask) const = 0;
};
class FolderStyleDialog : public SharedParametersDialog
{
public:
FolderStyleDialog();
void updateDlg();
protected :
void setKeywords2List(int ctrlID);
int getGroupIndexFromCombo(int ctrlID, bool & isFontSize) const {
switch (ctrlID)
{
case IDC_DEFAULT_FONT_COMBO :
isFontSize = false;
return STYLE_DEFAULT_INDEX;
case IDC_DEFAULT_FONTSIZE_COMBO :
isFontSize = true;
return STYLE_DEFAULT_INDEX;
case IDC_FOLDEROPEN_FONT_COMBO :
isFontSize = false;
return STYLE_BLOCK_OPEN_INDEX;
case IDC_FOLDEROPEN_FONTSIZE_COMBO :
isFontSize = true;
return STYLE_BLOCK_OPEN_INDEX;
case IDC_FOLDERCLOSE_FONT_COMBO :
isFontSize = false;
return STYLE_BLOCK_CLOSE_INDEX;
case IDC_FOLDERCLOSE_FONTSIZE_COMBO :
isFontSize = true;
return STYLE_BLOCK_CLOSE_INDEX;
default :
return -1;
}
};
int getStylerIndexFromCP(HWND hWnd, bool & isFG, ColourPicker **ppCP) const;
int getGroupeIndexFromCheck(int ctrlID, int & fontStyleMask) const;
};
class KeyWordsStyleDialog : public SharedParametersDialog
{
public:
KeyWordsStyleDialog() ;
void updateDlg();
protected :
BOOL CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam);
void setKeywords2List(int id);
// SEE @REF #01
int getGroupIndexFromCombo(int ctrlID, bool & isFontSize) const {
switch (ctrlID)
{
case IDC_KEYWORD1_FONT_COMBO :
isFontSize = false;
return STYLE_WORD1_INDEX;
case IDC_KEYWORD1_FONTSIZE_COMBO :
isFontSize = true;
return STYLE_WORD1_INDEX;
case IDC_KEYWORD2_FONT_COMBO :
isFontSize = false;
return STYLE_WORD2_INDEX;
case IDC_KEYWORD2_FONTSIZE_COMBO :
isFontSize = true;
return STYLE_WORD2_INDEX;
case IDC_KEYWORD3_FONT_COMBO :
isFontSize = false;
return STYLE_WORD3_INDEX;
case IDC_KEYWORD3_FONTSIZE_COMBO :
isFontSize = true;
return STYLE_WORD3_INDEX;
case IDC_KEYWORD4_FONT_COMBO :
isFontSize = false;
return STYLE_WORD4_INDEX;
case IDC_KEYWORD4_FONTSIZE_COMBO :
isFontSize = true;
return STYLE_WORD4_INDEX;
default :
return -1;
}
};
int getStylerIndexFromCP(HWND hWnd, bool & isFG, ColourPicker **ppCP) const;
int getGroupeIndexFromCheck(int ctrlID, int & fontStyleMask) const;
};
class CommentStyleDialog : public SharedParametersDialog
{
public :
CommentStyleDialog();
void updateDlg();
protected :
BOOL CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam);
void setKeywords2List(int id);
int getGroupIndexFromCombo(int ctrlID, bool & isFontSize) const {
switch (ctrlID)
{
case IDC_COMMENT_FONT_COMBO :
isFontSize = false;
return STYLE_COMMENT_INDEX;
case IDC_COMMENT_FONTSIZE_COMBO :
isFontSize = true;
return STYLE_COMMENT_INDEX;
case IDC_COMMENTLINE_FONT_COMBO :
isFontSize = false;
return STYLE_COMMENTLINE_INDEX;
case IDC_COMMENTLINE_FONTSIZE_COMBO :
isFontSize = true;
return STYLE_COMMENTLINE_INDEX;
case IDC_NUMBER_FONT_COMBO :
isFontSize = false;
return STYLE_NUMBER_INDEX;
case IDC_NUMBER_FONTSIZE_COMBO :
isFontSize = true;
return STYLE_NUMBER_INDEX;
default :
return -1;
}
};
int getStylerIndexFromCP(HWND hWnd, bool & isFG, ColourPicker **ppCP) const;
int getGroupeIndexFromCheck(int ctrlID, int & fontStyleMask) const;
private :
void convertTo(TCHAR *dest, const TCHAR *toConvert, TCHAR prefix) const;
void retrieve(TCHAR *dest, const TCHAR *toRetrieve, TCHAR prefix) const;
};
class SymbolsStyleDialog : public SharedParametersDialog
{
public :
static const bool ADD;
static const bool REMOVE;
SymbolsStyleDialog();
void updateDlg();
protected :
BOOL CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam);
void setKeywords2List(int ctrlID) {};
int getGroupIndexFromCombo(int ctrlID, bool & isFontSize) const {
switch (ctrlID)
{
case IDC_SYMBOL_FONT_COMBO :
isFontSize = false;
return STYLE_OPERATOR_INDEX;
case IDC_SYMBOL_FONTSIZE_COMBO :
isFontSize = true;
return STYLE_OPERATOR_INDEX;
case IDC_SYMBOL_FONT2_COMBO :
isFontSize = false;
return STYLE_DELIM2_INDEX;
case IDC_SYMBOL_FONTSIZE2_COMBO :
isFontSize = true;
return STYLE_DELIM2_INDEX;
case IDC_SYMBOL_FONT3_COMBO :
isFontSize = false;
return STYLE_DELIM3_INDEX;
case IDC_SYMBOL_FONTSIZE3_COMBO :
isFontSize = true;
return STYLE_DELIM3_INDEX;
default :
return -1;
}
};
int getStylerIndexFromCP(HWND hWnd, bool & isFG, ColourPicker **ppCP) const;
int getGroupeIndexFromCheck(int ctrlID, int & fontStyleMask) const;
private :
// 2 static const TCHAR * to have the compatibility with the old xml
static const TCHAR *_delimTag1;
static const TCHAR *_delimTag2;
void symbolAction(bool action);
void listboxsRemoveAll();
void listboxsInit();
void listboxsReInit() {
listboxsRemoveAll();
listboxsInit();
};
};
class UserDefineDialog : public SharedParametersDialog
{
friend class ScintillaEditView;
public :
UserDefineDialog();
~UserDefineDialog();
void init(HINSTANCE hInst, HWND hPere, ScintillaEditView *pSev) {
if (!_pScintilla)
{
Window::init(hInst, hPere);
_pScintilla = pSev;
}
};
void setScintilla(ScintillaEditView *pScinView) {
_pScintilla = pScinView;
};
virtual void create(int dialogID, bool isRTL = false) {
StaticDialog::create(dialogID, isRTL);
}
void destroy() {
// A Ajouter les fils...
};
int getWidth() const {
return _dlgPos.right;
};
int getHeight() const {
return _dlgPos.bottom;
};
void doDialog(bool willBeShown = true, bool isRTL = false) {
if (!isCreated())
create(IDD_GLOBAL_USERDEFINE_DLG, isRTL);
display(willBeShown);
};
virtual void reSizeTo(RECT & rc) // should NEVER be const !!!
{
Window::reSizeTo(rc);
display(false);
display();
};
void changeStyle();
bool isDocked() const {return _status == DOCK;};
void setDockStatus(bool isDocked) {_status = isDocked;};
int getNbKeywordList() {return nbKeywodList;};
bool isDirty() const {return _isDirty;};
HWND getFolderHandle() const {
return _folderStyleDlg.getHSelf();
};
HWND getKeywordsHandle() const {
return _keyWordsStyleDlg.getHSelf();
};
HWND getCommentHandle() const {
return _commentStyleDlg.getHSelf();
};
HWND getSymbolHandle() const {
return _symbolsStyleDlg.getHSelf();
};
void setTabName(int index, const TCHAR *name2set) {
_ctrlTab.renameTab(index, name2set);
};
protected :
virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
private :
ControlsTab _ctrlTab;
WindowVector _wVector;
UserLangContainer *_pCurrentUserLang;
FolderStyleDialog _folderStyleDlg;
KeyWordsStyleDialog _keyWordsStyleDlg;
CommentStyleDialog _commentStyleDlg;
SymbolsStyleDialog _symbolsStyleDlg;
bool _status;
RECT _dlgPos;
int _currentHight;
int _yScrollPos;
int _prevHightVal;
bool _isDirty;
void getActualPosSize() {
::GetWindowRect(_hSelf, &_dlgPos);
_dlgPos.right -= _dlgPos.left;
_dlgPos.bottom -= _dlgPos.top;
};
void restorePosSize(){reSizeTo(_dlgPos);};
void enableLangAndControlsBy(int index);
protected :
void setKeywords2List(int ctrlID){};
int getGroupIndexFromCombo(int ctrlID, bool & isFontSize) const {return -1;};
int getStylerIndexFromCP(HWND hWnd, bool & isFG, ColourPicker **ppCP) const {return -1;};
int getGroupeIndexFromCheck(int ctrlID, int & fontStyleMask) const {return -1;};
void updateDlg();
};
class StringDlg : public StaticDialog
{
public :
StringDlg() : StaticDialog() {};
void init(HINSTANCE hInst, HWND parent, TCHAR *title, TCHAR *staticName, TCHAR *text2Set, int txtLen = 0) {
Window::init(hInst, parent);
lstrcpy(_title, title);
lstrcpy(_static, staticName);
lstrcpy(_textValue, text2Set);
_txtLen = txtLen;
};
long doDialog() {
return long(::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_STRING_DLG), _hParent, (DLGPROC)dlgProc, (LPARAM)this));
};
virtual void destroy() {};
protected :
BOOL CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam)
{
switch (Message)
{
case WM_INITDIALOG :
{
::SetWindowText(_hSelf, _title);
::SetDlgItemText(_hSelf, IDC_STRING_STATIC, _static);
::SetDlgItemText(_hSelf, IDC_STRING_EDIT, _textValue);
if (_txtLen)
::SendDlgItemMessage(_hSelf, IDC_STRING_EDIT, EM_SETLIMITTEXT, _txtLen, 0);
return TRUE;
}
case WM_COMMAND :
{
switch (wParam)
{
case IDOK :
{
::GetDlgItemText(_hSelf, IDC_STRING_EDIT, _textValue, 256);
::EndDialog(_hSelf, int(_textValue));
return TRUE;
}
case IDCANCEL :
::EndDialog(_hSelf, 0);
return TRUE;
default:
return FALSE;
}
}
default :
return FALSE;
}
return FALSE;
}
private :
TCHAR _title[64];
TCHAR _textValue[256];
TCHAR _static[32];
int _txtLen;
};
#endif //USER_DEFINE_H

View File

@ -0,0 +1,270 @@
/*
this file is part of notepad++
Copyright (C)2003 Don HO < donho@altern.org >
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef USERDEFINEDIALOG_RC
#define USERDEFINEDIALOG_RC
#include <windows.h>
#include "UserDefineResource.h"
IDD_FOLDER_STYLE_DLG DIALOGEX 36, 44, 320, 460
STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | WS_CHILD
FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x0
BEGIN
GROUPBOX "Folder Open Keywords Setting", IDC_FOLDEROPEN_DESCGROUP_STATIC,5,114,300,127,BS_CENTER
LTEXT "Foreground color",IDC_FOLDEROPEN_FG_STATIC,27,144,58,8, 0,WS_EX_RIGHT
LTEXT "Background color",IDC_FOLDEROPEN_BG_STATIC,27,168,58,8, 0,WS_EX_RIGHT
COMBOBOX IDC_FOLDEROPEN_FONT_COMBO,185,140,104,78, CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_FOLDEROPEN_FONTSIZE_COMBO,249,162,40,82, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "Bold",IDC_FOLDEROPEN_BOLD_CHECK,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,141,166,46,10
CONTROL "Italic",IDC_FOLDEROPEN_ITALIC_CHECK,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,141,179,47,10
GROUPBOX "Font style",IDC_FOLDEROPEN_FONTSTYLEGROUP_STATIC,133, 125,164,71
GROUPBOX "Colour style",IDC_FOLDEROPEN_COLORSTYLEGROUP_STATIC,15, 125,111,71
LTEXT "Font Name :",IDC_FOLDEROPEN_FONTNAME_STATIC,138,142,44, 8,0,WS_EX_RIGHT
LTEXT "Font size :",IDC_FOLDEROPEN_FONTSIZE_STATIC,212,164,35, 8,0,WS_EX_RIGHT
EDITTEXT IDC_FOLDEROPEN_EDIT,15,203,282,28,ES_MULTILINE | WS_VSCROLL
GROUPBOX "Folder Close Keywords Setting", IDC_FOLDERCLOSE_DESCGROUP_STATIC,5,246,300,125,BS_CENTER
LTEXT "Foreground color",IDC_FOLDERCLOSE_FG_STATIC,27,277,58,8,0,WS_EX_RIGHT
LTEXT "Background color",IDC_FOLDERCLOSE_BG_STATIC,27,301,58,8,0,WS_EX_RIGHT
COMBOBOX IDC_FOLDERCLOSE_FONT_COMBO,185,272,104,78,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_FOLDERCLOSE_FONTSIZE_COMBO,249,292,40,82, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "Bold",IDC_FOLDERCLOSE_BOLD_CHECK,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,141,298,45,10
CONTROL "Italic",IDC_FOLDERCLOSE_ITALIC_CHECK,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,141,312,46,10
GROUPBOX "Font style",IDC_FOLDERCLOSE_FONTSTYLEGROUP_STATIC,133,257,164,69
GROUPBOX "Colour style",IDC_FOLDERCLOSE_COLORSTYLEGROUP_STATIC,15,257,111,69
LTEXT "Font Name :",IDC_FOLDERCLOSE_FONTNAME_STATIC,138,273,45,8,0,WS_EX_RIGHT
LTEXT "Font size :",IDC_FOLDERCLOSE_FONTSIZE_STATIC,212,294,35, 8,0,WS_EX_RIGHT
EDITTEXT IDC_FOLDERCLOSE_EDIT,15,334,282,28,ES_MULTILINE | WS_VSCROLL
GROUPBOX "Default Style Setting",IDC_DEFAULT_DESCGROUP_STATIC,5,7, 300,92,BS_CENTER
LTEXT "Foreground color",IDC_DEFAULT_FG_STATIC,27,38,59,8,0, WS_EX_RIGHT
LTEXT "Background color",IDC_DEFAULT_BG_STATIC,27,62,59,8,0, WS_EX_RIGHT
COMBOBOX IDC_DEFAULT_FONT_COMBO,185,33,104,78,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_DEFAULT_FONTSIZE_COMBO,249,55,40,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "Bold",IDC_DEFAULT_BOLD_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,141,59,45,10
CONTROL "Italic",IDC_DEFAULT_ITALIC_CHECK,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,141,73,46,10
GROUPBOX "Font style",IDC_DEFAULT_FONTSTYLEGROUP_STATIC,133,17, 164,73
GROUPBOX "Colour style",IDC_DEFAULT_COLORSTYLEGROUP_STATIC,15,17, 111,73
LTEXT "Font Name :",IDC_DEFAULT_FONTNAME_STATIC,137,34,47,8,0, WS_EX_RIGHT
LTEXT "Font size :",IDC_DEFAULT_FONTSIZE_STATIC,212,57,36,8,0, WS_EX_RIGHT
CONTROL "Underline",IDC_DEFAULT_UNDERLINE_CHECK,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,214,73,59,10
CONTROL "Underline",IDC_FOLDEROPEN_UNDERLINE_CHECK,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,213,179,59,10
CONTROL "Underline",IDC_FOLDERCLOSE_UNDERLINE_CHECK,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,212,312,59,10
END
IDD_KEYWORD_STYLE_DLG DIALOGEX 36, 44, 320, 460
STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | WS_CHILD
FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x0
BEGIN
LTEXT "Foreground color",IDC_KEYWORD1_FG_STATIC,26,25,56,8,0, WS_EX_RIGHT
LTEXT "Background color",IDC_KEYWORD1_BG_STATIC,26,45,56,8,0,WS_EX_RIGHT
COMBOBOX IDC_KEYWORD1_FONT_COMBO,184,26,104,78,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_KEYWORD1_FONTSIZE_COMBO,248,42,40,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "Bold",IDC_KEYWORD1_BOLD_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,140,44,45,10
CONTROL "Italic",IDC_KEYWORD1_ITALIC_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,140,59,41,10
GROUPBOX "Font style",IDC_KEYWORD1_FONTSTYLEGROUP_STATIC,132,13,164,61
GROUPBOX "Colour style",IDC_KEYWORD1_COLORSTYLEGROUP_STATIC,14,13,111,49
LTEXT "Font Name :",IDC_KEYWORD1_FONTNAME_STATIC,136,27,44,8,0,WS_EX_RIGHT
LTEXT "Font size :",IDC_KEYWORD1_FONTSIZE_STATIC,212,44,34,8,0,WS_EX_RIGHT
EDITTEXT IDC_KEYWORD1_EDIT,14,78,282,28,ES_MULTILINE | WS_VSCROLL
GROUPBOX "1st Group",IDC_KEYWORD1_DESCGROUP_STATIC,4,3,300,109,BS_CENTER | BS_FLAT
LTEXT "Foreground color",IDC_KEYWORD2_FG_STATIC,26,136,56,8,0,WS_EX_RIGHT
LTEXT "Background color",IDC_KEYWORD2_BG_STATIC,26,157,56,8,0,WS_EX_RIGHT
COMBOBOX IDC_KEYWORD2_FONT_COMBO,184,138,104,78,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_KEYWORD2_FONTSIZE_COMBO,248,154,40,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "Bold",IDC_KEYWORD2_BOLD_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,140,156,46,10
CONTROL "Italic",IDC_KEYWORD2_ITALIC_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,140,172,43,10
GROUPBOX "Font style",IDC_KEYWORD2_FONTSTYLEGROUP_STATIC,132,125,164,62
GROUPBOX "Colour style",IDC_KEYWORD2_COLORSTYLEGROUP_STATIC,14,125,111,49
LTEXT "Font Name :",IDC_KEYWORD2_FONTNAME_STATIC,136,139,44,8,0,WS_EX_RIGHT
LTEXT "Font size :",IDC_KEYWORD2_FONTSIZE_STATIC,212,156,34,8,0,WS_EX_RIGHT
EDITTEXT IDC_KEYWORD2_EDIT,14,192,282,28,ES_MULTILINE | WS_VSCROLL
GROUPBOX "2nd Group",IDC_KEYWORD2_DESCGROUP_STATIC,4,115,300,110,BS_CENTER | BS_FLAT
LTEXT "Foreground color",IDC_KEYWORD3_FG_STATIC,26,248,56,8,0,WS_EX_RIGHT
LTEXT "Background color",IDC_KEYWORD3_BG_STATIC,26,269,56,8,0,WS_EX_RIGHT
COMBOBOX IDC_KEYWORD3_FONT_COMBO,184,250,104,78,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_KEYWORD3_FONTSIZE_COMBO,248,266,40,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "Bold",IDC_KEYWORD3_BOLD_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,140,268,45,10
CONTROL "Italic",IDC_KEYWORD3_ITALIC_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,140,283,44,10
GROUPBOX "Font style",IDC_KEYWORD3_FONTSTYLEGROUP_STATIC,132,237,164,61
GROUPBOX "Colour style",IDC_KEYWORD3_COLORSTYLEGROUP_STATIC,14,237,111,49
LTEXT "Font Name :",IDC_KEYWORD3_FONTNAME_STATIC,136,251,44,8,0,WS_EX_RIGHT
LTEXT "Font size :",IDC_KEYWORD3_FONTSIZE_STATIC,212,268,34,8,0,WS_EX_RIGHT
EDITTEXT IDC_KEYWORD3_EDIT,14,303,282,28,ES_MULTILINE | WS_VSCROLL
GROUPBOX "3rd Group",IDC_KEYWORD3_DESCGROUP_STATIC,4,227,300,110,BS_CENTER | BS_FLAT
LTEXT "Foreground color",IDC_KEYWORD4_FG_STATIC,26,362,57,8,0,WS_EX_RIGHT
LTEXT "Background color",IDC_KEYWORD4_BG_STATIC,26,383,57,8,0,WS_EX_RIGHT
COMBOBOX IDC_KEYWORD4_FONT_COMBO,184,363,104,78,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_KEYWORD4_FONTSIZE_COMBO,248,379,40,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "Bold",IDC_KEYWORD4_BOLD_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,140,381,44,10
CONTROL "Italic",IDC_KEYWORD4_ITALIC_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,140,396,44,10
GROUPBOX "Font style",IDC_KEYWORD4_FONTSTYLEGROUP_STATIC,132,350,164,60
GROUPBOX "Colour style",IDC_KEYWORD4_COLORSTYLEGROUP_STATIC,14, 350,111,50
LTEXT "Font Name :",IDC_KEYWORD4_FONTNAME_STATIC,136,364,44,8, 0,WS_EX_RIGHT
LTEXT "Font size :",IDC_KEYWORD4_FONTSIZE_STATIC,212,381,34,8, 0,WS_EX_RIGHT
EDITTEXT IDC_KEYWORD4_EDIT,14,416,282,28,ES_MULTILINE | WS_VSCROLL
GROUPBOX "4th Group",IDC_KEYWORD4_DESCGROUP_STATIC,4,340,300,111, BS_CENTER | BS_FLAT
CONTROL "Prefix mode",IDC_KEYWORD1_PREFIX_CHECK,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,14,67,64,10
CONTROL "Prefix mode",IDC_KEYWORD2_PREFIX_CHECK,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,14,180,64,10
CONTROL "Prefix mode",IDC_KEYWORD3_PREFIX_CHECK,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,14,291,64,10
CONTROL "Prefix mode",IDC_KEYWORD4_PREFIX_CHECK,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,14,404,64,10
CONTROL "Underline",IDC_KEYWORD4_UNDERLINE_CHECK,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,211,396,58,10
CONTROL "Underline",IDC_KEYWORD3_UNDERLINE_CHECK,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,211,283,61,10
CONTROL "Underline",IDC_KEYWORD1_UNDERLINE_CHECK,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,211,59,59,10
CONTROL "Underline",IDC_KEYWORD2_UNDERLINE_CHECK,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,211,172,59,10
END
IDD_COMMENT_STYLE_DLG DIALOGEX 36, 44, 320, 460
STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | WS_CHILD
FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x0
BEGIN
LTEXT "Foreground color ",IDC_COMMENTLINE_FG_STATIC,24,31,58,8,0,WS_EX_RIGHT
LTEXT "Background color",IDC_COMMENTLINE_BG_STATIC,24,52,58,8,0,WS_EX_RIGHT
COMBOBOX IDC_COMMENTLINE_FONT_COMBO,184,32,104,78,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_COMMENTLINE_FONTSIZE_COMBO,248,48,40,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "Bold",IDC_COMMENTLINE_BOLD_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,140,50,43,10
CONTROL "Italic",IDC_COMMENTLINE_ITALIC_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,140,65,43,10
GROUPBOX "Font style",IDC_COMMENTLINE_FONTSTYLEGROUP_STATIC,132,19,164,63
GROUPBOX "Colour style",IDC_COMMENTLINE_COLORSTYLEGROUP_STATIC,14,19,111,50
LTEXT "Font Name :",IDC_COMMENTLINE_FONTNAME_STATIC,140,33,40,8,0,WS_EX_RIGHT
LTEXT "Font size :",IDC_COMMENTLINE_FONTSIZE_STATIC,212,50,34,8,0,WS_EX_RIGHT
EDITTEXT IDC_COMMENTLINE_EDIT,14,90,282,28,ES_MULTILINE | WS_VSCROLL
GROUPBOX "Comment Line",IDC_COMMENTLINE_DESCGROUP_STATIC,4,7,300,119,BS_CENTER
LTEXT "Foreground color",IDC_NUMBER_FG_STATIC,24,302,58,8,0,WS_EX_RIGHT
LTEXT "Background color",IDC_NUMBER_BG_STATIC,24,325,58,8,0,WS_EX_RIGHT
COMBOBOX IDC_NUMBER_FONT_COMBO,183,300,104,78,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_NUMBER_FONTSIZE_COMBO,247,316,40,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "Bold",IDC_NUMBER_BOLD_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,139,317,44,10
CONTROL "Italic",IDC_NUMBER_ITALIC_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,139,333,44,10
GROUPBOX "Font style",IDC_NUMBER_FONTSTYLEGROUP_STATIC,131,288,164,60
GROUPBOX "Colour style",IDC_NUMBER_COLORSTYLEGROUP_STATIC,13,288,111,60
LTEXT "Font Name :",IDC_NUMBER_FONTNAME_STATIC,139,301,40,8,0,WS_EX_RIGHT
LTEXT "Font size :",IDC_NUMBER_FONTSIZE_STATIC,211,317,34,8,0,WS_EX_RIGHT
GROUPBOX "Number",IDC_NUMBER_DESCGROUP_STATIC,3,274,300,85,BS_CENTER
LTEXT "Foreground color",IDC_COMMENT_FG_STATIC,24,158,57,8,0,WS_EX_RIGHT
LTEXT "Background color",IDC_COMMENT_BG_STATIC,24,179,57,8,0,WS_EX_RIGHT
COMBOBOX IDC_COMMENT_FONT_COMBO,184,159,104,78,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_COMMENT_FONTSIZE_COMBO,248,175,40,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "Bold",IDC_COMMENT_BOLD_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,140,177,44,10
CONTROL "Italic",IDC_COMMENT_ITALIC_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,140,193,43,10
GROUPBOX "Font style",IDC_COMMENT_FONTSTYLEGROUP_STATIC,132,146,164,64
GROUPBOX "Colour style",IDC_COMMENT_COLORSTYLEGROUP_STATIC,14,146,111,50
LTEXT "Font Name :",IDC_COMMENT_FONTNAME_STATIC,140,160,40,8,0,WS_EX_RIGHT
LTEXT "Font size :",IDC_COMMENT_FONTSIZE_STATIC,212,177,34,8,0,WS_EX_RIGHT
EDITTEXT IDC_COMMENTOPEN_EDIT,14,229,133,28,ES_MULTILINE | WS_VSCROLL
GROUPBOX "Comment Block",IDC_COMMENT_DESCGROUP_STATIC,4,133,300,132,BS_CENTER
EDITTEXT IDC_COMMENTCLOSE_EDIT,157,229,139,28,ES_MULTILINE | WS_VSCROLL
LTEXT "Comment Open :",IDC_COMMENTOPEN_STATIC,17,218,90,8
LTEXT "Comment Close :",IDC_COMMENTCLOSE_STATIC,158,218,88,8
CONTROL "Treat keyword as symbol",IDC_COMMENTLINESYMBOL_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,78,112,10
CONTROL "Treat keywords as symbols",IDC_COMMENTSYMBOL_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,203,112,10
CONTROL "Underline",IDC_COMMENT_UNDERLINE_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,211,193,59,10
CONTROL "Underline",IDC_COMMENTLINE_UNDERLINE_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,212,65,59,10
CONTROL "Underline",IDC_NUMBER_UNDERLINE_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,211,332,59,10
END
IDD_SYMBOL_STYLE_DLG DIALOGEX 36, 44, 320, 460
STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | WS_CHILD
FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x0
BEGIN
LISTBOX IDC_AVAILABLE_SYMBOLS_LIST,68,33,41,116,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "->",IDC_ADD_BUTTON,127,65,50,14
PUSHBUTTON "<-",IDC_REMOVE_BUTTON,127,94,50,14
LISTBOX IDC_ACTIVATED_SYMBOL_LIST,195,33,41,115,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
LTEXT "Activated Operators",IDC_ACTIVATED_SYMBOL_STATIC,182,18,86,8
LTEXT "Available Symbols",IDC_AVAILABLE_SYMBOLS_STATIC,59,18,90,8
LTEXT "Foreground color",IDC_SYMBOL_FG_STATIC,25,169,57,8,0,WS_EX_RIGHT
LTEXT "Background color",IDC_SYMBOL_BG_STATIC,25,192,57,8,0,WS_EX_RIGHT
COMBOBOX IDC_SYMBOL_FONT_COMBO,183,168,104,78,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_SYMBOL_FONTSIZE_COMBO,247,184,40,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "Bold",IDC_SYMBOL_BOLD_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,139,185,44,10
CONTROL "Italic",IDC_SYMBOL_ITALIC_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,139,199,44,10
GROUPBOX "Font style",IDC_SYMBOL_FONTSTYLEGROUP_STATIC,131,155,164,59
GROUPBOX "Colour style",IDC_SYMBOL_COLORSTYLEGROUP_STATIC,13,155,111,59
LTEXT "Font Name :",IDC_SYMBOL_FONTNAME_STATIC,135,169,44,8,0,WS_EX_RIGHT
LTEXT "Font size :",IDC_SYMBOL_FONTSIZE_STATIC,211,185,34,8,0,WS_EX_RIGHT
GROUPBOX "Operator",IDC_SYMBOL_DESCGROUP_STATIC,3,5,300,216,BS_CENTER
CONTROL "Underline",IDC_SYMBOL_UNDERLINE_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,211,199,59,10
LTEXT "Foreground color",IDC_SYMBOL_FG2_STATIC,26,268,56,8,0,WS_EX_RIGHT
LTEXT "Background color",IDC_SYMBOL_BG2_STATIC,26,289,56,8,0,WS_EX_RIGHT
COMBOBOX IDC_SYMBOL_FONT2_COMBO,184,266,104,78,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_SYMBOL_BO2_COMBO,85,237,40,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "Bold",IDC_SYMBOL_BOLD2_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,140,284,45,10
CONTROL "Italic",IDC_SYMBOL_ITALIC2_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,140,299,41,10
GROUPBOX "Font style",IDC_SYMBOL_FONTSTYLEGROUP2_STATIC,132,253,164,60
GROUPBOX "Colour style",IDC_SYMBOL_COLORSTYLEGROUP2_STATIC,14,253,111,60
LTEXT "Font Name :",IDC_SYMBOL_FONTNAME2_STATIC,136,267,44,8,0,WS_EX_RIGHT
LTEXT "Boundary open :",IDC_SYMBOL_BO2_STATIC,9,239,74,8,0,WS_EX_RIGHT
CONTROL "Underline",IDC_SYMBOL_UNDERLINE2_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,211,299,59,10
COMBOBOX IDC_SYMBOL_BC2_COMBO,256,237,40,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "Boundary close :",IDC_SYMBOL_BC2_STATIC,168,239,86,8,0,WS_EX_RIGHT
GROUPBOX "Delimiter 1",IDC_SYMBOL_DELIMGROUP1_STATIC,3,227,300,93,BS_CENTER | BS_FLAT
LTEXT "Foreground color",IDC_SYMBOL_FG3_STATIC,26,369,56,8,0,WS_EX_RIGHT
LTEXT "Background color",IDC_SYMBOL_BG3_STATIC,26,390,56,8,0,WS_EX_RIGHT
COMBOBOX IDC_SYMBOL_FONT3_COMBO,184,367,104,78,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_SYMBOL_BO3_COMBO,85,339,40,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "Bold",IDC_SYMBOL_BOLD3_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,140,385,45,10
CONTROL "Italic",IDC_SYMBOL_ITALIC3_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,140,400,41,10
GROUPBOX "Font style",IDC_SYMBOL_FONTSTYLEGROUP3_STATIC,132,355,164,60
GROUPBOX "Colour style",IDC_SYMBOL_COLORSTYLEGROUP3_STATIC,14,355,111,60
LTEXT "Font Name :",IDC_SYMBOL_FONTNAME3_STATIC,136,368,44,8,0,WS_EX_RIGHT
LTEXT "Boundary open :",IDC_SYMBOL_BO3_STATIC,9,340,74,8,0,WS_EX_RIGHT
CONTROL "Underline",IDC_SYMBOL_UNDERLINE3_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,211,400,59,10
COMBOBOX IDC_SYMBOL_BC3_COMBO,256,339,40,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "Boundary close :",IDC_SYMBOL_BC3_STATIC,168,340,86,8,0,WS_EX_RIGHT
GROUPBOX "Delimiter 2",IDC_SYMBOL_DELIMGROUP2_STATIC,3,328,300,93,BS_CENTER | BS_FLAT
COMBOBOX IDC_SYMBOL_FONTSIZE2_COMBO,248,283,40,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "Font size :",IDC_SYMBOL_FONTSIZE2_STATIC,212,285,34,8,0,WS_EX_RIGHT
COMBOBOX IDC_SYMBOL_FONTSIZE3_COMBO,248,384,40,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "Font size :",IDC_SYMBOL_FONTSIZE3_STATIC,212,386,34,8,0,WS_EX_RIGHT
END
IDD_GLOBAL_USERDEFINE_DLG DIALOGEX 36, 44, 340, 550
STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | WS_POPUP |
WS_CAPTION | WS_VSCROLL | WS_SYSMENU
EXSTYLE WS_EX_TOOLWINDOW
CAPTION "User Define"
FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x0
BEGIN
PUSHBUTTON "Rename",IDC_RENAME_BUTTON,174,40,62,14
PUSHBUTTON "Create New...",IDC_ADDNEW_BUTTON,34,40,62,14
PUSHBUTTON "Dock",IDC_DOCK_BUTTON,275,1,50,14,BS_FLAT
COMBOBOX IDC_LANGNAME_COMBO,71,23,95,58,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "Remove",IDC_REMOVELANG_BUTTON,243,40,62,14
PUSHBUTTON "Save As...",IDC_SAVEAS_BUTTON,104,40,62,14
LTEXT "User Language : ",IDC_LANGNAME_STATIC,5,24,63,8,0,WS_EX_RIGHT
EDITTEXT IDC_EXT_EDIT,291,23,33,14,ES_AUTOHSCROLL
RTEXT "Ext :",IDC_EXT_STATIC,257,25,33,8,0,WS_EX_RIGHT
CONTROL "Transparency",IDC_UD_TRANSPARENT_CHECK,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,150,3,66,10
CONTROL "",IDC_UD_PERCENTAGE_SLIDER,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | NOT WS_VISIBLE | WS_TABSTOP,209,3,53,10
CONTROL "Ignore case",IDC_LANGNAME_IGNORECASE_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,175,24,76,10
END
IDD_STRING_DLG DIALOGEX 0, 0, 151, 52
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
EXSTYLE WS_EX_TOOLWINDOW
FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1
BEGIN
LTEXT "STATIC :",IDC_STRING_STATIC,6,4,42,8,0,WS_EX_RIGHT
EDITTEXT IDC_STRING_EDIT,49,2,88,14
PUSHBUTTON "OK",IDOK,20,26,50,14
PUSHBUTTON "Cancel",IDCANCEL,87,26,50,14
END
#endif //USERDEFINEDIALOG_RC

View File

@ -0,0 +1,36 @@
/*
this file is part of Notepad++
Copyright (C)2003 Don HO <donho@altern.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef USER_DEFINE_LANG_REFERENCE_H
#define USER_DEFINE_LANG_REFERENCE_H
const int langNameLenMax = 16;
const int extsLenMax = 256;
const int nbKeywodList = 9;
//const int max_char = 4096;
const int max_char = 1024*30;
const int nbPrefixListAllowed = 4;
#endif //USER_DEFINE_LANG_REFERENCE_H

View File

@ -0,0 +1,265 @@
//this file is part of notepad++
//Copyright (C)2003 Don HO ( donho@altern.org )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#ifndef USERDEFINE_RC_H
#define USERDEFINE_RC_H
#define IDD_GLOBAL_USERDEFINE_DLG 20000
#define IDC_DOCK_BUTTON (IDD_GLOBAL_USERDEFINE_DLG + 1)
#define IDC_RENAME_BUTTON (IDD_GLOBAL_USERDEFINE_DLG + 2)
#define IDC_ADDNEW_BUTTON (IDD_GLOBAL_USERDEFINE_DLG + 3)
#define IDC_REMOVELANG_BUTTON (IDD_GLOBAL_USERDEFINE_DLG + 4)
#define IDC_SAVEAS_BUTTON (IDD_GLOBAL_USERDEFINE_DLG + 5)
#define IDC_LANGNAME_COMBO (IDD_GLOBAL_USERDEFINE_DLG + 6)
#define IDC_LANGNAME_STATIC (IDD_GLOBAL_USERDEFINE_DLG + 7)
#define IDC_EXT_EDIT (IDD_GLOBAL_USERDEFINE_DLG + 8)
#define IDC_EXT_STATIC (IDD_GLOBAL_USERDEFINE_DLG + 9)
#define IDC_UD_PERCENTAGE_SLIDER (IDD_GLOBAL_USERDEFINE_DLG + 10)
#define IDC_UD_TRANSPARENT_CHECK (IDD_GLOBAL_USERDEFINE_DLG + 11)
#define IDC_LANGNAME_IGNORECASE_CHECK (IDD_GLOBAL_USERDEFINE_DLG + 12)
#define IDC_AUTOCOMPLET_EDIT (IDD_GLOBAL_USERDEFINE_DLG + 13)
#define IDC_AUTOCOMPLET_STATIC (IDD_GLOBAL_USERDEFINE_DLG + 14)
#define IDD_FOLDER_STYLE_DLG 21000
#define IDC_DEFAULT (IDD_FOLDER_STYLE_DLG + 100)
#define IDC_DEFAULT_DESCGROUP_STATIC (IDC_DEFAULT+ 1)
#define IDC_DEFAULT_FG_STATIC (IDC_DEFAULT+ 2)
#define IDC_DEFAULT_BG_STATIC (IDC_DEFAULT + 3)
#define IDC_DEFAULT_FONT_COMBO (IDC_DEFAULT+ 4)
#define IDC_DEFAULT_FONTSIZE_COMBO (IDC_DEFAULT + 5)
#define IDC_DEFAULT_BOLD_CHECK (IDC_DEFAULT + 6)
#define IDC_DEFAULT_ITALIC_CHECK (IDC_DEFAULT + 7)
#define IDC_DEFAULT_FONTSTYLEGROUP_STATIC (IDC_DEFAULT+ 8)
#define IDC_DEFAULT_COLORSTYLEGROUP_STATIC (IDC_DEFAULT + 9)
#define IDC_DEFAULT_FONTNAME_STATIC (IDC_DEFAULT + 10)
#define IDC_DEFAULT_FONTSIZE_STATIC (IDC_DEFAULT+ 11)
#define IDC_DEFAULT_EDIT (IDC_DEFAULT+ 12)
#define IDC_DEFAULT_UNDERLINE_CHECK (IDC_DEFAULT + 13)
#define IDC_FOLDEROPEN (IDD_FOLDER_STYLE_DLG + 200)
#define IDC_FOLDEROPEN_DESCGROUP_STATIC (IDC_FOLDEROPEN + 1)
#define IDC_FOLDEROPEN_FG_STATIC (IDC_FOLDEROPEN + 2)
#define IDC_FOLDEROPEN_BG_STATIC (IDC_FOLDEROPEN + 3)
#define IDC_FOLDEROPEN_FONT_COMBO (IDC_FOLDEROPEN + 4)
#define IDC_FOLDEROPEN_FONTSIZE_COMBO (IDC_FOLDEROPEN + 5)
#define IDC_FOLDEROPEN_BOLD_CHECK (IDC_FOLDEROPEN + 6)
#define IDC_FOLDEROPEN_ITALIC_CHECK (IDC_FOLDEROPEN + 7)
#define IDC_FOLDEROPEN_FONTSTYLEGROUP_STATIC (IDC_FOLDEROPEN + 8)
#define IDC_FOLDEROPEN_COLORSTYLEGROUP_STATIC (IDC_FOLDEROPEN + 9)
#define IDC_FOLDEROPEN_FONTNAME_STATIC (IDC_FOLDEROPEN + 10)
#define IDC_FOLDEROPEN_FONTSIZE_STATIC (IDC_FOLDEROPEN + 11)
#define IDC_FOLDEROPEN_EDIT (IDC_FOLDEROPEN + 12)
#define IDC_FOLDEROPEN_UNDERLINE_CHECK (IDC_FOLDEROPEN + 13)
#define IDC_FOLDERCLOSE (IDD_FOLDER_STYLE_DLG + 300)
#define IDC_FOLDERCLOSE_DESCGROUP_STATIC (IDC_FOLDERCLOSE + 1)
#define IDC_FOLDERCLOSE_FG_STATIC (IDC_FOLDERCLOSE + 2)
#define IDC_FOLDERCLOSE_BG_STATIC (IDC_FOLDERCLOSE + 3)
#define IDC_FOLDERCLOSE_FONT_COMBO (IDC_FOLDERCLOSE + 4)
#define IDC_FOLDERCLOSE_FONTSIZE_COMBO (IDC_FOLDERCLOSE + 5)
#define IDC_FOLDERCLOSE_BOLD_CHECK (IDC_FOLDERCLOSE + 6)
#define IDC_FOLDERCLOSE_ITALIC_CHECK (IDC_FOLDERCLOSE + 7)
#define IDC_FOLDERCLOSE_FONTSTYLEGROUP_STATIC (IDC_FOLDERCLOSE + 8)
#define IDC_FOLDERCLOSE_COLORSTYLEGROUP_STATIC (IDC_FOLDERCLOSE + 9)
#define IDC_FOLDERCLOSE_FONTNAME_STATIC (IDC_FOLDERCLOSE + 10)
#define IDC_FOLDERCLOSE_FONTSIZE_STATIC (IDC_FOLDERCLOSE + 11)
#define IDC_FOLDERCLOSE_EDIT (IDC_FOLDERCLOSE + 12)
#define IDC_FOLDERCLOSE_UNDERLINE_CHECK (IDC_FOLDERCLOSE + 13)
#define IDD_KEYWORD_STYLE_DLG 22000 //(IDD_GLOBAL_USERDEFINE_DLG + 2000)
#define IDC_KEYWORD1 (IDD_KEYWORD_STYLE_DLG + 100)
#define IDC_KEYWORD1_DESCGROUP_STATIC (IDC_KEYWORD1 + 1)
#define IDC_KEYWORD1_FG_STATIC (IDC_KEYWORD1 + 2)
#define IDC_KEYWORD1_BG_STATIC (IDC_KEYWORD1 + 3)
#define IDC_KEYWORD1_FONT_COMBO (IDC_KEYWORD1 + 4)
#define IDC_KEYWORD1_FONTSIZE_COMBO (IDC_KEYWORD1 + 5)
#define IDC_KEYWORD1_BOLD_CHECK (IDC_KEYWORD1 + 6)
#define IDC_KEYWORD1_ITALIC_CHECK (IDC_KEYWORD1 + 7)
#define IDC_KEYWORD1_FONTSTYLEGROUP_STATIC (IDC_KEYWORD1 + 8)
#define IDC_KEYWORD1_COLORSTYLEGROUP_STATIC (IDC_KEYWORD1 + 9)
#define IDC_KEYWORD1_FONTNAME_STATIC (IDC_KEYWORD1 + 10)
#define IDC_KEYWORD1_FONTSIZE_STATIC (IDC_KEYWORD1 + 11)
#define IDC_KEYWORD1_EDIT (IDC_KEYWORD1 + 12)
#define IDC_KEYWORD1_PREFIX_CHECK (IDC_KEYWORD1 + 13)
#define IDC_KEYWORD1_UNDERLINE_CHECK (IDC_KEYWORD1 + 14)
#define IDC_KEYWORD2 (IDD_KEYWORD_STYLE_DLG + 200)
#define IDC_KEYWORD2_DESCGROUP_STATIC (IDC_KEYWORD2 + 1)
#define IDC_KEYWORD2_FG_STATIC (IDC_KEYWORD2 + 2)
#define IDC_KEYWORD2_BG_STATIC (IDC_KEYWORD2 + 3)
#define IDC_KEYWORD2_FONT_COMBO (IDC_KEYWORD2 + 4)
#define IDC_KEYWORD2_FONTSIZE_COMBO (IDC_KEYWORD2 + 5)
#define IDC_KEYWORD2_BOLD_CHECK (IDC_KEYWORD2 + 6)
#define IDC_KEYWORD2_ITALIC_CHECK (IDC_KEYWORD2 + 7)
#define IDC_KEYWORD2_FONTSTYLEGROUP_STATIC (IDC_KEYWORD2 + 8)
#define IDC_KEYWORD2_COLORSTYLEGROUP_STATIC (IDC_KEYWORD2 + 9)
#define IDC_KEYWORD2_FONTNAME_STATIC (IDC_KEYWORD2 + 10)
#define IDC_KEYWORD2_FONTSIZE_STATIC (IDC_KEYWORD2 + 11)
#define IDC_KEYWORD2_EDIT (IDC_KEYWORD2 + 12)
#define IDC_KEYWORD2_PREFIX_CHECK (IDC_KEYWORD2 + 13)
#define IDC_KEYWORD2_UNDERLINE_CHECK (IDC_KEYWORD2 + 14)
#define IDC_KEYWORD3 (IDD_KEYWORD_STYLE_DLG + 300)
#define IDC_KEYWORD3_DESCGROUP_STATIC (IDC_KEYWORD3 + 1)
#define IDC_KEYWORD3_FG_STATIC (IDC_KEYWORD3 + 2)
#define IDC_KEYWORD3_BG_STATIC (IDC_KEYWORD3 + 3)
#define IDC_KEYWORD3_FONT_COMBO (IDC_KEYWORD3 + 4)
#define IDC_KEYWORD3_FONTSIZE_COMBO (IDC_KEYWORD3 + 5)
#define IDC_KEYWORD3_BOLD_CHECK (IDC_KEYWORD3 + 6)
#define IDC_KEYWORD3_ITALIC_CHECK (IDC_KEYWORD3 + 7)
#define IDC_KEYWORD3_FONTSTYLEGROUP_STATIC (IDC_KEYWORD3 + 8)
#define IDC_KEYWORD3_COLORSTYLEGROUP_STATIC (IDC_KEYWORD3 + 9)
#define IDC_KEYWORD3_FONTNAME_STATIC (IDC_KEYWORD3 + 10)
#define IDC_KEYWORD3_FONTSIZE_STATIC (IDC_KEYWORD3 + 11)
#define IDC_KEYWORD3_EDIT (IDC_KEYWORD3 + 12)
#define IDC_KEYWORD3_PREFIX_CHECK (IDC_KEYWORD3 + 13)
#define IDC_KEYWORD3_UNDERLINE_CHECK (IDC_KEYWORD3 + 14)
#define IDC_KEYWORD4 (IDD_KEYWORD_STYLE_DLG + 400)
#define IDC_KEYWORD4_DESCGROUP_STATIC (IDC_KEYWORD4 + 1)
#define IDC_KEYWORD4_FG_STATIC (IDC_KEYWORD4 + 2)
#define IDC_KEYWORD4_BG_STATIC (IDC_KEYWORD4 + 3)
#define IDC_KEYWORD4_FONT_COMBO (IDC_KEYWORD4 + 4)
#define IDC_KEYWORD4_FONTSIZE_COMBO (IDC_KEYWORD4 + 5)
#define IDC_KEYWORD4_BOLD_CHECK (IDC_KEYWORD4 + 6)
#define IDC_KEYWORD4_ITALIC_CHECK (IDC_KEYWORD4 + 7)
#define IDC_KEYWORD4_FONTSTYLEGROUP_STATIC (IDC_KEYWORD4 + 8)
#define IDC_KEYWORD4_COLORSTYLEGROUP_STATIC (IDC_KEYWORD4 + 9)
#define IDC_KEYWORD4_FONTNAME_STATIC (IDC_KEYWORD4 + 10)
#define IDC_KEYWORD4_FONTSIZE_STATIC (IDC_KEYWORD4 + 11)
#define IDC_KEYWORD4_EDIT (IDC_KEYWORD4 + 12)
#define IDC_KEYWORD4_PREFIX_CHECK (IDC_KEYWORD4 + 13)
#define IDC_KEYWORD4_UNDERLINE_CHECK (IDC_KEYWORD4 + 14)
#define IDC_KEYWORD_SCROLLBAR (IDD_KEYWORD_STYLE_DLG + 500)
#define IDD_COMMENT_STYLE_DLG 23000 //(IDD_GLOBAL_USERDEFINE_DLG + 3000)
#define IDC_COMMENT (IDD_COMMENT_STYLE_DLG + 100)
#define IDC_COMMENT_DESCGROUP_STATIC (IDC_COMMENT + 1)
#define IDC_COMMENT_FG_STATIC (IDC_COMMENT + 2)
#define IDC_COMMENT_BG_STATIC (IDC_COMMENT+ 3)
#define IDC_COMMENT_FONT_COMBO (IDC_COMMENT + 4)
#define IDC_COMMENT_FONTSIZE_COMBO (IDC_COMMENT+ 5)
#define IDC_COMMENT_BOLD_CHECK (IDC_COMMENT+ 6)
#define IDC_COMMENT_ITALIC_CHECK (IDC_COMMENT+ 7)
#define IDC_COMMENT_FONTSTYLEGROUP_STATIC (IDC_COMMENT+ 8)
#define IDC_COMMENT_COLORSTYLEGROUP_STATIC (IDC_COMMENT+ 9)
#define IDC_COMMENT_FONTNAME_STATIC (IDC_COMMENT+ 10)
#define IDC_COMMENT_FONTSIZE_STATIC (IDC_COMMENT+ 11)
#define IDC_COMMENTOPEN_EDIT (IDC_COMMENT+ 12)
#define IDC_COMMENTOPEN_STATIC (IDC_COMMENT+ 13)
#define IDC_COMMENTCLOSE_EDIT (IDC_COMMENT + 14)
#define IDC_COMMENTCLOSE_STATIC (IDC_COMMENT + 15)
#define IDC_COMMENTLINESYMBOL_CHECK (IDC_COMMENT + 16)
#define IDC_COMMENTSYMBOL_CHECK (IDC_COMMENT + 17)
#define IDC_COMMENT_UNDERLINE_CHECK (IDC_NUMBER + 18)
#define IDC_NUMBER (IDD_COMMENT_STYLE_DLG + 200)
#define IDC_NUMBER_DESCGROUP_STATIC (IDC_NUMBER+ 1)
#define IDC_NUMBER_FG_STATIC (IDC_NUMBER+ 2)
#define IDC_NUMBER_BG_STATIC (IDC_NUMBER + 3)
#define IDC_NUMBER_FONT_COMBO (IDC_NUMBER+ 4)
#define IDC_NUMBER_FONTSIZE_COMBO (IDC_NUMBER + 5)
#define IDC_NUMBER_BOLD_CHECK (IDC_NUMBER + 6)
#define IDC_NUMBER_ITALIC_CHECK (IDC_NUMBER + 7)
#define IDC_NUMBER_FONTSTYLEGROUP_STATIC (IDC_NUMBER + 8)
#define IDC_NUMBER_COLORSTYLEGROUP_STATIC (IDC_NUMBER + 9)
#define IDC_NUMBER_FONTNAME_STATIC (IDC_NUMBER + 10)
#define IDC_NUMBER_FONTSIZE_STATIC (IDC_NUMBER + 11)
#define IDC_NUMBER_UNDERLINE_CHECK (IDC_NUMBER + 12)
#define IDC_COMMENTLINE (IDD_COMMENT_STYLE_DLG + 300)
#define IDC_COMMENTLINE_DESCGROUP_STATIC (IDC_COMMENTLINE + 1)
#define IDC_COMMENTLINE_FG_STATIC (IDC_COMMENTLINE + 2)
#define IDC_COMMENTLINE_BG_STATIC (IDC_COMMENTLINE + 3)
#define IDC_COMMENTLINE_FONT_COMBO (IDC_COMMENTLINE + 4)
#define IDC_COMMENTLINE_FONTSIZE_COMBO (IDC_COMMENTLINE + 5)
#define IDC_COMMENTLINE_BOLD_CHECK (IDC_COMMENTLINE + 6)
#define IDC_COMMENTLINE_ITALIC_CHECK (IDC_COMMENTLINE + 7)
#define IDC_COMMENTLINE_FONTSTYLEGROUP_STATIC (IDC_COMMENTLINE + 8)
#define IDC_COMMENTLINE_COLORSTYLEGROUP_STATIC (IDC_COMMENTLINE + 9)
#define IDC_COMMENTLINE_FONTNAME_STATIC (IDC_COMMENTLINE + 10)
#define IDC_COMMENTLINE_FONTSIZE_STATIC (IDC_COMMENTLINE + 11)
#define IDC_COMMENTLINE_EDIT (IDC_COMMENTLINE + 12)
#define IDC_COMMENTLINE_UNDERLINE_CHECK (IDC_COMMENTLINE + 13)
#define IDD_SYMBOL_STYLE_DLG 24000 //IDD_GLOBAL_USERDEFINE_DLG + 4000
#define IDC_SYMBOL (IDD_SYMBOL_STYLE_DLG + 100)
#define IDC_ACTIVATED_SYMBOL_STATIC (IDC_SYMBOL + 1)
#define IDC_ACTIVATED_SYMBOL_LIST (IDC_SYMBOL + 2)
#define IDC_AVAILABLE_SYMBOLS_STATIC (IDC_SYMBOL + 3)
#define IDC_AVAILABLE_SYMBOLS_LIST (IDC_SYMBOL + 4)
#define IDC_ADD_BUTTON (IDC_SYMBOL + 5)
#define IDC_REMOVE_BUTTON (IDC_SYMBOL + 6)
#define IDC_SYMBOL_DESCGROUP_STATIC (IDC_SYMBOL+ 7)
#define IDC_SYMBOL_FG_STATIC (IDC_SYMBOL + 8)
#define IDC_SYMBOL_BG_STATIC (IDC_SYMBOL + 9)
#define IDC_SYMBOL_FONT_COMBO (IDC_SYMBOL + 10)
#define IDC_SYMBOL_FONTSIZE_COMBO (IDC_SYMBOL + 11)
#define IDC_SYMBOL_BOLD_CHECK (IDC_SYMBOL+ 12)
#define IDC_SYMBOL_ITALIC_CHECK (IDC_SYMBOL + 13)
#define IDC_SYMBOL_FONTSTYLEGROUP_STATIC (IDC_SYMBOL + 14)
#define IDC_SYMBOL_COLORSTYLEGROUP_STATIC ( IDC_SYMBOL + 15)
#define IDC_SYMBOL_FONTNAME_STATIC (IDC_SYMBOL + 16)
#define IDC_SYMBOL_FONTSIZE_STATIC (IDC_SYMBOL + 17)
#define IDC_SYMBOL_UNDERLINE_CHECK (IDC_SYMBOL + 18)
#define IDC_SYMBOL2 (IDD_SYMBOL_STYLE_DLG + 200)
#define IDC_SYMBOL_DELIMGROUP1_STATIC (IDC_SYMBOL2 + 1)
#define IDC_SYMBOL_COLORSTYLEGROUP2_STATIC (IDC_SYMBOL2 + 2)
#define IDC_SYMBOL_FONTSTYLEGROUP2_STATIC (IDC_SYMBOL2 + 3)
#define IDC_SYMBOL_FG2_STATIC (IDC_SYMBOL2 + 4)
#define IDC_SYMBOL_BG2_STATIC (IDC_SYMBOL2 + 5)
#define IDC_SYMBOL_FONTNAME2_STATIC (IDC_SYMBOL2 + 6)
#define IDC_SYMBOL_BOLD2_CHECK (IDC_SYMBOL2 + 7)
#define IDC_SYMBOL_ITALIC2_CHECK (IDC_SYMBOL2 + 8)
#define IDC_SYMBOL_FONT2_COMBO (IDC_SYMBOL2 + 9)
#define IDC_SYMBOL_UNDERLINE2_CHECK (IDC_SYMBOL2 + 10)
#define IDC_SYMBOL_BO2_STATIC (IDC_SYMBOL2 + 11)
#define IDC_SYMBOL_BO2_COMBO (IDC_SYMBOL2 + 12)
#define IDC_SYMBOL_BC2_COMBO (IDC_SYMBOL2 + 13)
#define IDC_SYMBOL_BC2_STATIC (IDC_SYMBOL2 + 14)
#define IDC_SYMBOL_FONTSIZE2_COMBO (IDC_SYMBOL2 + 15)
#define IDC_SYMBOL_FONTSIZE2_STATIC (IDC_SYMBOL2 + 16)
#define IDC_SYMBOL3 (IDD_SYMBOL_STYLE_DLG + 300)
#define IDC_SYMBOL_DELIMGROUP2_STATIC (IDC_SYMBOL3 + 1)
#define IDC_SYMBOL_FG3_STATIC (IDC_SYMBOL3 + 2)
#define IDC_SYMBOL_BG3_STATIC (IDC_SYMBOL3 + 3)
#define IDC_SYMBOL_FONT3_COMBO (IDC_SYMBOL3 + 4)
#define IDC_SYMBOL_BO3_COMBO (IDC_SYMBOL3 + 5)
#define IDC_SYMBOL_BOLD3_CHECK (IDC_SYMBOL3 + 6)
#define IDC_SYMBOL_ITALIC3_CHECK (IDC_SYMBOL3 + 7)
#define IDC_SYMBOL_FONTSTYLEGROUP3_STATIC (IDC_SYMBOL3 + 8)
#define IDC_SYMBOL_COLORSTYLEGROUP3_STATIC (IDC_SYMBOL3 + 9)
#define IDC_SYMBOL_FONTNAME3_STATIC (IDC_SYMBOL3 + 10)
#define IDC_SYMBOL_BO3_STATIC (IDC_SYMBOL3 + 11)
#define IDC_SYMBOL_UNDERLINE3_CHECK (IDC_SYMBOL3 + 12)
#define IDC_SYMBOL_BC3_COMBO (IDC_SYMBOL3 + 13)
#define IDC_SYMBOL_BC3_STATIC (IDC_SYMBOL3 + 14)
#define IDC_SYMBOL_FONTSIZE3_COMBO (IDC_SYMBOL3 + 15)
#define IDC_SYMBOL_FONTSIZE3_STATIC (IDC_SYMBOL3 + 16)
#define IDD_STRING_DLG 25000
#define IDC_STRING_STATIC (IDD_STRING_DLG + 1)
#define IDC_STRING_EDIT (IDD_STRING_DLG + 2)
#endif //USERDEFIN_RC_H

View File

@ -0,0 +1,62 @@
//this file is part of notepad++
//Copyright (C)2003 Don HO ( donho@altern.org )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#ifndef COLORS_H
#define COLORS_H
#include <windows.h>
const COLORREF red = RGB(0xFF, 0, 0);
const COLORREF darkRed = RGB(0x80, 0, 0);
const COLORREF offWhite = RGB(0xFF, 0xFB, 0xF0);
const COLORREF darkGreen = RGB(0, 0x80, 0);
const COLORREF liteGreen = RGB(0, 0xFF, 0);
const COLORREF blueGreen = RGB(0, 0x80, 0x80);
const COLORREF liteRed = RGB(0xFF, 0xAA, 0xAA);
const COLORREF liteBlueGreen = RGB(0xAA, 0xFF, 0xC8);
const COLORREF liteBlue = RGB(0xA6, 0xCA, 0xF0);
const COLORREF veryLiteBlue = RGB(0xC4, 0xF9, 0xFD);
const COLORREF extremeLiteBlue = RGB(0xF2, 0xF4, 0xFF);
const COLORREF darkBlue = RGB(0, 0, 0x80);
const COLORREF blue = RGB(0, 0, 0xFF);
const COLORREF black = RGB(0, 0, 0);
const COLORREF white = RGB(0xFF, 0xFF, 0xFF);
const COLORREF darkGrey = RGB(64, 64, 64);
const COLORREF grey = RGB(128, 128, 128);
const COLORREF liteGrey = RGB(192, 192, 192);
const COLORREF veryLiteGrey = RGB(224, 224, 224);
const COLORREF brown = RGB(128, 64, 0);
//const COLORREF greenBlue = RGB(192, 128, 64);
const COLORREF darkYellow = RGB(0xFF, 0xC0, 0);
const COLORREF yellow = RGB(0xFF, 0xFF, 0);
const COLORREF cyan = RGB(0, 0xFF, 0xFF);
const COLORREF orange = RGB(0xFF, 0x80, 0x00);
const COLORREF purple = RGB(0x80, 0x00, 0xFF);
const COLORREF deepPurple = RGB(0x87, 0x13, 0x97);
const COLORREF extremeLitePurple = RGB(0xF8, 0xE8, 0xFF);
const COLORREF veryLitePurple = RGB(0xE7, 0xD8, 0xE9);
const COLORREF liteBerge = RGB(0xFE, 0xFC, 0xF5);
const COLORREF berge = RGB(0xFD, 0xF8, 0xE3);
/*
#define RGB2int(color)
(((((long)color) & 0x0000FF) << 16) | ((((long)color) & 0x00FF00)) | ((((long)color) & 0xFF0000) >> 16))
*/
#endif //COLORS_H

View File

@ -0,0 +1,255 @@
/*
this file is part of notepad++
Copyright (C)2003 Don HO ( donho@altern.org )
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "columnEditor.h"
BOOL CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG :
{
switchTo(activeText);
::SendDlgItemMessage(_hSelf, IDC_COL_DEC_RADIO, BM_SETCHECK, TRUE, 0);
goToCenter();
NppParameters *pNppParam = NppParameters::getInstance();
ETDTProc enableDlgTheme = (ETDTProc)pNppParam->getEnableThemeDlgTexture();
if (enableDlgTheme)
{
enableDlgTheme(_hSelf, ETDT_ENABLETAB);
redraw();
}
return TRUE;
}
case WM_COMMAND :
{
switch (wParam)
{
case IDCANCEL : // Close
display(false);
return TRUE;
case IDOK :
{
(*_ppEditView)->execute(SCI_BEGINUNDOACTION);
const int stringSize = 1024;
TCHAR str[stringSize];
bool isTextMode = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_COL_TEXT_RADIO, BM_GETCHECK, 0, 0));
if (isTextMode)
{
::SendDlgItemMessage(_hSelf, IDC_COL_TEXT_EDIT, WM_GETTEXT, stringSize, (LPARAM)str);
display(false);
if ((*_ppEditView)->execute(SCI_SELECTIONISRECTANGLE))
{
ColumnModeInfo colInfos = (*_ppEditView)->getColumnModeSelectInfo();
(*_ppEditView)->columnReplace(colInfos, str);
(*_ppEditView)->execute(SCI_SETCURRENTPOS,colInfos[colInfos.size()-1].second);
//(*_ppEditView)->execute(SCI_SETSEL, colInfos[0].first, colInfos[colInfos.size()-1].second);
//(*_ppEditView)->execute(SCI_SETSELECTIONMODE, 1);
}
else
{
int cursorPos = (*_ppEditView)->execute(SCI_GETCURRENTPOS);
int cursorCol = (*_ppEditView)->execute(SCI_GETCOLUMN, cursorPos);
int cursorLine = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, cursorPos);
int endPos = (*_ppEditView)->execute(SCI_GETLENGTH);
int endLine = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, endPos);
int lineAllocatedLen = 1024;
TCHAR *line = new TCHAR[lineAllocatedLen];
for (int i = cursorLine ; i <= endLine ; i++)
{
int lineBegin = (*_ppEditView)->execute(SCI_POSITIONFROMLINE, i);
int lineEnd = (*_ppEditView)->execute(SCI_GETLINEENDPOSITION, i);
int lineEndCol = (*_ppEditView)->execute(SCI_GETCOLUMN, lineEnd);
int lineLen = lineEnd - lineBegin + 1;
if (lineLen > lineAllocatedLen)
{
delete [] line;
line = new TCHAR[lineLen];
}
(*_ppEditView)->getGenericText(line, lineBegin, lineEnd);
generic_string s2r(line);
if (lineEndCol < cursorCol)
{
generic_string s_space(cursorCol - lineEndCol, ' ');
s2r.append(s_space);
s2r.append(str);
}
else
{
int posAbs2Start = (*_ppEditView)->execute(SCI_FINDCOLUMN, i, cursorCol);
int posRelative2Start = posAbs2Start - lineBegin;
s2r.insert(posRelative2Start, str);
}
(*_ppEditView)->replaceTarget(s2r.c_str(), lineBegin, lineEnd);
}
delete [] line;
}
}
else
{
int initialNumber = ::GetDlgItemInt(_hSelf, IDC_COL_INITNUM_EDIT, NULL, TRUE);
int increaseNumber = ::GetDlgItemInt(_hSelf, IDC_COL_INCREASENUM_EDIT, NULL, TRUE);
UCHAR format = getFormat();
display(false);
if ((*_ppEditView)->execute(SCI_SELECTIONISRECTANGLE))
{
ColumnModeInfo colInfos = (*_ppEditView)->getColumnModeSelectInfo();
(*_ppEditView)->columnReplace(colInfos, initialNumber, increaseNumber, format);
(*_ppEditView)->execute(SCI_SETCURRENTPOS,colInfos[colInfos.size()-1].second);
}
else
{
int cursorPos = (*_ppEditView)->execute(SCI_GETCURRENTPOS);
int cursorCol = (*_ppEditView)->execute(SCI_GETCOLUMN, cursorPos);
int cursorLine = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, cursorPos);
int endPos = (*_ppEditView)->execute(SCI_GETLENGTH);
int endLine = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, endPos);
int lineAllocatedLen = 1024;
TCHAR *line = new TCHAR[lineAllocatedLen];
UCHAR f = format & MASK_FORMAT;
bool isZeroLeading = (MASK_ZERO_LEADING & format) != 0;
int base = 10;
if (f == BASE_16)
base = 16;
else if (f == BASE_08)
base = 8;
else if (f == BASE_02)
base = 2;
int nbLine = endLine - cursorLine + 1;
int endNumber = initialNumber + increaseNumber * (nbLine - 1);
int nbEnd = getNbChiffre(endNumber, base);
int nbInit = getNbChiffre(initialNumber, base);
int nb = max(nbInit, nbEnd);
for (int i = cursorLine ; i <= endLine ; i++)
{
int lineBegin = (*_ppEditView)->execute(SCI_POSITIONFROMLINE, i);
int lineEnd = (*_ppEditView)->execute(SCI_GETLINEENDPOSITION, i);
int lineEndCol = (*_ppEditView)->execute(SCI_GETCOLUMN, lineEnd);
int lineLen = lineEnd - lineBegin + 1;
if (lineLen > lineAllocatedLen)
{
delete [] line;
line = new TCHAR[lineLen];
}
(*_ppEditView)->getGenericText(line, lineBegin, lineEnd);
generic_string s2r(line);
/*
Calcule generic_string
*/
int2str(str, stringSize, initialNumber, base, nb, isZeroLeading);
initialNumber += increaseNumber;
if (lineEndCol < cursorCol)
{
generic_string s_space(cursorCol - lineEndCol, ' ');
s2r.append(s_space);
s2r.append(str);
}
else
{
int posAbs2Start = (*_ppEditView)->execute(SCI_FINDCOLUMN, i, cursorCol);
int posRelative2Start = posAbs2Start - lineBegin;
s2r.insert(posRelative2Start, str);
}
(*_ppEditView)->replaceTarget(s2r.c_str(), lineBegin, lineEnd);
}
delete [] line;
}
}
(*_ppEditView)->execute(SCI_ENDUNDOACTION);
(*_ppEditView)->getFocus();
return TRUE;
}
case IDC_COL_TEXT_RADIO :
case IDC_COL_NUM_RADIO :
{
switchTo((wParam == IDC_COL_TEXT_RADIO)? activeText : activeNumeric);
return TRUE;
}
default :
{
switch (HIWORD(wParam))
{
case EN_SETFOCUS :
case BN_SETFOCUS :
//updateLinesNumbers();
return TRUE;
default :
return TRUE;
}
break;
}
}
}
default :
return FALSE;
}
return FALSE;
}
void ColumnEditorDlg::switchTo(bool toText)
{
HWND hText = ::GetDlgItem(_hSelf, IDC_COL_TEXT_EDIT);
::EnableWindow(hText, toText);
::EnableWindow(::GetDlgItem(_hSelf, IDC_COL_TEXT_GRP_STATIC), toText);
::SendDlgItemMessage(_hSelf, IDC_COL_TEXT_RADIO, BM_SETCHECK, toText, 0);
HWND hNum = ::GetDlgItem(_hSelf, IDC_COL_INITNUM_EDIT);
::SendDlgItemMessage(_hSelf, IDC_COL_NUM_RADIO, BM_SETCHECK, !toText, 0);
::EnableWindow(::GetDlgItem(_hSelf, IDC_COL_NUM_GRP_STATIC), !toText);
::EnableWindow(::GetDlgItem(_hSelf, IDC_COL_INITNUM_STATIC), !toText);
::EnableWindow(hNum, !toText);
::EnableWindow(::GetDlgItem(_hSelf, IDC_COL_INCRNUM_STATIC), !toText);
::EnableWindow(::GetDlgItem(_hSelf, IDC_COL_INCREASENUM_EDIT), !toText);
::EnableWindow(::GetDlgItem(_hSelf, IDC_COL_FORMAT_GRP_STATIC), !toText);
::EnableWindow(::GetDlgItem(_hSelf, IDC_COL_DEC_RADIO), !toText);
::EnableWindow(::GetDlgItem(_hSelf, IDC_COL_HEX_RADIO), !toText);
::EnableWindow(::GetDlgItem(_hSelf, IDC_COL_OCT_RADIO), !toText);
::EnableWindow(::GetDlgItem(_hSelf, IDC_COL_BIN_RADIO), !toText);
::EnableWindow(::GetDlgItem(_hSelf, IDC_COL_LEADZERO_CHECK), !toText);
::SetFocus(toText?hText:hNum);
}

View File

@ -0,0 +1,83 @@
/*
this file is part of notepad++
Copyright (C)2003 Don HO ( donho@altern.org )
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef COLUMNEDITOR_H
#define COLUMNEDITOR_H
#include "columnEditor_rc.h"
#include "StaticDialog.h"
#include "ScintillaEditView.h"
const bool activeText = true;
const bool activeNumeric = false;
class ColumnEditorDlg : public StaticDialog
{
public :
ColumnEditorDlg() : StaticDialog() {};
void init(HINSTANCE hInst, HWND hPere, ScintillaEditView **ppEditView) {
Window::init(hInst, hPere);
if (!ppEditView)
throw int(9900);
_ppEditView = ppEditView;
};
virtual void create(int dialogID, bool isRTL = false) {
StaticDialog::create(dialogID, isRTL);
};
void doDialog(bool isRTL = false) {
if (!isCreated())
create(IDD_COLUMNEDIT, isRTL);
bool isTextMode = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_COL_TEXT_RADIO, BM_GETCHECK, 0, 0));
display();
::SetFocus(::GetDlgItem(_hSelf, isTextMode?IDC_COL_TEXT_EDIT:IDC_COL_INITNUM_EDIT));
};
virtual void display(bool toShow = true) const {
Window::display(toShow);
if (toShow)
::SetFocus(::GetDlgItem(_hSelf, ID_GOLINE_EDIT));
};
void switchTo(bool toText);
UCHAR getFormat() {
bool isLeadingZeros = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_COL_LEADZERO_CHECK, BM_GETCHECK, 0, 0));
UCHAR f = 0; // Dec by default
if (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_COL_HEX_RADIO, BM_GETCHECK, 0, 0))
f = 1;
else if (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_COL_OCT_RADIO, BM_GETCHECK, 0, 0))
f = 2;
else if (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_COL_BIN_RADIO, BM_GETCHECK, 0, 0))
f = 3;
return (f | (isLeadingZeros?MASK_ZERO_LEADING:0));
};
protected :
virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
private :
ScintillaEditView **_ppEditView;
};
#endif// COLUMNEDITOR_H

View File

@ -0,0 +1,49 @@
/*
this file is part of notepad++
Copyright (C)2003 Don HO ( donho@altern.org )
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <windows.h>
#include "columnEditor_rc.h"
IDD_COLUMNEDIT DIALOGEX 26, 41, 223, 206
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_TOOLWINDOW | WS_EX_WINDOWEDGE
CAPTION "Column Editor"
FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x0
BEGIN
GROUPBOX "Text to insert",IDC_COL_TEXT_GRP_STATIC,12,10,124,54
GROUPBOX "Number to insert",IDC_COL_NUM_GRP_STATIC,12,75,204,119
CONTROL "",IDC_COL_TEXT_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP | WS_GROUP,7,10,8,9
CONTROL "",IDC_COL_NUM_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP | WS_GROUP, 7,75,8,9
EDITTEXT IDC_COL_TEXT_EDIT,25,32,97,14,ES_AUTOHSCROLL
RTEXT "Initial number :",IDC_COL_INITNUM_STATIC,15,91,76,8
EDITTEXT IDC_COL_INITNUM_EDIT,95,89,38,12,ES_NUMBER
RTEXT "Increase by :",IDC_COL_INCRNUM_STATIC,16,112,75,8
EDITTEXT IDC_COL_INCREASENUM_EDIT,95,110,38,12,ES_NUMBER
CONTROL "Leading zeros", IDC_COL_LEADZERO_CHECK,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,140,112,70,10
CONTROL "Dec",IDC_COL_DEC_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,30,148,50,10
CONTROL "Hex",IDC_COL_HEX_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,124,148,50,10
CONTROL "Oct",IDC_COL_OCT_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,30,167,50,10
CONTROL "Bin",IDC_COL_BIN_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,124,167,50,10
GROUPBOX "Format",IDC_COL_FORMAT_GRP_STATIC,20,132,188,54,BS_CENTER
DEFPUSHBUTTON "OK",IDOK,145,13,70,14,BS_NOTIFY
PUSHBUTTON "Cancel",IDCANCEL,145,36,70,14,BS_NOTIFY
END

View File

@ -0,0 +1,39 @@
/*
this file is part of notepad++
Copyright (C)2003 Don HO ( donho@altern.org )
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef COLUMNEDITOR_RC_H
#define COLUMNEDITOR_RC_H
#define IDD_COLUMNEDIT 2020
#define IDC_COL_INITNUM_EDIT (IDD_COLUMNEDIT + 1)
#define IDC_COL_INCREASENUM_EDIT (IDD_COLUMNEDIT + 2)
#define IDC_COL_TEXT_GRP_STATIC (IDD_COLUMNEDIT + 3)
#define IDC_COL_DEC_RADIO (IDD_COLUMNEDIT + 4)
#define IDC_COL_OCT_RADIO (IDD_COLUMNEDIT + 5)
#define IDC_COL_HEX_RADIO (IDD_COLUMNEDIT + 6)
#define IDC_COL_BIN_RADIO (IDD_COLUMNEDIT + 7)
#define IDC_COL_TEXT_RADIO (IDD_COLUMNEDIT + 8)
#define IDC_COL_NUM_RADIO (IDD_COLUMNEDIT + 9)
#define IDC_COL_INITNUM_STATIC (IDD_COLUMNEDIT + 10)
#define IDC_COL_INCRNUM_STATIC (IDD_COLUMNEDIT + 11)
#define IDC_COL_FORMAT_GRP_STATIC (IDD_COLUMNEDIT + 12)
#define IDC_COL_NUM_GRP_STATIC (IDD_COLUMNEDIT + 13)
#define IDC_COL_TEXT_EDIT (IDD_COLUMNEDIT + 14)
#define IDC_COL_LEADZERO_CHECK (IDD_COLUMNEDIT + 15)
#endif// COLUMNEDITOR_RC_H

View File

@ -0,0 +1,492 @@
//this file is part of notepad++
//Copyright (C)2003 Don HO <donho@altern.org>
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "xmlMatchedTagsHighlighter.h"
#include "ScintillaEditView.h"
int XmlMatchedTagsHighlighter::getFirstTokenPosFrom(int targetStart, int targetEnd, const char *token, pair<int, int> & foundPos)
{
//int start = currentPos;
//int end = (direction == DIR_LEFT)?0:_pEditView->getCurrentDocLen();
_pEditView->execute(SCI_SETTARGETSTART, targetStart);
_pEditView->execute(SCI_SETTARGETEND, targetEnd);
_pEditView->execute(SCI_SETSEARCHFLAGS, SCFIND_REGEXP|SCFIND_POSIX);
int posFind = _pEditView->execute(SCI_SEARCHINTARGET, (WPARAM)strlen(token), (LPARAM)token);
if (posFind != -1)
{
foundPos.first = _pEditView->execute(SCI_GETTARGETSTART);
foundPos.second = _pEditView->execute(SCI_GETTARGETEND);
}
return posFind;
}
TagCateg XmlMatchedTagsHighlighter::getTagCategory(XmlMatchedTagsPos & tagsPos, int curPos)
{
pair<int, int> foundPos;
int docLen = _pEditView->getCurrentDocLen();
int gtPos = getFirstTokenPosFrom(curPos, 0, ">", foundPos);
int ltPos = getFirstTokenPosFrom(curPos, 0, "<", foundPos);
if (ltPos != -1)
{
if ((gtPos != -1) && (ltPos < gtPos))
return outOfTag;
// Now we are sure about that we are inside of tag
// We'll try to determinate the tag category :
// tagOpen : <Tag>, <Tag Attr="1" >
// tagClose : </Tag>
// tagSigle : <Tag/>, <Tag Attr="0" />
int charAfterLt = _pEditView->execute(SCI_GETCHARAT, ltPos+1);
if (!charAfterLt)
return unknownPb;
if ((char)charAfterLt == ' ')
return invalidTag;
// so now we are sure we have tag sign '<'
// We'll see on the right
int gtPosOnR = getFirstTokenPosFrom(curPos, docLen, ">", foundPos);
int ltPosOnR = getFirstTokenPosFrom(curPos, docLen, "<", foundPos);
if (gtPosOnR == -1)
return invalidTag;
if ((ltPosOnR != -1) && (ltPosOnR < gtPosOnR))
return invalidTag;
if ((char)charAfterLt == '/')
{
int char2AfterLt = _pEditView->execute(SCI_GETCHARAT, ltPos+1+1);
if (!char2AfterLt)
return unknownPb;
if ((char)char2AfterLt == ' ')
return invalidTag;
tagsPos.tagCloseStart = ltPos;
tagsPos.tagCloseEnd = gtPosOnR + 1;
return tagClose;
}
else
{
// it's sure for not being a tagClose
// So we determinate if it's tagSingle or tagOpen
tagsPos.tagOpenStart = ltPos;
tagsPos.tagOpenEnd = gtPosOnR + 1;
int charBeforeLt = _pEditView->execute(SCI_GETCHARAT, gtPosOnR-1);
if ((char)charBeforeLt == '/')
return inSingleTag;
return tagOpen;
}
}
return outOfTag;
}
bool XmlMatchedTagsHighlighter::getMatchedTagPos(int searchStart, int searchEnd, const char *tag2find, const char *oppositeTag2find, vector<int> oppositeTagFound, XmlMatchedTagsPos & tagsPos)
{
const bool search2Left = false;
const bool search2Right = true;
bool direction = searchEnd > searchStart;
pair<int, int> foundPos;
int ltPosOnR = getFirstTokenPosFrom(searchStart, searchEnd, tag2find, foundPos);
if (ltPosOnR == -1)
return false;
// if the tag is found in non html zone, we skip it
const NppGUI & nppGUI = (NppParameters::getInstance())->getNppGUI();
int idStyle = _pEditView->execute(SCI_GETSTYLEAT, ltPosOnR);
if (idStyle >= SCE_HJ_START && !nppGUI._enableHiliteNonHTMLZone)
{
int start = (direction == search2Left)?foundPos.first:foundPos.second;
int end = searchEnd;
return getMatchedTagPos(start, end, tag2find, oppositeTag2find, oppositeTagFound, tagsPos);
}
TagCateg tc = outOfTag;
if (direction == search2Left)
{
tc = getTagCategory(tagsPos, ltPosOnR+2);
if (tc != tagOpen && tc != inSingleTag)
return false;
if (tc == inSingleTag)
{
int start = foundPos.first;
int end = searchEnd;
return getMatchedTagPos(start, end, tag2find, oppositeTag2find, oppositeTagFound, tagsPos);
}
}
pair<int, int> oppositeTagPos;
int s = foundPos.first;
int e = tagsPos.tagOpenEnd;
if (direction == search2Left)
{
s = foundPos.second;
e = tagsPos.tagCloseStart;
}
int ltTag = getFirstTokenPosFrom(s, e, oppositeTag2find, oppositeTagPos);
if (ltTag == -1)
{
if (direction == search2Left)
{
return true;
}
else
{
tagsPos.tagCloseStart = foundPos.first;
tagsPos.tagCloseEnd = foundPos.second;
return true;
}
}
else
{
// RegExpr is "<tagName[ >]", found tag could be a openTag or singleTag
// so we should make sure if it's a singleTag
XmlMatchedTagsPos pos;
if (direction == search2Right && getTagCategory(pos,ltTag+1) == inSingleTag)
{
while (true)
{
ltTag = getFirstTokenPosFrom(ltTag, e, oppositeTag2find, oppositeTagPos);
if (ltTag == -1)
{
tagsPos.tagCloseStart = foundPos.first;
tagsPos.tagCloseEnd = foundPos.second;
return true;
}
else
{
if (getTagCategory(pos,ltTag+1) == inSingleTag)
{
continue;
}
if (!isInList(ltTag, oppositeTagFound))
{
oppositeTagFound.push_back(ltTag);
break;
}
}
}
return getMatchedTagPos(foundPos.second, searchEnd, tag2find, oppositeTag2find, oppositeTagFound, tagsPos);
}
if (isInList(ltTag, oppositeTagFound))
{
while (true)
{
ltTag = getFirstTokenPosFrom(ltTag, e, oppositeTag2find, oppositeTagPos);
if (ltTag == -1)
{
if (direction == search2Left)
{
return true;
}
else
{
tagsPos.tagCloseStart = foundPos.first;
tagsPos.tagCloseEnd = foundPos.second;
}
return true;
}
else if (!isInList(ltTag, oppositeTagFound))
{
oppositeTagFound.push_back(ltTag);
break;
}
else
{
if (direction == search2Left)
{
XmlMatchedTagsPos tmpTagsPos;
getTagCategory(tmpTagsPos, ltTag+1);
ltTag = tmpTagsPos.tagCloseEnd;
}
}
}
}
else
{
oppositeTagFound.push_back(ltTag);
}
}
int start, end;
if (direction == search2Left)
{
start = foundPos.first;
end = searchEnd;
}
else
{
start = foundPos.second;
end = searchEnd;
}
return getMatchedTagPos(start, end, tag2find, oppositeTag2find, oppositeTagFound, tagsPos);
}
bool XmlMatchedTagsHighlighter::getXmlMatchedTagsPos(XmlMatchedTagsPos & tagsPos)
{
// get word where caret is on
int caretPos = _pEditView->execute(SCI_GETCURRENTPOS);
// if the tag is found in non html zone, then quit
const NppGUI & nppGUI = (NppParameters::getInstance())->getNppGUI();
int idStyle = _pEditView->execute(SCI_GETSTYLEAT, caretPos);
if (!nppGUI._enableHiliteNonHTMLZone && idStyle >= SCE_HJ_START)
return false;
int docLen = _pEditView->getCurrentDocLen();
// determinate the nature of current word : tagOpen, tagClose or outOfTag
TagCateg tagCateg = getTagCategory(tagsPos, caretPos);
static const char tagNameChars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_:";
switch (tagCateg)
{
case tagOpen : // if tagOpen search right
{
_pEditView->execute(SCI_SETWORDCHARS, 0, (LPARAM)tagNameChars);
int startPos = _pEditView->execute(SCI_WORDSTARTPOSITION, tagsPos.tagOpenStart+1, true);
int endPos = _pEditView->execute(SCI_WORDENDPOSITION, tagsPos.tagOpenStart+1, true);
tagsPos.tagNameEnd = endPos;
_pEditView->execute(SCI_SETCHARSDEFAULT);
char * tagName = new char[endPos-startPos+1];
_pEditView->getText(tagName, startPos, endPos);
basic_string<char> closeTag = "</";
closeTag += tagName;
closeTag += "[ ]*>";
basic_string<char> openTag = "<";
openTag += tagName;
openTag += "[ >]";
delete [] tagName;
vector<int> passedTagList;
return getMatchedTagPos(tagsPos.tagOpenEnd, docLen, closeTag.c_str(), openTag.c_str(), passedTagList, tagsPos);
}
case tagClose : // if tagClose search left
{
_pEditView->execute(SCI_SETWORDCHARS, 0, (LPARAM)tagNameChars);
int startPos = _pEditView->execute(SCI_WORDSTARTPOSITION, tagsPos.tagCloseStart+2, true);
int endPos = _pEditView->execute(SCI_WORDENDPOSITION, tagsPos.tagCloseStart+2, true);
_pEditView->execute(SCI_SETCHARSDEFAULT);
char * tagName = new char[endPos-startPos+1];
_pEditView->getText(tagName, startPos, endPos);
basic_string<char> openTag = "<";
openTag += tagName;
openTag += "[ >]";
basic_string<char> closeTag = "</";
closeTag += tagName;
closeTag += "[ ]*>";
delete [] tagName;
vector<int> passedTagList;
bool isFound = getMatchedTagPos(tagsPos.tagCloseStart, 0, openTag.c_str(), closeTag.c_str(), passedTagList, tagsPos);
if (isFound)
tagsPos.tagNameEnd = tagsPos.tagOpenStart + 1 + (endPos - startPos);
return isFound;
}
case inSingleTag : // if in single tag
{
_pEditView->execute(SCI_SETWORDCHARS, 0, (LPARAM)tagNameChars);
int endPos = _pEditView->execute(SCI_WORDENDPOSITION, tagsPos.tagOpenStart+1, true);
tagsPos.tagNameEnd = endPos;
_pEditView->execute(SCI_SETCHARSDEFAULT);
tagsPos.tagCloseStart = -1;
tagsPos.tagCloseEnd = -1;
return true;
}
default: // if outOfTag, just quit
return false;
}
return false;
}
vector< pair<int, int> > XmlMatchedTagsHighlighter::getAttributesPos(int start, int end)
{
vector< pair<int, int> > attributes;
int bufLen = end - start + 1;
char *buf = new char[bufLen+1];
_pEditView->getText(buf, start, end);
enum {\
attr_invalid,\
attr_key,\
attr_pre_assign,\
attr_assign,\
attr_string,\
attr_value,\
attr_valid\
} state = attr_invalid;
int startPos = -1;
int oneMoreChar = 1;
int i = 0;
for (; i < bufLen ; i++)
{
switch (buf[i])
{
case ' ':
case '\t':
case '\n':
case '\r':
{
if (state == attr_key)
state = attr_pre_assign;
else if (state == attr_value)
{
state = attr_valid;
oneMoreChar = 0;
}
}
break;
case '=':
{
if (state == attr_key || state == attr_pre_assign)
state = attr_assign;
else if (state == attr_assign || state == attr_value)
state = attr_invalid;
}
break;
case '"':
{
if (state == attr_string)
{
state = attr_valid;
oneMoreChar = 1;
}
else if (state == attr_key || state == attr_pre_assign || state == attr_value)
state = attr_invalid;
else if (state == attr_assign)
state = attr_string;
}
break;
default:
{
if (state == attr_invalid)
{
state = attr_key;
startPos = i;
}
else if (state == attr_pre_assign)
state = attr_invalid;
else if (state == attr_assign)
state = attr_value;
}
}
if (state == attr_valid)
{
attributes.push_back(pair<int, int>(start+startPos, start+i+oneMoreChar));
state = attr_invalid;
}
}
if (state == attr_value)
attributes.push_back(pair<int, int>(start+startPos, start+i-1));
delete [] buf;
return attributes;
}
void XmlMatchedTagsHighlighter::tagMatch(bool doHiliteAttr)
{
// Clean up all marks of previous action
_pEditView->clearIndicator(SCE_UNIVERSAL_TAGMATCH);
_pEditView->clearIndicator(SCE_UNIVERSAL_TAGATTR);
// Detect the current lang type. It works only with html and xml
LangType lang = (_pEditView->getCurrentBuffer())->getLangType();
if (lang != L_XML && lang != L_HTML && lang != L_PHP && lang != L_ASP)
return;
// Get the original targets and search options to restore after tag matching operation
int originalStartPos = _pEditView->execute(SCI_GETTARGETSTART);
int originalEndPos = _pEditView->execute(SCI_GETTARGETEND);
int originalSearchFlags = _pEditView->execute(SCI_GETSEARCHFLAGS);
// Detect if it's a xml/html tag. If yes, Colour it!
XmlMatchedTagsPos xmlTags;
if (getXmlMatchedTagsPos(xmlTags))
{
_pEditView->execute(SCI_SETINDICATORCURRENT, SCE_UNIVERSAL_TAGMATCH);
int openTagTailLen = 2;
// We colourise the close tag firstly
if ((xmlTags.tagCloseStart != -1) && (xmlTags.tagCloseEnd != -1))
{
_pEditView->execute(SCI_INDICATORFILLRANGE, xmlTags.tagCloseStart, xmlTags.tagCloseEnd - xmlTags.tagCloseStart);
// tag close is present, so it's not single tag
openTagTailLen = 1;
}
// Now the open tag and its attributs
_pEditView->execute(SCI_INDICATORFILLRANGE, xmlTags.tagOpenStart, xmlTags.tagNameEnd - xmlTags.tagOpenStart);
_pEditView->execute(SCI_INDICATORFILLRANGE, xmlTags.tagOpenEnd - openTagTailLen, openTagTailLen);
if (doHiliteAttr)
{
vector< pair<int, int> > attributes = getAttributesPos(xmlTags.tagNameEnd, xmlTags.tagOpenEnd - openTagTailLen);
_pEditView->execute(SCI_SETINDICATORCURRENT, SCE_UNIVERSAL_TAGATTR);
for (size_t i = 0 ; i < attributes.size() ; i++)
{
_pEditView->execute(SCI_INDICATORFILLRANGE, attributes[i].first, attributes[i].second - attributes[i].first);
}
}
}
// restore the original targets and search options to avoid the conflit with search/replace function
_pEditView->execute(SCI_SETTARGETSTART, originalStartPos);
_pEditView->execute(SCI_SETTARGETEND, originalEndPos);
_pEditView->execute(SCI_SETSEARCHFLAGS, originalSearchFlags);
}

View File

@ -0,0 +1,61 @@
//this file is part of notepad++
//Copyright (C)2003 Don HO <donho@altern.org>
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#ifndef XMLMATCHEDTAGSHIGHLIGHTER_H
#define XMLMATCHEDTAGSHIGHLIGHTER_H
#include <vector>
#include <windows.h>
using namespace std;
class ScintillaEditView;
enum TagCateg {tagOpen, tagClose, inSingleTag, outOfTag, invalidTag, unknownPb};
class XmlMatchedTagsHighlighter {
public:
XmlMatchedTagsHighlighter(ScintillaEditView *pEditView):_pEditView(pEditView){};
void tagMatch(bool doHiliteAttr);
private:
struct XmlMatchedTagsPos {
int tagOpenStart;
int tagNameEnd;
int tagOpenEnd;
int tagCloseStart;
int tagCloseEnd;
};
ScintillaEditView *_pEditView;
int getFirstTokenPosFrom(int targetStart, int targetEnd, const char *token, std::pair<int, int> & foundPos);
TagCateg getTagCategory(XmlMatchedTagsPos & tagsPos, int curPos);
bool getMatchedTagPos(int searchStart, int searchEnd, const char *tag2find, const char *oppositeTag2find, vector<int> oppositeTagFound, XmlMatchedTagsPos & tagsPos);
bool getXmlMatchedTagsPos(XmlMatchedTagsPos & tagsPos);
vector< pair<int, int> > getAttributesPos(int start, int end);
bool isInList(int element, vector<int> elementList) {
for (size_t i = 0 ; i < elementList.size() ; i++)
if (element == elementList[i])
return true;
return false;
};
};
#endif //XMLMATCHEDTAGSHIGHLIGHTER_H

View File

@ -0,0 +1,35 @@
//this file is part of notepad++
//Copyright (C)2003 Don HO ( donho@altern.org )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#ifndef STATIC_CONTROL_H
#define STATIC_CONTROL_H
#include "Window.h"
class StaticControl : public Window
{
public :
StaticControl() : Window() {};
~StaticControl(){};
void init(HINSTANCE hInst, HWND parent, int ctrlID) {
Window::init(hInst, parent);
//_hSelf = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_LUNA_DIALOG), NULL, cryptoGUI_dlgProc);
};
}
#endif //STATIC_CONTROL_H

View File

@ -0,0 +1,303 @@
/*
www.sourceforge.net/projects/tinyxml
Original file by Yves Berquin.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product documentation
would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#include "tinyxmlA.h"
#ifndef TIXMLA_USE_STL
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "tinystrA.h"
// TiXmlStringA constructor, based on a C string
TiXmlStringA::TiXmlStringA (const char* instring)
{
unsigned newlen;
char * newstring;
if (!instring)
{
allocated = 0;
cstring = NULL;
current_length = 0;
return;
}
newlen = strlen (instring) + 1;
newstring = new char [newlen];
memcpy (newstring, instring, newlen);
// strcpy (newstring, instring);
allocated = newlen;
cstring = newstring;
current_length = newlen - 1;
}
// TiXmlStringA copy constructor
TiXmlStringA::TiXmlStringA (const TiXmlStringA& copy)
{
unsigned newlen;
char * newstring;
// Prevent copy to self!
if ( &copy == this )
return;
if (! copy . allocated)
{
allocated = 0;
cstring = NULL;
current_length = 0;
return;
}
newlen = copy . length () + 1;
newstring = new char [newlen];
// strcpy (newstring, copy . cstring);
memcpy (newstring, copy . cstring, newlen);
allocated = newlen;
cstring = newstring;
current_length = newlen - 1;
}
// TiXmlStringA = operator. Safe when assign own content
void TiXmlStringA ::operator = (const char * content)
{
unsigned newlen;
char * newstring;
if (! content)
{
empty_it ();
return;
}
newlen = strlen (content) + 1;
newstring = new char [newlen];
// strcpy (newstring, content);
memcpy (newstring, content, newlen);
empty_it ();
allocated = newlen;
cstring = newstring;
current_length = newlen - 1;
}
// = operator. Safe when assign own content
void TiXmlStringA ::operator = (const TiXmlStringA & copy)
{
unsigned newlen;
char * newstring;
if (! copy . length ())
{
empty_it ();
return;
}
newlen = copy . length () + 1;
newstring = new char [newlen];
// strcpy (newstring, copy . c_str ());
memcpy (newstring, copy . c_str (), newlen);
empty_it ();
allocated = newlen;
cstring = newstring;
current_length = newlen - 1;
}
//// Checks if a TiXmlStringA contains only whitespace (same rules as isspace)
//bool TiXmlStringA::isblank () const
//{
// char * lookup;
// for (lookup = cstring; * lookup; lookup++)
// if (! isspace (* lookup))
// return false;
// return true;
//}
// append a const char * to an existing TiXmlStringA
void TiXmlStringA::append( const char* str, int len )
{
char * new_string;
unsigned new_alloc, new_size, size_suffix;
size_suffix = strlen (str);
if (len < (int) size_suffix)
size_suffix = len;
if (! size_suffix)
return;
new_size = length () + size_suffix + 1;
// check if we need to expand
if (new_size > allocated)
{
// compute new size
new_alloc = assign_new_size (new_size);
// allocate new buffer
new_string = new char [new_alloc];
new_string [0] = 0;
// copy the previous allocated buffer into this one
if (allocated && cstring)
// strcpy (new_string, cstring);
memcpy (new_string, cstring, length ());
// append the suffix. It does exist, otherwize we wouldn't be expanding
// strncat (new_string, str, len);
memcpy (new_string + length (),
str,
size_suffix);
// return previsously allocated buffer if any
if (allocated && cstring)
delete [] cstring;
// update member variables
cstring = new_string;
allocated = new_alloc;
}
else
{
// we know we can safely append the new string
// strncat (cstring, str, len);
memcpy (cstring + length (),
str,
size_suffix);
}
current_length = new_size - 1;
cstring [current_length] = 0;
}
// append a const char * to an existing TiXmlStringA
void TiXmlStringA::append( const char * suffix )
{
char * new_string;
unsigned new_alloc, new_size;
new_size = length () + strlen (suffix) + 1;
// check if we need to expand
if (new_size > allocated)
{
// compute new size
new_alloc = assign_new_size (new_size);
// allocate new buffer
new_string = new char [new_alloc];
new_string [0] = 0;
// copy the previous allocated buffer into this one
if (allocated && cstring)
memcpy (new_string, cstring, 1 + length ());
// strcpy (new_string, cstring);
// append the suffix. It does exist, otherwize we wouldn't be expanding
// strcat (new_string, suffix);
memcpy (new_string + length (),
suffix,
strlen (suffix) + 1);
// return previsously allocated buffer if any
if (allocated && cstring)
delete [] cstring;
// update member variables
cstring = new_string;
allocated = new_alloc;
}
else
{
// we know we can safely append the new string
// strcat (cstring, suffix);
memcpy (cstring + length (),
suffix,
strlen (suffix) + 1);
}
current_length = new_size - 1;
}
// Check for TiXmlStringA equuivalence
//bool TiXmlStringA::operator == (const TiXmlStringA & compare) const
//{
// return (! strcmp (c_str (), compare . c_str ()));
//}
//unsigned TiXmlStringA::length () const
//{
// if (allocated)
// // return strlen (cstring);
// return current_length;
// return 0;
//}
unsigned TiXmlStringA::find (char tofind, unsigned offset) const
{
char * lookup;
if (offset >= length ())
return (unsigned) notfound;
for (lookup = cstring + offset; * lookup; lookup++)
if (* lookup == tofind)
return lookup - cstring;
return (unsigned) notfound;
}
bool TiXmlStringA::operator == (const TiXmlStringA & compare) const
{
if ( allocated && compare.allocated )
{
assert( cstring );
assert( compare.cstring );
return ( strcmp( cstring, compare.cstring ) == 0 );
}
return false;
}
bool TiXmlStringA::operator < (const TiXmlStringA & compare) const
{
if ( allocated && compare.allocated )
{
assert( cstring );
assert( compare.cstring );
return ( strcmp( cstring, compare.cstring ) > 0 );
}
return false;
}
bool TiXmlStringA::operator > (const TiXmlStringA & compare) const
{
if ( allocated && compare.allocated )
{
assert( cstring );
assert( compare.cstring );
return ( strcmp( cstring, compare.cstring ) < 0 );
}
return false;
}
#endif // TIXMLA_USE_STL

View File

@ -0,0 +1,236 @@
/*
www.sourceforge.net/projects/tinyxml
Original file by Yves Berquin.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product documentation
would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#include "tinyxmlA.h"
#ifndef TIXMLA_USE_STL
#ifndef _INCLUDED
#define TIXMLA_STRING_INCLUDED
#pragma warning( disable : 4514 )
#include <assert.h>
/*
TiXmlStringA is an emulation of the std::string template.
Its purpose is to allow compiling TinyXML on compilers with no or poor STL support.
Only the member functions relevant to the TinyXML project have been implemented.
The buffer allocation is made by a simplistic power of 2 like mechanism : if we increase
a string and there's no more room, we allocate a buffer twice as big as we need.
*/
class TiXmlStringA
{
public :
// TiXmlStringA constructor, based on a string
TiXmlStringA (const char * instring);
// TiXmlStringA empty constructor
TiXmlStringA ()
{
allocated = 0;
cstring = NULL;
current_length = 0;
}
// TiXmlStringA copy constructor
TiXmlStringA (const TiXmlStringA& copy);
// TiXmlStringA destructor
~ TiXmlStringA ()
{
empty_it ();
}
// Convert a TiXmlStringA into a classical char *
const char * c_str () const
{
if (allocated)
return cstring;
return "";
}
// Return the length of a TiXmlStringA
unsigned length () const
{
return ( allocated ) ? current_length : 0;
}
// TiXmlStringA = operator
void operator = (const char * content);
// = operator
void operator = (const TiXmlStringA & copy);
// += operator. Maps to append
TiXmlStringA& operator += (const char * suffix)
{
append (suffix);
return *this;
}
// += operator. Maps to append
TiXmlStringA& operator += (char single)
{
append (single);
return *this;
}
// += operator. Maps to append
TiXmlStringA& operator += (TiXmlStringA & suffix)
{
append (suffix);
return *this;
}
bool operator == (const TiXmlStringA & compare) const;
bool operator < (const TiXmlStringA & compare) const;
bool operator > (const TiXmlStringA & compare) const;
// Checks if a TiXmlStringA is empty
bool empty () const
{
return length () ? false : true;
}
// Checks if a TiXmlStringA contains only whitespace (same rules as isspace)
// Not actually used in tinyxml. Conflicts with a C macro, "isblank",
// which is a problem. Commenting out. -lee
// bool isblank () const;
// single char extraction
const char& at (unsigned index) const
{
assert( index < length ());
return cstring [index];
}
// find a char in a string. Return TiXmlStringA::notfound if not found
unsigned find (char lookup) const
{
return find (lookup, 0);
}
// find a char in a string from an offset. Return TiXmlStringA::notfound if not found
unsigned find (char tofind, unsigned offset) const;
/* Function to reserve a big amount of data when we know we'll need it. Be aware that this
function clears the content of the TiXmlStringA if any exists.
*/
void reserve (unsigned size)
{
empty_it ();
if (size)
{
allocated = size;
TIXMLA_STRING cstring = new char [size];
cstring [0] = 0;
current_length = 0;
}
}
// [] operator
char& operator [] (unsigned index) const
{
assert( index < length ());
return cstring [index];
}
// Error value for find primitive
enum { notfound = 0xffffffff,
npos = notfound };
void append (const char *str, int len );
protected :
// The base string
char * cstring;
// Number of chars allocated
unsigned allocated;
// Current string size
unsigned current_length;
// New size computation. It is simplistic right now : it returns twice the amount
// we need
unsigned assign_new_size (unsigned minimum_to_allocate)
{
return minimum_to_allocate * 2;
}
// Internal function that clears the content of a TiXmlStringA
void empty_it ()
{
if (cstring)
delete [] cstring;
cstring = NULL;
allocated = 0;
current_length = 0;
}
void append (const char *suffix );
// append function for another TiXmlStringA
void append (const TiXmlStringA & suffix)
{
append (suffix . c_str ());
}
// append for a single char. This could be improved a lot if needed
void append (char single)
{
char smallstr [2];
smallstr [0] = single;
smallstr [1] = 0;
append (smallstr);
}
} ;
/*
TiXmlOutStreamA is an emulation of std::ostream. It is based on TiXmlStringA.
Only the operators that we need for TinyXML have been developped.
*/
class TiXmlOutStreamA : public TiXmlStringA
{
public :
TiXmlOutStreamA () : TiXmlStringA () {}
// TiXmlOutStreamA << operator. Maps to TiXmlStringA::append
TiXmlOutStreamA & operator << (const char * in)
{
append (in);
return (* this);
}
// TiXmlOutStreamA << operator. Maps to TiXmlStringA::append
TiXmlOutStreamA & operator << (const TiXmlStringA & in)
{
append (in . c_str ());
return (* this);
}
} ;
#endif // TIXMLA_STRING_INCLUDED
#endif // TIXMLA_USE_STL

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,50 @@
/*
www.sourceforge.net/projects/tinyxml
Original code (2.0 and earlier )copyright (c) 2000-2002 Lee Thomason (www.grinninglizard.com)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product documentation
would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#include "tinyxmlA.h"
// The goal of the seperate error file is to make the first
// step towards localization. tinyxml (currently) only supports
// latin-1, but at least the error messages could now be translated.
//
// It also cleans up the code a bit.
//
const char* TiXmlBaseA::errorString[ TIXMLA_ERROR_STRING_COUNT ] =
{
"No error",
"Error",
"Failed to open file",
"Memory allocation failed.",
"Error parsing Element.",
"Failed to read Element name",
"Error reading Element value.",
"Error reading Attributes.",
"Error: empty tag.",
"Error reading end tag.",
"Error parsing Unknown.",
"Error parsing Comment.",
"Error parsing Declaration.",
"Error document empty."
};

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,303 @@
/*
www.sourceforge.net/projects/tinyxml
Original file by Yves Berquin.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product documentation
would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#include "tinyxml.h"
#ifndef TIXML_USE_STL
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "tinystr.h"
// TiXmlString constructor, based on a C generic_string
TiXmlString::TiXmlString (const TCHAR* instring)
{
unsigned newlen;
TCHAR * newstring;
if (!instring)
{
allocated = 0;
cstring = NULL;
current_length = 0;
return;
}
newlen = lstrlen (instring) + 1;
newstring = new TCHAR [newlen];
memcpy (newstring, instring, newlen);
// lstrcpy (newstring, instring);
allocated = newlen;
cstring = newstring;
current_length = newlen - 1;
}
// TiXmlString copy constructor
TiXmlString::TiXmlString (const TiXmlString& copy)
{
unsigned newlen;
TCHAR * newstring;
// Prevent copy to self!
if ( &copy == this )
return;
if (! copy . allocated)
{
allocated = 0;
cstring = NULL;
current_length = 0;
return;
}
newlen = copy . length () + 1;
newstring = new TCHAR [newlen];
// lstrcpy (newstring, copy . cstring);
memcpy (newstring, copy . cstring, newlen);
allocated = newlen;
cstring = newstring;
current_length = newlen - 1;
}
// TiXmlString = operator. Safe when assign own content
void TiXmlString ::operator = (const TCHAR * content)
{
unsigned newlen;
TCHAR * newstring;
if (! content)
{
empty_it ();
return;
}
newlen = lstrlen (content) + 1;
newstring = new TCHAR [newlen];
// lstrcpy (newstring, content);
memcpy (newstring, content, newlen);
empty_it ();
allocated = newlen;
cstring = newstring;
current_length = newlen - 1;
}
// = operator. Safe when assign own content
void TiXmlString ::operator = (const TiXmlString & copy)
{
unsigned newlen;
TCHAR * newstring;
if (! copy . length ())
{
empty_it ();
return;
}
newlen = copy . length () + 1;
newstring = new TCHAR [newlen];
// lstrcpy (newstring, copy . c_str ());
memcpy (newstring, copy . c_str (), newlen);
empty_it ();
allocated = newlen;
cstring = newstring;
current_length = newlen - 1;
}
//// Checks if a TiXmlString contains only whitespace (same rules as isspace)
//bool TiXmlString::isblank () const
//{
// TCHAR * lookup;
// for (lookup = cstring; * lookup; lookup++)
// if (! isspace (* lookup))
// return false;
// return true;
//}
// append a const TCHAR * to an existing TiXmlString
void TiXmlString::append( const TCHAR* str, int len )
{
TCHAR * new_string;
unsigned new_alloc, new_size, size_suffix;
size_suffix = lstrlen (str);
if (len < (int) size_suffix)
size_suffix = len;
if (! size_suffix)
return;
new_size = length () + size_suffix + 1;
// check if we need to expand
if (new_size > allocated)
{
// compute new size
new_alloc = assign_new_size (new_size);
// allocate new buffer
new_string = new TCHAR [new_alloc];
new_string [0] = 0;
// copy the previous allocated buffer into this one
if (allocated && cstring)
// lstrcpy (new_string, cstring);
memcpy (new_string, cstring, length ());
// append the suffix. It does exist, otherwize we wouldn't be expanding
// strncat (new_string, str, len);
memcpy (new_string + length (),
str,
size_suffix);
// return previsously allocated buffer if any
if (allocated && cstring)
delete [] cstring;
// update member variables
cstring = new_string;
allocated = new_alloc;
}
else
{
// we know we can safely append the new generic_string
// strncat (cstring, str, len);
memcpy (cstring + length (),
str,
size_suffix);
}
current_length = new_size - 1;
cstring [current_length] = 0;
}
// append a const TCHAR * to an existing TiXmlString
void TiXmlString::append( const TCHAR * suffix )
{
TCHAR * new_string;
unsigned new_alloc, new_size;
new_size = length () + lstrlen (suffix) + 1;
// check if we need to expand
if (new_size > allocated)
{
// compute new size
new_alloc = assign_new_size (new_size);
// allocate new buffer
new_string = new TCHAR [new_alloc];
new_string [0] = 0;
// copy the previous allocated buffer into this one
if (allocated && cstring)
memcpy (new_string, cstring, 1 + length ());
// lstrcpy (new_string, cstring);
// append the suffix. It does exist, otherwize we wouldn't be expanding
// lstrcat (new_string, suffix);
memcpy (new_string + length (),
suffix,
lstrlen (suffix) + 1);
// return previsously allocated buffer if any
if (allocated && cstring)
delete [] cstring;
// update member variables
cstring = new_string;
allocated = new_alloc;
}
else
{
// we know we can safely append the new generic_string
// lstrcat (cstring, suffix);
memcpy (cstring + length (),
suffix,
lstrlen (suffix) + 1);
}
current_length = new_size - 1;
}
// Check for TiXmlString equuivalence
//bool TiXmlString::operator == (const TiXmlString & compare) const
//{
// return (! lstrcmp (c_str (), compare . c_str ()));
//}
//unsigned TiXmlString::length () const
//{
// if (allocated)
// // return lstrlen (cstring);
// return current_length;
// return 0;
//}
unsigned TiXmlString::find (TCHAR tofind, unsigned offset) const
{
TCHAR * lookup;
if (offset >= length ())
return (unsigned) notfound;
for (lookup = cstring + offset; * lookup; lookup++)
if (* lookup == tofind)
return lookup - cstring;
return (unsigned) notfound;
}
bool TiXmlString::operator == (const TiXmlString & compare) const
{
if ( allocated && compare.allocated )
{
assert( cstring );
assert( compare.cstring );
return ( lstrcmp( cstring, compare.cstring ) == 0 );
}
return false;
}
bool TiXmlString::operator < (const TiXmlString & compare) const
{
if ( allocated && compare.allocated )
{
assert( cstring );
assert( compare.cstring );
return ( lstrcmp( cstring, compare.cstring ) > 0 );
}
return false;
}
bool TiXmlString::operator > (const TiXmlString & compare) const
{
if ( allocated && compare.allocated )
{
assert( cstring );
assert( compare.cstring );
return ( lstrcmp( cstring, compare.cstring ) < 0 );
}
return false;
}
#endif // TIXML_USE_STL

View File

@ -0,0 +1,237 @@
/*
www.sourceforge.net/projects/tinyxml
Original file by Yves Berquin.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product documentation
would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#include "tinyxml.h"
#ifndef TIXML_USE_STL
#ifndef TIXML_STRING_INCLUDED
#define TIXML_STRING_INCLUDED
#pragma warning( disable : 4514 )
#include <assert.h>
#include <windows.h>
/*
TiXmlString is an emulation of the std::generic_string template.
Its purpose is to allow compiling TinyXML on compilers with no or poor STL support.
Only the member functions relevant to the TinyXML project have been implemented.
The buffer allocation is made by a simplistic power of 2 like mechanism : if we increase
a generic_string and there's no more room, we allocate a buffer twice as big as we need.
*/
class TiXmlString
{
public :
// TiXmlString constructor, based on a generic_string
TiXmlString (const TCHAR * instring);
// TiXmlString empty constructor
TiXmlString ()
{
allocated = 0;
cstring = NULL;
current_length = 0;
}
// TiXmlString copy constructor
TiXmlString (const TiXmlString& copy);
// TiXmlString destructor
~ TiXmlString ()
{
empty_it ();
}
// Convert a TiXmlString into a classical TCHAR *
const TCHAR * c_str () const
{
if (allocated)
return cstring;
return TEXT("");
}
// Return the length of a TiXmlString
unsigned length () const
{
return ( allocated ) ? current_length : 0;
}
// TiXmlString = operator
void operator = (const TCHAR * content);
// = operator
void operator = (const TiXmlString & copy);
// += operator. Maps to append
TiXmlString& operator += (const TCHAR * suffix)
{
append (suffix);
return *this;
}
// += operator. Maps to append
TiXmlString& operator += (TCHAR single)
{
append (single);
return *this;
}
// += operator. Maps to append
TiXmlString& operator += (TiXmlString & suffix)
{
append (suffix);
return *this;
}
bool operator == (const TiXmlString & compare) const;
bool operator < (const TiXmlString & compare) const;
bool operator > (const TiXmlString & compare) const;
// Checks if a TiXmlString is empty
bool empty () const
{
return length () ? false : true;
}
// Checks if a TiXmlString contains only whitespace (same rules as isspace)
// Not actually used in tinyxml. Conflicts with a C macro, TEXT("isblank"),
// which is a problem. Commenting out. -lee
// bool isblank () const;
// single TCHAR extraction
const TCHAR& at (unsigned index) const
{
assert( index < length ());
return cstring [index];
}
// find a TCHAR in a generic_string. Return TiXmlString::notfound if not found
unsigned find (TCHAR lookup) const
{
return find (lookup, 0);
}
// find a TCHAR in a generic_string from an offset. Return TiXmlString::notfound if not found
unsigned find (TCHAR tofind, unsigned offset) const;
/* Function to reserve a big amount of data when we know we'll need it. Be aware that this
function clears the content of the TiXmlString if any exists.
*/
void reserve (unsigned size)
{
empty_it ();
if (size)
{
allocated = size;
cstring = new TCHAR [size];
cstring [0] = 0;
current_length = 0;
}
}
// [] operator
TCHAR& operator [] (unsigned index) const
{
assert( index < length ());
return cstring [index];
}
// Error value for find primitive
enum { notfound = 0xffffffff,
npos = notfound };
void append (const TCHAR *str, int len );
protected :
// The base generic_string
TCHAR * cstring;
// Number of chars allocated
unsigned allocated;
// Current generic_string size
unsigned current_length;
// New size computation. It is simplistic right now : it returns twice the amount
// we need
unsigned assign_new_size (unsigned minimum_to_allocate)
{
return minimum_to_allocate * 2;
}
// Internal function that clears the content of a TiXmlString
void empty_it ()
{
if (cstring)
delete [] cstring;
cstring = NULL;
allocated = 0;
current_length = 0;
}
void append (const TCHAR *suffix );
// append function for another TiXmlString
void append (const TiXmlString & suffix)
{
append (suffix . c_str ());
}
// append for a single TCHAR. This could be improved a lot if needed
void append (TCHAR single)
{
TCHAR smallstr [2];
smallstr [0] = single;
smallstr [1] = 0;
append (smallstr);
}
} ;
/*
TiXmlOutStream is an emulation of std::ostream. It is based on TiXmlString.
Only the operators that we need for TinyXML have been developped.
*/
class TiXmlOutStream : public TiXmlString
{
public :
TiXmlOutStream () : TiXmlString () {}
// TiXmlOutStream << operator. Maps to TiXmlString::append
TiXmlOutStream & operator << (const TCHAR * in)
{
append (in);
return (* this);
}
// TiXmlOutStream << operator. Maps to TiXmlString::append
TiXmlOutStream & operator << (const TiXmlString & in)
{
append (in . c_str ());
return (* this);
}
} ;
#endif // TIXML_STRING_INCLUDED
#endif // TIXML_USE_STL

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,51 @@
/*
www.sourceforge.net/projects/tinyxml
Original code (2.0 and earlier )copyright (c) 2000-2002 Lee Thomason (www.grinninglizard.com)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product documentation
would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#include "tinyxml.h"
//#include "tchar.h"
// The goal of the seperate error file is to make the first
// step towards localization. tinyxml (currently) only supports
// latin-1, but at least the error messages could now be translated.
//
// It also cleans up the code a bit.
//
const TCHAR* TiXmlBase::errorString[ TIXML_ERROR_STRING_COUNT ] =
{
TEXT("No error"),
TEXT("Error"),
TEXT("Failed to open file"),
TEXT("Memory allocation failed."),
TEXT("Error parsing Element."),
TEXT("Failed to read Element name"),
TEXT("Error reading Element value."),
TEXT("Error reading Attributes."),
TEXT("Error: empty tag."),
TEXT("Error reading end tag."),
TEXT("Error parsing Unknown."),
TEXT("Error parsing Comment."),
TEXT("Error parsing Declaration."),
TEXT("Error document empty.")
};

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,136 @@
// Scintilla source code edit control
/** @file UniConversion.cxx
** Functions to handle UFT-8 and UCS-2 strings.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include <windows.h>
#include "UniConversion.h"
unsigned int UTF8Length(const wchar_t *uptr, unsigned int tlen) {
unsigned int len = 0;
for (unsigned int i = 0; i < tlen && uptr[i]; i++) {
unsigned int uch = uptr[i];
if (uch < 0x80)
len++;
else if (uch < 0x800)
len += 2;
else
len +=3;
}
return len;
}
void UTF8FromUCS2(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned int len) {
int k = 0;
for (unsigned int i = 0; i < tlen && uptr[i]; i++) {
unsigned int uch = uptr[i];
if (uch < 0x80) {
putf[k++] = static_cast<char>(uch);
} else if (uch < 0x800) {
putf[k++] = static_cast<char>(0xC0 | (uch >> 6));
putf[k++] = static_cast<char>(0x80 | (uch & 0x3f));
} else {
putf[k++] = static_cast<char>(0xE0 | (uch >> 12));
putf[k++] = static_cast<char>(0x80 | ((uch >> 6) & 0x3f));
putf[k++] = static_cast<char>(0x80 | (uch & 0x3f));
}
}
putf[len] = '\0';
}
unsigned int UCS2Length(const char *s, unsigned int len) {
unsigned int ulen = 0;
for (unsigned int i=0;i<len;i++) {
UCHAR ch = static_cast<UCHAR>(s[i]);
if ((ch < 0x80) || (ch > (0x80 + 0x40)))
ulen++;
}
return ulen;
}
unsigned int UCS2FromUTF8(const char *s, unsigned int len, wchar_t *tbuf, unsigned int tlen)
{
unsigned int ui=0;
const UCHAR *us = reinterpret_cast<const UCHAR *>(s);
unsigned int i=0;
while ((i<len) && (ui<tlen)) {
UCHAR ch = us[i++];
if (ch < 0x80) {
tbuf[ui] = ch;
} else if (ch < 0x80 + 0x40 + 0x20) {
tbuf[ui] = static_cast<wchar_t>((ch & 0x1F) << 6);
ch = us[i++];
tbuf[ui] = static_cast<wchar_t>(tbuf[ui] + (ch & 0x7F));
} else {
tbuf[ui] = static_cast<wchar_t>((ch & 0xF) << 12);
ch = us[i++];
tbuf[ui] = static_cast<wchar_t>(tbuf[ui] + ((ch & 0x7F) << 6));
ch = us[i++];
tbuf[ui] = static_cast<wchar_t>(tbuf[ui] + (ch & 0x7F));
}
ui++;
}
return ui;
}
unsigned int ascii_to_utf8(const char * pszASCII, unsigned int lenASCII, char * pszUTF8)
{
// length of pszUTF8 must be enough;
// its maximum is (lenASCII*3 + 1)
if (!lenASCII || !pszASCII)
{
pszUTF8[0] = 0;
return 0;
}
unsigned int lenUCS2;
unsigned int lenUTF8;
wchar_t *pszUCS2 = new wchar_t[lenASCII * 3 + 1];
if (!pszUCS2)
{
pszUTF8[0] = 0;
return 0;
}
lenUCS2 = ::MultiByteToWideChar(CP_ACP, 0, pszASCII, lenASCII, pszUCS2, lenASCII + 1);
lenUTF8 = UTF8Length(pszUCS2, lenUCS2);
// length of pszUTF8 must be >= (lenUTF8 + 1)
UTF8FromUCS2(pszUCS2, lenUCS2, pszUTF8, lenUTF8);
delete [] pszUCS2;
return lenUTF8;
}
int utf8_to_ascii(const char * pszUTF8, unsigned int lenUTF8, char * pszASCII)
{
// length of pszASCII must be enough;
// its maximum is (lenUTF8 + 1)
if (!lenUTF8 || !pszUTF8)
{
pszASCII[0] = 0;
return 0;
}
unsigned int lenUCS2;
wchar_t* pszUCS2;
pszUCS2 = new wchar_t[lenUTF8 + 1];
if (!pszUCS2)
{
pszASCII[0] = 0;
return 0;
}
lenUCS2 = UCS2FromUTF8(pszUTF8, lenUTF8, pszUCS2, lenUTF8);
pszUCS2[lenUCS2] = 0;
// length of pszASCII must be >= (lenUCS2 + 1)
int nbByte = ::WideCharToMultiByte(CP_ACP, 0, pszUCS2, lenUCS2, pszASCII, lenUCS2 + 1, NULL, NULL);
delete [] pszUCS2;
return nbByte;
}

Some files were not shown because too many files have changed in this diff Show More