Set cursor at end of Gtk.Entry - gtk

In gtk3, I'm setting the text of an Entry, but the cursor remains at the front (position 0) of the Entry, and I'd like to move the cursor to the end. Is there a way for me to do that?
my_entry.buffer.set_text my_text, my_text.length
# ...now the cursor is at the start of the entry

A GtkEntry implements GtkEditable. So you can use gtk_editable_set_position(editable, -1)

Related

TextField's current focus position in flutter

Hey I have a TextField and a controller for it through which I access its current text value and add some text like (Some Special Asterix or text with angular brackets just like hashnode's text editor) to it when needed, adding text at the end is easy.
controller.text += "Something";
The above code will add Something to the end. But I need to know the current TextFields Cursor position and add text according to it.
I really love to know how we can do it in flutter efficiently
Try this to get the cursor position
print(controller.selection.baseOffset);
print(controller.selection.extentOffset);
if they are the same, it is current cursor position.
if not, it means that some of text is selected, baseOffset is start position and extentOffset is end positon.

move cursor after final Line?

Once in a time I remember that in VSCode I could move my cursor after the final line. That is, if a file doesn't end with a trailing newline and I click the space after the last line, the cursor would be placed after the final line where there is no line number at the left. However, now in VSCode 1.37.1 it not longer behave like this. When I click the space, it just put the cursor at the end of the last line. How can I restore the old behaviour? I searched the settings but I can't find relevant option.
Try:
"editor.renderFinalNewline": false
I think that is what you want - if there is a newline at the end of the final line you can click in the line below (which has no line number) and enter text there.

Moving cursor position by offset value

$text->SetCursor( position );
This is used to move cursor at the given position.
Is there any way that I can move the cursor by a given offset value?
Thanks,
You just have to use the correct position descriptor; they support a little language of their own. For example, the string insert + 1 char describes the location one character further on than the insertion point (insert is a special kind of mark that represents where text will be inserted and is where the caret is located when focus is in the text widget).

move cursor up/down in UITextView

The only public API I found allowed me only to move the cursor right/left using selectedRange property.
Any workaround to perform that task up/down?
Thanks
If you haven't found an answer, you may just have to develop your own custom component using Core Text.
This is a pretty old question ... but for anyone still trying to find a way to do this:
You can count the number of \n characters up to the current range.location and set the new range.location to a \n before to the cursor up a row or to a \n after the cursor to move it down.
If you want to move it up or down and keep it in line with the characters on the row you will need to count the number of characters on each row and move it to the right location

clearing newline char from gtk.Textbuffer

I have a gtk.TextBuffer which is supposed to be cleared after pressing Enter, similar to the input box on most chat programs. I'm just setting the buffer back to a blank string. The newline character from Enter isn't removed though, and a blank line ends up above the cursor during the next input. Moving the cursor to the first gtk.Iter doesn't help.
By default, "gobject.connect()" callback is called before the default handler. You need to use "gobject.connect_after()".
def insert_text_cb(text_buffer, position, text, lenght):
if text == '\n':
text_buffer.set_text('')
text_view = gtk.TextView()
text_view.get_buffer().connect_after('insert-text', insert_text_cb)
Are you sure you're trigger on the proper event? Also try connecting it after.