This commit is contained in:
Christian Grasser 2015-05-31 20:15:35 +02:00
commit ebd90df66c
9 changed files with 292 additions and 10 deletions

View File

@ -12,4 +12,188 @@ Your pull requests are welcome; however, they may not be accepted for various re
In short: The easier the code review is, the better the chance your pull request will get accepted.
##Coding style:
####GENERAL
* Do not use Java-like braces:
GOOD:
```c
if ()
{
// Do something
}
```
BAD:
```c
if () {
// Do something
}
```
* Use tabs instead of whitespaces (we usually set our editors to 4
whitespaces for 1 tab, but the choice is up to you)
* Always leave one space before and after binary and ternary operators
Only leave one space after semi-colons in "for" statements.
GOOD:
```c
if (10 == a && 42 == b)
```
BAD:
```c
if (a==10&&b==42)
```
GOOD:
```c
for (int i = 0; i != 10; ++i)
```
BAD:
```c
for(int i=0;i<10;++i)
```
* Keywords are not function calls.
Function names are not separated from the first parenthesis:
GOOD:
```c
foo();
myObject.foo(24);
```
BAD:
```c
foo ();
```
* Keywords are separated from the first parenthesis by one space :
GOOD:
```c
if (true)
while (true)
```
BAD:
```c
if(myCondition)
```
* Use the following indenting for "switch" statements
```c
switch (test)
{
case 1:
{
// Do something
break;
}
default:
// Do something else
} // No semi-colon here
```
* Avoid magic numbers
BAD:
```c
while (lifeTheUniverseAndEverything != 42)
lifeTheUniverseAndEverything = buildMorePowerfulComputerForTheAnswer();
```
GOOD:
```c
if (foo < I_CAN_PUSH_ON_THE_RED_BUTTON)
startThermoNuclearWar();
```
* Prefer enums for integer constants
####NAMING CONVENTIONS
* Classes (camel case) :
GOOD:
```c
class IAmAClass
{};
```
BAD:
```c
class iAmClass
{};
class I_am_class
{};
```
* methods (camel case + begins with a lower case)
method parameters (camel case + begins with a lower case)
GOOD:
```c
void myMethod(uint myVeryLongParameter);
```
* member variables
Any member variable name of class/struct should be preceded by an underscore
```c
public:
int _publicAttribute;
private:
int _pPrivateAttribute;
float _pAccount;
```
* Always prefer a variable name that describes what the variable is used for
GOOD:
```c
if (hours < 24 && minutes < 60 && seconds < 60)
```
BAD:
```c
if (a < 24 && b < 60 && c < 60)
```
####COMMENTS
* Use C++ comment line style than c comment style
GOOD:
```
// Two lines comment
// Use still C++ comment line style
```
BAD:
```
/*
Please don't piss me off with that
*/
```
####BEST PRACTICES
* Prefer this form :
```c
++i
```
to
```c
i++
```
(It does not change anything for builtin types but it would bring consistency)
* Avoid using pointers. Prefer references. You might need the variable to
be assigned a NULL value: in this case the NULL value has semantics and must
be checked. Wherever possible, use a SmartPtr instead of old-school pointers.
* Avoid using new if you can use automatic variable.
* Don't place any "using namespace" directives in headers
* Compile time is without incidence. Increasing compile time to reduce execution
time is encouraged.
* Code legibility and length is less important than easy and fast end-user experience.

View File

@ -0,0 +1,42 @@
// This file is part of Notepad++ project
// Copyright (C)2003 Don HO <don.h@free.fr>
//
// 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.
//
// Note that the GPL places important restrictions on "derived works", yet
// it does not provide a detailed definition of that term. To avoid
// misunderstandings, we consider an application to constitute a
// "derivative work" for the purpose of this license if it does any of the
// following:
// 1. Integrates source code from Notepad++.
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
// installer, such as those produced by InstallShield.
// 3. Links to a library or executes a program that does any of the above.
//
// 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 "LongRunningOperation.h"
#include <mutex>
static std::recursive_mutex _operationMutex;
LongRunningOperation::LongRunningOperation()
{
_operationMutex.lock();
}
LongRunningOperation::~LongRunningOperation()
{
_operationMutex.unlock();
}

View File

@ -0,0 +1,39 @@
// This file is part of Notepad++ project
// Copyright (C)2003 Don HO <don.h@free.fr>
//
// 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.
//
// Note that the GPL places important restrictions on "derived works", yet
// it does not provide a detailed definition of that term. To avoid
// misunderstandings, we consider an application to constitute a
// "derivative work" for the purpose of this license if it does any of the
// following:
// 1. Integrates source code from Notepad++.
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
// installer, such as those produced by InstallShield.
// 3. Links to a library or executes a program that does any of the above.
//
// 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_LONGRUNNINGOPERATION_h
#define M30_IDE_LONGRUNNINGOPERATION_h
class LongRunningOperation
{
public:
LongRunningOperation();
~LongRunningOperation();
};
#endif //M30_IDE_LONGRUNNINGOPERATION_h

View File

@ -36,6 +36,7 @@
#include "documentMap.h"
#include "functionListPanel.h"
#include "Sorters.h"
#include "LongRunningOperation.h"
void Notepad_plus::macroPlayback(Macro macro)
@ -178,16 +179,22 @@ void Notepad_plus::command(int id)
break;
case IDM_EDIT_UNDO:
{
LongRunningOperation op;
_pEditView->execute(WM_UNDO);
checkClipboard();
checkUndoState();
break;
}
case IDM_EDIT_REDO:
{
LongRunningOperation op;
_pEditView->execute(SCI_REDO);
checkClipboard();
checkUndoState();
break;
}
case IDM_EDIT_CUT:
_pEditView->execute(WM_CUT);
@ -260,6 +267,7 @@ void Notepad_plus::command(int id)
case IDM_EDIT_PASTE:
{
LongRunningOperation op;
int eolMode = int(_pEditView->execute(SCI_GETEOLMODE));
_pEditView->execute(SCI_PASTE);
_pEditView->execute(SCI_CONVERTEOLS, eolMode);
@ -268,6 +276,7 @@ void Notepad_plus::command(int id)
case IDM_EDIT_PASTE_BINARY:
{
LongRunningOperation op;
if (!IsClipboardFormatAvailable(CF_TEXT))
return;
@ -312,6 +321,7 @@ void Notepad_plus::command(int id)
case IDM_EDIT_PASTE_AS_RTF:
case IDM_EDIT_PASTE_AS_HTML:
{
LongRunningOperation op;
UINT f = RegisterClipboardFormat(id==IDM_EDIT_PASTE_AS_HTML?CF_HTML:CF_RTF);
if (!IsClipboardFormatAvailable(f))
@ -354,6 +364,8 @@ void Notepad_plus::command(int id)
case IDM_EDIT_SORTLINES_DECIMALDOT_ASCENDING:
case IDM_EDIT_SORTLINES_DECIMALDOT_DESCENDING:
{
LongRunningOperation op;
size_t fromLine = 0, toLine = 0;
size_t fromColumn = 0, toColumn = 0;

View File

@ -34,6 +34,7 @@
#include "ScintillaEditView.h"
#include "EncodingMapper.h"
#include "uchardet.h"
#include "LongRunningOperation.h"
FileManager * FileManager::_pSelf = new FileManager();
@ -60,10 +61,11 @@ Buffer::Buffer(FileManager * pManager, BufferID id, Document doc, DocFileStatus
_userLangExt = TEXT("");
_fullPathName = TEXT("");
_fileName = NULL;
_currentStatus = type;
setFileName(fileName, ndds._lang);
updateTimeStamp();
checkFileState();
_currentStatus = type;
_isDirty = false;
_needLexer = false; //new buffers do not need lexing, Scintilla takes care of that
@ -674,6 +676,8 @@ For untitled document (new 4)
*/
bool FileManager::backupCurrentBuffer()
{
LongRunningOperation op;
Buffer * buffer = _pNotepadPlus->getCurrentBuffer();
bool result = false;
bool hasModifForSession = false;

View File

@ -31,6 +31,7 @@
#include "ScintillaEditView.h"
#include "Notepad_plus_msgs.h"
#include "UniConversion.h"
#include "LongRunningOperation.h"
FindOption * FindReplaceDlg::_env;
FindOption FindReplaceDlg::_options;
@ -725,6 +726,7 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
case IDREPLACE :
{
LongRunningOperation op;
if (_currentStatus == REPLACE_DLG)
{
setStatusbarMessage(TEXT(""), FSNoMessage);
@ -811,6 +813,7 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
case IDD_FINDINFILES_REPLACEINFILES :
{
LongRunningOperation op;
setStatusbarMessage(TEXT(""), FSNoMessage);
const int filterSize = 256;
TCHAR filters[filterSize];
@ -851,6 +854,7 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
case IDC_REPLACE_OPENEDFILES :
{
LongRunningOperation op;
if (_currentStatus == REPLACE_DLG)
{
setStatusbarMessage(TEXT(""), FSNoMessage);
@ -871,6 +875,7 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
case IDREPLACEALL :
{
LongRunningOperation op;
if (_currentStatus == REPLACE_DLG)
{
setStatusbarMessage(TEXT(""), FSNoMessage);

View File

@ -217,7 +217,7 @@
<Keywords name="type3">std ieee work standard textio std_logic_1164 std_logic_arith std_logic_misc std_logic_signed std_logic_textio std_logic_unsigned numeric_bit numeric_std math_complex math_real vital_primitives vital_timing</Keywords>
<Keywords name="type4">boolean bit character severity_level integer real time delay_length natural positive string bit_vector file_open_kind file_open_status line text side width std_ulogic std_ulogic_vector std_logic std_logic_vector X01 X01Z UX01 UX01Z unsigned signed</Keywords>
</Language>
<Language name="xml" ext="xml xsml xsl xsd kml wsdl xlf xliff config targets proj csproj vbproj fsproj vcxproj nproj pyproj javaproj wixproj filters settings testsettings ruleset vsmdi" commentLine="" commentStart="&lt;!--" commentEnd="--&gt;">
<Language name="xml" ext="xml xsml xsl xslt xsd kml wsdl xlf xliff xaml config manifest targets proj csproj vbproj fsproj vcxproj nproj pyproj javaproj wixproj filters settings testsettings ruleset vsmdi svg" commentLine="" commentStart="&lt;!--" commentEnd="--&gt;">
</Language>
<Language name="yaml" ext="yml" commentLine="#">
</Language>

View File

@ -138,6 +138,7 @@ copy ..\src\contextMenu.xml ..\bin\contextMenu.xml
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\src\MISC\Common\LongRunningOperation.cpp" />
<ClCompile Include="..\src\WinControls\AboutDlg\AboutDlg.cpp" />
<ClCompile Include="..\src\WinControls\AnsiCharPanel\ansiCharPanel.cpp" />
<ClCompile Include="..\src\ScitillaComponent\AutoCompletion.cpp" />

View File

@ -59,16 +59,13 @@
<FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
<AdditionalIncludeDirectories>..\src\WinControls\AboutDlg;..\..\scintilla\include;..\include;..\src\WinControls;..\src\WinControls\ImageListSet;..\src\WinControls\OpenSaveFileDialog;..\src\WinControls\SplitterContainer;..\src\WinControls\StaticDialog;..\src\WinControls\TabBar;..\src\WinControls\ToolBar;..\src\MISC\Process;..\src\ScitillaComponent;..\src\MISC;..\src\MISC\SysMsg;..\src\WinControls\StatusBar;..\src;..\src\WinControls\StaticDialog\RunDlg;..\src\tinyxml;..\src\WinControls\ColourPicker;..\src\Win32Explr;..\src\MISC\RegExt;..\src\WinControls\TrayIcon;..\src\WinControls\shortcut;..\src\WinControls\Grid;..\src\WinControls\ContextMenu;..\src\MISC\PluginsManager;..\src\WinControls\Preference;..\src\WinControls\WindowsDlg;..\src\WinControls\TaskList;..\src\WinControls\DockingWnd;..\src\WinControls\ToolTip;..\src\MISC\Exception;..\src\MISC\Common;..\src\tinyxml\tinyXmlA;..\src\WinControls\AnsiCharPanel;..\src\WinControls\ClipboardHistory;..\src\WinControls\FindCharsInRange;..\src\WinControls\VerticalFileSwitcher;..\src\WinControls\ProjectPanel;..\src\WinControls\DocumentMap;..\src\WinControls\FunctionList;..\src\uchardet;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;_USE_64BIT_TIME_T;TIXML_USE_STL;TIXMLA_USE_STL;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_CRT_NON_CONFORMING_SWPRINTFS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<ExceptionHandling>Async</ExceptionHandling>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>Create</PrecompiledHeader>
<PrecompiledHeaderFile>precompiledHeaders.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>$(IntDir)$(TargetName).pch</PrecompiledHeaderOutputFile>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DisableSpecificWarnings>4456;4457;4459</DisableSpecificWarnings>
</ClCompile>
<Link>
@ -106,12 +103,11 @@
<ExceptionHandling>Async</ExceptionHandling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>Create</PrecompiledHeader>
<PrecompiledHeaderFile>precompiledHeaders.h</PrecompiledHeaderFile>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DisableSpecificWarnings>4456;4457;4459</DisableSpecificWarnings>
</ClCompile>
<Link>
@ -211,7 +207,6 @@ copy ..\src\contextMenu.xml ..\bin\contextMenu.xml
<ClCompile Include="..\src\uchardet\nsUTF8Prober.cpp" />
<ClCompile Include="..\src\Parameters.cpp" />
<ClCompile Include="..\src\Misc\PluginsManager\PluginsManager.cpp" />
<ClCompile Include="..\src\MISC\Common\precompiledHeaders.cpp" />
<ClCompile Include="..\src\WinControls\Preference\preferenceDlg.cpp" />
<ClCompile Include="..\src\ScitillaComponent\Printer.cpp" />
<ClCompile Include="..\src\MISC\Process\Process.cpp" />