Skip to content
Snippets Groups Projects
  1. Jun 12, 2021
    • Simon Tatham's avatar
      Make TermWin's palette_get_overrides() take a Terminal *. · 329bdb34
      Simon Tatham authored
      Less than 12 hours after 0.75 went out of the door, a user pointed out
      that enabling the 'Use system colours' config option causes an
      immediate NULL-dereference crash. The reason is because a chain of
      calls from term_init() ends up calling back to the Windows
      implementation of the palette_get_overrides() method, which responds
      by trying to call functions on the static variable 'term' in window.c,
      which won't be initialised until term_init() has returned.
      
      Simple fix: palette_get_overrides() is now given a pointer to the
      Terminal that it should be updating, because it can't find it out any
      other way.
      
      (cherry picked from commit 571fa338)
      329bdb34
  2. Feb 07, 2021
    • Simon Tatham's avatar
      Flip direction of window pos/size queries. · 696550a5
      Simon Tatham authored
      Similarly to other recent changes, the frontend now proactively keeps
      Terminal up to date with the current position and size of the terminal
      window, so that escape-sequence queries can be answered immediately
      from the Terminal's own internal data structures without needing a
      call back to the frontend.
      
      Mostly this has let me remove explicit window-system API calls that
      retrieve the window position and size, in favour of having the front
      ends listen for WM_MOVE / WM_SIZE / ConfigureNotify events and track
      the position and size that way. One exception is that the window pixel
      size is still requested by Seat via a callback, to put in the
      wire-encoded termios settings. That won't be happening very much, so
      I'm leaving it this way round for the moment.
      696550a5
    • Simon Tatham's avatar
      Centralise palette setup into terminal.c. · ca9cd983
      Simon Tatham authored
      Now terminal.c makes nearly all the decisions about what the colour
      palette should actually contain: it does the job of reading the
      GUI-configurable colours out of Conf, and also the job of making up
      the rest of the xterm-256 palette. The only exception is that TermWin
      can provide a method to override some of the default colours, which on
      Windows is used to implement the 'Use system colours' config option.
      
      This saves code overall, partly because the front ends don't have to
      be able to send palette data back to the Terminal any more (the
      Terminal keeps the master copy and can answer palette-query escape
      sequences from its own knowledge), and also because now there's only
      one copy of the xterm-256 palette setup code (previously gtkwin.c and
      window.c each had their own version of it).
      
      In this rewrite, I've also introduced a multi-layered storage system
      for the palette data in Terminal. One layer contains the palette
      information derived from Conf; the next contains platform overrides
      (currently just Windows's 'Use system colours'); the last one contains
      overrides set by escape sequences in the middle of the session. The
      topmost two layers can each _conditionally_ override the ones below.
      As a result, if a server-side application manually resets (say) the
      default fg and bg colours in mid-session to something that works well
      in a particular application, those changes won't be wiped out by a
      change in the Windows system colours or the Conf, which they would
      have been before. Instead, changes in Conf or the system colours alter
      the lower layers of the structure, but then when palette_rebuild is
      called, the upper layer continues to override them, until a palette
      reset (ESC]R) or terminal reset (e.g. ESC c) removes those upper-layer
      changes. This seems like a more consistent strategy, in that the same
      set of configuration settings will produce the same end result
      regardless of what order they were applied in.
      
      The palette-related methods in TermWin have had a total rework.
      palette_get and palette_reset are both gone; palette_set can now set a
      contiguous range of colours in one go; and the new
      palette_get_overrides replaces window.c's old systopalette().
      ca9cd983
    • Simon Tatham's avatar
      Bring some order to colour palette indexing. · da3197f3
      Simon Tatham authored
      There are three separate indexing schemes in use by various bits of
      the PuTTY front ends, and _none_ of them was clearly documented, let
      alone all in the same place. Worse, functions that looked obviously
      related, like win_palette_set and win_palette_get, used different
      encodings.
      
      Now all the encodings are defined together in putty.h, with
      explanation of why there are three in the first place and clear
      documentation of where each one is used; terminal.c provides mapping
      tables that convert between them; the terminology is consistent
      throughout; and win_palette_set has been converted to use the sensible
      encoding.
      da3197f3
    • Simon Tatham's avatar
      Remove TermWin's is_minimised method. · 61571376
      Simon Tatham authored
      Again, I've replaced it with a push-based notification going in the
      other direction, so that when the terminal output stream includes a
      query for 'is the window minimised?', the Terminal doesn't have to
      consult the TermWin, because it already knows the answer.
      
      The GTK API I'm using here (getting a GdkEventWindowState via
      GtkWidget's window-state-event) is not present in GTK 1. The API I was
      previously using (gdk_window_is_viewable) _is_, but it turns out that
      that API doesn't reliably give the right answer: it only checks
      visibility of GDK window ancestors, not X window ancestors. So in fact
      GTK 1 PuTTY/pterm was only ever _pretending_ to reliably support the
      'am I minimised' terminal query. Now it won't pretend any more.
      61571376
    • Simon Tatham's avatar
      Move all window-title management into Terminal. · 42ad454f
      Simon Tatham authored
      Previously, window title management happened in a bipartisan sort of
      way: front ends would choose their initial window title once they knew
      what host name they were connecting to, but then Terminal would
      override that later if the server set the window title by escape
      sequences.
      
      Now it's all done the same way round: the Terminal object is always
      where titles are invented, and they only propagate in one direction,
      from the Terminal to the TermWin.
      
      This allows us to avoid duplicating in multiple front ends the logic
      for what the initial window title should be. The frontend just has to
      make one initial call to term_setup_window_titles, to tell the
      terminal what hostname should go in the default title (if the Conf
      doesn't override even that). Thereafter, all it has to do is respond
      to the TermWin title-setting methods.
      
      Similarly, the logic that handles window-title changes as a result of
      the Change Settings dialog is also centralised into terminal.c. This
      involved introducing an extra term_pre_reconfig() call that each
      frontend can call to modify the Conf that will be used for the GUI
      configurer; that's where the code now lives that copies the current
      window title into there. (This also means that GTK PuTTY now behaves
      consistently with Windows PuTTY on that point; GTK's previous
      behaviour was less well thought out.)
      
      It also means there's no longer any need for Terminal to talk to the
      front end when a remote query wants to _find out_ the window title:
      the Terminal knows the answer already. So TermWin's get_title method
      can go.
      42ad454f
    • Simon Tatham's avatar
      Remove TermWin's is_utf8 method. · 45b03419
      Simon Tatham authored
      All implementations of it work by checking the line_codepage field in
      the ucsdata structure that the terminal itself already has a pointer
      to. Therefore, it's a totally unnecessary query function: the terminal
      can check the same thing directly by inspecting that structure!
      
      (In fact, it already _does_ do that, for the purpose of actually
      deciding how to decode terminal output data. It only uses this query
      function at all for the auxiliary purpose of inventing useful tty
      modes to pass to the backend.)
      45b03419
  3. Jun 14, 2020
    • Simon Tatham's avatar
      fuzzterm.c: fix prototypes of stub dlg functions. · 602656ee
      Simon Tatham authored
      I'd forgotten to #include "dialog.h" in that file, which meant nothing
      was checking the prototypes of the stub implementations of the dlg_*
      function family against the real versions. They almost all needed a
      'void *dlg' parameter updating to 'dlgparam *dp', which is a change
      dating from commit 3aae1f9d nearly two years ago. And a handful of
      them also still had 'int' that should be now have become 'bool'.
      
      (cherry picked from commit c373fe97)
      602656ee
  4. May 16, 2020
    • Simon Tatham's avatar
      fuzzterm.c: fix prototypes of stub dlg functions. · c373fe97
      Simon Tatham authored
      I'd forgotten to #include "dialog.h" in that file, which meant nothing
      was checking the prototypes of the stub implementations of the dlg_*
      function family against the real versions. They almost all needed a
      'void *dlg' parameter updating to 'dlgparam *dp', which is a change
      dating from commit 3aae1f9d nearly two years ago. And a handful of
      them also still had 'int' that should be now have become 'bool'.
      c373fe97
  5. Mar 10, 2020
    • Simon Tatham's avatar
      Change vtable defs to use C99 designated initialisers. · b4e1bca2
      Simon Tatham authored
      This is a sweeping change applied across the whole code base by a spot
      of Emacs Lisp. Now, everywhere I declare a vtable filled with function
      pointers (and the occasional const data member), all the members of
      the vtable structure are initialised by name using the '.fieldname =
      value' syntax introduced in C99.
      
      We were already using this syntax for a handful of things in the new
      key-generation progress report system, so it's not new to the code
      base as a whole.
      
      The advantage is that now, when a vtable only declares a subset of the
      available fields, I can initialise the rest to NULL or zero just by
      leaving them out. This is most dramatic in a couple of the outlying
      vtables in things like psocks (which has a ConnectionLayerVtable
      containing only one non-NULL method), but less dramatically, it means
      that the new 'flags' field in BackendVtable can be completely left out
      of every backend definition except for the SUPDUP one which defines it
      to a nonzero value. Similarly, the test_for_upstream method only used
      by SSH doesn't have to be mentioned in the rest of the backends;
      network Plugs for listening sockets don't have to explicitly null out
      'receive' and 'sent', and vice versa for 'accepting', and so on.
      
      While I'm at it, I've normalised the declarations so they don't use
      the unnecessarily verbose 'struct' keyword. Also a handful of them
      weren't const; now they are.
      b4e1bca2
  6. Feb 02, 2020
    • Simon Tatham's avatar
      Remove the GLOBAL macro itself. · 9729aabd
      Simon Tatham authored
      Now it's no longer used, we can get rid of it, and better still, get
      rid of every #define PUTTY_DO_GLOBALS in the many source files that
      previously had them.
      9729aabd
  7. Sep 08, 2019
    • Simon Tatham's avatar
      Whitespace rationalisation of entire code base. · 5d718ef6
      Simon Tatham authored
      The number of people has been steadily increasing who read our source
      code with an editor that thinks tab stops are 4 spaces apart, as
      opposed to the traditional tty-derived 8 that the PuTTY code expects.
      
      So I've been wondering for ages about just fixing it, and switching to
      a spaces-only policy throughout the code. And I recently found out
      about 'git blame -w', which should make this change not too disruptive
      for the purposes of source-control archaeology; so perhaps now is the
      time.
      
      While I'm at it, I've also taken the opportunity to remove all the
      trailing spaces from source lines (on the basis that git dislikes
      them, and is the only thing that seems to have a strong opinion one
      way or the other).
          
      Apologies to anyone downstream of this code who has complicated patch
      sets to rebase past this change. I don't intend it to be needed again.
      5d718ef6
  8. Jun 30, 2019
    • Simon Tatham's avatar
      Don't implicitly load a session if Session pane not active. · e790adec
      Simon Tatham authored
      If you select an entry in the saved sessions list box, but without
      double-clicking to actually load it, and then you hit OK, the config-
      box code will automatically load it. That just saves one click in a
      common situation.
      
      But in order to load that session, the config-box system first has to
      ask the list-box control _which_ session is selected. On Windows, this
      causes an assertion failure if the user has switched away from the
      Session panel to some other panel of the config box, because when the
      list box isn't on screen, its Windows control object is actually
      destroyed.
      
      I think a sensible answer is that we shouldn't be doing that implicit
      load behaviour in any case if the list box isn't _visible_: silently
      loading and launching a session someone selected a lot of UI actions
      ago wasn't really the point. So now I make that behaviour only happen
      when the list box (i.e. the Session panel) _is_ visible. That should
      prevent the assertion failure on Windows, but the UI effect is cross-
      platform, applying even on GTK where the control objects for invisible
      panels persist and so the assertion failure didn't happen. I think
      it's a reasonable UI change to make globally.
      
      In order to implement it, I've had to invent a new query function so
      that config.c can tell whether a given control is visible. In order to
      do that on GTK, I had to give each control a pointer to the 'selparam'
      structure describing its config-box pane, so that query function could
      check it against the current one - and in order to do _that_, I had to
      first arrange that those 'selparam' structures have stable addresses
      from the moment they're first created, which meant adding a layer of
      indirection so that the array of them in the top-level dlgparam
      structure is now an array of _pointers_ rather than of actual structs.
      (That way, realloc half way through config box creation can't
      invalidate the important pointer values.)
      e790adec
  9. Mar 16, 2019
    • Simon Tatham's avatar
      Add a TermWin method to draw a 'trust sigil'. · 2a5d8e05
      Simon Tatham authored
      This is not yet used by anything, but the idea is that it'll be a
      graphic in the terminal window that can't be replicated by a server
      sending escape sequences, and hence can be used as a reliable
      indication that the text on a particular terminal line is generated by
      PuTTY itself and not passed through from the server. This will make it
      possible to detect a malicious server trying to mimic local prompts to
      trick you out of information that shouldn't be sent over the wire
      (such as private-key passphrases).
      
      The trust sigil I've picked is a small copy of the PuTTY icon, which
      is thematically nice (it can be read as if the PuTTY icon is the name
      of the speaker in a dialogue) and also convenient because we had that
      graphic available already on all platforms. (Though the contortions I
      had to go through to make the GTK 1 code draw it were quite annoying.)
      
      The trust sigil has the same dimensions as a CJK double-width
      character, i.e. it's 2 character cells wide by 1 high.
      2a5d8e05
  10. Nov 03, 2018
    • Simon Tatham's avatar
      Convert a lot of 'int' variables to 'bool'. · 3214563d
      Simon Tatham authored
      My normal habit these days, in new code, is to treat int and bool as
      _almost_ completely separate types. I'm still willing to use C's
      implicit test for zero on an integer (e.g. 'if (!blob.len)' is fine,
      no need to spell it out as blob.len != 0), but generally, if a
      variable is going to be conceptually a boolean, I like to declare it
      bool and assign to it using 'true' or 'false' rather than 0 or 1.
      
      PuTTY is an exception, because it predates the C99 bool, and I've
      stuck to its existing coding style even when adding new code to it.
      But it's been annoying me more and more, so now that I've decided C99
      bool is an acceptable thing to require from our toolchain in the first
      place, here's a quite thorough trawl through the source doing
      'boolification'. Many variables and function parameters are now typed
      as bool rather than int; many assignments of 0 or 1 to those variables
      are now spelled 'true' or 'false'.
      
      I managed this thorough conversion with the help of a custom clang
      plugin that I wrote to trawl the AST and apply heuristics to point out
      where things might want changing. So I've even managed to do a decent
      job on parts of the code I haven't looked at in years!
      
      To make the plugin's work easier, I pushed platform front ends
      generally in the direction of using standard 'bool' in preference to
      platform-specific boolean types like Windows BOOL or GTK's gboolean;
      I've left the platform booleans in places they _have_ to be for the
      platform APIs to work right, but variables only used by my own code
      have been converted wherever I found them.
      
      In a few places there are int values that look very like booleans in
      _most_ of the places they're used, but have a rarely-used third value,
      or a distinction between different nonzero values that most users
      don't care about. In these cases, I've _removed_ uses of 'true' and
      'false' for the return values, to emphasise that there's something
      more subtle going on than a simple boolean answer:
       - the 'multisel' field in dialog.h's list box structure, for which
         the GTK front end in particular recognises a difference between 1
         and 2 but nearly everything else treats as boolean
       - the 'urgent' parameter to plug_receive, where 1 vs 2 tells you
         something about the specific location of the urgent pointer, but
         most clients only care about 0 vs 'something nonzero'
       - the return value of wc_match, where -1 indicates a syntax error in
         the wildcard.
       - the return values from SSH-1 RSA-key loading functions, which use
         -1 for 'wrong passphrase' and 0 for all other failures (so any
         caller which already knows it's not loading an _encrypted private_
         key can treat them as boolean)
       - term->esc_query, and the 'query' parameter in toggle_mode in
         terminal.c, which _usually_ hold 0 for ESC[123h or 1 for ESC[?123h,
         but can also hold -1 for some other intervening character that we
         don't support.
      
      In a few places there's an integer that I haven't turned into a bool
      even though it really _can_ only take values 0 or 1 (and, as above,
      tried to make the call sites consistent in not calling those values
      true and false), on the grounds that I thought it would make it more
      confusing to imply that the 0 value was in some sense 'negative' or
      bad and the 1 positive or good:
       - the return value of plug_accepting uses the POSIXish convention of
         0=success and nonzero=error; I think if I made it bool then I'd
         also want to reverse its sense, and that's a job for a separate
         piece of work.
       - the 'screen' parameter to lineptr() in terminal.c, where 0 and 1
         represent the default and alternate screens. There's no obvious
         reason why one of those should be considered 'true' or 'positive'
         or 'success' - they're just indices - so I've left it as int.
      
      ssh_scp_recv had particularly confusing semantics for its previous int
      return value: its call sites used '<= 0' to check for error, but it
      never actually returned a negative number, just 0 or 1. Now the
      function and its call sites agree that it's a bool.
      
      In a couple of places I've renamed variables called 'ret', because I
      don't like that name any more - it's unclear whether it means the
      return value (in preparation) for the _containing_ function or the
      return value received from a subroutine call, and occasionally I've
      accidentally used the same variable for both and introduced a bug. So
      where one of those got in my way, I've renamed it to 'toret' or 'retd'
      (the latter short for 'returned') in line with my usual modern
      practice, but I haven't done a thorough job of finding all of them.
      
      Finally, one amusing side effect of doing this is that I've had to
      separate quite a few chained assignments. It used to be perfectly fine
      to write 'a = b = c = TRUE' when a,b,c were int and TRUE was just a
      the 'true' defined by stdbool.h, that idiom provokes a warning from
      gcc: 'suggest parentheses around assignment used as truth value'!
      3214563d
    • Simon Tatham's avatar
      Switch some Conf settings over to being bool. · 1378bb04
      Simon Tatham authored
      I think this is the full set of things that ought logically to be
      boolean.
      
      One annoyance is that quite a few radio-button controls in config.c
      address Conf fields that are now bool rather than int, which means
      that the shared handler function can't just access them all with
      conf_{get,set}_int. Rather than back out the rigorous separation of
      int and bool in conf.c itself, I've just added a similar alternative
      handler function for the bool-typed ones.
      1378bb04
    • Simon Tatham's avatar
      Adopt C99 <stdbool.h>'s true/false. · a6f1709c
      Simon Tatham authored
      This commit includes <stdbool.h> from defs.h and deletes my
      traditional definitions of TRUE and FALSE, but other than that, it's a
      100% mechanical search-and-replace transforming all uses of TRUE and
      FALSE into the C99-standardised lowercase spellings.
      
      No actual types are changed in this commit; that will come next. This
      is just getting the noise out of the way, so that subsequent commits
      can have a higher proportion of signal.
      a6f1709c
  11. Oct 25, 2018
    • Simon Tatham's avatar
      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
  12. Oct 11, 2018
    • Simon Tatham's avatar
      New abstraction 'Seat', to pass to backends. · b4c8fd9d
      Simon Tatham authored
      This is a new vtable-based abstraction which is passed to a backend in
      place of Frontend, and it implements only the subset of the Frontend
      functions needed by a backend. (Many other Frontend functions still
      exist, notably the wide range of things called by terminal.c providing
      platform-independent operations on the GUI terminal window.)
      
      The purpose of making it a vtable is that this opens up the
      possibility of creating a backend as an internal implementation detail
      of some other activity, by providing just that one backend with a
      custom Seat that implements the methods differently.
      
      For example, this refactoring should make it feasible to directly
      implement an SSH proxy type, aka the 'jump host' feature supported by
      OpenSSH, aka 'open a secondary SSH session in MAINCHAN_DIRECT_TCP
      mode, and then expose the main channel of that as the Socket for the
      primary connection'. (Which of course you can already do by spawning
      'plink -nc' as a separate proxy process, but this would permit it in
      the _same_ process without anything getting confused.)
      
      I've centralised a full set of stub methods in misc.c for the new
      abstraction, which allows me to get rid of several annoying stubs in
      the previous code. Also, while I'm here, I've moved a lot of
      duplicated modalfatalbox() type functions from application main
      program files into wincons.c / uxcons.c, which I think saves
      duplication overall. (A minor visible effect is that the prefixes on
      those console-based fatal error messages will now be more consistent
      between applications.)
      b4c8fd9d
  13. Oct 10, 2018
    • Simon Tatham's avatar
      Refactor the LogContext type. · ad0c502c
      Simon Tatham authored
      LogContext is now the owner of the logevent() function that back ends
      and so forth are constantly calling. Previously, logevent was owned by
      the Frontend, which would store the message into its list for the GUI
      Event Log dialog (or print it to standard error, or whatever) and then
      pass it _back_ to LogContext to write to the currently open log file.
      Now it's the other way round: LogContext gets the message from the
      back end first, writes it to its log file if it feels so inclined, and
      communicates it back to the front end.
      
      This means that lots of parts of the back end system no longer need to
      have a pointer to a full-on Frontend; the only thing they needed it
      for was logging, so now they just have a LogContext (which many of
      them had to have anyway, e.g. for logging SSH packets or session
      traffic).
      
      LogContext itself also doesn't get a full Frontend pointer any more:
      it now talks back to the front end via a little vtable of its own
      called LogPolicy, which contains the method that passes Event Log
      entries through, the old askappend() function that decides whether to
      truncate a pre-existing log file, and an emergency function for
      printing an especially prominent message if the log file can't be
      created. One minor nice effect of this is that console and GUI apps
      can implement that last function subtly differently, so that Unix
      console apps can write it with a plain \n instead of the \r\n
      (harmless but inelegant) that the old centralised implementation
      generated.
      
      One other consequence of this is that the LogContext has to be
      provided to backend_init() so that it's available to backends from the
      instant of creation, rather than being provided via a separate API
      call a couple of function calls later, because backends have typically
      started doing things that need logging (like making network
      connections) before the call to backend_provide_logctx. Fortunately,
      there's no case in the whole code base where we don't already have
      logctx by the time we make a backend (so I don't actually remember why
      I ever delayed providing one). So that shortens the backend API by one
      function, which is always nice.
      
      While I'm tidying up, I've also moved the printf-style logeventf() and
      the handy logevent_and_free() into logging.c, instead of having copies
      of them scattered around other places. This has also let me remove
      some stub functions from a couple of outlying applications like
      Pageant. Finally, I've removed the pointless "_tag" at the end of
      LogContext's official struct name.
      ad0c502c
  14. Sep 20, 2018
    • Simon Tatham's avatar
      Clean up a 'void *' in a unix.h typedef. · 7efa4a53
      Simon Tatham authored
      'struct draw_ctx' has a structure tag inside gtkwin.c, so as per this
      week's standard practice, let's expose the tag elsewhere so that
      pointers declared that way can't be confused with anything else.
      7efa4a53
  15. Sep 19, 2018
    • Simon Tatham's avatar
      Introduce a typedef for frontend handles. · 8dfb2a11
      Simon Tatham authored
      This is another major source of unexplained 'void *' parameters
      throughout the code.
      
      In particular, the currently unused testback.c actually gave the wrong
      pointer type to its internal store of the frontend handle - it cast
      the input void * to a Terminal *, from which it got implicitly cast
      back again when calling from_backend, and nobody noticed. Now it uses
      the right type internally as well as externally.
      8dfb2a11
    • Simon Tatham's avatar
      Expose the Ldisc structure tag throughout the code. · e72e8ebe
      Simon Tatham authored
      That's one fewer anonymous 'void *' which might be accidentally
      confused with some other pointer type if I misremember the order of
      function arguments.
      
      While I'm here, I've made its pointer-nature explicit - that is,
      'Ldisc' is now a typedef for the structure type itself rather than a
      pointer to it. A stylistic change only, but it feels more natural to
      me these days for a thing you're going to eventually pass to a 'free'
      function.
      e72e8ebe
  16. May 26, 2018
    • Simon Tatham's avatar
      Make lots of generic data parameters into 'void *'. · 7babe66a
      Simon Tatham authored
      This is a cleanup I started to notice a need for during the BinarySink
      work. It removes a lot of faffing about casting things to char * or
      unsigned char * so that some API will accept them, even though lots of
      such APIs really take a plain 'block of raw binary data' argument and
      don't care what C thinks the signedness of that data might be - they
      may well reinterpret it back and forth internally.
      
      So I've tried to arrange for all the function call APIs that ought to
      have a void * (or const void *) to have one, and those that need to do
      pointer arithmetic on the parameter internally can cast it back at the
      top of the function. That saves endless ad-hoc casts at the call
      sites.
      7babe66a
  17. Dec 16, 2017
    • Simon Tatham's avatar
      Add a system of clipboard identifiers. · 18297196
      Simon Tatham authored
      This lays some groundwork for making PuTTY's cut and paste handling
      more flexible in the area of which clipboard(s) it reads and writes,
      if more than one is available on the system.
      
      I've introduced a system of list macros which define an enumeration of
      integer clipboard ids, some defined centrally in putty.h (at present
      just a CLIP_NULL which never has any text in it, because that seems
      like the sort of thing that will come in useful for configuring a
      given copy or paste UI action to be ignored) and some defined per
      platform. All the front end functions that copy and paste take a
      clipboard id, and the Terminal structure is now configured at startup
      to tell it which clipboard id it should paste from on a mouse click,
      and which it should copy from on a selection.
      
      However, I haven't actually added _real_ support for multiple X11
      clipboards, in that the Unix front end supports a single CLIP_SYSTEM
      regardless of whether it's in OS X or GTK mode. So this is currently a
      NFC refactoring which does nothing but prepare the way for real
      changes to come.
      18297196
  18. Dec 10, 2017
    • Simon Tatham's avatar
      Stop front ends remembering the data of their last paste. · f26654f6
      Simon Tatham authored
      Previously, both the Unix and Windows front ends would respond to a
      paste action by retrieving data from the system clipboard, converting
      it appropriately, _storing_ it in a persistent dynamic data block
      inside the front end, and then calling term_do_paste(term), which in
      turn would call back to the front end via get_clip() to retrieve the
      current contents of that stored data block.
      
      But, as far as I can tell, this was a completely pointless mechanism,
      because after a data block was written into this storage area, it
      would be immediately used for exactly one paste, and then never
      accessed again until the next paste action caused it to be freed and
      replaced with a new chunk of pasted data.
      
      So why on earth was it stored persistently at all, and why that
      callback mechanism from frontend to terminal back to frontend to
      retrieve it for the actual paste action? I have no idea. This change
      removes the entire system and replaces it with the completely obvious
      alternative: the character-set-converted version of paste data is
      allocated in a _local_ variable in the frontend paste functions,
      passed directly to term_do_paste which now takes (buffer,length)
      parameters, and freed immediately afterwards. get_clip() is gone.
      f26654f6
  19. Nov 26, 2017
    • Simon Tatham's avatar
      Get rid of fatalbox() completely. · 4f3f4ed6
      Simon Tatham authored
      It's an incoherent concept! There should not be any such thing as an
      error box that terminates the entire program but is not modal. If it's
      bad enough to terminate the whole program, i.e. _all_ currently live
      connections, then there's no point in permitting progress to continue
      in windows other than the affected one, because all windows are
      affected anyway.
      
      So all previous uses of fatalbox() have become modalfatalbox(), except
      those which looked to me as if they shouldn't have been fatal in the
      first place, e.g. lingering pieces of error handling in winnet.c which
      ought to have had the severity of 'give up on this particular Socket
      and close it' rather than 'give up on the ENTIRE UNIVERSE'.
      4f3f4ed6
  20. Oct 19, 2017
  21. Oct 05, 2017
    • Simon Tatham's avatar
      Support OSC 4 terminal colour-palette queries. · 47437984
      Simon Tatham authored
      Markus Gans points out that some applications which (not at all
      unreasonably) don't trust $TERM to tell them the full capabilities of
      their terminal will use the sequence "OSC 4 ; nn ; ? BEL" to ask for
      the colour-palette value in position nn, and they may not particularly
      care _what_ the results are but they will use them to decide whether
      the right number of colour palette entries even exist.
      47437984
  22. Sep 30, 2017
    • Simon Tatham's avatar
      Support ESC[38;2;R;G;Bm for 24-bit true colour. · a4cbd3df
      Simon Tatham authored
      This is a heavily rewritten version of a patch originally by Lorenz
      Diener; it was tidied up somewhat by Christian Brabandt, and then
      tidied up more by me. The basic idea is to add to the termchar
      structure a pair of small structs encoding 24-bit RGB values, each
      with a flag indicating whether it's turned on; if it is, it overrides
      any other specification of fg or bg colour for that character cell.
      
      I've added a test line to colours.txt containing a few example colours
      from /usr/share/X11/rgb.txt. In fact it makes quite a good demo to run
      the whole of rgb.txt through this treatment, with a command such as
      
        perl -pe 's!^\s*(\d+)\s+(\d+)\s+(\d+).*$!\e[38;2;$1;$2;$3m$&\e[m!' rgb.txt
      a4cbd3df
  23. Feb 22, 2017
    • Simon Tatham's avatar
      Unix buildinfo: stop saying 'GTK' in pure CLI utilities. · 3f29d939
      Simon Tatham authored
      Unix PSCP, PSFTP, Plink and PuTTYgen now just report their build
      platform as '64-bit Unix' or '32-bit Unix', without mentioning
      irrelevant details of what flavour of GTK the other tools in the suite
      might have been built against.
      
      (In particular, they now won't imply anything outright untrue if there
      was no GTK present at build time at all!)
      3f29d939
  24. May 03, 2016
  25. Oct 28, 2015
Loading