Re: [9fans] More about /dev/draw

2016-05-30 Thread Richard Miller
> When I do cat
> /dev/draw/new, it's telling me it's an r6g5b6 channel while in drawterm
> it's x8r8g8b8. ...
> 
> Is there anything I can do about this?

You can set the screen depth to 24 on the pi instead of the default 16.
Set vgasize=WxHx24 in cmdline.txt where W and H are your screen dimensions.

When I tried this the colours were reversed.  I think the videocore
firmware must have changed from BGR to RGB some time since I last
looked.  I will look into this.  Meanwhile a quick fix is

diff /n/dump/2016/0530/sys/src/9/bcm/screen.c /sys/src/9/bcm/screen.c
342c342
<   chan = BGR24;
---
>   chan = RGB24;




Re: [9fans] More about /dev/draw

2016-05-30 Thread cinap_lenrek
6+5+6 is 17, not 16 bit. is this a typo or was r5g6b5 ment?

--
cinap



Re: [9fans] More about /dev/draw

2016-05-30 Thread Richard Miller
> I think the videocore
> firmware must have changed from BGR to RGB some time since I last
> looked.  I will look into this.

Yes, someone on the netbsd mailing list noticed (Jan 2015):

> Newer Raspberry Pi firmware has changed the framebuffer from BGR to RGB.
> The method we use to set the pixel order (vcprop set pixel order) does not
> seem to work, nor does querying the pixel order (vcprop get pixel order).
> 
> The firmware passes this information to the kernel by adding a
> "bcm2708_fb.fbswap" kernel cmdline arg. 0=BGR, 1=RGB. ...

It turns out that the interface 9pi used for querying framebuffer depth
is also now broken.  Setting framebuffer_depth=N in config.txt used to
work for changing the pixel format, now it doesn't.

Sadly there's been a history of the pi firmware interface quietly changing
behind the scenes.  Making a corresponding quiet change to their linux
kernel seems to be considered sufficient documentation.  Sigh.




Re: [9fans] More about /dev/draw

2016-05-30 Thread Richard Miller
> It turns out that the interface 9pi used for querying framebuffer depth
> is also now broken.  Setting framebuffer_depth=N in config.txt used to
> work for changing the pixel format, now it doesn't.

OK, new 9pi and 9pi2 kernels in /n/sources/contrib/miller should now do
the right thing for 24bpp, which can be requested with framebuffer_depth=24
in config.txt or vgasize=WxHx24 in cmdline.txt




Re: [9fans] More about /dev/draw

2016-05-30 Thread Dave MacFarlane
Probably a typo, I was going from memory. I thought it was a multiple of 8
bits per component, not for the whole thing, so that (and a typo) would
explain it.

But the bigger problem was that even if you only have 1 bit for r, g, and b
you should be able to represent yellow as 110, so any r>1g>1b>1 should be
able to handle it.

On Mon, May 30, 2016 at 5:27 AM,  wrote:

> 6+5+6 is 17, not 16 bit. is this a typo or was r5g6b5 ment?
>
> --
> cinap
>
>


-- 
- Dave


Re: [9fans] More about /dev/draw

2016-05-30 Thread Dave MacFarlane
On Mon, May 30, 2016 at 8:37 AM, Richard Miller <9f...@hamnavoe.com> wrote:

> > It turns out that the interface 9pi used for querying framebuffer depth
> > is also now broken.  Setting framebuffer_depth=N in config.txt used to
> > work for changing the pixel format, now it doesn't.
>
> OK, new 9pi and 9pi2 kernels in /n/sources/contrib/miller should now do
> the right thing for 24bpp, which can be requested with framebuffer_depth=24
> in config.txt or vgasize=WxHx24 in cmdline.txt
>

I was pretty sure it was either a kernel or libmemdraw bug, but I don't
know how you can possibly
track these things down so quickly without even getting a proper bug
report.

- Dave


Re: [9fans] More about /dev/draw

2016-05-30 Thread Richard Miller
> I was pretty sure it was either a kernel or libmemdraw bug, but I don't
> know how you can possibly
> track these things down so quickly without even getting a proper bug
> report.

All I did was to recover the ability to set r8g8b8 mode on 9pi, after
a firmware change broke it.  I don't know whether this will actually
help with your bug or not.




[9fans] Chords, ^, _, ^B and scroll with mouse wheel in p9p sam

2016-05-30 Thread trebol55555
> What would you think about moving the named pipe from samterm into sam?

Sorry for the delay, but I have had to put all this together...

I haven't studied the source so much, but it seams that sam communicates
with samterm (if not -d), and samterm flows the IO to and from it. The
pipe looks more like a "Plan B" in case the plumber is not available in
the machine where samterm is running. The programmer (R. Pike) didn't
implement a directory tree served like that of acme, because -I think-
he just did it in acme, acme is for him -III think- the new version
of the Plan 9 editor. He uses sam only for long distance connections
-I think. The funny thing is that some people do not see this new
version of the editor as an improvement, but as a mess. But this is
always the same with editors, it's a matter of taste, until you can
write the perfect one (for you, only for you) you have to use some
editor, the less annoying to you, written by a good programmer to be
sure (or practically sure) that hours of your work are not going to the
trash can. The reason because I'm posting all these things about sam is
because it is becoming my "some good programmer's editor I'm going to
use by now", and other people can use my experience (or laugh at the
silliness of it), but I'm not expending much more time altering it. I
don't really like sam. I don't really like acme. I can't say I'll be
able to write something half as useful or well written as any of them,
but all that time is going to be employed in trying to do it.

Aaaany way, the pipe is very useful, combined with the plumber. For example:

-
# poor man's sam file browser
type is text
data matches '([.a-zA-Z¡-�0-9_/\-;&$,'']+)'
arg isdir $0
plumb start rc -c 'if(pgrep sam >/dev/null){cd '$dir'; DIR = `{pwd}; {echo 
''{}''; echo B $DIR/~~samdir~~; echo '', /tmp/.sam.$USER^*}; if not plumb -d edit '$dir''
-

I put several echo so it is more easy to copy to Plan 9.

If you are going to use it in the command window, be aware that you
are going to send other text to it, its good to put same thing like ,,,
before the directory path so it will give an harmless error.

I've found a funny bug in sam playing with this, when you start the
editor to open a file, if before drawing the file in a window you make
an error in the command window, the copy of the file will be blanked.
The file itself is ok, close it and reopen it (tested in Plan 9, 9front and 
P9P).

-
# poor man's sam exec in current file's cwd
type is text
data matches '(¤)([a-zA-ZÀ-ʨ¡-�0-9_\-./\+^,()$:|#%<>&'' ]+)'
plumb start rc -c 'if(pgrep sam >/dev/null){cd '$wdir'; {echo '$wdir' 
¤'''$2'''; echo; {'$2'}; echo}> /tmp/sam_ecfcwd_$pid >[2=1]; {echo ''{}''; echo 
B '$wdir'^/~~cmd~~; echo ''$''; echo; echo ''> /tmp/.sam.$USER^*}'
-

I have to make sam itself delete the temporal file because the file was
actually read after been deleted.

Try it plumbing

¤hget 
'http://plan9.bell-labs.com/wiki/plan9/Tip_o%27_the_day/index.html' | htmlfmt

The {} is the less dangerous string I've found to ensure a new line before 
sending the commands.

This version is more secure, because sam waits until the command finishes,
but annoying if the command execution time is large. I've change the shell
in sam/unix.c to use rc in p9p (I don't understand why the use of sh):

-
# poor man's sam exec in current file's cwd, version 2
#type is text
#data matches '(¤)([a-zA-ZÀ-ʨ¡-�0-9_\-./\+^,()$:|#%<>&'' ]+)'
#plumb start rc -c 'if(pgrep sam >/dev/null){cd '$wdir'; {echo ''{}''; echo B 
'$wdir'^/~~cmd~~; echo ''$''; echo ''[2=1]; echo''}> /tmp/.sam.$USER^*}'
-

And it's good to get man pages in named windows rapidly, specially in
referencies to other man pages when I'm reading one:

-
## man index entries are synthesized
type is text
data matches '([a-zA-ZÀ-ʨ¡-�0-9_-./+\-]+)\(([1-8])\)'
plumb start rc -c 'if(pgrep sam >/dev/null){{echo ''{}''; echo ''B 
~~'$1'('$2')~~''; echo ''[2=1] | nobs''}> /tmp/.sam.$USER^*}; 
if not {man '$2' '$1' >[2=1] | nobs | plumb -i -d edit -a ''action=showdata 
filename=/man/'$1'('$2')''}'
-

As you can see all these crappy rules work with acme in the usual way
if sam is not running.

In Plan 9, I've problems with sam reading from the plumb port when the pipe is 
created, so I've slightly modified B, and renamed E:
-
#!/bin/rc

files=()
dest=()

if(~ $#* 0){
echo usage: E file ... >[1=2]
exit usage
}

for(i)
switch($i){
case /*
files = ( $files $i )
case *
files = ( $files `{cleanname `{pwd}^/$i} )
}

# using sam srv file

if(test -f /mnt/term/srv/sam.$user) dest = /mnt/term/srv/sam.$user
if not if(test -f /srv/sam.$user) dest = /srv/sam.$user
if not {
echo E: can

[9fans] Chords, ^, _, ^B and scroll with mouse wheel in p9p sam

2016-05-30 Thread trebol55555
I posted wrong code for Plan 9 by error.

The E script:
-
#!/bin/rc

files=()
dest=()

if(~ $#* 0){
echo usage: E file ... >[1=2]
exit usage
}

for(i)
switch($i){
case /*
files = ( $files $i )
case *
files = ( $files `{cleanname `{pwd}^/$i} )
}

if(test -f /mnt/term/srv/sam.$user) dest = /mnt/term/srv/sam.$user
if not if(test -f /srv/sam.$user) dest = /srv/sam.$user
if not {
switch($files){
case *:*
for(i in $files){
fi = `{echo $i | sed 's/(.*):[^:]*/\1/'}
ad = `{echo $i | sed 's/.*:([^:]*)/\1/'}
plumb -d edit -a 'addr='$"ad'' $fi
}
case *
plumb -d edit $files
}
exit
}

switch($files){
case *:*
for(i in $files)
echo $i | sed 's/^/B /;s/:(.*)$/\n\1/g' >> $dest
case *
echo B $files >> $dest
}
-

The plumb rules:

-
# existing files, possibly tagged by line number, go to editor
type is text
data matches '([.a-zA-Z¡-�0-9_/+\-]*[a-zA-Z¡-�0-9_/+\-])('$addr')?'
arg isfile  $1
plumb start E $file:$3

## man index entries are synthesized
type is text
data matches '([a-zA-ZÀ-ʨ¡-�0-9_-./+\-]+)\(([1-8])\)'
plumb start rc -c 'if(test -f /mnt/term/srv/sam.$user) dest = 
/mnt/term/srv/sam.$user; if not if(test -f /srv/sam.$user) dest = 
/srv/sam.$user; if not {man '$2' '$1' >[2=1] | plumb -i -d edit -a 
''action=showdata filename=/man/'$1'('$2')''; exit}; {echo ''{}''; echo ''B 
~~'$1'('$2')~~''; echo ''[2=1]''} >>$dest'

# poor man's sam file browser
type is text
data matches '([.a-zA-Z¡-�0-9_/\-;&$,'']+)'
arg isdir $0
plumb start rc -c 'if(test -f /mnt/term/srv/sam.$user) dest = 
/mnt/term/srv/sam.$user; if not if(test -f /srv/sam.$user) dest = 
/srv/sam.$user; if not {plumb -d edit '$dir'; exit}; cd '$dir'; DIR = `{pwd}; 
{echo ''{}''; echo B $DIR/~~samdir~~; echo '',>/srv/sam.$user'

## poor man's sam exec in current file's cwd
type is text
data matches '(¤)([a-zA-ZÀ-ʨ¡-�0-9_\-./\+^,()$:|#%<>*&'' ]+)'
plumb start rc -c 'if(test -f /mnt/term/srv/sam.$user) dest = 
/mnt/term/srv/sam.$user; if not if(test -f /srv/sam.$user) dest = 
/srv/sam.$user; if not {echo cant find sam server file >[1=2]; exit open}; 
{cd '$wdir'; {echo '$wdir' ¤'''$2'''; echo; {'$2'}; echo} >/tmp/sam_ecfcwd_$pid 
>[2=1]; {echo ''{}''; echo B '$wdir'^/~~cmd~~; echo ''$''; echo ''>$dest}'
-

I've tested it in 9front, and all works good. Of course you can delete
all the acme part if you don't use it.

Remember that you have to edit samterm/io.c to create always the pipe

[...]
hoststart();
plumbstart();
extstart();
}

And in P9P you need to set the shell to rc in sam/unix.c
#define SHNAME "rc"
#define SHPATHNAME "/usr/local/plan9/bin/rc"

Or adapt the rules for sh...

trebol.