Comments (7)
Hello, glad to hear you enjoy it !
So the problem might lie in the formatLastPrompt()
function down in the internal/ui/prompt.go
file.
I use an already escaped "\1" and "\2" strings to match, so maybe there is a redundant backslash in the backticked strings.
I'll try to fix this by the end of the week.
In the meantime, did you see that you can set the cursor style through inputrc options ?
You can use cursor-vi-insert
, cursor-emacs
, etc. Maybe it does not fit your use case though...
See https://github.com/reeflective/readline/wiki/Options#options and look the cursor-<keymap-name>
option.
Ping me if needed.
from readline.
Thanks @maxlandon I did see the cursor options, but I was initially hoping to keep my config the same between bash and this library. Maybe Chet Ramey would be interested in adding them to readline! I was able to match the functionality I had with vi-ins-mode-string & vi-cmd-mode-string using the following config and the sample console app:
$if example
set cursor-vi-insert beam
set cursor-vi beam
set cursor-vi-command block
set cursor-vi-move block
set cursor-vi-visual block
set cursor-vi-opp block
$endif
from readline.
Okay there is one important thing I had forgot and which makes your request unsatisfiable here...
So basically if you go into the code, you will see that the cursor is reprinted many many times (not only when the insertion mode changes, but also on redisplays), and so any cursor sequence you might include in the prompt string will actually have no effect...
As for the current configuration snippet: it's taste and colors so do as you please, but I would probably advise against changing the cursor-vi-opp
value, since it's very useful to know when you are in the middle of a command (most of the time, as you know, you are happy of knowing where you are at in your sequence because you have accidentally typed the wrong key)... but hey, just my two cents...
Original readline: I had to briefly check the code when writing this library, however I have no idea how complicated it would be to include those in the original C lib. Try your luck !
Keeping this open for some time, in case any of us (or someone else) has an idea on how to solve this better. Unfortunately it seems unlikely to me...
from readline.
Setting vi-ins-mode-string & vi-cmd-mode-string is pretty effective at changing the cursor in GNU readline, at least for my use case. I think your implementation is more robust, but it would be nice to stay compatible with GNU readline. I stole my config originally from this stackoverflow post.
from readline.
Update on this:
I tried again to make the behavior with escape sequences in prompt to be compatible with the legacy GNU C readline code.
Currently there is a bug in parsing .inputrc
values that include non-escaped spaces.
I'm waiting for the person who wrote the inputrc
package to fix this, as I'm not very very familiar with the parsing logic inside.
After this is solved, the behavior should be consistent and this issue solved.
from readline.
@maxlandon awesome, thanks for the update
from readline.
Fixed in #59 , prompt escapes work correctly based on my tests !
Update to the latest release.
from readline.
Related Issues (17)
- offset cursor HOT 15
- it doesn't work on git bash in Windows HOT 6
- expose keymapMode type HOT 1
- Don't add empty lines to history
- Extend support for more editors, with some comfort settings
- case insensitive tab completion HOT 4
- consolidating changes/fixes from hilbish's fork HOT 2
- Fix Windows tests for `.inputrc` code
- Implement multiline editing support HOT 1
- Implement proper Windows redisplay on resize
- '\' character consumed but not used HOT 14
- Remaining widgets to implement
- comments (?) behaviour HOT 14
- Implement testing suite HOT 1
- Port lmorg/readline code for WASM support
- Review or enhancements of terminal-specific code HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from readline.