Screenshots

As is the practice nowadays, we show you some screenshots to wet your appetite.

These screenshots demonstrate various features implemented with Lua. No C code is used.

See here how to enable these features.

First run

If you're a newbie you'll be asked, on startup, if you want to enable all the nice feutures you see on this page. No reason not to!

This lets you experiment with mc2 without configuring it first.

Fields

You can write your own fields in Lua.

  • This image shows some git-related fields. This saves you from having to do “git status” repeatedly.

  • We also see here that the Size field was redefined (again, using Lua alone) to show commas (or some other means the locale rules dictate), to make it easier to read.

  • We have a proportional scrollbar.

Let’s analyze what we see in the picture:

The git branch name is is displayed at the bottom of the panel (it’s not a field). The working directory is dirty (we have local modifications), which is why it’s displayed in red.

The When, Author, and Message fields tell us the details of the last commit of the file. For example, arg.c was last committed 22 days ago by Andrew. The commit’s ID (shown at the mini status) is 8c88aa01ad.


The St[atus] field is the realy useful field here (and is probably the only field you'll want displayed, especially since it has little performance penalty). It’s a two-character field showing the status of the file (see git-status(1) for the letters' meaning):

  • We've modified cons.handler.c.
  • We've renamed help.h to helping.h and also modified it.
  • We've added newfile.c (but not yet committed it).
  • We've created output.html, which is not tracked by git.
  • The subtree under man2hlp too has been modified in some way, to which the ** hints.

On the right panel: defs.js is ignored (by being listed in .gitignore), and a few other files are not tracked by git (indicated by ??). The working directory there is clean (displayed in green).

More fields; BiDi

  • This image shows some multimedia fields. We see the Durat[ion] of videos / songs, the Bi[trate] and, for videos, the Hei[ght] in pixels. These fields are sortable.

These fields are aggressively cached, so it’s feasible to use them even on slow machines.

  • The Name field was redefined to support BiDi languages like Arabic and Hebrew: the letters order is reversed and, for Arabic, character shaping is performed.

Note the drop-shadow effect for dialogs, the frame icons, and how the Sort order dialog was dragged away from the center to make the screenshot more useful. This “pyrotechnic” is implemented with just a few lines of Lua code. No “code bloat” is involved here.

Visual Rename

Sometimes you wish to rename a bunch of files using some regexp. MC can do this but with MC it’s like shooting in the dark: you don’t know the names you'll end up with till you perform the rename, and then you may discover, to your dismay, that you'll be overwriting some files!

Visual Rename solves this by showing you, as you type, how your files will end up. It also warns you if clashes (overwriting files) will occur. You can also rename files down a directory tree by “panelize"ing first.

You may even plug in your own code. No more wasting time on writing those little shell/ruby/perl script to rename files!


Also note the “Panelize” button. There’s a special mode that makes Visual Rename act somewhat like a filter-as-you-type feature.

“Folder Jumping”

Folder jumping lets you jump over folders that contain nothing more than a single sub-folder.

The feature was borrowed from GitHub.com.

This is a great time-saver sanity-saver when navigating projects that suffer from “Directoritis”, a syndrome that afflicts Java and modern PHP projects.

The screenshot at the background shows that you can use a fancy separator instead of “/”.

Filesystems

You can write filesystems in Lua. The following naive code:

local myfs = {

  prefix = "myfs",

  readdir = function ()
    return { "one.txt", "two.txt", "three.txt" }
  end,

  file = function (_, path)
    if path == "one.txt" then
      return "Mary had a little lamb.\nHis fleece was white as snow."
    end
  end

}

fs.register_filesystem(myfs)

results in:

You'll also find bundled filesystems for SQLite, MySQL and MHT.

Editor

The editor too can benefit from scripting, as we'll see here.

Speller

A basic speller can be implemented in just 5 lines of code.

The speller script shown here interacts with your actual speller via the aspell / ispell / hunspell / spell binary.

This is very different than MC’s current approach of linking against a certain C library, an approach which deprives you of the freedom to choose a speller, and of the freedom to decide whether this feature is actually enabled (as it’s a compile-time decision).

Note, in the picture, that misspellings are only highlighted when they occur in comments (and string literals). We certainly don’t want “misspellings” occurring in the main code (e.g. “g_getenv”) to be highlighted.

Linter

Linter for various languages.

… you can also use it to conveniently browse a disassembler’s output (or whatever other tool that’s of interest to you).

Visual Replace

The Visual Rename we've seen earlier also works in the editor, where it’s known as Visual Replace. It lets you see all the changes in advance, making it a safe alternative to the potentially hazardous “Replace All”.

Function list

Shows a menu of your functions.

Modeline

Modeline support.

UnicodeData.txt; ruler; scrollbar

We see three features here:

  • The unicodedata.lua script shows the UTF-8 bytes, and the appropriate line from UnicodeData.txt, of a character we're curious about.

  • There’s a ruler if you need to measure distances on the screen. It works anywhere, not just in the editor.

  • There’s a scrollbar at the left.

UnWind

Are you editing files created by Windows/DOS programmers? Let the unwind module automatically convert CR+LF to LF for you. No more distracting “^M” at line ends!

It also lets you toggle visible tabs with a hotkey (as files coming from Visual Studio often use tabs).

This screenshot shows the indicator it displays at the bottom-right corner:

  • “cr-converted” means that the line-endings have been converted.
  • “T” means that visible tabs is on.
  • “4” is the tab size.

“Actors”

The idea behind the “modeline” feature —of embedding meta information in the text— can be used for implementing various creative ideas.

Here we've embedded the names of the characters of a novel at the start of the text. Our "actors" script then colors them up. Males are in bluish color; females in pinkish.

Also shown here is our dictionary.lua script.

User Interface

We have an elegant, easy, and yet powerful API for creating user interfaces.

A game.

In this picture we also happen to be editing the source code of the game. We can edit Lua code right inside MC and then ask it to reload the Lua subsystem when we want to see the effects of our modified code. We don’t need to restart MC.

Notice, in the picture, several things borrowed from the JavaScript world: set_interval and on_click. Additionally, Lua is a dynamic language, which makes it possible to use different styles of programming.


Also note the scrollbar at the left.

Creating frontends for command-line tools

While the command-line is gods' gift to mankind, it’s sometimes a drag having to revisit the manual pages to refresh your memory on how to run some programs.

Dread no more! You can now create your own UI frontends. Here is one used to scan images.

Recently Visited Files; xterm titles

Here’s a box showing you the files you've recently visited. That is, files you're currently or have recently edited or viewed.

This feature saves you a huge amount of keystrokes because you no longer need to navigate among directories. There’s also a “Goto” button which makes this box an alternative to the “Directory hotlist” box.

Files you're currently editing are marked with “*”. Files currectly viewed are marked with “v”. You can switch to them right from this box, which makes it also a replacement for MC’s “Screens” box.

Files edited in other MC processes are marked with “!”.

You can even provide your own code to alter the list. E.g., you can add there files edited in Vim or gedit. Or you can populate it with all the files in your project.


You also see here alternative xterm titles. Note the terminal’s three tabs: MC’s builtin xterm titles would have wasted precious space. Here we have “[M] /path/to/dir” shown for the filemanager, and “[E] edited-file.txt” for the editor. You may customize this. E.g., you can add the process ID to the title.

Note that we're editing the “TODO” file in the left tab. Indeed, our Recently visited files box indicates (with a “!”) that this file is being edited by another process.

Snapshots

Want to save the state of your panels? You have it: snapshots.

This feature is somewhat like tabs, and somewhat like the “Directory hotlist”.


Note the “sb” snapshot, which doesn’t record a directory (indicated by <none>). We use it to easily restore a sorting order and a custom listing format.

The “p” snapshot, on the other hand, records nothing but directory paths (indicated by a missing +).

In the “radio” snapshot one (or both) of the panels is panelized (indicated by the P).

Tabs

You want tabs? You've got them.

Calculator

Tired of running irb, python, ghci, etc. every time you need to evaluate some formula? Sure you are.

Here’s the solution. A calculator.

You're not limited to math formulas: any Lua expression works.

Find-as-you-type; hotkeys; clock

This image shows three accessories:

  • As the purple arrows shows, you can search in any listbox. Here we demonstrate this with the Directory Hotlist dialog, but it works anywhere.

(“broo” matches “Brooks” because the search is case insensitive unless you type an uppercase letter. If the search string isn’t found, the “Search” box is painted in alert colors (typically red).)

  • The yellow arrows demonstrate the hotlist-keys module, which lets you associate keys with directories (or groups). You embed key names in square brackets and then you can activate items by pressing these keys. (The “Raw” button is a convenience button that opens ~/.config/mc/hotlist in the editor.)

  • You also see a clock at the top-right corner.

Docks

You can inject your own widgets into the filemanager (this is just a “by product” of our fine user interface API).

The ticker module injects widgets that show you the output of shell commands and have this display updated every X seconds.

In this picture we see two tickers. The top one (the reddish) shows some RSS feeds. The bottom one (the khaki) shows a random line from a text file (useful for people learning some [human] language and needing to improve their vocabulary, for example).

The user can easily improvise a clock by using a ticker, but there’s already one.


Some other potential uses for this ability:

  • A bar with extra information about the selected file or files.
  • A tab bar.

Access-warning

We can inject widgets to the editor too. Here we use this ability to inject, besides a scrollbar, a label warning you about files you won’t be able to save. It also makes the editbox read-only in such cases.

(This label, as the scrollbar, doesn’t come on top of the text: it’s docked south of it.)

Scrollbar; filter-as-you-type

We see two features here:

  • A scrollbar. (If you look very carefully you'll see that it’s shown for the inactive panel too.)

Unlike MC’s useless non-proportional listbox scrollbar, this scrollbar is proportional (same is true for the scrollbar in the editor).

  • A filter-as-you-type box. But you may find the panelize mode of Visual Rename superior (as, among other things, it can filter directories).

Restore selection

Imagine that you find out that the USB stick you copied a few files to was accidentally formatted. You use the restore selection feature to go back in time and re-select those files so that you can copy them again.

Various accessories

Will the four files on the left, weighting “1,857,302K bytes” fit in the “1,819” MiB free space on the right? You're not sure. Thankfully, Size calculator says your files consume just “1,813.77 MiB”. Hurrey! They will fit!

Screensavers

A screensaver showing an analog clock (indicating 12:38:26).

Standalone mode

You can run scripts from the command line. You don’t have to be “inside” MC. Let’s see some examples.

HTMLizer

The htmlizer uses the syntax highlighting support of MC’s editor to convert source files to HTML.

User interface

You can use the UI even in standalone mode…

We've seen this game earlier. Here we see it used “outside” MC.

…which makes standalone mode an ideal replacement for dialog(1) and zenity(1).

More…

There are many useful scripts bundled that aren’t mentioned here. Go ahead and experiment!

skip-toc

generated by LDoc 1.4.3 Last updated 2016-08-23 17:29:40