Scite Lua Scripting Extension API Beginner

This may be a stupid question but how do I access things like editor:addtext()?

http://www.scintilla.org/PaneAPI.html

http://www.scintilla.org/SciTELua.html

I can see how to use it, but don't know where to put it. Where are the functions accessible from? And how do they get run? Can it work from any normal Lua program?

Answers


Stupid example: 1. Open menu "Options" -> "Open Lua Startup Script" 2. Write any Lua code, e.g. print('Selected: <'..editor:GetSelText()..'>') 3. Press Ctrl-S (as if you want to save this file), your script will be immediately executed, output will appear in the output pane (on the right). 4. Repeat steps 2-3


Less stupid example: Insert this into SciTEGlobal.properties

ext.lua.startup.script=$(SciteDefaultHome)/your_script.lua

#print length of selected text
command.33.*=PrintSelectionLength
command.subsystem.33.*=3
command.mode.33.*=savebefore:no
command.shortcut.33.*=F1

# User defined key commands
user.shortcuts=\
F1|1133|\
Ctrl+Shift+V|IDM_PASTEANDDOWN|\
Ctrl+PageUp|IDM_PREVFILE|\
Ctrl+PageDown|IDM_NEXTFILE|

user.context.menu=\
Selection Length    (F1)|1133|\
||\
Toggle Output|IDM_TOGGLEOUTPUT|

Insert this in your_script.lua

function PrintSelectionLength()
   local sel = editor:GetSelText()
   print(#sel..' chars selected')
   print(table.concat({sel:byte(1,-1)},','))
end

Now you can press F1 to see ASCII codes of symbols under selection while editing any file in SciTE.


Need Your Help

Google Calendar like interface

ajax user-interface google-calendar-api

I need to write an application that essentially functions like a week-view of a calendar, columns for the days and then rows for appointments. Where the height of the appointment box visually repr...

How can I echo a scraped div in PHP?

php curl foreach web-scraping screen-scraping

How do I echo and scrape a div class? I tried this but it doesn't work. I am using cURL to establish the connection. How do I echo it? I want it just how it is on the actual page.