Skip to content

Commit 642a181

Browse files
committed
Merge pull request #266 from parallaxinc/add-stamp-directives
add directive builder function and modify newFile handler
2 parents 5c339d2 + e080792 commit 642a181

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

src/lib/directive.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
3+
function device(type){
4+
return `'{$STAMP ${type}}`;
5+
}
6+
7+
function pbasic(ver){
8+
return `'{$PBASIC ${ver}}`;
9+
}
10+
11+
function directive(board, language){
12+
return `${device(board)}\n${pbasic(language)}\n\n`;
13+
}
14+
15+
module.exports = directive;

src/plugins/handlers.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const consoleStore = require('../console-store');
1212
const Terminal = require('../lib/terminal');
1313
const Documents = require('../lib/documents');
1414
const highlighter = require('../lib/highlighter');
15+
const directive = require('../lib/directive');
1516

1617
const {
1718
NEW_FILE,
@@ -102,11 +103,14 @@ function handlers(app, opts, done){
102103
return;
103104
}
104105

105-
workspace.newFile(builtName, '')
106+
const insertDirective = directive('BS2', 2.5);
107+
108+
workspace.newFile(builtName, insertDirective)
106109
.then(() => userConfig.set('last-file', builtName))
107110
.then(function(){
108-
documents.create(path.join(cwd, builtName), '');
111+
documents.create(path.join(cwd, builtName), insertDirective);
109112
documents.focus();
113+
goDocEnd();
110114
});
111115
}
112116

@@ -296,6 +300,10 @@ function handlers(app, opts, done){
296300
cm.execCommand('replace');
297301
}
298302

303+
function goDocEnd(){
304+
cm.execCommand('goDocEnd');
305+
}
306+
299307
function moveByScrollUpLine(){
300308
const scrollbox = cm.getScrollInfo();
301309
cm.scrollTo(null, scrollbox.top - cm.defaultTextHeight());

0 commit comments

Comments
 (0)