anoved.net: January 2008anoved.net logo

Posted on Thursday, January 31, 2008:

MarsEdit Preview

If you arrange MarsEdit’s post and preview windows to your liking, don’t forget that you can choose Save Default Window Size from the Window menu to use the same window layout for every session. Together with the automatic Open the Preview window preference, this provides a nice side-by-side preview interface for each post you edit.

example screenshot of tiled MarsEdit post and preview windows

2:18 PM Comment (0)

Posted on Wednesday, January 30, 2008:

Hacking Leopard Help

Update: A better way to improve the help viewer's usability is documented here.

Mac OS X 10.5’s help viewer application is widely considered to be a piece of crap. Unlike the help viewer in previous iterations of Mac OS X, it presents no Dock icon, no proper menu bar, and exhibits an annoying tendency to obscure the application you needed help with in the first place.

So, fix it. Or at least have your vengeance by grossly disfiguring it.

Navigate to /System/Library/CoreServices. Copy Help Viewer.app to the Desktop, right-click the copy, and select Show Package Contents.

Open the Contents folder and open Info.plist. Change the value of the LSUIElement property to 0:

lsuielement

This makes the application’s Dock icon and menu bar visible. There are definitely some quirks (keyboard shortcuts don’t seem to work as expected), but it works.

Next open the Resources folder and the appropriate subfolder for your localization (English.lproj in my case). Open HelpWindow.nib with Interface Builder and select the HelpWindow item:

helpwindownib

Display the Inspector (from the Tools menu) if it is not already visible and display the Attributes pane. Uncheck Utility and Non Activating under Panel Style:

panelstyle

This makes the help window look and behave a bit more like a regular window. Unfortunately, I can’t figure out how to prevent it from floating above other windows (perhaps that behavior is not controlled by the nib file). However, if you check Hide On Deactivate under Window Behavior in the same Inspector pane, the help window will at least sweep itself out of the way when you bring a different application to the front.

windowbehavior

Clicking the help viewer’s Dock icon makes the window visible again, but also creates a new help window.

To apply your changes, save and close HelpWindow.nib and drag your copy of Help Viewer.app back to /System/Library/CoreServices. You’ll need to authenticate the copy operation since you really shouldn’t be diddling around in this directory. (You did make a back up, didn’t you? Good. Neither did I.)

You can test your modified copy of Help Viewer before copying it back to CoreServices, of course, but it won’t handle requests from the Help menu until you do.

Now when you seek help, Help Viewer will actually show up in the Dock. You’ll have menus, and you can even open multiple help windows. Unfortunately, the program launches in the background, so you’ll still have to switch applications with Command-Tab or click the Dock icon to view the requested documentation.

Please share any corrections, clarifications, or further contributions to the cause! I’m no Cocoa or Interface Builder expert. Most importantly, minimize the need for constant help consultation by thinking carefully about the use and design of your application. Put reference material in a nice PDF and call it a day.

5:38 PM Comment (1)

Posted on Tuesday, January 29, 2008:

Msgcat and Mac OS X

The Tcl core library includes msgcat, a package which facilities program localization. msgcat provides means to define a catalog of messages in multiple languages and a procedure to retrieve messages appropriate to a specific locale, typically determined by cues from the operating system.

In general, to localize puts "Hello, world!", you provide equivalent strings for each supported locale and select the appropriate one at runtime by stating puts [mc "Hello, world!"]. For example, this command might print ¡Hola, mundo! if the locale is es. Default strings in the programmer’s native language can usually be used as keys to the message catalog.

Anyway, msgcat looks at a couple environment variables (or the Windows registry) to determine the proper locale. On Mac OS X, this works fine for scripts launched from the command line, but spiffy desktop applications don’t necessarily have access to the same environment variables. If no supported environment variables are available, msgcat uses the locale implied by the “Region” setting of the “Formats” pane of Mac OS X’s “International” system preferences. You can query this string from the command line with:

defaults read 'Apple Global Domain' AppleLocale

It is also available from within Tcl as the variable ::tcl::mac::locale.


To test localized Tcl desktop applications on Mac OS X without changing your system region, you can define the locale in ~/.MacOSX/environment.plist. Environment variables specified in this file are available to programs launched from the Finder, so msgcat will see these settings before resorting to the system locale. For instance, to set the locale to es, add this property to environment.plist:

<key>LANG</key>
<string>es</string>

See QA1067 for more information about environment.plist, including how to create it if it does not already exist. Note that variables defined in this file will be visible to all programs, and may therefore affect other applications.


Here’s how I usually comment the code I use to initialize msgcat:

# localization courtesy of Message Cat:
#
#  |\        /|      MEOW
#  | \______/ |       MYAU
#  /  _    _  \        MJAU
#  | <l>  <l> |        MIAUW
#  \    __    /       MIAULE
# ----- \/ -----     MIAU
#  --\__/\__/--     MIAO
#

mc "MEOW" thanks to Flippy’s Cat Page.

11:51 PM Comment (0)

Workspaces

Amar Sagoo (author of Namely) finds that a tabletop whiteboard is a useful tool for planning and discussion:

We’ve found ourselves using it virtually every day, illustrating explanations, walking through calculations and brainstorming design ideas. Visitors will intuitively pick up a pen and start using the whiteboard when explaining things. It somehow seems to invite people to use it more than most whiteboards. However, it’s not only a collaborative tool: it also makes a great scratch-pad when you’re brainstorming on your own. To ensure that it stays useful, we make an effort to keep the board clean; nothing tends to stay on there for longer than a day or so.

I’ve got a large roll of packing paper which I use for a similar purpose at my desk. It’s great to be able to jot down a note or a doodle without pausing to search for paper or an appropriate notebook. As the sheet fills up, I pull it down to reveal a clean area. I’ve yet to devise an effective spool, but the scroll nevertheless contains an interesting record of spontaneous notes and drawings.

Desktop Paper

Now that I’m studying mechanical drawing, I’ve developed an interest in drafting equipment and techniques. Perhaps in the future my desk will receive further augmentation. In the meantime, a fine set of parallel rules can be made from surplus LEGO:

LEGO Parallel Rules LDraw File

Lastly, I’ve fiddled with some of my shelving to make a nice standing work area for my laptop:

Standing Workstation

It may not be the best arrangement for long sessions, but I’ve found it surprisingly practical for many tasks. I think that standing up helps me to stay focused. When my mind wanders (as it is wont to do) it is easier to step back and tend to other things than when seated.

The kitchen table is a good place to get things done, too.

8:06 PM Comment (0)

Posted on Thursday, January 17, 2008:

Yojimbo Tag Companions

I use this little script when I want to ensure that every Yojimbo item with a certain tag also has some other tags. For instance, to ensure that every leoben item is also tagged cylon, I run the script, select leoben from the first list of tags that appears, and cylon from the second list.

Download Tag Companions (4k)

1:40 PM Comment (0)

Posted on Wednesday, January 16, 2008:

Scalable Images with CSS

If you use ems to define an image’s height property, the image will be scaled relative to an implicit 1em text height.

For example, here is code to display the same image twice — first normally, then scaled to exactly five times the normal text height:

<p>Normal: <img src="http://anoved.net/images/cssize/flower.jpg" />
 Scalable: <img src="http://anoved.net/images/cssize/flower.jpg" style="height:5em;" /></p>

Here is how these images appear:

Normal: Scalable:

Try using your browser’s controls to increase or decrease the displayed text size. The first instance of the image will remain the same as the neighboring text changes size, but the second instance of the image will grow or shrink with the text, preserving the proportions of the original design.

I use this trick to fit my impish logo in the title bar at the top of the page regardless of the visitor’s text size preferences. It works surprisingly well in contemporary browsers, but of course it looks dumb without CSS. The scaling does appear to be off by one pixel at alternating sizes in Safari.

Worth noting is that Opera scales the entire page layout instead of just textual elements, which strikes me as clever and correct.

Comments and technical corrections welcome.

7:59 PM Comment (2)

An Introduction to News Feeds

Most web sites are updated from time to time. News feeds are supplementary files (in RSS or Atom format) that provide a summary or an alternative source of recent additions to such sites. These feeds are read by programs (or web-based services) known as feed readers, which provide people with an overview of what’s new at their favorite sites.

Popular feed readers include NetNewsWire and Google Reader. I use Vienna. Current browsers can display feeds, too.

Web sites that offer news feeds are usually identified by an icon in the browser tool bar. Safari displays a blue “RSS” badge when it detects an available feed; Firefox and other browsers show an orange logo. Alternatively, a link or button within the web page, labeled “RSS/Atom,” “XML,” or “feed,” may indicate that a news feed is available. In any case, clicking the icon or link will establish a subscription to that feed.

Subscribing to an RSS feed in Safari

Your feed reader will periodically check to see if any of your subscriptions have been updated. If so, it will retrieve information about the new content — often including the new content itself — and display each new item in a list resembling an email inbox.

Viewing a subscription in Vienna

You can read new posts right in the news reader or follow a link to read them in context at the original web site. Since some news feeds provide only the title of new articles, you must visit the associated page to read the actual content in these cases.

Viewing an article in Vienna

Different feed readers provide different ways to manage your subscriptions. There are some common features, however. You can group related subscriptions, and you can save or discard items you’ve read — otherwise, they may eventually expire.

Feed readers are sometimes called news aggregators because they collect information from many sources in one convenient location. I find this service useful because it helps prevent me from wasting time online: instead of surfing from site to site and back again, I simply subscribe to sites I find interesting. It’s like receiving a newspaper instead of spending all day gathering news myself. It also helps me to keep an eye on sites I might otherwise forget to check.

1:02 PM Comment (0)

Sketchcast

This is a fun way to share little drawings: sketchcast.com/channel/anoved/

I used my old tablet for most of these, but it’s not impossible to use the mouse, either.

9:52 AM Comment (0)

Posted on Tuesday, January 8, 2008:

Computing Power

The current Mac Pro is available with eight 3.2 GHz 64-bit cores, 32 GB of RAM, terabytes of storage, and support for up to eight 30-inch displays (eight 30-inch displays!), all in a practical form factor that runs certified UNIX.

Sure puts some of the rack-mount monstrosities I’ve met in perspective.

Anyway, perhaps you’d rather meet my calculators.

9:48 AM Comment (0)

Posted on Tuesday, January 1, 2008:

File Comparison with FileMerge

Wherein I explain the anatomy of a FileMerge window

FileMerge is a visual diff utility included with the developer tools that ship with Mac OS X. As its name suggests, it is intended to help compare and resolve differences between files. It is particularly useful for quickly and clearly reviewing changes between different revisions of a single file under version control.

You can choose which files to compare with a dialog

Compare Files dialog

or via the opendiff command:

opendiff original new

For this example, I will compare the contrived sample files used in Wikipedia’s diff article. In either use case, the files are displayed side-by-side with differences highlighted:

FileMerge window

Blue highlights indicate changes. The regions where these changes occurred in each file are connected by gray highlights.

Scrolling is synchronized to show most unchanged areas together; as you scroll, each pane moves at variable speed to maintain this visual correspondence between reference points. It’s nice.

The relative location of each change in the file is indicated by a tick mark in the scroll bar. For long files, these marks act like a simple histogram to summarize the distribution of changes throughout the file.


A dark border surrounds the currently selected difference (number 2, in this example). The up or down arrows move the selection to the previous or next difference.

The left and right arrows keys can be used to select which version of the current region of change should take precedence if you save a merged version of the files. In this example, and by default, the arrows in the center column indicate that the file on the right always takes precedence.

The separator near the bottom of the window can be dragged up to reveal a preview of the merged file. The Actions menu offers additional ways to merge the selected change.


FileMerge can preprocess a file if a command line filter is assigned to the file’s extension. This can be used to compare dynamically-generated text representations of binary files.

Default FileMerge filters


Update: The new application Changes performs a similar function with the advantage of Unicode support. Might be especially useful for revising localized files like message catalogs.

11:15 PM Comment (0)