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

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.

Related

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

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.

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.

How to get the cursor position (not row or column) in Ace Editor?

Is there a way to get the cursor position (not the row and column) in Ace Editor.
For example, if the contents of the Ace Editor are the following:
Hello
World
And the cursor was after the "Wo" in "World". The position or index would be 7 or 8 (if you count newline).
Is there a method to get the position?
Ace calls {row, column} objects position, and the number of characters since the document start index.
You can convert position to index using editor.session.doc.positionToIndex method https://github.com/ajaxorg/ace/blob/v1.2.6/lib/ace/document.js#L678, but note that this method is not very fast since it has to iterate over the whole document, so use it and indexToPosition as sparingly as possible.

Cursor between the wrong characters when clicking an inactive NSTextField with the "Truncate Head" Line Break

I used Interface Builder to create an NSTextField and set its Line Break to Truncate Head (because if its text is too long to display all at once, I'd rather see the last few words than the first few).
My problem is that the modified Line Break compromises my ability to place my cursor in a specific position when making the NSTextField active (a.k.a. First Responder) by clicking the mouse. In this example, the NSTextField is not active, and I attempt to place my cursor between the "L" and "A" in "lazy".
After clicking, the cursor appears before the word "over".
Clearly, the NSTextField is ignoring the modified Line Break, and positioning the cursor as if it were the default. Can I achieve the effect of Truncate Head but keep the ability to place the cursor in a specific location by clicking?
I had the idea to record the mouseDown location, compare that to attributedStringValue's size, and calculate where the cursor should go, but I quickly got in over my head.
Original question: NSTextField keep scrolling at the end
I have the following silly problem:
I placed a single-line NSTextField on my View. The idea would be that it contains a long URL, but in my case mostly the ending is interesting.
So I would like the content to appear like scrolled to the end (so the beginning is not visible if it is longer than the textfield). The problem is that I do not know how to set this properly. I tried the "Text Direction" option to Right To Left which then displays properly, but as soon the user clicks on the field it jumps back to the beginning, thus confusing the user.
Please let me know what I am missing.
Thanks!

In- and out-points in TextMate.app

This could be more of a Superuser question, but here goes:
I find myself deleting large amounts of text all the time, I do so by holding Shift-Arrow followed by Delete. However I would love to be able to delete in the way you edit in a video editing application, by adding in- and out-points.
You would press the "IN" keyboard shortcut where you would like the edit to begin and the "OUT" where it should end, followed by delete.
Is this crazy? Is there a way to do this in Textmate?
The cursor doesn't move when you use page-down or page-up, so you could just place the cursor at the beginning of the text, move the pointer to the end of the text, or page-down to where the end of the text is and move the pointer to the end, then hold the shift key down as you click after the last character you wish to delete, and all of the text between the first point and the second will be selected. Then you can hit delete. This will work in either direction (select start then end or select end then start).

Resources