csup - Crystal rewrite of sup email client

Crscope
Login

Crscope

Crscope is a source code browsing tool for Crystal and Ruby. It is a partial reimplementation of cscope, the venerable source code browing tool for C.

Crscope uses different parsing strategies for Crystal and Ruby:

Like cscope, crscope can also search for files, using a partial match of the term you enter, and can also search using regular expressions.

Crscope records information about method and class names using a qualified syntax of the form Class1.Class2[...].MethodName, where nested classes are separated with periods. This is slightly different from the scoping syntax used in Crystal and Ruby, but it allows for a consistent and simple naming scheme.

New features

Crscope has several features that are missing in cscope:

Curses-based interface

Aside from completions and search field editing (described below), the default curses-based user interface attempts to be close to cscope, though some features are missing.

(Note: in the following descriptions, Ctrl key combinations are indicated using the notation C-x, where x is a letter key.)

The screen is divided into two sections:

Switch between the two sections using the Tab (C-i) key. In each section, you can move from one line to another using the Down, Up, C-n, and C-p keys.

In the search entry fields, you can use EMACS-style editing keys. In symbol searches, hit the * key to show partial matches in the search results, or hit Enter to perform a more precise search.

In the search results section, hit the Enter key to run your editor on the selected file and jump to the selected line number. You can also type the letter shown on the left column to run the editor on that file and line.

Press C-d at any point to quit.

Press C-c at any point to toggle the "ignore case" flag.

Press C-q at any point to toggle the "qualified match" flag.

Crscope's search types are similar to those in cscope, but differ slightly in some ways.

Line-oriented interface

Crscope has a line-oriented mode whose interface is identical to cscope's, but with a limited set of search types. Start the line-oriented mode with the -l option:

crscope -l

This mode is used by MicroEMACS, and it could possibly be used by other editors that have cscope integration. This mode implements the following search types:

Crscope will repreatedly prompt with ">> ", and read a line from standard input. The first character of the line is the search type, as described above. The rest of the line is the string to search.

In response, Crscope will respond with a line containing the number of matches found, followed the matches, one on each line. For example, here is a session where I asked cscope to do an inexact search for initialize:

>> 0initialize
cscope: 89 lines
./lib/ncurses/src/ncurses/mouse_event.cr NCurses.initialize 9 def initialize(event : LibNCurses::MEVENT)
./lib/ncurses/src/ncurses/mouse_event.cr NCurses.initialize 15 def initialize(@device_id, @coordinates, @state)
./lib/ncurses/src/ncurses/window.cr NCurses.Window.initialize 12 def initialize(height = nil, width = nil, y = 0, x = 0)
./lib/ncurses/src/ncurses.cr NCurses.Window.initialize 31 def initialize(@window : LibNCurses::Window)
./lib/email/src/email/address.cr EMail.Address.initialize 31 def initialize(mail_address : String, mailbox_name : String? = nil)
./lib/email/src/email/concurrent_sender.cr EMail.ConcurrentSender.initialize 45 def initialize(@config)
./lib/email/src/email/concurrent_sender.cr EMail.ConcurrentSender.initialize 51 def initialize(*args, **named_args)
./lib/email/src/email/header.cr EMail.Header.initialize 70 def initialize(field_name : String)
./lib/email/src/email/header.cr EMail.Header.Date.initialize 183 def initialize
./lib/email/src/email/header.cr EMail.Header.MimeVersion.initialize 218 def initialize(@version : String = "1.0")
./lib/email/src/email/header.cr EMail.Header.ContentType.initialize 232 def initialize(@mime_type : String, @params = Hash(String, String).new)
... [remainder of lines omitted]

Note that the first line says "cscope" instead of "crscope". This is done to ensure compatiblity with editors (such as MicroEMACS) that expect "cscope" in the response..

Each line contains four fields, separated by a space:

Press C-d (Ctrl-D) at the prompt to quit.

Files

Crscope uses two files:

Environment Variables

Crscope uses the following environment variables:

Running crscope

Crscope takes the following options:

If you don't specify -l, crscope will start the curses-based interface.

You can specify filenames after any options; crscope will search those files for symbols. If you don't specify any filenames, crscope will read crscope.files to get the names of files to read.

Each time you run crscope without the -d option, it will reparse all specified files, and reconstruct the symbol file crscope.out from scratch. On the ancient machines of the 80s, this would have been a very expensive operation; hence, cscope had several ways to optimize this, by only parsing those files that had changed, and by modifying only the parts of the symbol database for those changed files. These optimizations are unnecessary on today's fast machines; crscope should be fast enough even with its brute force strategy.

Build

Build crscope using:

make crscope

Then copy the binary to some place in your PATH.