Baron-von-Riedesel / DOS-debug

Debug and DebugX (short: Debug/X) are extended versions of MS DEBUG
58 stars 12 forks source link

Recall previous inputs with up/down arrows #1

Open jwt27 opened 4 years ago

jwt27 commented 4 years ago

This patch implements recalling previously typed commands with the up and down arrow keys, as is common in most shells and other debuggers.

Binary size is increased by 244 bytes and memory requirement by 516 bytes (adjustable with LINE_HISTORY_LEN).

ecm-pushbx commented 3 years ago

After implementing my own history recall feature in lDebug I compared yours in this PR to mine. Differences:

  1. I use 2 bytes for an offset per entry, you are using 4 bytes for the next/previous pointers

  2. I don't store the terminating CR as you seem to

  3. I don't have to scan a history entry to find its size

  4. I don't bother skipping leading whitespace

  5. I default to allocate the buffer in its own segment instead of in the debugger's data segment

  6. I started with 1 KiB for the data segment buffer and increased the size to 8 KiB for the additional segment buffer, whereas you use about 500 bytes by default

  7. I only allow using Up or Down to navigate the history recall if no editing took place yet

  8. It appears your history recall is only for rawinput, that is if inDOS is set. This is similar to mine, but I document that and provide ways to enable using rawinput even if the input is from a DOS stdin terminal

  9. I allow more than one way to encode the Up/Down arrow keypresses which makes it work on dosemu in -dumb mode

Similarities also include rejecting empty lines and those duplicating the prior line.

ecm-pushbx commented 3 years ago

Correction: It appears your patch does away with the interrupt 21h service 0Ah call entirely and always uses interrupt 16h to read input. In my implementation DOS application terminal input is still done with the DOS service by default, which means the debugger's line history is not available. (I do enter received lines into the history buffer regardless.) And if rawinput is used (eg DCO flag 800h set) then it can still use interrupt 21h to read input, but using services which read single bytes from stdin.