I want a String Control on my Front Panel to emulate the behavior of a command line interface.
Some features might include:
- ability to cycle through previous commands using 'up' and 'down' arrow keys
- prevention of cursor moving further back than the most recent prompt
- pressing 'Enter' sends the user-entered text after the most recent prompt for processing (e.g. enqueues it for consumption by a parallel loop), and displays reponse when ready, before displaying the subsequent prompt
I have a few ideas about the best / cleanest way of implementing this, but it would be good to hear any suggestions.
I'd just make an event case with both the "Key Down" and "Key Repeat" events. Store the previous commands array in the shift register.
VKey "Left" goes past prompt? Wire "T" into "Discard?". Up key? Index previous commands array, write to value ... etc.
I would suggest using a string indicator to prevent character insertion anywhere but the end of the string buffer. You'll use the key events to maintain a string array in a while loop that updates the indicator after various key events. Add a new end-of-line and prompt string array element when the "Return" key is detected. Discard further event processing as appropriate for certain keys. Here's a possible starting point: