9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] Implementing cooked mode
@ 2006-12-21  0:54 Joel Salomon
  2006-12-21  1:08 ` Russ Cox
  2006-12-21  2:27 ` [9fans] " Joel Salomon
  0 siblings, 2 replies; 8+ messages in thread
From: Joel Salomon @ 2006-12-21  0:54 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

If a program has the console in raw mode, can it erase characters or
words that it has echoed to the screen?

Context is a homework assignment to implement cooked mode in user
space.  The code in /sys/src/cmd/rio/wind.c looks to be a start, but I
don't see how to remove characters from the screen.  I suppose I could
use string() in libdraw and draw the string graphically rather than
echoing.  Rio's wind.c and acme's text.c both handle the various
control characters, but they aren't pretending to write to the
console.

Nemo's book has a similar assignment, so it seems to be doable; I just
haven't found how in the manual.

Failing that, are there printable glyphs shown if control characters
are write()n to the console?

--Joel


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [9fans] Implementing cooked mode
  2006-12-21  0:54 [9fans] Implementing cooked mode Joel Salomon
@ 2006-12-21  1:08 ` Russ Cox
  2006-12-21  1:47   ` Russ Cox
  2006-12-21  2:27 ` [9fans] " Joel Salomon
  1 sibling, 1 reply; 8+ messages in thread
From: Russ Cox @ 2006-12-21  1:08 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> If a program has the console in raw mode, can it erase characters or
> words that it has echoed to the screen?

No.

Russ


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [9fans] Implementing cooked mode
  2006-12-21  1:08 ` Russ Cox
@ 2006-12-21  1:47   ` Russ Cox
  2006-12-21 12:50     ` Brantley Coile
  0 siblings, 1 reply; 8+ messages in thread
From: Russ Cox @ 2006-12-21  1:47 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> > If a program has the console in raw mode, can it erase characters or
> > words that it has echoed to the screen?
>
> No.

This is actually only half true.  You can echo backspaces and it will
erase up to the beginning of the line, but no earlier.

Russ


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [9fans] Re: Implementing cooked mode
  2006-12-21  0:54 [9fans] Implementing cooked mode Joel Salomon
  2006-12-21  1:08 ` Russ Cox
@ 2006-12-21  2:27 ` Joel Salomon
  2006-12-21  4:01   ` Russ Cox
  1 sibling, 1 reply; 8+ messages in thread
From: Joel Salomon @ 2006-12-21  2:27 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On 12/20/06, Joel Salomon <joelcsalomon@gmail.com> wrote:
> If a program has the console in raw mode, can it erase characters or
> words that it has echoed to the screen?

Oops. I meant a program running under rio, having written "rawon" to
/dev/consctl.

Experimentally, echoing backspaces does work—sort of—under rio.
Emphasis on the "sort of".  I'm going to stick with echoing the
control picture ␈ while doing the Right Thing™ to the buffer being
built up.  So entering:
	0123455<bs>6789
will echo:
	0123455␈6789
while filling the buffer with:
	0123456789
The program's due before midnight, so this implementation will have to do.

BTW: do all programs that accept passwords in (rio) console raw mode
have to implement the full cooking themselves?

--Joel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [9fans] Re: Implementing cooked mode
  2006-12-21  2:27 ` [9fans] " Joel Salomon
@ 2006-12-21  4:01   ` Russ Cox
  0 siblings, 0 replies; 8+ messages in thread
From: Russ Cox @ 2006-12-21  4:01 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> BTW: do all programs that accept passwords in (rio) console raw mode
> have to implement the full cooking themselves?

Yes, but there is a library routine to ask for a password.
Also, very few programs actually read passwords -- usually
factotum does it for them.

Russ


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [9fans] Implementing cooked mode
  2006-12-21  1:47   ` Russ Cox
@ 2006-12-21 12:50     ` Brantley Coile
  0 siblings, 0 replies; 8+ messages in thread
From: Brantley Coile @ 2006-12-21 12:50 UTC (permalink / raw)
  To: 9fans

>> > If a program has the console in raw mode, can it erase characters or
>> > words that it has echoed to the screen?
>>
>> No.
> 
> This is actually only half true.  You can echo backspaces and it will
> erase up to the beginning of the line, but no earlier.
> 
> Russ

I was about to point this out.  We had to implement a reasonable subset
of readline for the SR EtherDrive firmware, if you can have the words
reasonable and readline in the same sentence.  People kept hitting ^P
to back up a line in history, causing an unexpected reboot. ☹

I stuck it in rc(1) and put rc in raw mode.  Not for public consumption, which
is a good thing. ☺



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [9fans] Implementing cooked mode
  2006-12-21  1:37 [9fans] " erik quanstrom
@ 2007-02-15 17:44 ` Harri Haataja
  0 siblings, 0 replies; 8+ messages in thread
From: Harri Haataja @ 2007-02-15 17:44 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Wed, Dec 20, 2006 at 08:37:31PM -0500, erik quanstrom wrote:
> plan 9 has a different attitude about the console than linux.
> one can't interrupt a program running at a console.  the console
> is there for bringing a machine up.  nobody wants to work at the
> console.

You can't actually interrupt a program on console in Linux either,
unless you have init and things running underneath.

It's only funny so many times to forget to give a count to ping when
doing .. something .. in the initrd shell before it mounts root.

-- 
Topi ajatteli hoitaa kuntoaan polkemalla televisiota
katsellessa kuntopyörää.
	-- Ilta-Sanomat 19.2.94


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [9fans] Implementing cooked mode
@ 2006-12-21  1:37 erik quanstrom
  2007-02-15 17:44 ` Harri Haataja
  0 siblings, 1 reply; 8+ messages in thread
From: erik quanstrom @ 2006-12-21  1:37 UTC (permalink / raw)
  To: joelcsalomon, 9fans

russ is right.  raw mode on the console is really raw.  control
characters are printed out.  if you've got a pc, you'll see ibm-432
characters.

plan 9 has a different attitude about the console than linux.
one can't interrupt a program running at a console.  the console
is there for bringing a machine up.  nobody wants to work at the
console.

rio really does implement raw mode in userspace.  just because it's
doing things with string() -- "graphically" -- instead of opening up /dev/x
and using write(2) on that device doesn't make it less of a raw
interface in userspace.  in fact, string(2) is using write on /dev/draw
under the covers.

compare pc/cga.c with what rio does with the screen.  the main
difference is that the byte value is written to a memory location
in cga.c whereas rio needs to write a raster image to a block of
memory.  logically, it's a similar operation. ...

just because you're not bit-banging the 8042 and moving bytes
into the cga window, doesn't mean it's not in "raw" mode. ;-)

- erik

On Wed Dec 20 19:55:34 EST 2006, joelcsalomon@gmail.com wrote:
> If a program has the console in raw mode, can it erase characters or
> words that it has echoed to the screen?
> 
> Context is a homework assignment to implement cooked mode in user
> space.  The code in /sys/src/cmd/rio/wind.c looks to be a start, but I
> don't see how to remove characters from the screen.  I suppose I could
> use string() in libdraw and draw the string graphically rather than
> echoing.  Rio's wind.c and acme's text.c both handle the various
> control characters, but they aren't pretending to write to the
> console.
> 
> Nemo's book has a similar assignment, so it seems to be doable; I just
> haven't found how in the manual.
> 
> Failing that, are there printable glyphs shown if control characters
> are write()n to the console?
> 
> --Joel



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-02-15 17:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-21  0:54 [9fans] Implementing cooked mode Joel Salomon
2006-12-21  1:08 ` Russ Cox
2006-12-21  1:47   ` Russ Cox
2006-12-21 12:50     ` Brantley Coile
2006-12-21  2:27 ` [9fans] " Joel Salomon
2006-12-21  4:01   ` Russ Cox
2006-12-21  1:37 [9fans] " erik quanstrom
2007-02-15 17:44 ` Harri Haataja

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).