• Post Reply Bookmark Topic Watch Topic
  • New Topic

API for CLI apps?  RSS feed

 
Gabe Herbert
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a special name for apps that use a command-line, yet "graphical" interface? My thinking ranges from old DOS apps to modern things like vim, top, dselect, etc. Basically, the unique factor that I'm observing is that they aren't simply limited to drawing new lines of text. How do you place text at certain locations on the screen?

Gabe
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For apps that you access through a terminal (hardward or software, like telnet), you can print special codes that control location and color. For example, the VT-220 has a set of codes for this, if I remember correctly. I never programmed them, but used apps that used them.

For the Windows command shell, you'd need to look up what codes it accepts. I would suspect a lot of the original DOS modes are supported.

Definitely in the first case and I would bet in the second case, it's simply a matter of printing various ASCII characters to the console. The shell/terminal interprets them and takes the correct action. If you're in the wrong medium, though, you'll see garbage.

While it didn't directly answer your question, hopefully it gave you enough terms to narrow down a search. Try "terminal escape codes" and "ANSI graphics".
[ April 28, 2005: Message edited by: David Harkness ]
 
M Beck
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
of course, writing special escape sequences every time you want to move the cursor, change color, and so on, quickly becomes a chore. if you're willing instead to take on the chore of including a native-code library in your application and accessing it through JNI, then you can go googling for "java curses" and see what you find.

the "curses" library is a neat thing we get from the Unix tradition that abstracts away all those pesky escape sequences, and also tries to handle device dependencies (different computers wanting different escape sequences for the same thing). it should be much nicer to code for than plain old escape sequences — but, of course, you'll have to cope instead with JNI and native code.
[ April 28, 2005: Message edited by: M Beck ]
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you! I've been trying to remember the name "curses" since I posted that. Guess I should have cursed more.
 
Gabe Herbert
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the pointers, I've found a jcurses library that looks potentially promising.

Gabe
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!