Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Question about write a simple shell : how to output resoult to tty correctly
Hi all

I am write a console based application.
Something like a "shell" :  enter string and parser explain it, (actually
like cisco's console).

I want my app can be controlled on tty via telnet/ssh. so what I want to
reach is quite like juniper's cli:
sense sample:

host%
host%./app

<APP/MODULE>
>command you input            // input command pre defined , it will cause
>"parser" parse it and execute it

Command "command you input"  executed!
This execute resoult here.


<APP/MODULE>
>                             // giving prompt and waiting command again

<APP/MODULE>
>exit
sure to exit (y/n) y

host%


=======================================

My basic design idea:
"
tty? <------    OutputBuffer        <-------  app
|             ^
|             |
|-----> VirtualKeyboard     ------->  parser --------> execute

"


I think what I needed is, maybe like  a cli text editor. so I am trying to
read source code of "vi" ,but too much for me -- sorry to say , out of my
mind.

then I am trying to using "ncurses" ,and I found using ncurses's WINDOW* and
set it's y-x manually make more complex mechanism .(scroll screen, echoback
etc.)
also directly using it may cause wrong display on other telnet
client.(tested the "Digipad")


My confuse is between tty and OutBuffer , how to make my OutBuffer class
link with tty more easier ? (may be just like std::cout.)


And what's the next step I should do? any suggest?

Sorry for my knowledge on tty/unix,I am trying.



Thank you very much.


key9






Report this thread to moderator Post Follow-up to this message
Old Post
key9
05-17-06 12:09 AM


Re: Question about write a simple shell : how to output resoult to tty correctly
thank you for your reply;

> Are you trying to write a shell in C++?
something like that

> why you should resort to ncurses or anything other than std::cin and
> std::cout to do your command I/O.

>If you are trying to implement some
> kind of command line editing, then you might want to set the tty into
> "raw" mode to allow you to override the built-in editing.  If you are
> not trying to implement command line editing, then why not just stick
> with stdio?


May be the story beginning from my self educated roadmap of how
rogramming  -- 2 year ,a reversed way:

"OO design  ; C++  ; STD; design patterns ; ACE ; UNIX/LINUX BASIC(fd thread
process mutex...);UNIX SOCKET ; UNIX IO, gnu clib...)
(no C experience,start from little/almost no programming experience)

So my application is design/running on my mind for 2 years.

before coding ,I don't think I/O is a problem until I met I must scan "a
keypress" to make my parser to determine action. std::cin have no this
function(getch()),
also I want my app(actually it can be called a  Library) can running on
other OS . either GUI and CLI , so there must be a adapter layer.(use
"string" to link them)

I found I have to design an other lib to adapter UNIX I/O,

and may be due to greed, I want lib have "ERR  , DEBUG , COUT_..."belong to
itself , they can display on same screen or sparated, or dump to file ,so
it's may be need a window manager.
.......
......
......

finally I lost my mind , my pool knowledge about ui design drive me crazy.
reinvent the big wheel?

so I found "ncurses" and pin my hope on it , and after serval day's trying ,
almost there , but still have problem --- telnet can not display it
correctly.... crazy again. ^_^

......


As you see I am a "dabbler" now ,especially  no experience on C  :-) . may
be afraid , may be just too lazy to study "tty" it self.


now I am reading "Joe's Own Editor" , I  hope after another serval days , I
can master it.


ps: I didn't found there's a c++ lib can do such things -----(pure code) a
chartype  window manager ,support sub window ,with string to as display ,can
adapter with basic IO . etc...
to wrote it is too expensive for me , if you know one , please tell me.













Report this thread to moderator Post Follow-up to this message
Old Post
key9
05-17-06 12:09 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Unix Programming archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 06:09 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.