The Wayback Machine - https://web.archive.org/web/20210725013140/https://github.com/neovim/neovim/issues/12929
Skip to content
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

UI Protocol: make neovim send hint for history hiding #12929

Open
glacambre opened this issue Sep 17, 2020 · 6 comments · May be fixed by #13729
Open

UI Protocol: make neovim send hint for history hiding #12929

glacambre opened this issue Sep 17, 2020 · 6 comments · May be fixed by #13729

Comments

@glacambre
Copy link
Member

@glacambre glacambre commented Sep 17, 2020

It is currently expected that UIs will figure out when to hide msg_history_show messages by themselves.

I think this is bad for two reasons:

  • It makes UIs less similar, increasing the number of things to learn when going from one UI to another.
  • It makes UIs different from the TUI, which offers a press ENTER prompt when the time to hide msg_history_show messages has come.

After discussing this on Gitter, @bfredl suggests hooking in the press ENTER mechanism in a configurable way:

yea, we could do that
hook in the press-enter thing
we probably want a global option to enable/disable press-enter across all message kinds

I'm not sure I see the value of doing this for all message kinds as neovim already tells UI when to hide them and the TUI does not offer a press ENTER prompt every time a message is echo'ed, but it would be useful to have that for msg_history_show.

@bfredl
Copy link
Member

@bfredl bfredl commented Nov 16, 2020

@GeorgeSheridan yes I think it is.

If any interested newcomer has questions, just ping me : )

@claudemuller
Copy link

@claudemuller claudemuller commented Nov 24, 2020

Howdy @bfredl

I'm a newcomer, love Neo(Vim) and would love to give it a shot. Mind if I do?

@bfredl
Copy link
Member

@bfredl bfredl commented Nov 24, 2020

@claudemuller please go ahead. Also join https://gitter.im/neovim/neovim for general questions about development :)

@devbhansingh
Copy link

@devbhansingh devbhansingh commented Dec 31, 2020

@claudemuller any updates?
Can I take this up?

@glacambre
Copy link
Member Author

@glacambre glacambre commented Jan 8, 2021

@claudemuller @devbhansingh Here's a small reproducer if you want:

import time
from pynvim import attach
from threading import Thread

def isInteresting (evt):
    return True

class UIThread(Thread):
    def __init__(self, nvim):
        Thread.__init__(self)
        self.nvim = nvim
        self.do_print = False
    def run(self):
        self.nvim.run_loop(self.callback, self.callback)
    def callback(self, event_name, events):
        if self.do_print:
            [print(event) for event in events if isInteresting(event[0])]

nvim = attach('child', argv=["nvim", "--embed", "-u", "NORC", "-i", "NONE"])
ui = UIThread(nvim)
ui.start()

# Create a ui with 5 lines of 80 characters.
nvim.async_call(nvim.ui_attach, 80, 5, ext_linegrid = True, ext_messages = True, rgb = True)

# Fillup history
nvim.async_call(nvim.input, ":echom 1<CR>")
nvim.async_call(nvim.input, ":echom 2<CR>")
nvim.async_call(nvim.input, ":echom 3<CR>")

time.sleep(1)
ui.do_print = True

# Print history
nvim.async_call(nvim.input, ":messages<CR>")

# Simulate user pressing keys
time.sleep(1)
nvim.async_call(nvim.input, ":<Esc>")

time.sleep(1)
ui.do_print = False
nvim.async_call(nvim.input, ":qa!<Enter>")
time.sleep(1)

This will print the following:

['msg_clear', []]
['cmdline_show', [[[0, 'messages']], 8, ':', '', 0, 1]]
['mode_change', ['cmdline_normal', 4]]
['flush', []]
['cmdline_hide', [1]]
['msg_history_show', [[['echomsg', [[0, '1']]], ['echomsg', [[0, '2']]], ['echomsg', [[0, '3']]]]]]
['mode_change', ['normal', 0]]
['flush', []]
['cmdline_hide', [1]]
['msg_showmode', [[]]]
['mode_change', ['normal', 0]]
['flush', []]

Notice how there aren't any msg_history_clear messages.

But replace nvim.async_call(nvim.input, ":messages<CR>") with nvim.async_call(nvim.input, ':echo "A"<CR>') and you'll get the following output:

['msg_clear', []]
['cmdline_show', [[[0, "echo 'A'"]], 8, ':', '', 0, 1]]
['mode_change', ['cmdline_normal', 4]]
['flush', []]
['cmdline_hide', [1]]
['msg_show', ['echo', [[0, 'A']], False]]
['mode_change', ['normal', 0]]
['flush', []]
['msg_clear', []]
['cmdline_hide', [1]]
['msg_showmode', [[]]]
['mode_change', ['normal', 0]]
['flush', []]

echo "a" is sent with a msg_show which is then cleared by a msg_clear message.

@quklali
Copy link

@quklali quklali commented Jan 11, 2021

import time
from pynvim import attach
from threading import Thread

def isInteresting (evt):
return True

class UIThread(Thread):
def init(self, nvim):
Thread.init(self)
self.nvim = nvim
self.do_print = False
def run(self):
self.nvim.run_loop(self.callback, self.callback)
def callback(self, event_name, events):
if self.do_print:
[print(event) for event in events if isInteresting(event[0])]

nvim = attach('child', argv=["nvim", "--embed", "-u", "NORC", "-i", "NONE"])
ui = UIThread(nvim)
ui.start()

Create a ui with 5 lines of 80 characters.

nvim.async_call(nvim.ui_attach, 80, 5, ext_linegrid = True, ext_messages = True, rgb = True)

Fillup history

nvim.async_call(nvim.input, ":echom 1")
nvim.async_call(nvim.input, ":echom 2")
nvim.async_call(nvim.input, ":echom 3")

time.sleep(1)
ui.do_print = True

Print history

nvim.async_call(nvim.input, ":messages")

Simulate user pressing keys

time.sleep(1)
nvim.async_call(nvim.input, ":")

time.sleep(1)
ui.do_print = False
nvim.async_call(nvim.input, ":qa!")
time.sleep(1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

7 participants
@bfredl @claudemuller @glacambre @devbhansingh @quklali and others