* [Edbrowse-dev] [acmebrowse] Mouse driven interface for edbrowse
@ 2014-07-30 12:40 Paul Onyschuk
2014-07-30 14:30 ` Chris Brannon
0 siblings, 1 reply; 4+ messages in thread
From: Paul Onyschuk @ 2014-07-30 12:40 UTC (permalink / raw)
To: edbrowse-dev
First of all I would like to thank for edbrowse - this is a fine
software. Second, this isn't much of use for users without a sight.
Since edbrowse accepts the plain text on a standard input and spits out
the plain text on a standard output, it can be scripted. Acme is a
graphical text editor from the Plan9 operating system. I won't go into
much detail explaining exactly what Acme can do. Russ Cox made a
video presenting some of the features [1].
Acme provides interfaces, where events like mouse clicks can be
captured. The acmebrowse script parses those events and pipes
meaningful actions into edbrowse, then an output from edbrowse is piped
back into a window in acme.
Example: the middle click on a text containing "Print" in acme is
translated into "," command, which is sent to edbrowse. Edbrowse
will print whole buffer, which is piped back into acme. I have in the
mind making a screencast, since describing it in words can be hard.
The result is an interface that can be used almost without keyboard.
At the same time no modifications to edbrowse, neither to acme were
done.
Acme can be obtained along with plan9port [2]. After compiling
plan9port, just copy the script and launch it inside acme e.g.:
$ cp acmebrowse ~/plan9port/bin/
$ cd ~/plan9port/bin/
$ ./9 acme
# Execute acmebrowse in acme
[1] http://research.swtch.com/acme
[2] http://swtch.com/plan9port/
I'm including readme (need to update it) and script in a message
(enclosed into "--" marks), since I'm not sure if the mailing list is
accepting attachments.
ACMEBROWSE(1)
NAME
acmebrowse - mouse driven interface for edbrowse
DESCRIPTION
Some familiarity with acme(1) and edbrowse(1) is assumed.
First of all win(1) isn't used. Instead events emitted by acme
are parsed using acmeevent(1). This allows to assign a new context
to the mouse actions. The result is an interface that can be used
almost without a keyboard.
The basic usage is very simple. The text executed with a button two
is send to edbrowse as a literal command with an additional lookup
for custom commands in this script. In a similar fashion button
three is used for sending the selected text as a regular expression.
Example. After launching acmebrowse, an address can by typed in the
tag. Clicking "b http://the-brannons.com/edbrowse/" with a button
two will send text as a literal command, edbrowse will open this
page (not much to see, beside a status information). "Print" after
a button two click will be translated to "," command, which will
print a whole site. The text in a window can be clicked with a
button three to send a search query e.g. "{user's guide}" will be
translated to "/{user's guide}/". The first line with a phrase
will be printed. "Go" clicked with a button two will be send as
"g1" and "," commands - edbrowse will follow a first link in the
line and then print a whole page.
This is pretty much it. Commands with an exclamation mark need some
explanation. The way acme works, a button two click on "Quit!" will
select only "Quit". This quirk/feature is used to prevent an
accidental execution of a command. Whole phrase "Quit!" must be
drag-selected with a button two. In some cases it is used to
provide an alternative version of command e.g. "Go!" will follow
a link without printing.
FILES
~/.eb/bookmarks
EXAMPLES
Managing the bookmarks. "URLs" command will print the HTML version
of links on a specified line. "Bookmarks!" will append the content
of a buffer to a bookmark file. Those commands combined will add
a new entry in bookmarks.
SEE ALSO
acme(1), acmeevent(1), edbrowse(1), rc(1), acme(4)
BUGS
"Paste" and "Edit" aren't working properly (sometimes?).
--
#!/home/melville/p9/bin/rc
# ^ Adjust shebang accordingly.
. 9.rc
. $PLAN9/lib/acme.rc
follow = off
fn acmeinit {
# Create new window in acme, change name
newwindow
winname none
# Add commands to tag in acme
echo '' | winwrite tag
echo -n 'Back! Print Go! Go2! | URLs Bookmarks! Write! | Follow' \
'Javascript Quit! | i? i* i= | DDG | b http://' \
| winwrite tag
}
fn clearwin {
# Select all content of window in acme and erase it
echo -n , | winwrite addr
winctl 'dot=addr'
winwrite data
}
fn ebecho {
# Write command also to acme, so it's visible.
echo $* | winwrite body
echo $*
}
fn setwinname {
# Use '_ variable in eb for winname, if empty replace with "none".
echo '!echo "''_" | sed -e "s/\.browse$//" -e "s/^$/none/"' \
'-e "s/^/name /" | 9p write acme/' ^ $winid ^ '/ctl'
}
fn topofwin {
# Block till edbrowse is done.
sleep 60 &
echo '!kill' $apid
wait $apid >[2=]
# Jump to the top/beginning of text in acme
echo -n 0 | winwrite addr
winctl 'dot=addr'
winctl show
}
fn sanitizere {
# Turn special characters into dots, handle {m,n} pattern
echo $* | tr '^$[]+*?\/' '.' | sed 's/{([0-9]+(,[0-9]+)?)}/.\1./g'
}
fn parsecmd {
switch ($1) {
case Back # Go back one level
ebecho '^'
case Back! # Refresh page - can be useful for JS
ebecho rf
case Bookmarks # Open bookmark file and print
ebecho 'b ~/.eb/bookmarks'
ebecho ,
case Bookmarks! # Add bookmark, used together with URLs command.
ebecho 'w+ ~/.eb/bookmarks'
case DDG* # Searching in duckduckgo.com
ddg = `{echo $1}
ddg = $ddg(2-)
ddg = 'b http://ddg.gg/lite?q=' ^ $"ddg
ebecho $ddg
ebecho ,
case Follow # Toggle opening page after regexp
if (~$follow off) follow = on
if not follow = off
echo Following is $follow | winwrite body
case Go # Follow 1st link in the line and print
ebecho g1
ebecho ,
case Go2 # Follow 2nd link and...
ebecho g2
ebecho ,
case Go! # Follow without print - for binary files etc
ebecho g1
case Go2!
ebecho g2
case Javascript # Toggle off/on javascript
ebecho js
case Print # Print whole file
ebecho ,
case Quit! # With exclamation mark, must be drag-selected.
ebecho qt
windel sure
exit
case URLs # Show addresses behind links in selected line.
ebecho A
ebecho ,
case Write! # Save (binary) file to disk.
ebecho w/
case * # Send selection as plain command to edbrowse
ebecho $1
}
}
# man acmeevent(1)
fn event {
# $1 - c1 origin of event
# $2 - c2 type of action
# $3 - q0 beginning of selection
# $4 - q1 end of selection
# $5 - eq0 beginning of expanded selection
# $6 - eq1 end of expanded selection
# $7 - flag
# $8 - nr number of runes in $9
# $9 - text
# $10 - chorded argument
# $11 - origin of chorded argument
switch ($1$2) {
case E* # write to body or tag
case F* # generated by ourselves; ignore
case K* # type away we do not care
case Mi # mouse: text inserted in tag
case MI # mouse: text inserted in body
case Md # mouse: text deleted from tag
case MD # mouse: text deleted from body
# We don't care about those events
winwriteevent $*
case Mx MX # button 2 in tag or body
if (~ $9 Cut Edit* Look Paste Snarf)
winwriteevent $*
if not {
clearwin
parsecmd $9
setwinname
topofwin
}
case Ml ML # button 3 in tag or body
# Send selection as regexp to edbrowse
clearwin
regexp = `{sanitizere $9}
ebecho / ^ $"regexp ^ /
if (~ $follow on) {
ebecho g1
ebecho ,
setwinname
topofwin
}
}
}
# Initialize acme and start loop
acmeinit
wineventloop | edbrowse | winwrite body
--
Paul Onyschuk
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Edbrowse-dev] [acmebrowse] Mouse driven interface for edbrowse
2014-07-30 12:40 [Edbrowse-dev] [acmebrowse] Mouse driven interface for edbrowse Paul Onyschuk
@ 2014-07-30 14:30 ` Chris Brannon
2014-07-30 15:32 ` Paul Onyschuk
0 siblings, 1 reply; 4+ messages in thread
From: Chris Brannon @ 2014-07-30 14:30 UTC (permalink / raw)
To: edbrowse-dev
Paul Onyschuk <ptmelville@gmail.com> writes:
> The result is an interface that can be used almost without keyboard.
> At the same time no modifications to edbrowse, neither to acme were
> done.
Wow, that is some awesome work! It's a GUI for edbrowse!
Do you run Plan 9 natively? The latest edbrowse will probably never run
there, but I think the Perl version might. There used to be a Perl port
for Plan 9, so I'm guessing that your little setup might work natively
with the old edbrowse 1.5 release.
-- Chris
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Edbrowse-dev] [acmebrowse] Mouse driven interface for edbrowse
2014-07-30 14:30 ` Chris Brannon
@ 2014-07-30 15:32 ` Paul Onyschuk
0 siblings, 0 replies; 4+ messages in thread
From: Paul Onyschuk @ 2014-07-30 15:32 UTC (permalink / raw)
To: edbrowse-dev
On Wed, 30 Jul 2014 07:30:06 -0700
Chris Brannon wrote:
> Wow, that is some awesome work! It's a GUI for edbrowse!
> Do you run Plan 9 natively? The latest edbrowse will probably never
> run there, but I think the Perl version might. There used to be a
> Perl port for Plan 9, so I'm guessing that your little setup might
> work natively with the old edbrowse 1.5 release.
I don't use Plan9 natively. plan9port, which I linked in a previous
message provides the userland from Plan9 for unix-like systems, so you
can run acme on Linux (as I do). Beside Plan9 doesn't have C++
compiler, so mozjs won't happen there. My script uses acmeevent script
provided by plan9port, on Plan9 itself it would be a bit different.
Even more, I'm not a regular acme user. Acmebrowse is written in rc
shell, tool from Plan9 I like the most so far. I'm not sure how
Algol-like syntax of bourne shell compares to C-like syntax (which rc
uses), when accessed via a screen reader, but I think some users of
edbrowse could enjoy rc.
Rc avoids a mess of escaping strings/variables common in /bin/sh. This
on top of other things makes scripts very clear and readable, which you
could see/hear in my previous message I guess. It is very small, even
compared to /bin/sh, especially documentation wise.
Paper describing rc is available online [1], man page is also useful
[2]. Rc can be obtained via smaller packaging [3]. I hope such an
advertisement isn't too aggressive.
Acmebrowse is still evolving as I tune it to my needs. I'm open to
feedback/criticism.
[1] http://plan9.bell-labs.com/sys/doc/rc.html
[2] http://swtch.com/plan9port/man/man1/rc.html
[3] http://tools.suckless.org/9base
--
Paul Onyschuk
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Edbrowse-dev] [acmebrowse] Mouse driven interface for edbrowse
@ 2014-07-31 7:24 Karl Dahlke
0 siblings, 0 replies; 4+ messages in thread
From: Karl Dahlke @ 2014-07-31 7:24 UTC (permalink / raw)
To: Edbrowse-dev
I probably won't have time to follow up with this very much,
except to say that I love it.
People always find creative ways to use edbrowse,
things I would not have thought of.
I'll keep your email and maybe add it to the project documentation some day.
Karl Dahlke
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-07-31 7:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-30 12:40 [Edbrowse-dev] [acmebrowse] Mouse driven interface for edbrowse Paul Onyschuk
2014-07-30 14:30 ` Chris Brannon
2014-07-30 15:32 ` Paul Onyschuk
2014-07-31 7:24 Karl Dahlke
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).