AnsweredAssumed Answered

Terminal text menu code example?

Question asked by FridgeFreezer on Mar 7, 2012
Latest reply on Aug 10, 2012 by FridgeFreezer

Background: Our project has a text-based menu which is displayed on a screen and navigated by using a joystick (up, down, left, right) to configure settings etc.

 

A hardware change may remove the screen from the project, so as an alternative we're looking at sending the same menu out over the serial port to allow user control via a terminal program.

 

Now, the communications part is done (we can send & recieve data), and the menu structure and navigation is there (we can traverse a menu structure & modify variables) but the issue is correctly controlling the terminal output to re-write the screen / move the cursor (however it's easiest to make it work) rather than spit out multiple pages.

 

Example:

 

If you have this menu output on the serial port:

MENU>1 = Login 2 = Setup 3 = Options 4 = Help 5 = Exit

 

 

And then maybe press the "down" key or enter "4", the software would have to re-send the text again:

MENU 1 = Login 2 = Setup 3 = Options>4 = Help 5 = Exit

 

But that means your terminal screen (EG hyperterm) now looks like this:

MENU>1 = Login 2 = Setup 3 = Options 4 = Help 5 = Exit4MENU 1 = Login 2 = Setup 3 = Options>4 = Help 5 = Exit

 I've found some stuff on Google about VT100 escape codes etc. but not a lot of source code / examples, it seems to be such a common thing (built into everything Linux etc.) that no-one ever codes it themselves or if they do they don't feel it's worth mentioning.

 

So, before I try to roll my own from scratch, does anyone have any VT100 or similar routines/examples?

Outcomes