cursor-position

Adding ANSI color escape sequences to a bash prompt results in bad cursor position when recalling/editing commands

孤人 提交于 2019-11-27 17:43:51
问题 If I set my command prompt like: export PS1='\033[0;33m[\u@\h \w]\$ \033[00m' The color of the prompt will be yellow and everything after the '$' character will be the default terminal color. This is what I expect. However, If I recall a command line and attempt to edit it, moving the cursor -- either UpArrow/Ctrl-A (set -o emacs) or ESC K (set -o vi) if the command line I'm trying to edit is long enough, the cursor is not positioned at the beginning of the command. Typing either Ctrl-A (set

Setting the Cursor Position in a Win32 Console Application

两盒软妹~` 提交于 2019-11-27 08:39:54
How can I set the cursor position in a Win32 Console application? Preferably, I would like to avoid making a handle and using the Windows Console Functions. (I spent all morning running down that dark alley; it creates more problems than it solves.) I seem to recall doing this relatively simply when I was in college using stdio, but I can't find any examples of how to do it now. Any thoughts or suggestions would be greatly appreciated. Thanks. Additional Details Here is what I am now trying to do: COORD pos = {x, y}; HANDLE hConsole_c = CreateConsoleScreenBuffer( GENERIC_READ | GENERIC_WRITE,

Set the caret/cursor position to the end of the string value WPF textbox

点点圈 提交于 2019-11-27 07:31:50
I am try to set the caret/cursor position to the end of the string value in my WPF textbox when I open my window for the first time. I use the FocusManager to set the focus on my textbox when my window opens. Nothing seems to work. Any ideas? Note, I am using the MVVM pattern, and I included only a portion of the XAML from my code. <Window FocusManager.FocusedElement="{Binding ElementName=NumberOfDigits}" Height="400" Width="800"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition/> </Grid.RowDefinitions> <TextBox

How to find cursor position in a contenteditable DIV?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 00:40:28
I am writing a autocompleter for a content editable DIV (need to render html content in the text box. So preferred to use contenteditable DIV over TEXTAREA). Now I need to find the cursor position when there is a keyup/keydown/click event in the DIV. So that I can insert the html/text at that position. I am clueless how I can find it by some computation or is there a native browser functionality that would help me find the cursor position in a contententeditable DIV. If all you want to do is insert some content at the cursor, there's no need to find its position explicitly. The following

Inserting text in TinyMCE Editor where the cursor is

折月煮酒 提交于 2019-11-27 00:27:18
问题 I've been trying to insert text into the TinyMCE Editor at the focused paragraph element ( <p> ) exactly where the cursor is but got no luck!! var elem = tinyMCE.activeEditor.dom.get('tinymce'); var child = elem.firstChild; while (child) { if (child.focused) { $(child).insertAtCaret("some text"); } child = child.nextSibling; } If anyone has any idea on how to solve this I'll be very thankful. 回答1: You should use the command mceInsertContent . See the TinyMCE documentation. tinymce

Set cursor at a length of 14 onfocus of a textbox

谁说我不能喝 提交于 2019-11-26 21:05:50
Hai Guys, I want to set cursor at a position of length 14 on a textbox which will not have a value.. Iknow initially cursor will be at 0 i want it to be at 14 IE use different approach at setting cursor position than Firefox,Opera and Chrome. It's better to make a helper function, which will do it for you. I use this one for own needs. function setCursor(node,pos){ node = (typeof node == "string" || node instanceof String) ? document.getElementById(node) : node; if(!node){ return false; }else if(node.createTextRange){ var textRange = node.createTextRange(); textRange.collapse(true); textRange

Set cursor at a length of 14 onfocus of a textbox

送分小仙女□ 提交于 2019-11-26 17:26:50
问题 Hai Guys, I want to set cursor at a position of length 14 on a textbox which will not have a value.. Iknow initially cursor will be at 0 i want it to be at 14 回答1: IE use different approach at setting cursor position than Firefox,Opera and Chrome. It's better to make a helper function, which will do it for you. I use this one for own needs. function setCursor(node,pos){ node = (typeof node == "string" || node instanceof String) ? document.getElementById(node) : node; if(!node){ return false;

jquery Setting cursor position in contenteditable div

对着背影说爱祢 提交于 2019-11-26 17:15:09
The old version of the question is below, after researching more, I decided to rephrase the question. The problem as before is, I need to focus a contenteditable div without highlighting the text, doing straight up focus highlights the text in Chrome. I realize that people solved this problems in textareas by resetting the caret position in the textarea. How can I do that with a contenteditable element? All the plugins I've tried only works with textareas. Thanks. Old Phrasing of the question: I have a contenteditable element that I want to focus, but only insofar as to place the cursor at the

Setting the Cursor Position in a Win32 Console Application

。_饼干妹妹 提交于 2019-11-26 14:15:39
问题 How can I set the cursor position in a Win32 Console application? Preferably, I would like to avoid making a handle and using the Windows Console Functions. (I spent all morning running down that dark alley; it creates more problems than it solves.) I seem to recall doing this relatively simply when I was in college using stdio, but I can't find any examples of how to do it now. Any thoughts or suggestions would be greatly appreciated. Thanks. Additional Details Here is what I am now trying

Set the caret/cursor position to the end of the string value WPF textbox

本小妞迷上赌 提交于 2019-11-26 13:21:40
问题 I am try to set the caret/cursor position to the end of the string value in my WPF textbox when I open my window for the first time. I use the FocusManager to set the focus on my textbox when my window opens. Nothing seems to work. Any ideas? Note, I am using the MVVM pattern, and I included only a portion of the XAML from my code. <Window FocusManager.FocusedElement="{Binding ElementName=NumberOfDigits}" Height="400" Width="800"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition/> </Grid