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

Addition of virtual events. #23

Open
iogf opened this issue Mar 12, 2017 · 3 comments
Open

Addition of virtual events. #23

iogf opened this issue Mar 12, 2017 · 3 comments

Comments

@iogf
Copy link
Member

iogf commented Mar 12, 2017

It may be better to implement custom keymaps for plugins
to use virtual events like:

class ExampleEvent(object):
    def __init__(self, area):
        self.area = area
        area.install(('BETA', '<<ExampleEvent.OutputData>>', self.output_data))
        area.event_add('<<ExampleEvent.OutputData>>', '<Key-h>')

    def output_data(self, e):
        self.area.insert('end', 'This is nice')

install = ExampleEvent

or it could be.

"""
Overview
========

Just a test to demonstrate virtual events.

Keycommands
===========

Mode: BETA
Event: <<ExampleEvent.OutputData>>, <Key-h>
Description: insert the text 'This is nice' on the focused
areavi.
"""

class ExampleEvent(object):
    def __init__(self, area):
        self.area = area
        area.install(('BETA', ('<<ExampleEvent.OutputData>>', '<Key-h>', ...), self.output_data))
        # area.event_add('<<ExampleEvent.OutputData>>', '<Key-h>')

    def output_data(self, e):
        self.area.insert('end', 'This is nice')

install = ExampleEvent
@Malex
Copy link
Contributor

Malex commented Oct 31, 2018

I do prefer the first one, but I don't get why going for this.
Is it a shortcut to bind multiple keys to the same function?
Like
<< VirtualEvent >> -> my_pretty_function
Key-a -> << VirtualEvent >>
Key-b -> << VirtualEvent >>

?

@iogf
Copy link
Member Author

iogf commented Nov 2, 2018

The main goal would be turning it easier for users to remap functionalities. Instead of having to remap a key to a key, one could just remap a custom event to a keypress. The custom event would be documented by the plugin. Basicly, you would do something like:

remap('<SomeFunctionality>', '<Key-x>')

Instead of

remap('<Key-y>', '<Key-x>')

Where Key-y is linked to some function. It is much more meaningful to have

'<Somefunctionality>' 

rather than

'<Key-y>' 

when having to remap keys.

@Malex
Copy link
Contributor

Malex commented Nov 5, 2018

Definetly true.
Although it could also be done the other way around by having a way to pass plugins params from vyrc where you could specify the keys you desires (as well other configurations some plugins might need, like where to find a language server if a plugin needs one) and, only if not found, fallback to default.

I still think remap is a cool feature to keep, but I do think it should not be the default for plugins key.

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

No branches or pull requests

2 participants