links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Scamper tweaks
Last updated at 1:45 pm UTC on 16 January 2006
A "tweak" is a small modification that makes a program more suited to your indiviual needs or tastes. Ideally, end user programs should be quite tweakable, in that it's easy to make such modifications and obvious how to do them and they don't mess up things in general.

Anyway, here are some small tweaks for Scamper.

Browse without Pictures. (updated 10/28/2000)

The simplest way to turn off pictures is to change the HtmlImage>>addToFormatter method to:
<pre>    formatter addString: ' [', self alt, '] '.</pre>

This will preserve hyperlinks, but won't make the alt text stand out any.

Of course, you can easily add other formatting commands to the text by sending the requisite commands to the formatter (e.g., #increaseBold and #decreaseBold).

Even better would be to have the "boxed" placeholders that DownloadingImageMorph generates...either "actual" image size, or just the alt text size. And voila! Change DownloadingImageMorph>>setContents to "^self setNoImageContents" and yer done! (Note: I have no idea how this will affect imagemaps.)

To get "alt text sized" boxes, one can alter DownloadingImageMorph>>setNoImageContents so that the "extent" temp variable get's initialized to 0@0,e.g.,:
<pre>     "figure out how big to make the box"
      extent := 0@0. "defaultExtent ifNil: [ 0 @ 0 ]."...</pre>

Clearly, it would be very easy to insert a test or two to make browsing with/without images or even without "boxes" (i.e., pure text mode) a preference. It would be good to have this slightly sophisticated so that one could toggle the preference on a per page, per session, per window basis. Then, like iCab, more sophisticated image filtering could be added.

Clickable loading of images would be cool too. Getting a popup allowing you to load or download the image seems the right thing.

One problem with the box tweak is that the images still get downloaded! Eeek! (Ok, commenting out #downloadStateIn: seems to work.) As I think about this, it occurs to me that a separate class "NonDownloadingImageMorph" or some such is probably the right thing. I need to figure out how to substitute objects in a WebPage.

Underlined links.

Yes, now you too can make your hyperlinks redundantly visible via the archaic practice of underlining them. Of course, if you lack a color moniter, this might even be useful.

The simplest tweak is to HtmlAncher>>addToFormatter:. The change is to the "ifFalse:" clause:
<pre>  ...ifFalse: [formatter startLink: href.
        formatter increaseUnderline. "Add this"
        super addToFormatter: formatter.
        formatter decreaseUnderline. "Add this"
        formatter endLink: href. ].</pre>

Slightly trickier, but useful for changing hyperlinks everywhere (not just in Scamper), or for changing color, is to muck with TextAction or its subclass TextUrl. In particular, check out #emphasizeScanner:. Adding the following line to TextAction>>emphasizeScanner will underline all TextActions
<pre>scanner addEmphasis: TextEmphasis underlined emphasisCode</pre>

I suspect that overidding #emphasizeScanner in TextUrl will restrict the underlining to Scamper, and is probably the best way to change the Scamper link color. (I haven't tried or tested this.)

A big disadvantage of these methods is that blank text separating Image based links get underlined too, and it strange places, leading to annoying visual artifacts. Presumably, this could be fixed by mucking with #allSubEntitiesDo:. Indeed, (some mucking later), that does the job:
<pre>  ...ifFalse: [ 	
      formatter startLink: href.
         self allSubentitiesDo: [:e | 
           (e isKindOf: HtmlImage) ifFalse: 
              [formatter increaseUnderline.
               super addToFormatter: formatter
               formatter decreaseUnderline.
            ifTrue: [super addToFormatter: formatter.]].
          formatter endLink: href. ].</pre>

Ok, ok, the use of #isKindOf: is butt-ugly, but ok, IMHO, for a quick hack/tweak. I didn't want to mess with the testing protocol because I don't quite understand it (e.g., HtmlImage isTextualEntity = true!).

Better (I suppose) would be to have the subEntities know how to format themselves appropriately in a "link" context. It seems the right place to make this work is in HtmlFormatter>>startLink: and #endLink:. Unfortunately, they just take the url and set state in the formatter. So, some sort of mucking with HtmlImage and HtmlTextEntity is required (I haven't figured it out yet).