Giter VIP home page Giter VIP logo

Comments (7)

maxlandon avatar maxlandon commented on May 30, 2024

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.

lollipopman avatar lollipopman commented on May 30, 2024

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.

maxlandon avatar maxlandon commented on May 30, 2024

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.

lollipopman avatar lollipopman commented on May 30, 2024

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.

maxlandon avatar maxlandon commented on May 30, 2024

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.

lollipopman avatar lollipopman commented on May 30, 2024

@maxlandon awesome, thanks for the update

from readline.

maxlandon avatar maxlandon commented on May 30, 2024

Fixed in #59 , prompt escapes work correctly based on my tests !
Update to the latest release.

from readline.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.