SciTE can not find user defined function. The editor executes "/bin/sh" for some reason - lua

So, this is my first attempt to make my source code editing more comfortable. I follow the SciTE scripting guide.
ext.lua.startup.script=$(SciteDefaultHome)/startup.lua
command.name.1.*= Programmer's Manual (selected text)
command.subsystem.1.*= 3
command.1.*=man_select
command.shortcut.1.*=F1
Above is the user properties file. It binds F1 key to user defined Lua function.
The problem is, that insteed of starting the function, man_select in my case, the SciTE editor output gives me
>man_select
/bin/sh: man_select: not found
>Exit code: 127
So, the editor runs a shell with my function name as a argument. I can't find no SciTE logs, or console, to see what the cause is.
I define man_select as a simple Lua function, without arguments:
function man_select()
local sel = editor:GetSelText()
...
end
What should I do to make my own Lua functions visible to SciTE editor? Is there a way to ask SciTE for more information on its scripting system flow?

Related

Multiline command-line editing in Gforth console

I have just started learning the Forth programming language.
I'm using Gforth on Ubuntu. In Gforth interactive console, I want to do indentation but it requires changing line. Enter key didn't work, it executed code. For comparison, for example, when one tests JavaScript code in web browser console, shift+enter change line without executing code. I want something like that. What key should I press? Is there a way other than using text editors like vim?
Best.
Gforth doesn't support multiline editing (see the manual).
A workaround is to edit a file in your favorite editor in another window and reload this file in Gforth console as:
include /tmp/scratch.fs
An external file can be also edited in Gforth console via a command like:
"vim /tmp/scratch.fs" system
So a one-liner for that is:
"vim /tmp/scratch.fs" system "/tmp/scratch.fs" included
That can be wrapped into a definition as:
: scratch "vim /tmp/scratch.fs" system "/tmp/scratch.fs" included ;
So the word scratch will open an editor and than load the edited file.
NB: if you use a quite old build of Gforth, you have to use s" ccc" instead of "ccc" for string literals.
To conditionally include/exclude some parts in a file the words [defined] and [if] can be used; to erase the previous instance of the loaded definitions the word marker can be used as:
[defined] _clear [if] _clear [then]
marker _clear
\ some definitions
\ ...
Take into account that usual control-flow words can be used in definitions only.

lua custom terminal not having command outputs

Im trying to make a terminal but im stuck on one thing. In the doer program command do. I want docom to be the output of of the loadstring. input = io.read() its a lua terminal inside my program but nothing displays any output. Here is the code that is relevant:
docom = loadstring(input)
print(docom)
How do i make the output display? Because currently its like this:
welcome to the terminal!
loaded
do
do:
print("hello")
function: 0x809b60
do:
The third and fifth line are user inputs. how do i fix this so it shows the hello string instead of the function name. i want this to be able to manage it as i have everything else in the same lua script. please help.
You probably want print(docom()).
loadstring compile a script into a function. That's what you see function: 0x809b60.
loadstring does not run the function. Hence the call docom().
You may want to add error handling by checking whether docom is nil and by calling docom via pcall.

Is there any editor or popular editor extension that automatically remove quotes/brackets?

There are too many text editors, which have the function, that if I just select a piece of the code and press the quote/bracket key, the selected code becomes wrapped into the type of the quotes/brackets I pressed. But do you know any or are you using any, which has also the function, that if I select the piece of the code wrapped into the quotes/brackets and press the same quote/bracket key or some key combination, that piece of code becomes unwrapped?
Also if you know any editor or popular editor extension that automatically remove all quotes/brackets from the code, please write it too. Everything would be helpful.
We are doing some research and this question is still unanswered. Please help us if you know anything about.
I create a simple Zeus (Windows) Lua script that does this for the quote case (i.e. the macro wraps any marked area in quotes).
In a similar fashion another script could be written for the brackets case.
Also as this simple script shows, this should be possible in any scriptable editor.
The script can be found here: http://www.zeusedit.com/zforum/viewtopic.php?t=7148
SynWrite editor (Windows) can do scripting for u. You can write Python plugin in 10min, and assign it a hotkey, so selection (or all text) will dequote, or what ever.
Finally, I've made it by writing my own extension to my favourite editor.

Run lua dissector and tap in tshark at the same time

I have a custom dissector (written in Lua) that I am using in many aspects of my current project.
I would also like to write a tap to perform some specific calculations for a particular task. I would like to keep this separate from the general purpose dissector for purposes of modularity.
Is there a way to invoke a dissector and a tap, both written in Lua, from the tshark command line? More generally, can an arbitrary number of Lua scripts be invoked, and if so, will they get invoked in the correct order?
EDIT:
I have tried invoking the two scripts from the command line:
tshark -Xlua_script:my_diss.lua -Xlua_script:my_tap.lua -r my.pcap
But I get an error:
tshark: Lua: Error during loading:
[string "my_tap.lua"]:9: bad argument #1 to 'new' (Field_new: a field with this name must exist)
The field name that this line refers to is created in my_diss.lua, but it is apparently not visible when my_tap.lua is being loaded.
That would require that the "initialize Lua" code in libwireshark be told which Lua scripts are dissectors and which Lua scripts are taps, and load them at the appropriate time so that, for example, all dissectors are loaded before all taps.
That means Wireshark would have to be changed; please file an bug at the Wireshark Bugzilla for this.
This is now supported in the wireshark codebase (version 1.8.5). I built from source and was able to get the desired behavior.
The relevant issue is: https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6020
The relevant commit is: http://anonsvn.wireshark.org/viewvc?view=revision&revision=47877

An error with io.read() in lua

When I use io.read() I get input from the user but when I do so it wont count backspaces, so if I type:
blah blah blaht
when my program wants input then if I delete the t:
blah blah blah
It still reads it as if the t is there, help?
EDIT: Only does this when debugging, im using SciTE, thx
I have been trying to figure this out for a long time and I came across this:
You have two programs here: SciTE and cmd. SciTE sends each visible
character like 'r' through to cmd as soon as it is typed. ScITE
interprets the backspace key internally to change the buffer but does
not send the key through to cmd. You can not edit a command line as
you want. Simplest to type Enter and try again. (source)
Unfortunately it doesn't seem to be possible to fix this.
Your best options are:
Execute the Lua script outside of SciTE and then you wont have this issue
Use another editor

Resources