bpm's Operations Room

understanding & extending Opera

Showcode: click to see inside toolbars and menus

,

(last edited 2009-1-2) (green links are button-installer tags)

Buttons you add to menus and toolbars; click to see the code for the menu or toolbar they're on. Useful for examining code, identifying function calls you were wondering about - or copying off the screen to make a button for someone else. If you see something that needs changing, two more taps (sourceview, F3) open sourceview for editing and take you back to the item.


What it does is very simple - open a file, run a search. Here's the code for one button:
Go to page,"tb" & Enable mediumscreen mode & Delay,200 & Find inline, "Pagebar Head.content"
(Mediumscreen is fit-to-width. The delay command is needed to prevent the Find from being issued before the page loads.) The idea is to make code access effortless, and pushbutton simple: almost like having "edit item code" on a context menu. You don't have to think about which file to call, dredge up a toolbar name, and work out what search string to type in: you just point at the thing that's puzzling you and click.

Actually, I use it quite often just to check the names of menus and toolbars: tap Showcode, read the name, dismiss the page.

setup: making sure you have custom INI files, making sure they open with no dialog, and nicknaming them:
  • making sure you have custom menu & toolbar INIs: Prefs / Advanced / Toolbars; look at the Toolbar setup window: more than one file, one saying "modified"? If not, click "duplicate". Now rename the modified file (so you know it's your custom one, especially if Opera generates other duplicates, which happens quite a bit): you could call it "tb", to match the nickname we'll give it - or any other name you like. To make it the active file, select it and click OK. Same for menu, in the lower window: duplicate if necessary to get a "modified" file, then give it a distinctive name.
  • making sure they open: navigate to your toolbar folder within Profile, and open it. (If you don't know how: type the drive ID of your hard drive (usually C:) into the address field & press Enter; click on folders to work your way to Profile (if not sure where it is, check Help / About Opera / Opera directory); click on the Toolbar folder inside Profile.) There you will see your custom toolbar INI (which may not have the name you gave it - Opera's name being different from the filename). It's a text file, and Opera can open them. Click on it. If you get a "save or open?" dialog, that's an issue: need them to just open (and - longstanding bug - the "Remember This" option on the dialog doesn't work). What does work is adding the INI file type to the set of extensions on the Text/plain line at Prefs / Advanced / Downloads (uncheck "hide file types opened by Opera" and type "text" in the quickfind box to see it). Button for that (adding ini,adr,dat,lng,mbs,idx to the list: making it possible to inspect and edit most of Opera's innards within the browser): MakeSystemFilesEditable. Some people don't have this problem; file types handling is a murky topic (discussed here).
  • assigning nicknames: to avoid the need for paths, Showcode uses nicknames - calls your toolbar INI by the nickname "tb", and menu INI by the nickname "mn" (short nicks used to make the files very easy to open by keystroke as well: F2,tb,Enter). So you have to assign these: with INI file displayed, bookmark it, click the Details button on the bookmark dialog, and assign the nickname.

Here are the buttons, in two versions: the form with the toolbar name as anchor has the benefit of displaying the name when hovered, and the drawback of occupying a stretch of toolbar as wide as the name if you choose to display button titles. So - you may want to use the nameless specimen for bars where you display titles, but be sure you get the right one! (It's still easy to check names: just click the button. Read, close page.)
// . . Main bar
// . . Status bar
// . . Start bar
// . . Address bar
My Buttons (special case: buttons on the panel are not clickable - must go on a toolbar)
// . . Pagebar head
// . . Source View Toolbar
// . . Panel header
// . . Notes panel toolbar
// . . Boomarks panel toolbar
// . . History panel toolbar
// . . Notes full toolbar
Manage Bookmarks toolbar: // . . Bookmarks full toolbar
Manage History toolbar: // . . History full toolbar

For a trial, pick one for a toolbar you use, drag and drop it on the far right (or bottom, if the toolbar is vertical) of the bar (so the showcode line will be at the bottom of the listing to give you a search-hit bracketing effect), and click. Hopefully your toolbar INI pops open, the search dialog pops up with "(bar you picked) content" in its field, and the search runs. You should see the code for your toolbar, with a green search hit on the section header. You probably won't see the yellow search hit on the Showcode-button line - because that line won't exist in the file on disk yet; if you close and restart Opera, your toolbar changes will be saved to disk and then you'll see it. (Neat, eh? The search string finds itself.)

Edit & swapout/save/reload From there, if you want to edit, you use View Document Source to open it in editable form (Ctrl+F3 or Alt,v,o), and tap F3 to repeat the search and get you back to the proper section in the sourceview window. (One could have Showcode open sourceview automatically; this however creates another tab to dismiss. Which is more efficient depends on how often you edit, and how often only inspect.)
A caution: you can get versioning glitches by editing the toolbar INI you have loaded. This is because after loading it into memory, Opera does not automatically save to disk after changes, or reload after filesaves. So - if you have modified your toolbars during a session, and open the toolbar.ini on disk, it may be stale. And if you edit the loaded file but then do not reload it, the changes will be lost when the file is overwritten during Opera shutdown. So it's safest to swap back to the standard toolbar INI (causing Opera to update your custom INI on disk) before opening the custom INI file. That's Prefs /Advanced/toolbars again (you'll be putting that on a keystroke if you use this as much as I do); select the standard file, click OK.
You save your edits by clicking the "save changes" button on the sourceview toolbar, or tapping F5 - then reload your custom file.

Menu showcode
Same concept: for each menu you'd like to be able to pop open, add this line at the bottom of its section in your menu INI file:
Item, "Z: showcode (whichever)" = New page & go to page, "mn" & enable mediumscreen mode & delay,200 & Find inline, "(whichever) menu*"
And nickname your menu.ini as "mn". (The asterisk is to prevent search hits where menus are mentioned elsewhere in the file: the line only finds itself.) Putting the menu name in the label is pointless for those on the menu-bar, but useful for popups.
There's no danger of versioning problems with menu.ini, because it's not modifiable through dialogs and therefore never gets saved from memory to disk. So there's no need to swap out of it. Quickest way to reload after saving changes: tap the "rename" button, then "OK".

Tab Aliaser 2 Better sessions functions you've never seen

Comments

Tedsoilman Sunday, July 6, 2008 8:08:55 PM

Wow. Button to automatically open specific text file at specific spot, for specific toolbar ini file, menu, keyboard file, mouse gesture ini file, etcetera, is terrific. I didn't even realize Opera now had a built-in text editor. Last time I looked, it just had a text viewer. I didn't see mention of the editor, in the changelog.

judejudedon Saturday, January 2, 2010 12:37:15 PM

This is very useful for getting the menu's name, but since Opera has about 200 menus in the menu configuration file, it's also a hard work to add your showcode to each menu, so I wrote a button which will use Opera itself to add these code to the ini file.

The macro is like:find inline,"Menu]" & delay,1 & next character & range go to line start & copy & next line & find inline,"Menu]" & delay,1 & next character & delay,1 & previous line & insert,"0A" & convert hex to unicode & insert,"item,Check this section in menu.ini=new page & go to page," & insert,"22" & convert hex to unicode & insert,"D:\app\Opera1893\ui\standard_menu.ini" & insert,"22" & convert hex to unicode & insert,"& delay,10 & view document source & delay,10 & find & insert," & insert,"22" & convert hex to unicode & paste & insert,"22" & convert hex to unicode & insert,"& click default button" & insert,"0A" & convert hex to unicode But unfortunately, Opera can't do a same work in loop, so I have to copy these lines for 20 times. Once clicked, 20 menus will be processed, then click the button again until all menus have been processed.

judejudedon Saturday, January 2, 2010 3:55:30 PM

The process Opera executes this macro looks cool, I even made a video of it: http://www.vimeo.com/8497834

bpm Saturday, January 2, 2010 6:25:34 PM

Neat macro.

As for the use - there has always been a problem with merging changes Opera makes with customizations. After upgrades, you don't see the changes to menus which are being pre-empted by your custom versions. One has to go through once in a while and figure out what has changed in the standard file. So taking the whole standard file and showcodizing every menu has a drawback. If you really wanted Showcode everywhere, you could routinely add it to the standard file (in program folder, not "Opera folder") after upgrades and still have a custom INI too - that way you wouldn't be hiding anything extra just because of Showcode.

Minor suggested changes: "find inline" is better - doesn't put the dialog in front of what you want to see (I didn't know it took an argument when I first set this up); jumping up another line after the second Find would keep the Showcode line with the rest of the menu (macro at present leaves a blank line between); and adding a marker such as * to the menu-name search target would ensure that the menu code ends up onscreen (the search command would find itself, at the bottom of the section, not the label at the top). And a nice short nickname for the menu file - but I guess you have an issue with that!

bpm Sunday, January 3, 2010 6:56:21 PM

Incidentally, Jude, you don't really mean "button", right? Because Insert and Paste don't work from buttons (unless you put two Focus Next Widget commands or delay,1 in front).

Also you can leave out this:

" & insert,"

before each special character: just stick 22 or 0A on the end of the other string. You have a problem if the last character is 0-9 or a-f, but you have that problem anyway. (Solution is to include an inert character and delete it after the conversion: "1234@22" & convert hex to unicode & previous character & backspace & next character.

judejudedon Tuesday, January 5, 2010 3:18:51 PM

It's odd that the insert command doesn't work from a toolbar button, but my above button however indeed works, well others don't, a delay for 1 ms is needed. I have found that the length Opera will search for a hex strings is 5, so insert 00022 instead of 22 will solve the problem you said.

I have to go to sleep now, goodnight from China! lol What's the time in your country?

bpm Tuesday, January 5, 2010 9:19:42 PM

00022/0000A is good to know! Time here is GMT-8.

judejudedon Wednesday, January 6, 2010 6:54:23 AM

So we are 16 hours ahead of you, I should say good morning to you when I go to sleep ^^

I made a video of using the "convert hex to unicode" command to make poem in Opera, lol:D http://www.vimeo.com/8549769

bpm Wednesday, February 17, 2010 3:27:05 AM

Doubtful as a tool of romance... but cool hack!

Write a comment

New comments have been disabled for this post.