Skip to content

Commit

Permalink
Enable Scintilla Lexer SCLEX_BAAN (BaanC Language)
Browse files Browse the repository at this point in the history
Closes #2696
  • Loading branch information
oirfeodent authored and donho committed Jan 22, 2017
1 parent 4e14e14 commit 1b12653
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 9 deletions.
2 changes: 1 addition & 1 deletion PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h
Expand Up @@ -39,7 +39,7 @@ enum LangType {L_TEXT, L_PHP , L_C, L_CPP, L_CS, L_OBJC, L_JAVA, L_RC,\
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, L_COBOL, L_GUI4CLI, L_D, L_POWERSHELL, L_R, L_JSP,\
L_COFFEESCRIPT, L_JSON, L_JAVASCRIPT, L_FORTRAN_77,\
L_COFFEESCRIPT, L_JSON, L_JAVASCRIPT, L_FORTRAN_77, L_BAANC,\
// Don't use L_JS, use L_JAVASCRIPT instead
// The end of enumated language type, so it should be always at the end
L_EXTERNAL};
Expand Down
24 changes: 17 additions & 7 deletions PowerEditor/src/Notepad_plus.cpp
Expand Up @@ -2803,6 +2803,8 @@ enum LangType Notepad_plus::menuID2LangType(int cmdID)
return L_R;
case IDM_LANG_COFFEESCRIPT :
return L_COFFEESCRIPT;
case IDM_LANG_BAANC:
return L_BAANC;

case IDM_LANG_USER :
return L_USER;
Expand Down Expand Up @@ -3932,7 +3934,9 @@ bool Notepad_plus::doBlockComment(comment_mode currCommentMode)
if (not isSingleLineAdvancedMode)
{
comment = commentLineSymbol;
comment += aSpace;

if (!(buf->getLangType() == L_BAANC)) // BaanC standardization - no space.
comment += aSpace;

comment_length = comment.length();
}
Expand Down Expand Up @@ -3961,7 +3965,9 @@ bool Notepad_plus::doBlockComment(comment_mode currCommentMode)
//--FLS: count lines which were un-commented to decide if undoStreamComment() shall be called.
int nUncomments = 0;
//Some Lexers need line-comments at the beginning of a line.
const bool avoidIndent = buf->getLangType() == L_FORTRAN_77;
const bool avoidIndent = (buf->getLangType() == L_FORTRAN_77 || buf->getLangType() == L_BAANC);
//Some Lexers comment blank lines, per their standards.
const bool commentEmptyLines = (buf->getLangType() == L_BAANC);

_pEditView->execute(SCI_BEGINUNDOACTION);

Expand All @@ -3971,14 +3977,16 @@ bool Notepad_plus::doBlockComment(comment_mode currCommentMode)
size_t lineIndent = _pEditView->execute(SCI_GETLINEINDENTPOSITION, i);
size_t lineEnd = _pEditView->execute(SCI_GETLINEENDPOSITION, i);

// empty lines are not commented
if (lineIndent == lineEnd)
// empty lines are not commented, unless required by the language.
if (lineIndent == lineEnd && !commentEmptyLines)
continue;

if (avoidIndent)
lineIndent = lineStart;

size_t linebufferSize = lineEnd - lineIndent + 2;
//size_t linebufferSize = lineEnd - lineIndent + 2;
// Replace hard coded 2 (commentLineSymbol + aSpace) to comment_length.
size_t linebufferSize = lineEnd - lineIndent + comment_length;
TCHAR* linebuf = new TCHAR[linebufferSize];

_pEditView->getGenericText(linebuf, linebufferSize, lineIndent, lineEnd);
Expand All @@ -3993,9 +4001,11 @@ bool Notepad_plus::doBlockComment(comment_mode currCommentMode)
//--FLS: In order to do get case insensitive comparison use strnicmp() instead case-sensitive comparison.
// Case insensitive comparison is needed e.g. for "REM" and "rem" in Batchfiles.
//if (linebufStr.substr(0, comment_length - 1) == comment.substr(0, comment_length - 1))
if (generic_strnicmp(linebufStr.c_str(), comment.c_str(), comment_length - 1) == 0)
//if (generic_strnicmp(linebufStr.c_str(), comment.c_str(), comment_length - 1) == 0)
if (generic_strnicmp(linebufStr.c_str(), comment.c_str(), !(buf->getLangType() == L_BAANC) ? comment_length - 1 : comment_length) == 0)
{
size_t len = linebufStr[comment_length - 1] == aSpace[0] ? comment_length : comment_length - 1;
//size_t len = linebufStr[comment_length - 1] == aSpace[0] ? comment_length : comment_length - 1;
size_t len = linebufStr[comment_length - 1] == aSpace[0] ? comment_length : !(buf->getLangType() == L_BAANC) ? comment_length - 1 : comment_length;

_pEditView->execute(SCI_SETSEL, lineIndent, lineIndent + len);
_pEditView->replaceSelWith("");
Expand Down
7 changes: 6 additions & 1 deletion PowerEditor/src/Notepad_plus.rc
Expand Up @@ -674,6 +674,7 @@ BEGIN
MENUITEM "ASP", IDM_LANG_ASP
MENUITEM "Assembly", IDM_LANG_ASM
MENUITEM "AutoIt", IDM_LANG_AU3
MENUITEM "BaanC", IDM_LANG_BAANC
MENUITEM "Batch", IDM_LANG_BATCH
MENUITEM "C", IDM_LANG_C
MENUITEM "C#", IDM_LANG_CS
Expand Down Expand Up @@ -741,7 +742,11 @@ BEGIN
MENUITEM "Assembly", IDM_LANG_ASM
MENUITEM "AutoIt", IDM_LANG_AU3
END
MENUITEM "Batch", IDM_LANG_BATCH
POPUP "B"
BEGIN
MENUITEM "BaanC", IDM_LANG_BAANC
MENUITEM "Batch", IDM_LANG_BATCH
END
POPUP "C"
BEGIN
MENUITEM "C", IDM_LANG_C
Expand Down
1 change: 1 addition & 0 deletions PowerEditor/src/NppCommands.cpp
Expand Up @@ -2782,6 +2782,7 @@ void Notepad_plus::command(int id)
case IDM_LANG_R :
case IDM_LANG_JSP :
case IDM_LANG_COFFEESCRIPT:
case IDM_LANG_BAANC:
case IDM_LANG_USER :
{
setLanguage(menuID2LangType(id));
Expand Down
3 changes: 3 additions & 0 deletions PowerEditor/src/Parameters.cpp
Expand Up @@ -5850,6 +5850,9 @@ int NppParameters::langTypeToCommandID(LangType lt) const
case L_COFFEESCRIPT :
id = IDM_LANG_COFFEESCRIPT; break;

case L_BAANC:
id = IDM_LANG_BAANC; break;

case L_SEARCHRESULT :
id = -1; break;

Expand Down
4 changes: 4 additions & 0 deletions PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp
Expand Up @@ -139,6 +139,7 @@ LanguageName ScintillaEditView::langNames[L_EXTERNAL+1] = {
{TEXT("json"), TEXT("json"), TEXT("JSON file"), L_JSON, SCLEX_CPP },
{TEXT("javascript.js"), TEXT("JavaScript"), TEXT("JavaScript file"), L_JAVASCRIPT, SCLEX_CPP },
{TEXT("fortran77"), TEXT("Fortran fixed form"), TEXT("Fortran fixed form source file"), L_FORTRAN_77, SCLEX_F77},
{TEXT("baanc"), TEXT("BaanC"), TEXT("BaanC File"), L_BAANC, SCLEX_BAAN },
{TEXT("ext"), TEXT("External"), TEXT("External"), L_EXTERNAL, SCLEX_NULL}
};

Expand Down Expand Up @@ -1507,6 +1508,9 @@ void ScintillaEditView::defineDocType(LangType typeDoc)
case L_COFFEESCRIPT :
setCoffeeScriptLexer(); break;

case L_BAANC:
setBaanCLexer(); break;

case L_TEXT :
default :
if (typeDoc >= L_EXTERNAL && typeDoc < _pParameter->L_END)
Expand Down
5 changes: 5 additions & 0 deletions PowerEditor/src/ScitillaComponent/ScintillaEditView.h
Expand Up @@ -867,6 +867,11 @@ friend class Finder;
setLexer(SCLEX_COFFEESCRIPT, L_COFFEESCRIPT, LIST_0 | LIST_1 | LIST_2 | LIST_3);
};

void setBaanCLexer() {
setLexer(SCLEX_BAAN, L_BAANC, LIST_0 | LIST_1);
execute(SCI_SETPROPERTY, reinterpret_cast<WPARAM>("styling.within.preprocessor"), reinterpret_cast<LPARAM>("1"));
};

//--------------------

void setSearchResultLexer() {
Expand Down
6 changes: 6 additions & 0 deletions PowerEditor/src/langs.model.xml
Expand Up @@ -30,6 +30,12 @@
<Keywords name="type4">#region #endregion</Keywords>
<Keywords name="type5"></Keywords>
</Language>
<Language name="baanc" ext="bc cln" commentLine="|">
<!-- name="KEYWORDS" (Do not Change) Reserved Keywords -->
<Keywords name="instre1">alike all and array as asc at avg base based between boolean both break bset buffer by call case cast chart clear clearunref common const continue count cross current_date current_timestamp date date.num date.to.num debug default delete deleteempty deleteerror desc dim distinct dll dllusage domain double else empty end endcase enddelete enddllusage endfor endfunctionusage endif endselect endupdate endwhile enum_description eq escape exists extern false fatal fetching field first fixed for from full function functionusage ge global goto group gt having hint hints if in include index inner input inrange integer is join label last le leading left like long lt max mb menu message min multibyte ne no nodebug not notransactions nowarnings null on or order ordered outer path pi prepared print prompt question raw real ref reference refers repeat retry return right row rows select selectbind selectdo selectempty selecteos selecterror session set setunref size skip static step sticky stop strict_boolean string subhint sum table text_content then timestamp to trailing trim true union unref until update updateempty updateerror use used void warning warnings when where wherebind whereused while with</Keywords>
<!-- name="FUNCTIONS" Functions (Set your Functions based on Baan version & TIV level. in Settings -> Style Configurator -> BaanC -> Functions -> User Defined Keywords) -->
<Keywords name="instre2">abort abort.io db.after.delete db.after.insert db.after.update xmlSetData zoom.to$</Keywords>
</Language>
<Language name="bash" ext="bash sh bsh csh bash_profile bashrc profile" commentLine="#">
<Keywords name="instre1">7z adduser alias apt-get ar as asa autoconf automake awk banner base64 basename bash bc bdiff blkid break bsdcpio bsdtar bunzip2 bzcmp bzdiff bzegrep bzfgrep bzgrep bzip2 bzip2recover bzless bzmore c++ cal calendar case cat cc cd cfdisk chattr chgrp chmod chown chroot chvt cksum clang clang++ clear cmp col column comm compgen compress continue convert cp cpio crontab crypt csplit ctags curl cut date dc dd deallocvt declare deluser depmod deroff df dialog diff diff3 dig dircmp dirname disown dmesg do done dpkg dpkg-deb du echo ed egrep elif else env esac eval ex exec exit expand export expr fakeroot false fc fdisk ffmpeg fgrep fi file find flex flock fmt fold for fsck function functions fuser fusermount g++ gas gawk gcc gdb genisoimage getconf getopt getopts git gpg gpgsplit gpgv grep gres groff groups gunzip gzexe hash hd head help hexdump hg history httpd iconv id if ifconfig ifdown ifquery ifup in insmod integer inxi ip jobs join kill killall killall5 lc ld ldd let lex line ln local logname look ls lsattr lsb_release lsblk lscpu lshw lslocks lsmod lsusb lzcmp lzegrep lzfgrep lzgrep lzless lzma lzmainfo lzmore m4 mail mailx make man mkdir mkfifo mkswap mktemp modinfo modprobe mogrify more mount msgfmt mt mv nameif nasm nc ndisasm netcat newgrp nl nm nohup ntps objdump od openssl p7zip pacman passwd paste patch pathchk pax pcat pcregrep pcretest perl pg ping ping6 pivot_root poweroff pr print printf ps pwd python python2 python3 ranlib read readlink readonly reboot reset return rev rm rmdir rmmod rpm rsync sed select service set sh sha1sum sha224sum sha256sum sha3sum sha512sum shift shred shuf shutdown size sleep sort spell split start stop strings strip stty su sudo sum suspend switch_root sync systemctl tac tail tar tee test then time times touch tr trap troff true tsort tty type typeset ulimit umask umount unalias uname uncompress unexpand uniq unlink unlzma unset until unzip unzipsfx useradd userdel uudecode uuencode vi vim wait wc wget whence which while who wpaste wstart xargs xdotool xxd xz xzcat xzcmp xzdiff xzfgrep xzgrep xzless xzmore yes yum zcat zcmp zdiff zegrep zfgrep zforce zgrep zless zmore znew zsh</Keywords>
</Language>
Expand Down
1 change: 1 addition & 0 deletions PowerEditor/src/menuCmdID.h
Expand Up @@ -482,6 +482,7 @@
#define IDM_LANG_COFFEESCRIPT (IDM_LANG + 56)
#define IDM_LANG_JSON (IDM_LANG + 57)
#define IDM_LANG_FORTRAN_77 (IDM_LANG + 58)
#define IDM_LANG_BAANC (IDM_LANG + 59)

#define IDM_LANG_EXTERNAL (IDM_LANG + 65)
#define IDM_LANG_EXTERNAL_LIMIT (IDM_LANG + 79)
Expand Down
12 changes: 12 additions & 0 deletions PowerEditor/src/stylers.model.xml
Expand Up @@ -77,6 +77,18 @@
<WordsStyle name="EXPAND" styleID="13" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" keywordClass="type5" />
<WordsStyle name="COMOBJ" styleID="14" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
</LexerType>
<LexerType name="baanc" desc="BaanC" ext="">
<WordsStyle name="KEYWORDS" styleID="4" fgColor="008080" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" keywordClass="instre1" />
<WordsStyle name="FUNCTIONS" styleID="10" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" keywordClass="instre2" />
<WordsStyle name="COMMENT" styleID="1" fgColor="808040" bgColor="FFFFFF" fontName="" fontStyle="3" fontSize="" />
<WordsStyle name="COMMENT DOC" styleID="2" fgColor="004000" bgColor="FCFDDB" fontName="" fontStyle="3" fontSize="" />
<WordsStyle name="NUMBER" styleID="3" fgColor="FF0000" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" />
<WordsStyle name="STRING" styleID="5" fgColor="FF0080" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" />
<WordsStyle name="PREPROCESSOR" styleID="6" fgColor="0000A0" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" />
<WordsStyle name="OPERATOR" styleID="7" fgColor="800040" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" />
<WordsStyle name="DEFAULT" styleID="8" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="STRING EOL NC" styleID="9" fgColor="000000" bgColor="E0C0E0" fontName="" fontStyle="3" fontSize="" />
</LexerType>
<LexerType name="bash" desc="bash" ext="">
<WordsStyle name="DEFAULT" styleID="0" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="ERROR" styleID="1" fgColor="FFFFFF" bgColor="FF0000" fontName="" fontStyle="0" fontSize="" />
Expand Down

0 comments on commit 1b12653

Please sign in to comment.