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
Related
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?
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.
I have a code block in an org document
#+NAME: result_whatever
#+BEGIN_SRC python :session data :results value :exports none
return(8.1 - 5)
#+END_SRC
which I evaluate inline:
Now, does this work? Let's see: call_result_whatever(). I'd be surprised ...
When exporting to LaTeX, this generates the following:
Now, does this work? Let's see: \texttt{3.1}. I'd be surprised \ldots{}
However, I don't want the results to be displayed in monospace. I want it to be formatted in "normal" upright font, without any special markup.
How can I achieve this?
You should be able to get it work using the optional header arguments which can be added to call_function().
I don't have LaTeX installed on this system so can't fully test the outputs to ensure they come out exactly as desired, I'm using the plain text output to compare instead. However you can use the following syntax as part of your call to modify the results.
Now, does this work? Let's see call_results_whatever()[:results raw].
I'd be surprised ...
Without the [:results raw] the output to Plain Text (Ascii buffer) is Let's see `3.0999999999999996'.. With the added results it becomes Let's see 3.0999999999999996.
For full details of the available results keywords as well as other optional header arguments for the inline blocks please see Evaluation Code Blocks and Results arguments.
this is 5 years later. apparently in org-mode 8.2 or so, a new variable was introduced (documenting in "Evaluating Code Blocks" in the org-mode manual, but this from etc/ORG-NEWS in the source tree):
*** New option: org-babel-inline-result-wrap
If you set this to the following
: (setq org-babel-inline-result-wrap "$%s$")
then inline code snippets will be wrapped into the formatting string.
so, to eliminate \texttt{}
(setq org-babel-inline-result-wrap "%s")
The problem of this type can be solved in two ways:
1: Easy does it:
A plain query-replace on the exported buffer.
Once you're in the LaTeX buffer,
beginning-of-buffer or M-<
query-replace or M-%
enter \texttt as the string that you want to replace
enter nothing as the replacement
continue to replace each match interactively
with y/n or just replace everything with !
2: But I wanna!
The second way is to nag the org-mode mailing list into
implementing a switch or an option for your specific case.
While it's necessary sometimes, it also produces a system
with thousands of switches, which can become unwieldy.
You can try, but I don't recommend.
Is there any editor or add-on/plugin which replaces some keywords with prepared snippets in place of written keyword.
For example i'm typing key1 and it's instantly or after a space is replaced with snippet that is assigned to this keyword.
I saw some tutorial from Jeffrey Way long ago, but can't find it now. :s
Thanks ;)
FingerText for Notepad++ pretty much does what you want.
Just use Tab after typing in the keyword you set up for the snippet, and it'll replace it with the snippet.
The Zeus editor has a template feature that does exactly this. A template is a keyword with an associated code snippet and typing in a keyword followed by the space key results in the keyword being replaced by the associated code snippet.
Try installing AutoHotkey version 1.1.19.03 or greater.
One thing it can do is look for sequences of keyboard characters and replace them with other sequences on the fly. As soon as it sees a sequence it will replace it. No activating character is required.
To set up the replacement definitions:
Right click on the Desktop
New
AutoHotkey Script
This will create a template for
your script with the name New AutoHotkey Script.ahk
Edit New AutoHotkey Script.ahk with Notepad++
Put your key snippet lines at
the end, like so:
:*:key1::snippet for key1
:*:key2::snippet this time for key2
Save As My Snippet definitions.ahk
To invoke it: Double click My Snippet definitions.ahk
You can control AutoHotkey by right clicking on its icon on the taskbar.
I'm using Lua Mac 5.1.4 Compiler.
I'm trying to import lua file and run it.
I tried using this code:
% lua hello.lua
But I'm getting this error: stdin:1: unexpected symbol near '%'
Am I doing something wrong? This is my first day using lua so be easy on me.
Thank you.
The problem is probably that you saw this verbatim text in a tutorial:
% lua hello.lua
The '%' at the beginning of the line is not something you are supposed to type into your terminal, but is rather a generic prompt indicator. Sometimes you might see it written as '$' instead:
$ lua hello.lua
In either case, the first character is not something you type, but rather is a typographical convention to suggest that what follows is to be typed at a prompt. Your actual prompt might look something like this:
mo#macbook$
So you would type lua hello.lua but your screen would look like this:
mo#macbook$ lua hello.lua
So, try just entering lua hello.lua and see what happens.
Note that the error message you got regarding stdin:1 is likely from your shell (e.g. bash), and not from Lua (which never even started running due to the malformed command in the shell).
The error stdin:1: unexpected symbol near '%' suggests that you typed in % lua hello.lua while in an interactive lua session (or you executed a script containing it). Now that's something that you should type in in the commandline window.
Instead try something like print'Hello World!'
Lua provides two ways to call a file. One is the loadfile() and the other is the dofile() commands. Try using dofile("hello.lua").That should work.If it doesn't type the absolute path...:)