Replies: 3 comments
-
|
Also -- SCI_GETLENGTH
local iL = geany.scintilla(2006, 0, 0)
local n1, n2, n3
n2 = 0
while true do
-- SCI_INDICATORVALUEAT
n1 = geany.scintilla(2507, 8, n2)
if n1 ~= 0 then
-- SCI_LINEFROMPOSITION
n3 = geany.scintilla(2166, n1, 0)
-- SCI_MARKERADD
geany.scintilla(2043, n3, 1)
-- SCI_GETLINEENDPOSITION
n2 = geany.scintilla(2136, n3, 0)
end
n2 = n2 + 1
if n2 >= iL then break end
enddidn't work. |
Beta Was this translation helpful? Give feedback.
-
|
Here is the English version of the explanation and the corrected script, ready for you to share with the community or the original author. Why the Original Script Failed (Infinite Loop) So, if you are at position n2 = 10 and there is no highlight, SCI_INDICATORSTART will jump all the way back to 0 (the beginning of the file where the text is also unmarked). This resets your n1 to 0, making n2 become 1 in the next iteration, trapping the script in an infinite loop. The Solution: Using SCI_INDICATOREND (2509) When you call SCI_INDICATOREND while sitting on an unmarked region, Scintilla automatically fast-forwards to the start of the next actual highlight. Here is the corrected and working Lua script: Lua Try this hope will help |
Beta Was this translation helpful? Give feedback.
-
|
I also wrote this version: -- SCI_GETLENGTH
local iL = geany.scintilla(2006, 0, 0)
local n1, n2
n1 = 0
while true do
-- SCI_INDICATORVALUEAT
if geany.scintilla(2507, 8, n1) > 0 then
-- SCI_LINEFROMPOSITION
n2 = geany.scintilla(2166, n1, 0)
-- SCI_MARKERADD
geany.scintilla(2043, n2, 1)
-- SCI_GETLINEENDPOSITION
n1 = geany.scintilla(2136, n2, 0)
end
n1 = n1 + 1
if n1 > iL then break end
endand this version started working. @kupernikus87 -- SCI_GETLENGTH
local iL = geany.scintilla(2006, 0, 0)
local n1, n2, n3
n1 = 0
while true do
-- SCI_INDICATORVALUEAT
if geany.scintilla(2507, 8, n1) > 0 then
-- SCI_LINEFROMPOSITION
n3 = geany.scintilla(2166, n1, 0)
-- SCI_MARKERADD
geany.scintilla(2043, n3, 1)
-- SCI_INDICATOREND
n2 = geany.scintilla(2509, 8, n1)
else
-- SCI_INDICATOREND
n2 = geany.scintilla(2509, 8, n1)
end
if n2 <= n1 then break end
n1 = n2
if n1 > iL then break end
endI tested both with a large number of bookmarks (~1600-1700) with a plain text file (i.e. without syntax highlighting) and the second script works significantly faster (in this case, approximately five times faster). It is still unclear why P.S.
For commands like "Mark" and "Go to * marker" Geany uses marker 1. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Please, help needed: I guess, I'm missing something obvious, but I haven't figured out what it is yet.
I tried to set bookmark for each line with marked text (after "Mark All" or related button in the Find dialog):
This script didn't work, so I tried another way:
but didn't work too.
Any ideas?
Edit:
Fix
geany.scintilla(2043, n3, 0)in the second variant (0 -> 1).Beta Was this translation helpful? Give feedback.
All reactions