mirror of
https://github.com/slap-editor/slap.git
synced 2024-09-11 04:45:47 +03:00
Merge branch 'master' into issue-193
This commit is contained in:
commit
2cc7511678
4
CONTRIBUTING.md
Normal file
4
CONTRIBUTING.md
Normal file
@ -0,0 +1,4 @@
|
||||
Contributing
|
||||
============
|
||||
|
||||
Contributors can get involved by filing PRs and demonstrating sufficient interest in maintaining the code base and its corollaries.
|
38
README.md
38
README.md
@ -1,6 +1,6 @@
|
||||
![Screenshot](https://raw.githubusercontent.com/slap-editor/slap/master/screenshot.png)
|
||||
|
||||
slap :wave: [![Build Status](https://img.shields.io/travis/slap-editor/slap.svg)](https://travis-ci.org/slap-editor/slap) [![Donate](https://img.shields.io/gratipay/dbkaplun.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=DHDCDVEQSXB8S&lc=US&item_name=slap¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted)
|
||||
slap :wave: [![Build Status](https://img.shields.io/travis/slap-editor/slap.svg)](https://travis-ci.org/slap-editor/slap) [![Donate](https://img.shields.io/gratipay/slap.svg)](https://gratipay.com/slap/)
|
||||
====
|
||||
|
||||
slap is a Sublime-like terminal-based text editor that strives to make editing
|
||||
@ -9,7 +9,7 @@ from the terminal easier. It has:
|
||||
* first-class mouse support (even over an SSH connection)
|
||||
* a Sublime-like file sidebar
|
||||
* double-click to select word, highlight other occurrences
|
||||
* configurable Sublime-like [keybindings](slap.ini#L51)[*](#some-keys-dont-work) (Ctrl+S save, Ctrl+Z undo, etc.)
|
||||
* configurable Sublime-like [keybindings](#default-keybindings)[*](#some-keys-dont-work) (Ctrl+S save, Ctrl+Z undo, etc.)
|
||||
* copying/pasting with OS clipboard support
|
||||
* infinite undo/redo
|
||||
* syntax highlighting for [100+ languages](https://github.com/isagalaev/highlight.js/tree/master/src/languages)
|
||||
@ -32,17 +32,31 @@ Usage
|
||||
|
||||
$ slap fish.c
|
||||
$ slap fish1.c fish2.c
|
||||
$ slap redfish/ # open dir in browser
|
||||
$ slap # new file in current dir
|
||||
$ slap redfish/ # open dir
|
||||
$ slap # new file
|
||||
|
||||
### Default keybindings
|
||||
|
||||
* **Quit**: <kbd>Ctrl+Q</kbd>
|
||||
* **Movement**: mouse or arrow keys and <kbd>PageUp/Down</kbd>/<kbd>Home</kbd>/<kbd>End</kbd>
|
||||
* <kbd>Shift</kbd> or click+drag to select, <kbd>Ctrl</kbd>/<kbd>Alt</kbd> to move faster
|
||||
* **Save**: <kbd>Ctrl+S</kbd>
|
||||
* **Undo**: <kbd>Ctrl+Z</kbd>, **redo**: <kbd>Ctrl+Y</kbd>
|
||||
* **Next/previous tab**: <kbd>Ctrl+Alt+PageUp/Down</kbd>
|
||||
* **Close tab**: <kbd>Ctrl+W</kbd>
|
||||
* **Find**: <kbd>Ctrl+F</kbd>
|
||||
* **Go to line**: <kbd>Ctrl+G</kbd>
|
||||
* **Go to matching bracket**: <kbd>Ctrl+]</kbd>
|
||||
* **Open**: <kbd>Ctrl+O</kbd> (or click the filebrowser)
|
||||
* **New file**: <kbd>Ctrl+N</kbd>
|
||||
|
||||
### Configuration
|
||||
|
||||
Use `~/.slap/config` to override the defaults in [slap/slap.ini](slap.ini#L1):
|
||||
slap supports INI or JSON config files. You can put configuration [wherever rc can find it](https://github.com/dominictarr/rc#standards).
|
||||
A mostly empty configuration file with some useful comments is created in [`~/.slap/config`](default-config.ini)
|
||||
if an existing file isn't found.
|
||||
|
||||
[header.style]
|
||||
bg = "red"
|
||||
|
||||
Alternatively, pass options in via command line:
|
||||
Pass configuration via command line:
|
||||
|
||||
$ slap --header.style.bg red file.c
|
||||
|
||||
@ -83,6 +97,8 @@ nature.
|
||||
|
||||
### Some keys don't work!
|
||||
|
||||
*NOTE: if you are using Terminal.app, see [slap-Terminal.app-profile](https://github.com/slap-editor/slap-Terminal.app-profile).*
|
||||
|
||||
Unfortunately most terminal emulators do not support certain keystrokes and as
|
||||
such there is no way to handle them. These include `C-backspace`, `S-home/end`,
|
||||
and `S-pageup/down`. Most of these actions have alternate keybindings, inspired
|
||||
@ -92,9 +108,7 @@ by emacs and other editors, but if you find one that doesn't work, please
|
||||
### Slow on single cores, Raspberry Pi
|
||||
|
||||
slap is based on Github's [atom/text-buffer](https://github.com/atom/text-buffer),
|
||||
and as such should be very performant, even with very large files. There are a
|
||||
few performance bottlenecks that still exist related to rendering, but should
|
||||
not affect most use cases.
|
||||
and as such should be very performant, even with very large files.
|
||||
|
||||
Try `--editor.highlight false` or adding the following to `~/.slap/config`:
|
||||
|
||||
|
@ -103,9 +103,7 @@ module.exports = function (options) {
|
||||
} else if (!opts._.length) { // if no files are passed
|
||||
new Pane({parent: slap}).setCurrent(); // open a new empty file
|
||||
if (!opts.config) { // first run without a file passed
|
||||
slap.open(path.join(baseDir, 'README.md'), true)
|
||||
.tap(function (pane) { pane.editor.readOnly(true); })
|
||||
.done();
|
||||
slap.help().done();
|
||||
fs.createReadStream(path.join(__dirname, '..', 'default-config.ini')).pipe(fs.createWriteStream(path.join(userDir, 'config')));
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ BaseFindForm.prototype._initHandlers = function () {
|
||||
}
|
||||
});
|
||||
|
||||
textBuf.on('changed', function () { self.find(textBuf.getText()); });
|
||||
textBuf.onDidChange(function () { self.find(textBuf.getText()); });
|
||||
self.findField.on('keypress', function (ch, key) {
|
||||
var text = textBuf.getText();
|
||||
switch (self.resolveBinding(key)) {
|
||||
|
@ -127,8 +127,8 @@ Pane.prototype._initHandlers = function () {
|
||||
|
||||
self.on('close', function () { self.screen.slap.header.message(null); });
|
||||
editor.on('insertMode', function () { self.screen.slap.header.render(); });
|
||||
['path-changed', 'changed'].forEach(function (evt) {
|
||||
editor.textBuf.on(evt, function () { self.screen.slap.header.render(); });
|
||||
['onDidChange', 'onDidChangePath'].forEach(function (prop) {
|
||||
editor.textBuf[prop](function () { self.screen.slap.header.render(); });
|
||||
});
|
||||
|
||||
return BaseWidget.prototype._initHandlers.apply(self, arguments);
|
||||
|
@ -85,8 +85,18 @@ Slap.prototype.quit = function () {
|
||||
};
|
||||
Slap.prototype.help = function () {
|
||||
return this
|
||||
.open(path.join(__dirname, '../../slap.ini'), true)
|
||||
.tap(function (pane) { pane.editor.readOnly(true); });
|
||||
.open(path.join(__dirname, '..', '..', 'README.md'), true)
|
||||
.tap(function (pane) {
|
||||
var editor = pane.editor;
|
||||
editor.readOnly(true);
|
||||
editor.textBuf.scan(/^Usage/, function (match) {
|
||||
var start = match.range.start;
|
||||
editor.selection.setRange([start, start]);
|
||||
editor.scroll = start.translate([-editor.buffer.options.cursorPadding.top, 0]);
|
||||
editor._updateContent();
|
||||
match.stop();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Slap.prototype._stopKeyPropagation = function () {
|
||||
|
22
package.json
22
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "slap",
|
||||
"version": "0.1.52",
|
||||
"version": "0.1.56",
|
||||
"description": "Sublime-like terminal-based text editor",
|
||||
"preferGlobal": true,
|
||||
"main": "lib/cli.js",
|
||||
@ -21,25 +21,21 @@
|
||||
"author": "",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"base-widget": "1.0.7",
|
||||
"base-widget": "1.0.9",
|
||||
"blessed": "0.1.81",
|
||||
"bluebird": "2.10.2",
|
||||
"editor-widget": "1.0.14",
|
||||
"bluebird": "3.0.6",
|
||||
"editor-widget": "1.1.0",
|
||||
"lodash": "3.10.1",
|
||||
"mkdirp": "0.5.1",
|
||||
"node-clap": "0.0.5",
|
||||
"rc": "1.1.2",
|
||||
"slap-clipboard-plugin": "0.0.13",
|
||||
"rc": "1.1.5",
|
||||
"slap-util": "1.0.5",
|
||||
"update-notifier": "0.5.0"
|
||||
"update-notifier": "0.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"get-random-port": "0.0.1",
|
||||
"istanbul": "0.3.21",
|
||||
"node-inspector": "0.12.3",
|
||||
"tape": "4.2.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "<0.11 >=0.12.5"
|
||||
"istanbul": "0.4.1",
|
||||
"node-inspector": "0.12.5",
|
||||
"tape": "4.2.2"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user