Git Product home page Git Product logo

janeway's Introduction

Janeway

A Node.js console REPL with object inspection and many other features.

NPM version Flattr this git repo

Console

Install

Install it for use in your own application:

npm install janeway

Or use it globally:

npm install -g janeway

Features

  • Interactive command line, that always has focus
  • Autocomplete
  • Output is clickable. Variables can be inspected, just like in the browser
  • Selected variables can be copied to clipboard

Use it globally

Start your applications like so:

janeway my_js_file.js

Use as standalone

If you just want to give it a go, try out the start.js file in Janeway's main folder:

node start.js

Use in your application

You can load Janeway like this:

var Janeway = require('janeway');

// Janeway will take over the screen only when you call start
Janeway.start(function started() {

});

The screen automatically scrolls down when a new line is pushed (unless you've scrolled the screen manually). You can disable this like so:

Janeway.scroll_down = false;

uncaughtExceptions

By default Janeway will add an uncaughtException handler.

It simple re-throws the error to circumvent blessed's one, which would hide the error message and stacktrace.

As soon as you add another listener, Janeway will ignore uncaught exceptions and let you handle them.

You can also let Janeway simply print out errors, instead of closing:

Janeway.shutdown_on_exception = false;

This is not recomended, but can be useful during development.

Set terminal title

You can set the terminal's title with this Janeway method:

Janeway.setTitle('My beautiful title');

When the application exits the title will be restored. You can also manually unset the title with an explicit false as parameter:

Janeway.setTitle(false);

Set statusbar

Since version 0.2.0 Janeway also has a statusbar at the bottom of the screen. This can be used for shorter, text-only messages of medium importance.

Janeway.setStatus('This is the statusbar!');

By default Janeway will add {right} blessed tags, which causes the text to be rendered on the right side of the screen. You can also use other blessed tags in your text.

Janeway will also return a Status object. In case you plan on creating some kind of spinner there, it is best to update it like this:

var spinner;

// Some crappy code just to show how status setText works
var id = setInterval(function spinnerInterval() {

    var spintext;

    if (!spinner) {
        spinner = Janeway.setStatus();
    }

    i += 10;

    spintext = Janeway.Blast.Bound.String.multiply('*', Math.ceil(i/10));
    spintext += Janeway.Blast.Bound.String.multiply(' ', Math.ceil((100-i)/10));

    spinner.setText(spintext);

    if (i == 100) {
        clearInterval(id);
    }
}, 500);

This is done because (in a later version) status messages are stored in an array so you can see a history of them.

Indicators

Since version 0.2.1 an indicator area has been added to the topright corner, you can add one like this:

var indicator = Janeway.addIndicator({icon: '{red-fg}โ—‰{/red-fg}'});

// Change the icon
indicator.setIcon('โ—‹');

// Set a hover text
indicator.setHover('This is some hovertext');

// Remove the indicator again
indicator.remove();

Copy to clipboard

At the top of the screen there is a menubar, currently it only contains 1 button: "Copy".

When you click this, the currently selected element will be copied into the clipboard. Objects will be JSON-ified using JSON-Dry.

Here are a few things you might need to configure first:

  • Install xclip
  • Enable X11 forwarding when using an SSH session
  • You might need xvfb on headless SSH servers
  • If you're multiplexing SSH connections, the first one will need to have X11 forwarding enabled!

Stored configuration

You can store your configuration in ~/.janeway/janeway.json.

These are currently the default values:

{
    "autocomplete" : {

        // Set to false to turn autocomplete off
        "enabled" : true,

        // The height of the autocomplete popup
        "height"  : 6
    },

    // output is the main output screen in the middle
    "output" : {

        // Main scrollbar style
        "scrollbar": {
            "bg" : "blue"
        },

        // General output style
        "style" : {
            "bg" : "transparent",
            "fg" : "white"
        }
    },

    // cli is the inputbox on the bottom
    "cli" : {
        "style" : {
            "bg" : "white",
            "fg" : "blue"
        },

        // Unselect open items on return
        "unselect_on_return": true
    },

    // the statusbar on the bottom
    "status" : {
        "enabled" : true,
        "style"   : {
            "bg": "grey",
            "fg": "white"
        }
    },

    // popups, also used by autocomplete
    "popup" : {
        "scrollbar": {
            "bg" : "green"
        },
        "border": {
            "type" : "line"
        },
        "style": {
            "bg": "blue",
            "fg": "white"
        },
        "shadow": true,
    },

    // menubar
    "menu" : {
        // This style only applies to unused parts and indicators
        "style": {
            "bg": "white"
        },
        "button": {
            "bg"    : "white",
            "fg"    : 235,
            "focus" : {
                "bg" : "red",
                "fg" : 249
            },
            "hover" : {
                "bg": "red",
                "fg": 249
            }
        }
    },

    // indicators
    "indicator": {
        "style": {
            "bg": 240,
            "fg": 231,

        }
    },

    "cli_history": {

        // Amount of lines to save
        "save"      : 100,

        // Use title in filename?
        "per_title" : true
    }
}

Author

You can follow me on twitter: Twitter@skeriten

License

MIT

janeway's People

Contributors

skerit avatar

Watchers

James Cloos avatar songz avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.