Perform 'insert' from command line (possibly via Lua script?)

22 views
Skip to first unread message

sdaau

unread,
Jan 4, 2011, 3:20:19 AM1/4/11
to scite-interest
Hi all,

I have set up Scite so it starts with a single instance. In that case
- if Scite is already startedand on the command line I call, say,

$ scite /path/to/file1.txt

... then the particular command above will return instantly - and
'file1.txt' will be opened in the currently running instance of Scite.
If after that I call:

$ scite /path/to/file2.txt

... then 'file2.txt' will be opened in a new tab of the currently
running instance of Scite.

Following this logic, I'd like to be able to do a insert of text
content from the command line, for instance:

$ scite -insert:"Some text to be inserted"

... would insert the text "Some text to be inserted" at the current
cursor position, in the currently active tab, in the currently running
instance of Scite (i.e. in this example, the text would be inserted in
'fle2.txt'). Obviously, the command would return instantly here too,
so I could call 'scite -insert' multiple times, and insert multiple
pieces of text in the currently opened document.

I think it would be preferable for me to actually call some sort of a
Lua script to do the actual inserting, because then I could possibly
control the caret (i.e. insert, then move caret at end), as well as
file saving (i.e. save file automatically as soon as insert has been
performed).

So, I tried looking through

http://www.scintilla.org/SciTEDoc.html#Command%20line%20arguments

... but unfortunately, I cannot find references to either inserting,
or calling Lua scripts, via command line arguments. On the other hand
- I found this:

SciTe command-line launcher: "-i text Insert text in the file."
http://www.frykholm.se/scitecmd.html

... which is for Windows (I use Linux) - and the code (http://
www.frykholm.se/main_cpp.html) uses:

........
} else if (cmd == "-i") {
REQUIRE_ARG;
std::string arg = argv[opt++];
std::string command = std::string("insert:") +
encode(arg);
commands.push_back(command);
......
SendMessage(w, WM_COPYDATA, 0, (long)&cds);
......

I guess, this is in line with what I would need - but that wrapper
launcher, being for Windows, is of no use to me.

So I'd like to ask - is it possible to somehow do this insert via
command line, in 'vanilla' Scite for Linux?? Possibly by calling a Lua
script?

Thanks in advance,
Cheers!

Neil Hodgson

unread,
Jan 4, 2011, 9:12:09 PM1/4/11
to scite-i...@googlegroups.com

sdaau

unread,
Jan 6, 2011, 2:25:54 AM1/6/11
to scite-interest
Hi Neil,

>    http://www.scintilla.org/SciTEDirector.html
>    http://groups.google.com/group/scite-interest/msg/1bf5e032b3d83c33
>

Thanks a lot for your answer - I think it is exactly what I needed!

To summarize - doing an 'insert' from a command line would require
exchanging messages with Scite, which is supported through the so-
called Scite Director Interface, which is described at first link;
however, first link also describes only the interface for Windows.

The second link states that also functionality for Linux is present,
although not properly documented - however, the post itself has
examples of usage.

Haven't tried it yet, but with these links, I think there is a fairly
good chance of success :)

Thanks again,
Cheers!
Reply all
Reply to author
Forward
0 new messages