Code fix for the "slow ESC" key input in old variants?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • smbhax
    Swordsman
    • Oct 2021
    • 340

    Code fix for the "slow ESC" key input in old variants?

    Old variants such as Hellband and Zangband process ESC key input only after a momentary delay, at least in Curses mode; the "tilde" key just below ESC does the same thing, but operates immediately.

    Is there a general code fix for the slow ESC key input in these variants?
    Last edited by smbhax; January 22, 2022, 03:11.
    My Angband videos
  • Gwarl
    Administrator
    • Jan 2017
    • 1025

    #2
    seems like it was fixed some time between vanilla 3.2.0 and vanilla 3.4.1. I daren't check 3.3.0 right now

    Comment

    • wobbly
      Prophet
      • May 2012
      • 2629

      #3
      If its the same problem oangband has I get round it by macro-ing the escape key to the escape key. Don't know why that works, just seems to.

      Comment

      • smbhax
        Swordsman
        • Oct 2021
        • 340

        #4
        Originally posted by Gwarl
        seems like it was fixed some time between vanilla 3.2.0 and vanilla 3.4.1. I daren't check 3.3.0 right now
        Intriguing!

        Originally posted by wobbly
        If its the same problem oangband has I get round it by macro-ing the escape key to the escape key. Don't know why that works, just seems to.
        Oh that's interesting. I tried doing some kind of ESC/tilde keymap in Zangband but couldn't seem to get it to take, same with an ESC-ESC one. I don't know my way around macros very well, though.
        My Angband videos

        Comment

        • smbhax
          Swordsman
          • Oct 2021
          • 340

          #5
          Current Angband has a section in src/main-gcu.c starting with this disclaimer

          Code:
          	/* This might be a bad idea, but...
          	 *
          	 * Here we try to second-guess ncurses. In some cases, keypad() mode will
          	 * fail to translate multi-byte escape sequences into things like number-
          	 * pad actions, function keys, etc. So we can hardcode a small list of some
          	 * of the most common sequences here, just in case.
          and including

          Code:
          		case 27:        i = ESCAPE; break;
          and similar statements for arrow keys, keypad keys, etc. Zangband's src/main-gcu.c has no analogous section as far as I can tell. Perhaps this section has something to do with it?

          Angband's also has
          Code:
          	/* We do it like this to prevent a link error with curseses that
          	 * lack ESCDELAY. */
          	if (!getenv("ESCDELAY")) {
          #if _POSIX_C_SOURCE < 200112L
          		static char escdelbuf[80] = "ESCDELAY=20";
          		putenv(escdelbuf);
          #else
          		setenv("ESCDELAY", "20", 1);
          #endif
          	}
          which looked tantalizing, but just dropping it in Zangband did not magically cure the sluggish ESC key. ;; )
          Last edited by smbhax; January 23, 2022, 05:20.
          My Angband videos

          Comment

          • smbhax
            Swordsman
            • Oct 2021
            • 340

            #6
            Originally posted by Gwarl
            seems like it was fixed some time between vanilla 3.2.0 and vanilla 3.4.1. I daren't check 3.3.0 right now
            I went to try out the releases in this range but for all of them got "multiple definitions" compile errors concerning z-file.h or z-term.h, so I have been of no use.
            My Angband videos

            Comment

            • smbhax
              Swordsman
              • Oct 2021
              • 340

              #7
              In build notes, the only thing that jumped out at me--not that I know that I'm looking for--is that 3.4.0 included "Upgrade to UTF-8."

              Oh and "Fix GCU port to recognise backspace and del as distinct keys."
              My Angband videos

              Comment

              • smbhax
                Swordsman
                • Oct 2021
                • 340

                #8
                Modern ESC key support was added to Angband by stefanor@cox.net on January 22, 2009 in https://github.com/angband/angband/c...f76cc30dcb9bc5

                Their description of that commit is

                * Make pseudo graphics the default for main-gcu, as they are for the other ports.
                * Changed the default macros to use the new pre-processed keys, thus mostly eliminating the "escape delay" and being more portable.
                * Implement support for the curses "alternate character set", used for pseudographics e.g. by nethack 'DECgraphics'. The high bit of characters is repurposed for this, hopefully the Eastern Europe community won't mind.
                * We now use curses to parse keys, which does a much better job than the old "abuse of macro system". More portable and significantly faster, especially for Escape.
                * Unprintable characters are blotted with ?s, removing another irritating display glitch from the visual editor.
                It DOES include that "ESCDELAY" section in main-gcu.c.

                It went out in Angband 3.1.1, 26th July 2009, noted specifically as

                Use curses to parse keys, which is more portable and removes the Escape delay
                under the heading "Curses port."

                For an example of how it was incorporated into a variant that had forked from an earlier version of Angband: PosChengband incorporated it on February 25, 2015 as "Curses Port: Fix unacceptable delay on ESC keypress" https://github.com/NickMcConnell/pos...6af5a176ec0661, with changes to main-gcu.c, util.c, and externs.h; there were also changes to Makefile, main.c, and z-config.h in that commit, but those may have been incidental.
                Last edited by smbhax; February 1, 2022, 02:46.
                My Angband videos

                Comment

                Working...
                😀
                😂
                🥰
                😘
                🤢
                😎
                😞
                😡
                👍
                👎