popup window filter, what is <80><fd>` ?

70 views
Skip to first unread message

Maxim Kim

unread,
Aug 7, 2022, 10:01:02 AM8/7/22
to vim_use
Hi, currently there is no built-in way to have a prompt in a popup window so am trying to fake it with filtering.

While in the early stages, I found out that the filter func constantly gets <80><fd>` value.

What is this?
How can I properly filter it out?

With the following code:

vim9script

export def TestPopup(contents: string)
    var prompt = ""
    var main_id = popup_create(contents, {
        pos: 'center',
        mapping: 0,
        filter: (id, key) => {
            if key == "\<esc>"
                popup_close(id, -1)
            else
                prompt ..= key
            endif
            return true
        },
        callback: (id, result) => {
                echom prompt
            }
        })
enddef

TestPopup('hello')

If you wait a 3-4 seconds and close popup with ESC, you will see <80><fd>`:
viim-filter.gif

Bram Moolenaar

unread,
Aug 7, 2022, 10:53:37 AM8/7/22
to vim...@googlegroups.com, Maxim Kim
Don't see it in the GIF.

here probably is a third byte that you don't see. 0x80 0xfd is a
prefix for a special key. There is a list in src/keymap.h, "enum
key_extra".

--
hundred-and-one symptoms of being an internet addict:
269. You receive an e-mail from the wife of a deceased president, offering
to send you twenty million dollar, and you are not even surprised.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Salman Halim

unread,
Aug 7, 2022, 11:20:08 AM8/7/22
to Vim Users


Salman

It shows up on the command line at the bottom at the end of the GIF.

Maxim Kim

unread,
Aug 7, 2022, 11:40:05 AM8/7/22
to Bram Moolenaar, vim...@googlegroups.com

On 2022-08-07 17:53, Bram Moolenaar wrote:
>
> Don't see it in the GIF.
in the message area at the end of gif <80><fd>`
>
> here probably is a third byte that you don't see.
Third byte is `
> 0x80 0xfd is a
> prefix for a special key. There is a list in src/keymap.h, "enum
> key_extra".

I have checked this enum, and have absolutely no idea how to figure out
what is 0x80 0xfd `  and why it appears in the filter at all.

It looks like it happens on cursorhold event, not 100% sure though.

Maxim Kim

unread,
Aug 7, 2022, 11:49:03 AM8/7/22
to Bram Moolenaar, vim...@googlegroups.com

It looks like it happens on cursorhold event, not 100% sure though.

Indeed, if I change `set updatetime=1000` then I get this every second:


vim9script

def Test()
    var prompt: string = ''
    const wid: number = popup_create('', {
        minwidth: 20,
        maxheight: 1,
        mapping: false,
        filter: (winid: number, key: string): bool => {
            if key == "\<esc>"
                popup_close(winid, -1)
            else
                prompt ..= key
                popup_settext(winid, prompt)
            else
                return false
            endif
            return true
        },
        callback: (_: number, result: number) => {
            if result == 0
                echomsg prompt
            endif
        }
    })
enddef

Test()


Maxim Kim

unread,
Aug 7, 2022, 11:55:46 AM8/7/22
to vim_use
The issue is with windows gvim 9.0.133
I have tried the same in fedora36 vim 9.0.161 and it doesn't have this.

воскресенье, 7 августа 2022 г. в 18:49:03 UTC+3, Maxim Kim:

Maxim Kim

unread,
Aug 7, 2022, 12:05:36 PM8/7/22
to vim_use
And this is actually cursorhold, and I can filter it out with

            if key == "\<cursorhold>"
                return true
...

Full snippet:

vim9script

def Test()
    var prompt: string = ''
    const wid: number = popup_create('', {
        minwidth: 20,
        maxheight: 1,
        mapping: false,
        filter: (winid: number, key: string): bool => {
            if key == "\<cursorhold>"
                return true
            elseif key == "\<esc>"

                popup_close(winid, -1)
            else
                prompt ..= key
                popup_settext(winid, prompt)
            else
                return false
            endif
            return true
        },
        callback: (_: number, result: number) => {
            if result == 0
                echomsg prompt
            endif
        }
    })
enddef

Test()


Still not sure why in gvim I get it into a filter func...

воскресенье, 7 августа 2022 г. в 18:55:46 UTC+3, Maxim Kim:
Reply all
Reply to author
Forward
0 new messages