TeXstudio macro script : how to move the cursor to specified position? - latex

For example, I want to write the following macro in script in TeXstudio(using QtScript):
%SCRIPT
editor.write("\\textcolor{red}{}")
After invoking this macro, I want the cursor to move into the second pair of curly braces automatically. How can I modify my code to achieve the desired effect?

%SCRIPT
txt = "\\textcolor{red}{}"
cursor.insertText(txt)
cursor.movePosition(1,cursorEnums.Left)

Related

Migrate Vim/Vimscript for asynchronously running external editors to Lua/Neovim

In my Vim's configuration file init.vim I am using code, that sets a default viewer for practically any kind of file suffix. Here I will demonstrate only an example for .md files:
let g:netrw_browsex_viewer="-"
function! NFH_md(f)
call asyncrun#run("", "cwd", "typora " . a:f)
endfunction
First paragraph makes sure to choose the function based on suffix of the file ("URI under cursor"). Second paragraph shows a function whose name i.e. NFH_md implies that this is the function opened when .md file is in the "URI under the cursor". Inside this function there is an call that opens an external program typora asynchronously so that I am still able to continue using Vim.
If you want to know more use :help netrw_browsex_viewer.
I tried porting the mentioned Vim script to Neovim & Lua but I only managed to port first line:
vim.g.netrw_browsex_viewer="-"
For I don't know, how to properly port the second paragraph. This is why for now I just use Vimscript source code like this:
vim.api.nvim_exec(
[[
function! NFH_md(f)
call asyncrun#run("", "cwd", "marktext " . a:f)
endfunction
]],
false
)
But I would love to translate all the code to Lua - Could anyone help a bit to translate this remaining Vimscript code to Lua?

IBM Cobol 6.3 Copy Replacing with pseudo-text

Cobol Reference Manual (6.3), on page 526, affirms literally:
Comment lines, inline comments, or blank lines in pseudo-text-2 or partial-word-2 are copied into the resultant program unchanged whenever pseudo-text-2 or partial-word-2 is placed into the source text as a result of text replacement.
Is it possible to have an example of how to build such a pseudo-text?
Thank you.
Livio Felicella
COPY MYLIB REPLACING ==some words== by ==
* comment line
* after an empty line
DISPLAY 'DONE'. *> with inline comment
==.

run move_base node and get costmap from text file

The move_base node call the function makePlan:
bool makePlan(
const geometry_msgs::PoseStamped& start,
const geometry_msgs::PoseStamped& goal,
std::vector<geometry_msgs::PoseStamped>& plan
)
I wrote a c++ program to randomly generate start, goal, and map, which is a 2d array of 0s(free) and 100s(obstacle), and store this data into text file.
How can I configure makePlan to take start and goal from this text file, and how to allow move_base to use the 2d array stored in the text file?
Appreciate any help.
You can create your own GlobalPlanner by implementing a GlobalPlanner Plugin see: http://wiki.ros.org/navigation/Tutorials/Writing%20A%20Global%20Path%20Planner%20As%20Plugin%20in%20ROS
Then frist step would be to copy the original source code of the GlobalPlanner to your own GlobalPlanner and make it work.
Now you can change the make_plan method in your own global planner and adjust it as you like.

Insert an Inline Code with Back Tics do not work in Medium.com

Following this Blog:
https://medium.com/blogging-guide/how-to-insert-a-code-block-or-inline-code-into-a-medium-article-7b697bd12e0a
It should be simple to add inline Code with Back Tics (`).
However it does not work for me - it only displays the back tics as characters:
Is there something that I miss?
If you are using other than "Standard US English Keyboard" then medium formatting options may vary.
For instance, I am using ABC-QWERTZ layout on my mac.
For me:
To enter into inline code block:
[Single backtick + space key] worked.
To come out from inline code block:
[Single backtick key]
Start writing after pressing key.
On U.S. Keyboard:
To enter into inline code block:
[Single backtick].
To come out from inline code block:
[Single backtick key]
Note:
When you want to add inline block in the middle of sentence, add one space before pressing single backtick.
For me none of the backtick solutions worked, but at least for code blocks (not inline code between two words)
ALT + CMD + 6
did the job.
For MAC Users:
⌥ + ⌘ + 6
If you type the code rather than highlighting existing code, and start with a backtick, you enter inline code mode. To escape, another backtick doesn't work for me - I have to use right arrow.
Selecting code and pressing backtick just deletes the code and displays a backtick. Pretty useless really...
It's a quite old question, but i found a way on French keyboard to it : You need to use the # button (and not the ` button), which is fact at the same place on an English keyboard :

How do I make sure that a directory name is quoted in OMake?

I have a relatively complicated suite of OMake files designed for cross-compiling on a specific platform. My source is in C++.
I'm building from Windows and I need to pass to the compiler include directories which have spaces in their names. The way that the includes string which is inserted in the command line to compile files is created is by the line:
public.PREFIXED_INCLUDES = $`(addprefix $(INCLUDES_OPT), $(set $(absname $(INCLUDES))))
At some other point in the OMake files I have a line like:
INCLUDES += $(dir "$(LIBRARY_LOCATION)/Path with spaces/include")
In the middle of the command line this expands to:
-IC:\Library location with spaces\Path with spaces\include
I want it to expand to:
-I"C:\Library location with spaces\Path with spaces\include"
I don't want to change anything but the "INCLUDES += ..." line if possible, although modifying something else in that file is also fine. I don't want to have to do something like change the definition of PREFIXED_INCLUDES, as that's in a suite of OMake files which are part of an SDK which may change beneath me. Is this possible? If so, how can I do it? If not, in what ways can I make sure that includes with spaces in them are quoted by modifying little makefile code (hopefully one line)?
The standard library function quote adds escaped quotes around its argument, so it should do the job:
INCLUDES += $(quote $(dir "$(LIBRARY_LOCATION)/Path with spaces/include"))
If needed, see quote in Omake manual.
In case someone else is having the same problem, I thought I'd share the solution I eventually went with, having never figured out how to surround with quotes. Instead of putting quotes around a name with spaces in it I ended up converting the path to the short (8.3) version. I did this via a a simple JScript file called shorten.js and a one line OMake function.
The script:
// Get Access to the file system.
var FileSystemObject = WScript.CreateObject("Scripting.FileSystemObject");
// Get the short path.
var shortPath = FileSystemObject.GetFolder(WScript.Arguments(0)).ShortPath;
// Output short path.
WScript.StdOut.Write(shortPath);
The function:
ShortDirectoryPath(longPath) =
return $(dir $(shell cscript /Nologo $(dir ./tools/shorten.js) "$(absname $(longPath))"))
So now I just use a line like the following for includes:
INCLUDES += $(ShortDirectoryPath $(dir "$(LIBRARY_LOCATION)/Path with spaces/include"))

Resources