From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wg0-x229.google.com (mail-wg0-x229.google.com [IPv6:2a00:1450:400c:c00::229]) by hurricane.the-brannons.com (Postfix) with ESMTPS id C812377D56 for ; Wed, 30 Jul 2014 05:41:32 -0700 (PDT) Received: by mail-wg0-f41.google.com with SMTP id z12so1144510wgg.24 for ; Wed, 30 Jul 2014 05:40:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:mime-version:content-type :content-transfer-encoding; bh=J+vA5FFpzp2kG6NUgzsAXpkOA/4NJRTmqtzG9scdTUg=; b=TBQUvGJXPjJ5Sd75EF4ExTlxx7BeK088ahj4WSagpWsjsVPGnDL6GB51a+0/fzyML2 mxUBQHJ+7Flk1z+nmXrOxk5KznelArgDOK28GIwd4ZflKYH7Lqq3TcX/+ksuRBQhUxZa dKPjgoNVXVIO0Cc7xelnirwv9ilZA0a6lgniUXmbvkFeukkJSGIjLxzsacLxRRBFXhwK uJzrDQ4TS6DTaOBaLHZ+e8hMPtWHuJv7whmQGmt9IkAnH5fIFIUpAxf027SjDt56t7XI B9Vxl8waMOu/hB6yvrjKiRdrkt1WjSxgsXkZZKATcsf1Wc2lohymwaYV0Fa5DJXSPbJk OMVQ== X-Received: by 10.194.176.167 with SMTP id cj7mr5802591wjc.93.1406724051717; Wed, 30 Jul 2014 05:40:51 -0700 (PDT) Received: from sigil.Belkin ([109.231.17.100]) by mx.google.com with ESMTPSA id je3sm9276168wic.11.2014.07.30.05.40.49 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Jul 2014 05:40:50 -0700 (PDT) Date: Wed, 30 Jul 2014 14:40:46 +0200 From: Paul Onyschuk To: edbrowse-dev@lists.the-brannons.com Message-Id: <20140730144046.9db3985ff43654767c4eee8c@gmail.com> X-Mailer: Sylpheed 3.4.2 (GTK+ 2.24.23; x86_64-alpine-linux-musl) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: [Edbrowse-dev] [acmebrowse] Mouse driven interface for edbrowse X-BeenThere: edbrowse-dev@lists.the-brannons.com X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Edbrowse Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Jul 2014 12:41:33 -0000 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