Skip to content
Snippets Groups Projects
  • Simon Tatham's avatar
    64f8f68a
    Remove the 'Frontend' type and replace it with a vtable. · 64f8f68a
    Simon Tatham authored
    After the recent Seat and LogContext revamps, _nearly_ all the
    remaining uses of the type 'Frontend' were in terminal.c, which needs
    all sorts of interactions with the GUI window the terminal lives in,
    from the obvious (actually drawing text on the window, reading and
    writing the clipboard) to the obscure (minimising, maximising and
    moving the window in response to particular escape sequences).
    
    All of those functions are now provided by an abstraction called
    TermWin. The few remaining uses of Frontend after _that_ are internal
    to a particular platform directory, so as to spread the implementation
    of that particular kind of Frontend between multiple source files; so
    I've renamed all of those so that they take a more specifically named
    type that refers to the particular implementation rather than the
    general abstraction.
    
    So now the name 'Frontend' no longer exists in the code base at all,
    and everywhere one used to be used, it's completely clear whether it
    was operating in one of Frontend's three abstract roles (and if so,
    which), or whether it was specific to a particular implementation.
    
    Another type that's disappeared is 'Context', which used to be a
    typedef defined to something different on each platform, describing
    whatever short-lived resources were necessary to draw on the terminal
    window: the front end would provide a ready-made one when calling
    term_paint, and the terminal could request one with get_ctx/free_ctx
    if it wanted to do proactive window updates. Now that drawing context
    lives inside the TermWin itself, because there was never any need to
    have two of those contexts live at the same time.
    
    (Another minor API change is that the window-title functions - both
    reading and writing - have had a missing 'const' added to their char *
    parameters / return values.)
    
    I don't expect this change to enable any particularly interesting new
    functionality (in particular, I have no plans that need more than one
    implementation of TermWin in the same application). But it completes
    the tidying-up that began with the Seat and LogContext rework.
    64f8f68a
    History
    Remove the 'Frontend' type and replace it with a vtable.
    Simon Tatham authored
    After the recent Seat and LogContext revamps, _nearly_ all the
    remaining uses of the type 'Frontend' were in terminal.c, which needs
    all sorts of interactions with the GUI window the terminal lives in,
    from the obvious (actually drawing text on the window, reading and
    writing the clipboard) to the obscure (minimising, maximising and
    moving the window in response to particular escape sequences).
    
    All of those functions are now provided by an abstraction called
    TermWin. The few remaining uses of Frontend after _that_ are internal
    to a particular platform directory, so as to spread the implementation
    of that particular kind of Frontend between multiple source files; so
    I've renamed all of those so that they take a more specifically named
    type that refers to the particular implementation rather than the
    general abstraction.
    
    So now the name 'Frontend' no longer exists in the code base at all,
    and everywhere one used to be used, it's completely clear whether it
    was operating in one of Frontend's three abstract roles (and if so,
    which), or whether it was specific to a particular implementation.
    
    Another type that's disappeared is 'Context', which used to be a
    typedef defined to something different on each platform, describing
    whatever short-lived resources were necessary to draw on the terminal
    window: the front end would provide a ready-made one when calling
    term_paint, and the terminal could request one with get_ctx/free_ctx
    if it wanted to do proactive window updates. Now that drawing context
    lives inside the TermWin itself, because there was never any need to
    have two of those contexts live at the same time.
    
    (Another minor API change is that the window-title functions - both
    reading and writing - have had a missing 'const' added to their char *
    parameters / return values.)
    
    I don't expect this change to enable any particularly interesting new
    functionality (in particular, I have no plans that need more than one
    implementation of TermWin in the same application). But it completes
    the tidying-up that began with the Seat and LogContext rework.