-
Notifications
You must be signed in to change notification settings - Fork 76
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
vi mode-dependent cursor shape #220
Comments
Similarly, would it be possible to decide the apperance of the vi mode indicator? |
@YlanAllouche, I found the answer in a related issue: options(
radian.vi_mode_prompt = list(
"ins" = "(I) ",
"nav" = "(N) ",
"rep" = "(R) "
)
) As for cursor shape, it might be possible to use another example from that same issue to adapt my ipython_config.py to radian. |
Wow, I just pasted the relevant code from my Is settings.py the right place for it? Or is it better for this to be handled by a config file? Should I submit a pull request? I think everyone who uses the radian vi mode will want this. import sys
from prompt_toolkit.application.current import get_app
from prompt_toolkit.key_binding.vi_state import InputMode, ViState
def get_input_mode(self):
if sys.version_info[0] == 3:
# Decrease input flush timeout from 500ms to 10ms.
app = get_app()
app.ttimeoutlen = 0.01
app.timeoutlen = 0.2
return self._input_mode
def set_input_mode(self, mode):
shape = {InputMode.NAVIGATION: 2, InputMode.REPLACE: 4}.get(mode, 6)
cursor = "\x1b[{} q".format(shape)
if hasattr(sys.stdout, "_cli"):
write = sys.stdout._cli.output.write_raw
else:
write = sys.stdout.write
write(cursor)
sys.stdout.flush()
self._input_mode = mode
ViState._input_mode = InputMode.INSERT
ViState.input_mode = property(get_input_mode, set_input_mode) |
I submitted a pull request #222. If anyone wants to install the change to try it out, run the line below.
The change is a small addition to the apply_settings() function in radian/session.py. |
Thanks a lot for the tip for the vi mode prompt. I tried in both Xterm and Kitty to make sure it was not a terminal compatibility problem. |
@YlanAllouche, thanks for giving it a try. Sorry to hear it didn't work for you. There should be no additional setup required. In addition to using a container, you could also try a virtual environment. Click here for minimal virtual environment example that I hope will be reproducible🤞bash --norc --noprofile
mkdir cursor
cd cursor
python -m venv ./venv
source ./venv/bin/activate
python -m pip install git+https://github.com/mskar/radian.git@cursor
./venv/bin/radian Click here for the result of
|
Hey @mskar, Thanks a lot for detailed steps. |
I would like radian to have a beam cursor (
|
) in vi insert mode and a block cursor in vi navigation (normal) mode.Since both radian and IPython use prompt-toolkit, I think it will be helpful to link to the relevant prompt-toolkit issue.
By including the code from the issue in my
ipython_config.py
file, i was able to set up IPython with a vi mode-dependent cursor:How could I do something similar in my
.radian_profile
?The text was updated successfully, but these errors were encountered: