Posts

Showing posts with the label acme

lab 103 - python content assist

NAME lab 103 - python content assist NOTES Building on lab 102 I've started to write an acme client for python content-assist in python. I read the code for python's IDLE editor and pulled some pieces out of that to help with my implementation. The AutoComplete.py and CallTip.py modules are copied out of idlelib and reduced to just the functions I needed. Just as in lab 102 the acme client is implemented using pyxp to connect to the acme file system. In an acme editor window execute PyAssist. Start typing some python. After typing a dot the client will display available attributes for the module. Continue typing and it will reduce the list to those names with a matching prefix. Press the Tab key to complete a name or prefix depending on whether there is one or more names. After typing an open parenthesis the client will show the call tip for the function. The client implements an Import command so that more python modules can be added to the namespace. PyAssist ...

lab 102 - python acme client

NAME lab 102 - python acme client NOTES A recent post to 9phackers announced Pyxp , another implementation of Styx in Python. I immediately downloaded Pyxp and tried it out. I had no trouble using it so I started thinking about python clients I could write. Python is still new to me so writing a styx client was an excuse to get more practice. I started with an acme client. I translated the acmewin limbo module I use for most acme-sac clients to python. Below is a simple example opening a new acme window and doing some operations on it. from acmewin import Acmewin win = Acmewin() win.writebody("hello, world!\n\n\n") win.tagwrite("Hello") win.writebody("goodbye") win.replace("/goodbye/", "GOODBYE") win.select(",") win.show() Remember to export the namespace before trying it out. % styxlisten -A 'tcp!*!localhost' export / % textclient.py I recently saw on Hacker News a repost of Peter Norvig's spelli...

lab 98 - acme Ctag

NAME lab 98 - acme Ctag NOTES Ctag is a new client for acme that reads the tags file generated by ctags. In particular I worked with Exuberant Ctags on windows. While working on acme content-assist in lab 94 I thought a next possible step was using ctags for code completion. So in writing this program I wanted to explore using exuberant ctags by doing something easier, that is by providing assistance with code navigation. Exuberant ctags understands many languages, but for the current effort I tried it on Java and Python. For example, I generated tags for the python standard libraries, cd:/Python30 ctags -R --excmd=number --exclude=test Then run the client on the tags file, Ctag /n/D/Python30/tags What you start with is a blank window. In the tagline is a File command. Give it an argument of a filename which it will grep for in the ctags file. File mailbox It will then show all classes and methods within matching files. You can right-click on a method name to open ...

lab 97 - acme Navigator

NAME lab 97 - acme Navigator NOTES I created a simple directory browser for acme. Called Navigator, it opens directories in the same window. This makes descending deep but unfamiliar directory hierarchies easier because it avoids the proliferation of windows that clutter the desktop. The client understands the command Pin for creating a standard acme directory window for the current directory (to pin the current directory to the desktop). This is an example for a rather simple client for acme. FILES inferno-lab/97

lab 96 - acme color schemes

NAME lab 96 - acme color schemes NOTES The inferno version of acme always contained some code to configure the acme color scheme, but I'm not sure if it always, if ever worked. I modified the code a little in acme-sac to make the color configuration work. And I came up with a few new schemes. The schemes are checked into acme-sac under /acme/color . To use a different scheme add a line like this to your $home/lib/profile run /acme/color/evening Running the "evening" scheme will make acme look like this. The configuration files sets a few environment variables of the following form: acme-fg-text-0='#000000' This sets the foreground text color in the body text to black. It's possible to mix two colors, as for the standard acme background. acme-bg-text-0='#FFFFAA/#FFFFFF' Another simple scheme is "bw" for black and white. There is also a file /acme/color/standard for the default acme color scheme which can be copied tweaked...

lab 95 - acme side-by-side diff

NAME lab 95 - acme side-by-side diff NOTES Here's a script I wrote to help do side-by-side diffs in Acme. Run adiff as normal inside acme. And then in the adiff output window type the command NextDiff. Executing this command will step through each diff in the adiff output and highlight the changed region in each file. The script will highlight each line, avoiding the cursor jump to highlighted regions as happens by plumbing or right-clicking on a file pattern. Though the cursor jump will occur the first time the diffed files are opened, for subsequent execution of NextDiff for diffs within the same files the cursor will remain over the NextDiff command and the highlighted regions will change with file scrolling to show at least part of the changed regions. When the files first open you'll still need to manually arrange the files side by side. There is no acme API for window placement. However, the command will save some amount of scrolling, clicking, and mouse moveme...

lab 94 - acme content assist

NAME lab 94 - acme content assist NOTES This lab explores a way of implementing content assist for acme. I've focused on the user interface and how that might work inside acme and not specific language support. The command is called Assist. Launch it within an editor window and it will provide assistance for that window only. A new window will open and while you type in the edit window Assist will attempt to match the currently typed word against the content of /lib/words using the command look(1). The results are displayed in the +Assist window. With results in the +Assist window and with focus still in the editor window type Ctrl-l to step down through the results. Each result will be selected in turn and the selection will wrap around to the top. To choose a selection and replace the currently edited word with the selected text type Ctrl-k. The Assist command also supports file completions. Start typing a path in the edit window and type Ctrl-y to show file completions i...

lab 91 - using freetype

NAME lab 91 - using freetype NOTES While fiddling with Charon's fonts and wondering what work would be involved to replace the whole set I decided to take a quick look at the freetype module. This lab documents some of my progress. A recent post to the acme-sac mail-list pointed me to the DejaVu fonts . They are derived from Bitstream Vera Fonts but with more characters. It includes various styles: Sans, Serif, Italic, Oblique, Bold, and Mono, making it a good choice for Charon. At first I considered converting the whole set over to Inferno format. There is a program to convert TrueType fonts to the inferno format. But the program is designed to run on Plan 9 and I don't have a ready Plan 9 environment anymore. So the effort of setting up an environment, compiling and fixing problems I know exist in the conversion tool, creating font files for all the styles, and in a variety of sizes, and I was ready to look for an easier solution. The Freetype library is compiled i...

lab 79 - acme javascript

NAME lab 79 - acme javascript NOTES I'm excited about today's lab. I hope others pick up on this and experiment with it because I think some cool acme clients would come of it. The idea behind this lab is to mix together acme, javascript and json web services. I've been poking around at inferno's javascript, hoping to improve it. The best way of doing that is to start using it more heavily. In earlier labs I created a tool called js that ran javascript scripts outside of charon. But without knowing what set of host objects to build it has languished. Looking to use javascript more, I've been taking another look at web services APIs, and noticing that JSON is getting strong support, especially from Google and Yahoo. I'm pleased about this, since the SOAP stuff looked so horrid. So I really want to pull JSON web services into inferno using javascript. But web services don't work too well when text is just output to the command line, they need more ...

lab 71 - pruning

NAME lab 71 - pruning NOTES I've tried to reduce acme-sac source tree to what I consider the core. I'm cutting out dead wood to encourage new growth. Except that what counts as dead wood is highly debatable. I removed files I tended not to use, but my well traveled paths through inferno are not necessarily going to match yours. So while acme-sac still stands alone, it depends on the larger world of inferno-os for diversity and range of applications. The smaller mass of code is intended to have less inertia. Not only can a programmer more easily understand it all, but he can also make changes system wide and so turn it to new directions. For example, if a new system library were to be imagined that could be applied to the whole limbo code set, the size of the code should not present so much resistance that an individual would not attempt it. This reduction effort started in lab 58. The source from that became acme-sac. The recent "right-sizing" removed a lot of...

lab 65 - Man pages in Acme

NAME lab 65 - Man pages in Acme NOTES This lab's purpose is to have man-pages opened in acme automatically. Easiest way to do this is to allow plumb to get it's data piped from another program. So we can do: man2txt /man/sec/file | plumb -i -d edit -a action showdata -a filename '/man/file(sec)'; given that we want to plumb it to acme we have to set the destination port -d edit, and instruct acme to show the data with the tag set to the value of the filename argument. So now we can add to our plumbing rules something like: # man pages kind is text data matches '([a-zA-Z0-9\-]+)\(([0-9]+)\)' plumb alwaysstart man # nasty plumbing hack plumb start /dis/sh.dis -c '/usr/salva/dis/man -b 2ドル 1ドル' where /usr/salva/dis/man is an adaptation of /rc/bin/man from Plan9, and in particular when invoked with the -b option does: man2txt $file | plumb -i -d edit -a action showdata -a filename '/man/'^${tl $*}^'('^${hd $*}^')' But if w...

lab 64 - Chat

NAME lab 64 - Chat NOTES Chat is an acme client that connects to the chatsrv filesystem. This is a very basic text chat service. It is considerably simpler than the Irc client. Part of the reason I did this was to have a simpler client I could use to help debug some of the acme interaction, and help me improve Irc. Another reason was a recent urge I had to setup some private communication channels, merely for privacy's sake. Chatsrv is part of the demo code under /appl/demo . I borrowed code from /appl/demo/chat.b and the Irc client I ported from Russ. A chatsrv service is running on tcp!canto.hopto.org!6683. But I've only allowed rc4_256 encryption to use the service, and of course you need a certificate from the canto.hopto.org signer ( Getting Started ). To mount the service within acme and start Chat Local mount -C rc4_256 tcp!canto.hopto.org!6683 /n/chat Chat /n/chat Note that the simplest client can be run inside wm/sh, or win: % {cat & cat >[1=0]...

lab 63 - Calendar

NAME lab 63 - Calendar NOTES I wrote a little calendar client for acme based on Inferno's wm/calendar(1). It uses rawdbfs(1) in the same way to store calendar entries. The calendar window displays a month much like cal(1), and has commands Next and Prev to move between months. Days that have calendar entries have a plus superscript symbol. Right click on the days of the month to open and edit a calendar entry. To use it make sure you have a directory /mnt/schedule, and a file in your home directory called, schedule. mkdir /mnt/schedule touch schedule Calendar schedule Or Local rawdbfs schedule /mnt/schedule Calendar FILES caerwyn.com/lab/63

lab 59 - acme SAC

NAME lab 59 - acme stand alone complex NOTES A project that's been on my mind for quite a while is to package Inferno's acme as a stand alone editor. I only had Windows in mind as a target host, but the work should be quite easy to reproduce on other hosts. I wanted the editor to blend well with the host system, and work as a substitute for other popular programmer editors such as vim, emacs, or jedit. Acme and Inferno being already stable and mature, there were only a few things I felt needed to be in place for this to work. cut & paste between the host and acme (lab 55) acme to resize with the host window dead simple packaging and install of acme on windows. This lab covers the code to do the acme resize with host windows. I copied the code from /emu/port/devpointer.c and made devwmsz.c . The code is almost identical except for the name changes. This device holds a short queue of window resize events and serves a file /dev/wmsize that's the same fo...

lab 56 - acme web

NAME lab 56 - acme web NOTES I started using charon again because I wanted a web browser that started faster and used less memory than firefox. I wanted the browser to check my gmail account and scan reddit etc. But after implementing cut & paste (lab 55) I found it frustrating all over again to not be able to cut & paste from charon. So I started looking for a solution to that. I began by just dumping the text to stdout. Since I was always starting charon from inside acme the stdout would go to an acme window. Then I thought I might as well write directly to a new acme window, so I built an acme client to charon. Then I added the links handling, which was pretty easy, and tada! a charon hack turns into an acme web browser. And a surprisingly good one too, since charon is doing all the work. The links appear in acme as superscript numbers to the anchor text. Right-click on the number or word to follow the link. Only one link can be handled at a time. You can minimize cha...

lab 49 - wrappers

NAME lab 49 - wrappers NOTES Acme is the hub of my activity where all my tools are at hand. It is inconvenient to have to step outside it while working on a task. But it is impractical to port all the tools I need into Inferno. However, Inferno is an integrating environment. It is oftentimes easy to put a wrapper around an external tool so that it is usable within Acme. In this lab I show a few examples of putting wrappers around external tools so that they blend in to the Inferno environment and work together with Inferno's tools. The first, very simple example is awk . fn awk {os awk $*} With this definition it is only possible to use awk as a filter without naming files as command line arguments. But this is often good enough. Very often I work on my laptop which has NT as the host os. But I need to use dict and spell all the time, and my laptop doesn't have these installed. I integrate these tools into my environment by running emu on a Plan9 or Linux machine a...

lab 44 - acme irc client

NAME lab 44 - acme irc client NOTES The code in this lab is a port of an irc client for the Acme editor. The original was by Russ Cox. The translation was pretty straight forward, that is without any creative input from me. While the code is usable as an IRC client there are still plenty of bugs I've left in it for the reader to explore. FILES caerwyn.com/lab/44

lab 43 - acme Wiki

NAME lab 43 - acme Wiki NOTES I ported the Acme Wiki client from Plan 9 to Inferno. At the moment (20050925) a small patch to Inferno's Acme is needed to get this to work. Make the following change (using ed) to /appl/acme/regx.b: 193c if ((nc := xgetc(a0, a1, q)) != '#' && nc != '/' && nc != '?') . Download the wiki.tgz and unpack under /acme. Then mount a wiki and start Acme. % cd /acme % gunzip I took a lot of the code that interfaces with the Acme filesystem from the Mail command and put it into the Acmewin module. This module should be useful to other Acme clients. Once I started using this it flushed out a few bugs with my inferno wikifs port. I've updated the code under the original lab 30 with fixes. Thanks to Russ Cox for writing the original wikifs and Acme wiki client. My version is not nearly as well tested as the original, so blame me for all bugs.