Skip to content

Support multi-line prompts#34

Merged
jart merged 1 commit intojart:masterfrom
MaxGyver83:multi-line-prompts
Oct 21, 2024
Merged

Support multi-line prompts#34
jart merged 1 commit intojart:masterfrom
MaxGyver83:multi-line-prompts

Conversation

@MaxGyver83
Copy link
Contributor

How to test

You can test multi-line prompts in rc linked with bestline.

This branch alone isn't compatible with rc. But you can use my custom branch which contains some additional changes (like #33):

cd /tmp
git clone -b custom https://github.com/MaxGyver83/bestline
cd bestline
make libbestline.so
sudo cp libbestline.so /usr/local/lib/

cd ..
git clone https://github.com/rakitzis/rc
cd rc
make EDIT=bestline
./rc

fn prompt = { prompt = ($nl^`pwd^$nl^'% ' '  ') }

@jart
Copy link
Owner

jart commented Oct 20, 2024

Could you take a look at the changes I've made to bestline called "llama mode"? llamafile uses bestline which now supports triple quote syntax shown in this screenshot: https://www.phoronix.com/news/Llamafile-0.8.14 Does something like this help your use case?

@MaxGyver83
Copy link
Contributor Author

MaxGyver83 commented Oct 20, 2024

Could you take a look at the changes I've made to bestline called "llama mode"? llamafile uses bestline which now supports triple quote syntax shown in this screenshot: https://www.phoronix.com/news/Llamafile-0.8.14 Does something like this help your use case?

Thanks for your hint to "llama mode". I had a look into this. As far as I understand, this does not help here because the triple quote syntax is only for (multiline) commands typed by the user. This pull request is about allowing newlines in the prompt. Bestline quits on a newline in the prompt even with llama mode activated.

Copy link
Owner

@jart jart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand now. So you want to be able to say for example:

while((line = bestline("hello\nthere> ")) != NULL) { ... }

It's not great that when I press CTRL-L it discards all but the last line. However looking at the code, that would be quite ugly to remedy. So the approach you chose seems pretty reasonable. If you're happy with this, then I approve it.

Thanks!

@jart jart merged commit 2c964b0 into jart:master Oct 21, 2024
@MaxGyver83 MaxGyver83 deleted the multi-line-prompts branch October 22, 2024 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants