fix(help): better help and first run experience

This commit is contained in:
Dan Kaplun 2015-10-07 20:10:30 -04:00
parent b98ffae01c
commit 1a654419ff
2 changed files with 13 additions and 5 deletions

View File

@ -86,9 +86,7 @@ module.exports = function (options) {
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')));
}
}

View File

@ -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 () {