Can I actually save several cursor positions using ANSI escape sequences? - bash

According to this source, these are the operations that can be done about the cursor :
- Position the Cursor:
\033[<L>;<C>H
Or
\033[<L>;<C>f
puts the cursor at line L and column C.
- Move the cursor up N lines:
\033[<N>A
- Move the cursor down N lines:
\033[<N>B
- Move the cursor forward N columns:
\033[<N>C
- Move the cursor backward N columns:
\033[<N>D
- Clear the screen, move to (0,0):
\033[2J
- Erase to end of line:
\033[K
- Save cursor position:
\033[s
- Restore cursor position:
\033[u
So you can save the cursor position, using \033[s, and then restore it using \033[u. But what if I want to save several cursor positions?
For example, let's say I want to save two cursor positions, and then restoring them. Values will get erased right? So my question is : Is there a way, using ANSI escaped sequences or not, to save several cursor positions to restore them later in bash?

The ANSI terminal does not have a memory of cursor positions. If you need to anything complicated like that, you will have to keep track of the cursor position yourself.
That's a lot of work and tricky to get right. You're much better off using ncurses.

Related

How to insert a text (not a node) in Summernote and move the cursor back X characters?

In Summernote, one can easily insert a text like so:
$('#summernote').summernote('editor.insertText', 'hello world'));
One could also insert a node like so:
$('#summernote').summernote('insertNode', node);
When inserting the Node, the cursor conveniently stays within the boundaries of the tag, for example when inserting the kbd tag, the cursor stays in between : <kbd> Cursor </kbd>
My question is how could one insert a text (not a tag) like "aa" and maintains the cursor in between the the two a's "a cursor a". So the only thing that I can think of is to control the cursor which I don't know how after many hours of researching. It doesn't have to be through cursor control if one knows a better way.

How to disable the console cursor from moving automatically

Situation:
I am crating an console application for windows using rust. Fore that I use winapi and kernel32.
Lets say my cursor position within the console is at 4,4 (X,Y) then I print an character like print!("#"); at position 4,4. Then the console automatically moves the cursor one to the right 5,4 for the next character to be printed there.
Question
Is it possible to prevent this default behavior, and have the cursor stay at 4,4 instead of moving to the next cell, usingwinapi/kernel32? What I mean by that is that the console should not change cursor position in any case until I manually tell the console to change the cursor position to another cell.
Example or solution maybe in any language.

Xcode Editor text selection issue

If I want to delete few lines of text in most of text editors, not touching some words on the bottom line and the whole upper line, I put cursor on the bottom row leaving all unnecessary words to the left of the cursor. Then I select few lines vertically by holding Shift + ↑. I stop on upper row and get some selection: part below + right part of the upper row:
In this example I want to get rid of if word and an empty space between the function header and the code, not touching the function header (even hough let will stick to the opening bracket {).
Normally (not in Xcode) I would still hold Shift and will press cmd + ➝ to deselect the right (selected) part or the top row.
Result will be like this:
I can simply press Delete and job is done.
However, in Xcode such shortcut usage makes bottom row fully selected (till the right) and not changes upper row selection:
Same thing happens if you select from top to bottom and you need to remove extra selection from the bottom line.
I tried to rebind shortcuts in Preferences but didn't find a solution.
This example is very particular and maybe not the best, however I face such selection problems only in Xcode and have to use mouse which is not handy.
This is a rather old question, but what you want is fairly simple to achieve. If your cursor is between the if and the let, you would only need to press option-shift-left arrow twice. The first time, it would select the if and the leading tabs, and the second would select the empty line.

how to move the dotted line from the middle of a "alt" sequence diagram

I'm using the UML sequence diagram in gliffy for Jira and I can't seem to move the dotted line to the middle of the alt box - it stays stuck to the top and I don't see a handle for it. How do I move it to the middle?
It's really fiddly but it possible.
1) Double click the top guard condition [If] to go into text edit mode.
2) Add some carriage returns (new lines) at the end - the idea is to move the cursor down to where you want the line to go
If the line doesn't move when you insert the new lines (it's a bit flaky) then click outside the box (to save) and wait a few seconds for it to catch up.
If it still doesn't move the line, then move the shape a little to get it to redraw.
Finally, delete the shape and start again if it still won't move it.
As I said, it's a bit flaky.

Vi Move Cursor by bytes

I have a file with only one single line of content inside, but this line is very very long.
When I open it up in Vi, it fills up the whole screen.
How could I move the cursor by number of words or bytes so I can see the content of the next 'page'.
If your goal is to navigate down a single wrapped line, you should consider using g before motions. For example:
gj: go down one line visually
g8j: go down 8 visual lines
You could also move to a specific index in the line with |, e.g. 10| to go to character 10 (one-indexed).
w will move you over words (delimiting with certain punctuation), while W will move you over whole words, not counting certain punctuation. Combine with number prefixes to "scan" around.
If you'd prefer not to see your text wrapped and filling the screen, you can call :set nowrap and move with standard motions (e.g. w and W for moving words). Moving the whole window, with zl, zh, zj, and zk are options too.
Pressing l takes you to the next character.
Pressing w takes you to the next word.
If you prefix those with a number, you can specify how many words or characters you want to move, e.g. 1000w.
Maybe for such a thing you shouldn't use vi (but I don't want to start a religious war here).

Resources