Skip to content

Commit

Permalink
npp 8.4.x compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
jangko committed Jun 12, 2022
1 parent 6e56212 commit 44a5104
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if "%1"=="x64" goto nppnim64
@echo building 32 bit version
SET BASE=release\nppnim32
SET TMPPATH=%PATH%
SET PATH=e:\mingw32\mingw32\bin;f:\projects\new_nim\bin;%PATH%
SET PATH=F:\mingw32\bin;%PATH%
windres -i resource\resource.rc -F pe-i386 -o resource\resource32.o
nim c -d:release --cpu:i386 -o:%BASE%\nppnim.dll nppnim
strip %BASE%\nppnim.dll
Expand Down
22 changes: 20 additions & 2 deletions nppnim.nim
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,15 @@ const
'|', '=', '%', '&', '$', '@', '~', ':', '\x80'..'\xFF'}

const
lexer_ver {.strdefine.} = "release4"
lexer_ver {.strdefine.} = "release5"

proc Version(lex: Lexer): cint {.stdcall.} =
when lexer_ver == "original":
lvOriginal
else:
elif lexer_ver == "release4":
lvRelease4
else:
lvRelease5

proc Release(lex: Lexer) {.stdcall.} = discard
proc PropertyNames(lex: Lexer): cstring {.stdcall.} = nil
Expand Down Expand Up @@ -458,6 +460,14 @@ proc DescriptionOfStyle(lex: Lexer, style: cint): cstring {.stdcall.} =
else:
emptyString[0].unsafeAddr

proc GetName(lex: Lexer): cstring {.stdcall.} =
"npp.nim.lexer".cstring

proc GetIdentifier(lex: Lexer): cint {.stdcall.} = 0

proc PropertyGet(lex: Lexer, key: cstring): cstring {.stdcall.} =
"".cstring

proc GetLexerCount(): int {.stdcall, exportc, dynlib.} = 1

proc GetLexerName(idx: int, name: pointer, nameLen: int) {.stdcall, exportc, dynlib.} =
Expand Down Expand Up @@ -500,8 +510,16 @@ proc lexFactory(): ptr ILexer {.stdcall.} =
vTable[23] = TagsOfStyle
vTable[24] = DescriptionOfStyle

# ILexer5
vTable[25] = GetName
vTable[26] = GetIdentifier
vTable[27] = PropertyGet

lex.vTable = vTable.addr
result = lex.addr

proc GetLexerFactory(idx: int): LexerFactoryProc {.stdcall, exportc, dynlib.} =
result = lexFactory

proc CreateLexer(name: cstring): ptr ILexer {.stdcall, exportc, dynlib.} =
lexFactory()
13 changes: 8 additions & 5 deletions support.nim
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,20 @@ type
const
#IDocument version
dvOriginal* = 0
dvLineEnd* = 1
dvLineEnd* = 1
dvRelease4* = 2

#ILexer version
lvOriginal* = 0
lvOriginal* = 0
lvSubStyles* = 1
lvRelease4* = 2
lvRelease4* = 2
lvRelease5* = 3

# Nim ver 0.13.0 use const, but 0.15.0 regression
# force me to use let
let
NimKeywords* = ["addr",
NimKeywords* = [
"addr",
"and",
"as",
"asm",
Expand Down Expand Up @@ -186,7 +189,7 @@ type
WordType* = enum
WT_KEYWORD, WT_TYPE, WT_IDENT, WT_MAGIC, WT_CTYPE

VTABLE* = array[0..25, pointer]
VTABLE* = array[0..30, pointer]

IDocument* {.pure, final.} = ptr object
vTable: ptr VTABLE
Expand Down

0 comments on commit 44a5104

Please sign in to comment.