[Tutor] Building a simple text editor
Asrarahmed Kadri
ajkadri at googlemail.com
Sat Oct 14 17:04:02 CEST 2006
Is it possible to make the utility like in vi, where the user keeps on
entering the data and when he hits ':wq', the work is saved and the
application exists.
I guess the use of standard input file would be applicable???
Thanks.
Regrds,
Asrar
On 10/14/06, Alan Gauld <alan.gauld at btinternet.com> wrote:
>
> > I am trying to build a simple text editor which has a couple of
> > options of
> > editing, displaying and saving the file.
>
> Are you using a GUI or console?
> The solution is potentially quite different depending on the choice.
>
> > Now what I want to do is to allow teh user to keep entering the text
> > unless
> > he pressed ':q'.
>
> How are you reading the characters in the first place?
>
> if you can find a way to read characters from the keyboard
> one at a time then
>
> while True
> ch = getchar()
> if ch ==':'
> ch = getchar()
> if ch == 'q': break
>
> Will work.
>
> So the question becomers do you know how to write getchar()?
>
> Alan G.
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
--
To HIM you shall return.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20061014/d827feb4/attachment.html
More information about the Tutor
mailing list