cyrus-and / gdb-dashboard

Modular visual interface for GDB in Python
MIT License
10.99k stars 768 forks source link

Add a way to provide a complete method to a gdb.Command #276

Closed ccalmels closed 1 year ago

ccalmels commented 1 year ago

Currently only a gdb.COMPLETE_xxx constant can be used to specify the complete policy of a Dashboad.Module commands. This patch allows to pass a callable that will provide a complete method to the gdb.Command.

An example:

class Example(Dashboard.Module):
    """ Example """
    def __init__(self):
        super().__init__()

    def lines(self, term_width, term_height, style_changed):
        return []

    def do(self, arg):
        pass

    def do_complete(self, text, word):
        values = ['abc', 'aab', 'aaa']

    return [x for x in values if x.startswith(word)]

    def commands(self):
        return {
            'do': {
                'action': self.do,
                'doc': 'do something',
                'complete': self.do_complete,
            }
        }
ccalmels commented 1 year ago

For more context, a module that is using this enhancement: gdb-dashboard-svd

cyrus-and commented 1 year ago

This is a good idea, thanks!

PS sorry for the ages taken to merge this...

ccalmels commented 1 year ago

This is a good idea, thanks!

PS sorry for the ages taken to merge this...

No problem. Thank you very much for your work!