My Lua extension script has a function that centers the cursor in the middle of the screen, using code suggested by Neil. This works fine when called from the tool menu. FYI I called this 'CenterCursor'

Additionally I have a function that hooks OnOpen, to locate a key word. When this word is found, the position the cursor was at when the file was saved is retrieved and repositioned. This too works fine.

However, recently I added a call to 'CenterCursor' after the cursor has been position by the OnOpen hook. This is not working. This error is reported: > ...\SciTEExtension.lua:510: bad argument #1 to `VisibleFromDocLine' (number expected, got string)

The function is:
function CenterCursor()
   local line = props.SelectionStartLine;
local topLineWanted = editor:VisibleFromDocLine(line) - editor.LinesOnScreen / 2; -- line 510
   editor:LineScroll(0, topLineWanted - editor.FirstVisibleLine)
end

FYI, if you like the script, you may find this revision useful for a second one called TopCursor(). Change the second line to:
   local topLineWanted = editor:VisibleFromDocLine(line) - 2;

April

--
A fool must now and then be right by chance.
Cowper

_______________________________________________
Scite-interest mailing list
Scite-interest@lyra.org
http://mailman.lyra.org/mailman/listinfo/scite-interest

Reply via email to