OnStyle callback is never called (confirmed also in the example file)
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 42/100
Rechercherichtung
Reproduziere den Callback-Ablauf mit examples/StyleCustom.lua und dem .abc-Beispieldokument, wobei du die beschriebenen print-Anweisungen verwendest. Lies src/LuaScript.cpp um Zeile 308 und verfolge, wie editor:Colourise(0, -1) mit der SCN_STYLENEEDED-Benachrichtigung zusammenhängt. Erledigt ist es, wenn OnStyle empfangen und CustomStyle aufgerufen wird, sodass das Dokument das erwartete benutzerdefinierte Styling erhält.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
CustomStyle.lua example file
--[[ An example file
proc clip(int a)
« Clip into the positive zone »
if (a > 0) a
0
end
]]
-- Define style numbers
S_DEFAULT = 0
S_IDENTIFIER = 1
S_KEYWORD = 2
S_UNICODECOMMENT = 3
-- Anytime a file is switched, check to see if it needs styled
npp.AddEventHandler("OnSwitchFile", function(filename, bufferid)
if npp:GetExtPart() == ".abc" then
-- Add the event handler for our custom style function
npp.AddEventHandler("OnStyle", CustomStyle)
-- Make sure to set the lexer as a custom container
editor.Lexer = SCLEX_CONTAINER
-- Set up the styles as appropriate
editor.StyleFore[S_DEFAULT] = 0x7f007f
editor.StyleBold[S_DEFAULT] = true
editor.StyleFore[S_IDENTIFIER] = 0x000000
editor.StyleFore[S_KEYWORD] = 0x800000
editor.StyleBold[S_KEYWORD] = true
editor.StyleFore[S_UNICODECOMMENT] = 0x008000
editor.StyleFont[S_UNICODECOMMENT] = "Georgia"
editor.StyleItalic[S_UNICODECOMMENT] = true
editor.StyleSize[S_UNICODECOMMENT] = 9
-- Clear any style and re-lex the entire document
editor:ClearDocumentStyle()
editor:Colourise(0, -1)
else
-- Can remove the handler if it's not needed
npp.RemoveEventHandler("OnStyle", CustomStyle)
end
return false
end)
-- Style the document. Handles UTF-8 characters
function CustomStyle(styler)
identifierCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
styler:StartStyling(styler.startPos, styler.lengthDoc, styler.initStyle)
while styler:More() do
-- Exit state if needed
if styler:State() == S_IDENTIFIER then
if not identifierCharacters:find(styler:Current(), 1, true) then
identifier = styler:Token()
if identifier == "if" or identifier == "end" then
styler:ChangeState(S_KEYWORD)
end
styler:SetState(S_DEFAULT)
end
elseif styler:State() == S_UNICODECOMMENT then
if styler:Match("»") then
styler:ForwardSetState(S_DEFAULT)
end
end
-- Enter state if needed
if styler:State() == S_DEFAULT then
if styler:Match("«") then
styler:SetState(S_UNICODECOMMENT)
elseif identifierCharacters:find(styler:Current(), 1, true) then
styler:SetState(S_IDENTIFIER)
end
end
styler:Forward()
end
styler:EndStyling()
end
- This source defines a function for callback
OnSwitchFile. It declares to callCustomStylefor the eventOnStyleif the file extension isabc. - My understanding is that
editor:Colourise(0, -1)should lead to invocation of callbackOnStyle. - Handling the callback
OnStyleand thus callingCustomStyleshould colorize the document as a consequence. - By adding
print()statements and opening the Lua Console, one can observe which functions are actually run.
Expected behavior:
- Callback
OnSwitchFileis handled. - Callback
OnStyleis handled.
Actual behavior:
- Callback
OnSwitchFileis handled. - Callback
OnStyleis never handled, thus the functionCustomStyleis never called.
This can be confirmed by the resulting styling. The given example document (stored with a filepath ending with .abc) leads to the following coloring:
This coloring (every foreground text color is purple) can be explained by the editor.StyleFore[S_DEFAULT] = 0x7f007f which is run and sets the default color to purple. But the actual styling function CustomStyle is not run.
Environment:
- Windows 10
- LuaScript v0.12 (64 bit). Lua 5.3.5
- Seems like the OnStyle handling should be triggered here but SCN_STYLENEEDED does not seem to be a received Scintilla notification.
- Vorherrschende Sprache
- C
- Sterne
- 130
- Forks
- 24
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus dail8859/LuaScript
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 52/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 35/100
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 20/100
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 55/100
-
Binding "tab" keyOffen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 35/100
Alle Issues in dail8859/LuaScript
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag
-
elf_loader: Xtensa ignores the addend of R_XTENSA_GLOB_DAT / R_XTENSA_JMP_SLOT (C++ vtables)Evtl. vergeben @diplfranzhoepfinger hat das heute übernommen. Offenelf_loader
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
espressif/esp-iot-solution#813 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Status: Opened Type: Bug
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
Maintainer antworten meist innerhalb von 1 Tag