-
Notifications
You must be signed in to change notification settings - Fork 543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement cursor moving and editing with arrow keys in the textarea widget. #156
base: master
Are you sure you want to change the base?
Conversation
That's okay, we want a small editor in blessed. So this would be perfect. @dbkaplun, what do you think? |
Hey, I completely agree that blessed could use some improved text editing. I took a look a cursory look at this patch and it has some bugs:
Good job @golbin! |
@dbkaplun, yes those first two bugs should be fixed, but I don't think it should go into This also needs to be refactored a little bit to match coding style. edit: Actually taking a second look, it's pretty good in that regard, just concatenation or addition always uses the operator at the beginning of the line when line feed separated: |
@golbin, have you tested this with all manner of fullUnicode characters? double-width, double-width surrogates, surrogates, and combining chars? That would be the trickiest part. I don't think I ever had it perfect. If you got that working it would be fantastic. |
@chjj I've test surrogate and combining functions but it did't works well. So, I just check character width and it works almost cases for CJK. There is a known bug which is during character is combining. |
@golbin, @dbkaplun, I think you two should work together on a concensus minimal text editor for Textarea. @dbkaplun has the most experience with editing and @golbin dealt with all the unicode gotchas and made text navigation of his own. If @dbkaplun rips some of his text navigation code and @golbin adds the unicode/double-width/surrogate/combining/fuck-unicode/etc stuff, I think you guys would make something good. Would you guys work together on this? |
I'm OK both way. 😄 |
Would love to have this functionality in textboxes as well so a user can edit a line of text using cursor movements (left and right only though). |
Hey, I've been meaning to mention, I've factored out the editor widget from slap here. It features navigation via configurable keybindings as well as mouse support. Hope it's useful! |
@dbkaplun This may be exactly what I need. Thanks! |
Is this PR still active or the recommended way to get arrow support in textarea is now editor-widget ? |
I was planning on using this custom Textarea because editor-widget just pulls in way too many dependencies when you only want some arrow navigation and such. So I tried using this, but the cursor ends up in the totally wrong place and characters get... scrambled, somehow, while typing. I looked at the code and found that this was the issue, in
fixed that issue for me. I don't know if it's because I positioned the widget using |
@oaknuggins I think it works with latest blessed. But it's a little buggy. |
Awesome work @golbin |
@golbin good work. why lastest blessed desn't merge this pr? no progress on this problem? |
Blessed is dead for years now. I’m thinking to creating new one from scratch, if I find some time. |
id be happy to contribute if you do start something new. |
Now, users can move with arrow keys and edit text anywhere on a cursor. And it works well with multi-byte characters but there is a little bug.
And actually It has a performance problem when you copy a large text and if we want fix this, fix "element.parseContent" function.
But I think, it's enough for editing small text and if someone want to edit large text, it's better to use slap-editor.