Code Browser Documentation

Abstract

Code Browser is a folding and outlining editor for Linux and Windows.

Table of Contents

Introduction
Principle
1. Concepts
Files and Windows
Folders and Links
Folders
Links
Layouts
Undo - Redo
Find and Replace
2. Customization
Files
Edit the User Preferences
Edit Schemes
User Tools
Add or Modify a Language Definition
A. Miscellaneous
Tips

List of Tables

2.1. Variables in Arguments
2.2. Attributes for a Language Definition

Introduction

Table of Contents

Principle

Code Browser is a text editor that allows you to structure your source code like an hyper-text document: the source code can be cut into pages independently of the file structure. A page can be referenced using links or can be nested into another page. It gives a better visibilty on large projects and makes navigation easier.

For a quick start, open samples/tutorial.c with the application.

Principle

Special directives are inserted in the source code as comments. The file saved on disk is completely compatible with any programming language having comments (single or multi-lines). It does not require any transformation before processing.

Chapter 1. Concepts

Files and Windows

The application supports two independent features:

  • multiple files
  • multiple windows

A loaded file can be displayed in zero, one or more windows.

Usually, a text editor has only one window per file. When you want to open a file that is already opened, it just brings its window to front. With Code Browser, a file is loaded only once but several windows can be opened on it.

Opening a File

The Open command from the File menu opens a file in a new window. If this file is already loaded, it is not reloaded.

Viewing Loaded Files

The Files command from the File menu shows all loaded files and allows to open or re-open a file in a new window.

Closing a Window

Use the Close command from the Window menu to close the active window. This command does not unload any file. That's why it never asks for save confirmation. Confirmations occur only when exiting.

Cloning a Window

Use the Clone command from the Window menu to create an exact copy of the active window: the new window will have the same layouts that display the same folders in panes.

Reloading a File

A file can be reloaded when it is modified by another application. The reload.mode in options can change the behavior when an external file change is detected:

  • never: never reload
  • ask: ask before reload
  • always: reload without asking unless the file is modified

Sometimes some windows could unexpectedly disapear while reloading. But don't worry, the file has been reloaded and you can re-open a window on it with the Files... command from the File menu. It happens only with windows displaying sub-folders and where changes occured on a parent folder.

Folders and Links

Folders

A folder is a group of lines collapsed into one single line. A folder can include sub-folders. By default, folder lines are displayed in blue. Folders can be used only with a language having a comment directive.

Inserting a New Folder

The Folder command from the Insert menu opens the folder creation dialog. Enter a name and an identifier. Use \t to put tabs in the name. The identifier is needed only if you want to reference this folder (i.e. creating a link to it).

Any text selected before is moved into the newly created folder. This feature helps to structure an existing flat file.

Editing Folder Properties

When the caret is on a folder, you can use the Properties command from the Edit menu to modify its name and identifier.

The command is also available from the contextual menu.

Entering into a Folder

When the caret is on a folder, you can use the Enter command (ALT-Right) from the Go menu to edit its content.

This command is also available by double-clicking on the line.

Leaving a Folder

To go back to the previous folder, use the Back command (ALT-Left) from the Go menu.

Links

A link is a reference to a folder either in the same file or in an other file. This concept is similar to links in HTML documents. It can be useful to add links to related items (related functions, definitions of classes, ...).

A link is similar to a folder: the Enter command follows the link instead of opening a folder. Properties are edited in the same way.

By default, link lines are displayed in green.

The syntax for the path is:

<filename>[#<folder-path>]

Where <filename> is the filename with path relative to the current file. The path separators are '/' even on Windows platform, not '\' in order to have platform independent files. <folder-path> is optional, it is the path in the file to reach the target folder. The path separators are also '/' between folders.

Reminder

  • A folder (blue) owns its content
  • A link (green) is a reference to a remote folder
In short: deleting a blue line deletes the content, deleting the green line has no effect on the source code.

Layouts

Each window can show one or more panes: each one displays the content of the folder or link selected by its predecessor. The layout of the active window can be changed using the View menu.

There is 3 classes of layouts.

One Pane

Display only one folder. This is the default mode.

Two Panes

Can be arranged horizontally or vertically. The second pane displays a preview of the line selected by the first pane.

More than Two Panes

This is more complex layouts, there is several 'list' panes arranged in a row or a column and a 'text' pane at the bottom or the right.

A folder is displayed in a list pane if it contains only links, sub-folders and comments but no text, otherwise it is displayed in the text pane.

Tree View

Display one folder and a tree view of the file. Sub-folders can be reached directly with this tree. Links are also expanded in the tree.

Customizing the default layout

The layout can be customized for each configuration. So it is possible to open a file in a new window with a layout depending on the file type. There is two attributes in the general section of preferences: 'layout' and 'tree.view'. These attributes can be overridden for each configuration. See the user-preferences file for more information.

Undo - Redo

There is an unlimited undo stack for each loaded file.

You must be careful since a window can display several files and several windows can display the same file: undo may cancel a change made in another window if the focus is in the wrong pane. Anyway an undo operation can always be undone with the redo command.

Find and Replace

Code Browser has two types of search: iterative-find and find-all. Find-all searches all occurrences of a string and displays a list of links to matching lines. The two modes does not support same features:

Iterative Search (CTRL-F)

  • Cannot find text in headlines
  • Cannot follow links
  • Cannot search in sub-folders if scope is current folder
  • Can perform replace

Find All (CTRL-H)

  • Can find text in headlines
  • Can follow links
  • Can search in sub-folders if scope is current folder
  • Cannot perform replace

Chapter 2. Customization

Files

The editor uses two configuration files:

  • languages.cb-config: this file describes syntax of languages. It is used to colorize code and to know how to insert fold markers.
  • user-preferences.cb-config: this file contains user preferences such as colors, tab size, user tools, ... These options are accessible from the Tools/Options... menu item.

For each configuration file, the program first searches in the program folder, then in the home folder.

On Unix platform

  • the program folder is (by default): /usr/local/share/code-browser
  • the home folder is: $(HOME)/.code-browser

On Windows platform

  • the program folder is the folder of the executable
  • the home folder is: "\Documents and Settings\CurrentUser\Application Data\code-browser"

Edit the User Preferences

Use the Options command from the Tools menu to edit the preferences.

If there is no preference file in the home folder, the file is loaded from the program folder and is immediately renamed with the home folder, so it will be saved to the right location. If the directory does not exist, it will be created automatically.

Edit Schemes

An edit scheme allows to customize auto indentation, tabulations and word wrapping.

Each edit scheme is defined as follow:

def name
  auto.indentation = (true|false)
  expand.tabulation = (true|false)
  tabulation.size = size
  word.wrap = (true|false)
end

User Tools

Customized tools can be launched from the 'Tools' menu. To add new tools, edit the 'tools' section from the options. Each tool is defined as follow:

def name
  caption = caption
  command = command name
  arguments = list of arguments
  directory = initial directory
  save.all = (true|false)
  show.window = (true|false)
end

The name identifies the tool but it is not used yet.

caption
This text will be displayed in the Tools menu and in the title of the output window.
command
The full name of the command to execute. Blanks are accepted, no need to use quotes.
arguments
The arguments to pass to the command. This attribute accepts special variables that will be substitute when launching the command. The syntax is $(variablename) where 'variablename' must be one of:

Table 2.1. Variables in Arguments

NameDescription
FilePathThe full name of the current file
FileDirThe directory of the current file
FileNameThe filename without directory and without extension
FileNameExtThe filename with extension but without directory
CurTextThe current selection or the word under the caret. This value will be empty if the selection contains new lines.
directory
The directory where you want the command to execute. This attribute accepts the same variables as the arguments attribute.
save.all
If true, all file are saved before launching the command.
show.window
Set this attribute to true for graphical tools, set it to false to the other to prevent the opening of a console. This attribute is unused on Linux platform.

When a tool is run, its output is parsed. If a line is recognized as an error or warning message, it will appear in the output window as a link. The editor recognizes two syntaxes:

filename:line:message
filename(line):message

If the file is not an absolute path, the directory specified in tool is used. If there is no directory specified, the current working directory of the editor is used instead.

Add or Modify a Language Definition

If you want to edit the language file, either copy languages.cb-config in your home folder, or backup it before re-installing a new version.

Note

The language file is loaded only once at startup. Any change to this file won't take effect until restarting the application.

Table 2.2. Attributes for a Language Definition

NameDescription
colorizer The name of the colorizer function.

It can be one of:

  • generic
  • cxx
  • makefile
  • html
  • python
  • tex
  • monochrome

Only the generic colorize function uses all of the following attributes.

line.comment The beginning of a comment line. This attribute is used for folding as well as for colorization.
line.comment.2 The beginning of an alternative comment line. This attribute is used for colorization only.
open.comment The beginning of a comment block. This attribute is used for folding as well as for colorization.
close.comment The end of a comment block
open.comment.2The beginning of an alternative comment block
close.comment.2The end of an alternative comment block
preprocessorThe preprocessor characters (e.g. '#')
hexa.prefixThe hexadecimal prefix (e.g. '0x')
string.delimiterThe delimiter character for strings
string.escape.charThe escape character inside strings
regex.delimiterThe delimiter character for regex (e.g. '/' in Ruby)
regex.escape.charThe escape character inside a regex (e.g. '\' in Ruby)
char.delimiterThe delimiter character for characters
char.escape.charThe escape character inside characters
char.prefixThe prefix character for chars (e.g. '$' in Smalltalk)
escape.charThe escape character
ignore.case'true' if keywords are not case sensitive
words.1First class of words
words.2Second class of words
words.3Third class of words
words.4Fourth class of words
chars.1First class of chars
chars.2Second class of chars
chars.3Third class of chars
chars.4Fourth class of chars

Appendix A. Miscellaneous

Table of Contents

Tips

Tips

This is a various collection of tips to better use the potential of the program.

Using Bookmarks

There is no bookmark, but you can use an alternate window to remember a position:

  1. Use the Clone command (CTRL-K) from the Window menu to open the current folder in a new tab.
  2. Perform any action: search, edit,...
  3. Either close the window or switch current window using CTRL-TAB: you should recover your previous location.

Using a Project File

Code Browser does not handle projects, but it is easy to create a file to access all files of a project: just create a file project.cbi and then add links to the source files.

Transforming Text to Comment and Vice Versa

The Text Line and Comment Line commands in the Insert menu can be used to transform the current selection into comment or text. It can be useful to comment/uncomment source code, but also to transform source comments into Code Browser comments.