From 487296cd047be195aa5c3df486a9694614c9a2f4 Mon Sep 17 00:00:00 2001 From: Matthew Shepard Date: Wed, 1 Jul 2015 18:17:50 -0700 Subject: [PATCH 01/11] Implement syntax highlighting on compiler error --- plugins/editor/key-extension.js | 8 ++++++ plugins/sidebar/index.js | 3 ++ src/actions/editor.js | 9 ++++++ src/stores/editor.js | 49 +++++++++++++++++++++++++++++++-- src/stores/file.js | 5 ++++ 5 files changed, 72 insertions(+), 2 deletions(-) diff --git a/plugins/editor/key-extension.js b/plugins/editor/key-extension.js index 705a0ac..97efaaa 100644 --- a/plugins/editor/key-extension.js +++ b/plugins/editor/key-extension.js @@ -6,6 +6,7 @@ const { findNext, findPrevious, replace } = require('../../src/actions/find'); const { moveByScrollUpLine, moveByScrollDownLine } = require('../../src/actions/editor-move'); const { dedent, indent } = require('../../src/actions/text-move'); const { print } = require('../../src/actions/system'); +const { syntaxCheck } = require('../../src/actions/editor'); const { newFile, saveFile } = require('../../src/actions/file'); const { hideOverlays, showSave, showDownload, showProjects } = require('../../src/actions/overlay'); const { disableAuto, enableAuto } = require('../../src/actions/device'); @@ -120,6 +121,13 @@ const keyExtension = { evt.preventDefault(); showProjects(); } + }, + syntaxCheck: { + code: ['CTRL_T', 'F7'], + exec(evt){ + evt.preventDefault(); + syntaxCheck(); + } } }; diff --git a/plugins/sidebar/index.js b/plugins/sidebar/index.js index 7d0eaf1..9f5b17d 100644 --- a/plugins/sidebar/index.js +++ b/plugins/sidebar/index.js @@ -22,6 +22,7 @@ function sidebar(app, opts, done){ const overlay = app.overlay; const userConfig = app.userConfig; const irken = app; + const compile = app.compile.bind(irken); const getBoard = app.getBoard.bind(irken); const scanBoards = app.scanBoards.bind(irken); @@ -63,6 +64,8 @@ function sidebar(app, opts, done){ deviceStore.getBoard = getBoard; deviceStore.scanBoards = scanBoards; + editorStore.toast = toast; + editorStore.compile = compile; editorStore.workspace = space; fileStore.workspace = space; diff --git a/src/actions/editor.js b/src/actions/editor.js index fcb34f4..29bbd30 100644 --- a/src/actions/editor.js +++ b/src/actions/editor.js @@ -6,6 +6,15 @@ class EditorActions { handleInput(inst) { this.dispatch(inst); } + highlight(position, len) { + this.dispatch({ + position: position, + length: len + }); + } + syntaxCheck(){ + this.dispatch(); + } } module.exports = alt.createActions(EditorActions); diff --git a/src/stores/editor.js b/src/stores/editor.js index 28354ad..61d3ddf 100644 --- a/src/stores/editor.js +++ b/src/stores/editor.js @@ -1,9 +1,11 @@ 'use strict'; const alt = require('../alt'); +const styles = require('../../plugins/sidebar/styles'); const { findNext, findPrevious, replace } = require('../actions/find'); -const { handleInput } = require('../actions/editor'); +const { handleError, handleSuccess } = require('../actions/file'); +const { handleInput, highlight, syntaxCheck } = require('../actions/editor'); const { moveByScrollUpLine, moveByScrollDownLine } = require('../actions/editor-move'); const { dedent, indent } = require('../actions/text-move'); const { print } = require('../actions/system'); @@ -17,10 +19,12 @@ class EditorStore { onFindPrevious: findPrevious, onHandleInput: handleInput, onIndent: indent, + onHighlight: highlight, onMoveByScrollUpLine: moveByScrollUpLine, onMoveByScrollDownLine: moveByScrollDownLine, onPrint: print, - onReplace: replace + onReplace: replace, + onSyntaxCheck: syntaxCheck }); } @@ -77,7 +81,48 @@ class EditorStore { cm.execCommand('replace'); } + onSyntaxCheck() { + const { workspace, compile } = this.getInstance(); + const result = compile({ + type: 'bs2', + source: workspace.current.deref() + }); + if(result.error){ + this.handleError(result.error); + }else{ + this.handleSuccess('Tokenization successful!'); + } + } + onHighlight(opts) { + const { cm } = this.getInstance(); + const doc = cm.getDoc(); + + const anchor = doc.posFromIndex(opts.position); + const head = doc.posFromIndex(opts.position + opts.length); + + console.log('onHighlight', opts, anchor, head); + doc.setSelection(anchor, head); + } + + //duplicated from file store due to dispatch->dispatch invariant + handleError(err){ + // leaving this in for better debugging of errors + console.log(err); + const { toast } = this.getInstance(); + + toast.show(err.message, { style: styles.errorToast }); + if(err && err.errorLength){ + this.onHighlight({ position: err.errorPosition, length: err.errorLength }); + } + } + + //duplicated from file store due to dispatch->dispatch invariant + handleSuccess(msg){ + const { toast } = this.getInstance(); + + toast.show(msg, { style: styles.successToast, timeout: 5000 }); + } } EditorStore.config = { diff --git a/src/stores/file.js b/src/stores/file.js index c4bd879..50a210e 100644 --- a/src/stores/file.js +++ b/src/stores/file.js @@ -8,6 +8,8 @@ const alt = require('../alt'); const styles = require('../../plugins/sidebar/styles'); const { hideOverlays, hideSave } = require('../actions/overlay'); +const { highlight } = require('../actions/editor.js'); + const { clearName, updateName, @@ -207,6 +209,9 @@ class FileStore { const { toast } = this.getInstance(); toast.show(err.message, { style: styles.errorToast }); + if(err && err.errorLength){ + highlight(err.errorPosition, err.errorLength); + } } onHandleSuccess(msg){ From f3654475d5005eb830e88cdef0fff29779f1c6ee Mon Sep 17 00:00:00 2001 From: Matthew Shepard Date: Thu, 2 Jul 2015 13:18:49 -0700 Subject: [PATCH 02/11] Implement tokenization shortcut --- plugins/editor/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/editor/index.js b/plugins/editor/index.js index 0d8658d..1112c8f 100644 --- a/plugins/editor/index.js +++ b/plugins/editor/index.js @@ -67,7 +67,8 @@ function editor(app, opts, done){ 'Ctrl-Up': false, 'Ctrl-Down': false, 'Tab': false, - 'Shift-Tab': false + 'Shift-Tab': false, + 'Ctrl-T': false }); keyExtension.setup(app); editorStore.cm = codeEditor; From c658ffaa8d84faf5d9f4eff38cbd963c0c359179 Mon Sep 17 00:00:00 2001 From: Matthew Shepard Date: Thu, 2 Jul 2015 14:11:11 -0700 Subject: [PATCH 03/11] Remove log --- src/stores/editor.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/stores/editor.js b/src/stores/editor.js index 61d3ddf..f132f25 100644 --- a/src/stores/editor.js +++ b/src/stores/editor.js @@ -100,7 +100,6 @@ class EditorStore { const anchor = doc.posFromIndex(opts.position); const head = doc.posFromIndex(opts.position + opts.length); - console.log('onHighlight', opts, anchor, head); doc.setSelection(anchor, head); } From 068ddb61afcc81da25df51b36d7fe4a19f66ee36 Mon Sep 17 00:00:00 2001 From: Matthew Shepard Date: Thu, 2 Jul 2015 14:12:08 -0700 Subject: [PATCH 04/11] Bump irken version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7e924f4..6a6d930 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "frylord": "^0.6.0", "holovisor": "^0.2.0", "iggins": "^0.2.1", - "irken": "^0.7.0", + "irken": "^0.7.1", "lodash": "^3.9.1", "react": "^0.13.1", "react-loader": "^1.2.0", From 172d3ee4d384295c93a34ca72f7c9c9ae2d6d76f Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Thu, 2 Jul 2015 15:15:48 -0700 Subject: [PATCH 05/11] avoid dispatching handleSuccess/handleError actions --- plugins/editor/index.js | 29 ++++++++++++++++++++++-- plugins/overlays/index.js | 7 ++---- plugins/sidebar/index.js | 22 +++++++----------- src/actions/file.js | 8 ------- src/lib/toasts.js | 47 +++++++++++++++++++++++++++++++++++++++ src/stores/device.js | 30 ++++++++++++++++++++----- src/stores/editor.js | 41 ++++++++++++---------------------- src/stores/file.js | 39 ++++++++++++-------------------- 8 files changed, 136 insertions(+), 87 deletions(-) create mode 100644 src/lib/toasts.js diff --git a/plugins/editor/index.js b/plugins/editor/index.js index 1112c8f..2e0cec1 100644 --- a/plugins/editor/index.js +++ b/plugins/editor/index.js @@ -9,19 +9,23 @@ require('codemirror/addon/selection/mark-selection'); require('codemirror/lib/codemirror.css'); require('../../assets/theme/parallax.css'); +const React = require('react'); const CodeMirror = require('codemirror'); require('./pbasic')(CodeMirror); const keyExtension = require('./key-extension'); + const consoleStore = require('../../src/stores/console'); const editorStore = require('../../src/stores/editor'); const fileStore = require('../../src/stores/file'); + const { handleInput } = require('../../src/actions/editor'); const DocumentsStore = require('../../src/stores/documents'); -const React = require('react'); const TransmissionBar = require('./transmission-bar'); +const makeToasts = require('../../src/lib/toasts'); + function editor(app, opts, done){ var codeEditor; @@ -37,9 +41,30 @@ function editor(app, opts, done){ } } + function highlighter(position, length) { + if(!codeEditor){ + return; + } + + const doc = codeEditor.getDoc(); + + const anchor = doc.posFromIndex(position); + const head = doc.posFromIndex(position + length); + + doc.setSelection(anchor, head); + } + consoleStore.listen(refreshConsole); - var space = app.workspace; + const space = app.workspace; + const compile = app.compile.bind(app); + // seems strange to pass highlighter to toasts + // maybe this should be named "handlers" or something + const toasts = makeToasts(app.toast, highlighter); + + editorStore.toasts = toasts; + editorStore.compile = compile; + editorStore.workspace = space; app.view('editor', function(el, cb){ console.log('editor render'); diff --git a/plugins/overlays/index.js b/plugins/overlays/index.js index 78e3eb5..dda0694 100644 --- a/plugins/overlays/index.js +++ b/plugins/overlays/index.js @@ -11,7 +11,7 @@ const overlayStore = require('../../src/stores/overlay'); const projectStore = require('../../src/stores/project'); const { confirmDelete, changeProject, deleteProject } = require('../../src/actions/project'); -const { handleError, handleSuccess, deleteFile, saveFileAs } = require('../../src/actions/file'); +const { deleteFile, saveFileAs } = require('../../src/actions/file'); const { hideSave, hideDelete, hideDownload, showProjects, hideProjects } = require('../../src/actions/overlay'); function overlays(app, opts, done){ @@ -61,10 +61,7 @@ function overlays(app, opts, done){ if(showDownloadOverlay){ component = ( + onCancel={hideDownload} /> ); } diff --git a/plugins/sidebar/index.js b/plugins/sidebar/index.js index 9f5b17d..207ff4e 100644 --- a/plugins/sidebar/index.js +++ b/plugins/sidebar/index.js @@ -10,21 +10,20 @@ const FileOperations = require('./file-operations'); const ProjectOperations = require('./project-operations'); const deviceStore = require('../../src/stores/device'); -const editorStore = require('../../src/stores/editor'); const fileStore = require('../../src/stores/file'); const { loadFile } = require('../../src/actions/file'); +const makeToasts = require('../../src/lib/toasts'); + function sidebar(app, opts, done){ const space = app.workspace; - const toast = app.toast; - const overlay = app.overlay; const userConfig = app.userConfig; - const irken = app; - const compile = app.compile.bind(irken); - const getBoard = app.getBoard.bind(irken); - const scanBoards = app.scanBoards.bind(irken); + const getBoard = app.getBoard.bind(app); + const scanBoards = app.scanBoards.bind(app); + + const toasts = makeToasts(app.toast); function refreshDirectory(){ // TODO: expose a method to refresh directory without changing it @@ -59,18 +58,13 @@ function sidebar(app, opts, done){ // Store bindings deviceStore.workspace = space; - deviceStore.toast = toast; - deviceStore.overlay = overlay; + deviceStore.toasts = toasts; deviceStore.getBoard = getBoard; deviceStore.scanBoards = scanBoards; - editorStore.toast = toast; - editorStore.compile = compile; - editorStore.workspace = space; - fileStore.workspace = space; fileStore.userConfig = userConfig; - fileStore.toast = toast; + fileStore.toasts = toasts; done(); } diff --git a/src/actions/file.js b/src/actions/file.js index 14a9bb0..7a4e413 100644 --- a/src/actions/file.js +++ b/src/actions/file.js @@ -30,14 +30,6 @@ class FileActions { saveFileAs(name) { this.dispatch(name); } - - handleError(err) { - this.dispatch(err); - } - - handleSuccess(msg) { - this.dispatch(msg); - } } module.exports = alt.createActions(FileActions); diff --git a/src/lib/toasts.js b/src/lib/toasts.js new file mode 100644 index 0000000..bbd4ebe --- /dev/null +++ b/src/lib/toasts.js @@ -0,0 +1,47 @@ +'use strict'; + +const red = '#da2100'; +const green = '#159600'; + +const styles = { + errorToast: { + backgroundColor: red + }, + successToast: { + backgroundColor: green + } +}; + +function toasts(api, highlighter){ + + function success(msg){ + api.show(msg, { style: styles.successToast, timeout: 5000 }); + } + + function error(err){ + // leaving this in for better debugging of errors + console.log(err); + + api.show(err.message, { style: styles.errorToast }); + + if(typeof highlighter !== 'function'){ + return; + } + + if(err && err.errorLength){ + highlighter(err.errorPosition, err.errorLength); + } + } + + function clear(){ + api.clear(); + } + + return { + success, + error, + clear + }; +} + +module.exports = toasts; diff --git a/src/stores/device.js b/src/stores/device.js index a0911dc..43df8ee 100644 --- a/src/stores/device.js +++ b/src/stores/device.js @@ -1,13 +1,13 @@ 'use strict'; -const alt = require('../alt'); const _ = require('lodash'); +const alt = require('../alt'); + const { rx, tx } = require('../actions/transmission'); const { hideDownload, showDownload } = require('../actions/overlay'); const { clearOutput, output } = require('../actions/console'); const { enableAuto, disableAuto, reloadDevices, updateSelected } = require('../actions/device'); -const { handleSuccess, handleError } = require('../actions/file'); class DeviceStore { constructor() { @@ -134,7 +134,7 @@ class DeviceStore { this.setState({ progress: progress }); } - const { workspace, toast, getBoard } = this.getInstance(); + const { workspace, getBoard } = this.getInstance(); const { selectedDevice } = this.state; const name = workspace.filename.deref(); @@ -155,9 +155,9 @@ class DeviceStore { .tap(() => clearOutput()) .then(() => board.on('terminal', output)) .then(() => board.on('terminal', rx)) - .tap(() => toast.clear()) - .tap(() => handleSuccess(`'${name}' downloaded successfully`)) - .catch(handleError) + .tap(() => this._handleClear()) + .tap(() => this._handleSuccess(`'${name}' downloaded successfully`)) + .catch((err) => this._handleError(err)) .finally(() => { board.removeListener('progress', updateProgress); this.setState({ progress: 0 }); @@ -165,6 +165,24 @@ class DeviceStore { }); } + _handleClear(){ + const { toasts } = this.getInstance(); + + toasts.clear(); + } + + _handleError(err){ + const { toasts } = this.getInstance(); + + toasts.error(err); + } + + _handleSuccess(msg){ + const { toasts } = this.getInstance(); + + toasts.success(msg); + } + } DeviceStore.config = { diff --git a/src/stores/editor.js b/src/stores/editor.js index f132f25..9387dfa 100644 --- a/src/stores/editor.js +++ b/src/stores/editor.js @@ -1,11 +1,9 @@ 'use strict'; const alt = require('../alt'); -const styles = require('../../plugins/sidebar/styles'); const { findNext, findPrevious, replace } = require('../actions/find'); -const { handleError, handleSuccess } = require('../actions/file'); -const { handleInput, highlight, syntaxCheck } = require('../actions/editor'); +const { handleInput, syntaxCheck } = require('../actions/editor'); const { moveByScrollUpLine, moveByScrollDownLine } = require('../actions/editor-move'); const { dedent, indent } = require('../actions/text-move'); const { print } = require('../actions/system'); @@ -19,7 +17,6 @@ class EditorStore { onFindPrevious: findPrevious, onHandleInput: handleInput, onIndent: indent, - onHighlight: highlight, onMoveByScrollUpLine: moveByScrollUpLine, onMoveByScrollDownLine: moveByScrollDownLine, onPrint: print, @@ -88,39 +85,29 @@ class EditorStore { source: workspace.current.deref() }); if(result.error){ - this.handleError(result.error); - }else{ - this.handleSuccess('Tokenization successful!'); + this._handleError(result.error); + } else { + this._handleClear(); + this._handleSuccess('Tokenization successful!'); } } - onHighlight(opts) { - const { cm } = this.getInstance(); - const doc = cm.getDoc(); - const anchor = doc.posFromIndex(opts.position); - const head = doc.posFromIndex(opts.position + opts.length); + _handleClear(){ + const { toasts } = this.getInstance(); - doc.setSelection(anchor, head); + toasts.clear(); } + _handleError(err){ + const { toasts } = this.getInstance(); - //duplicated from file store due to dispatch->dispatch invariant - handleError(err){ - // leaving this in for better debugging of errors - console.log(err); - const { toast } = this.getInstance(); - - toast.show(err.message, { style: styles.errorToast }); - if(err && err.errorLength){ - this.onHighlight({ position: err.errorPosition, length: err.errorLength }); - } + toasts.error(err); } - //duplicated from file store due to dispatch->dispatch invariant - handleSuccess(msg){ - const { toast } = this.getInstance(); + _handleSuccess(msg){ + const { toasts } = this.getInstance(); - toast.show(msg, { style: styles.successToast, timeout: 5000 }); + toasts.success(msg); } } diff --git a/src/stores/file.js b/src/stores/file.js index 50a210e..4a772b1 100644 --- a/src/stores/file.js +++ b/src/stores/file.js @@ -5,10 +5,8 @@ const path = require('path'); const _ = require('lodash'); const alt = require('../alt'); -const styles = require('../../plugins/sidebar/styles'); const { hideOverlays, hideSave } = require('../actions/overlay'); -const { highlight } = require('../actions/editor.js'); const { clearName, @@ -17,9 +15,7 @@ const { loadFile, saveFile, saveFileAs, - deleteFile, - handleError, - handleSuccess } = require('../actions/file'); + deleteFile } = require('../actions/file'); class FileStore { constructor() { @@ -27,8 +23,6 @@ class FileStore { this.bindListeners({ onClearName: clearName, onDeleteFile: deleteFile, - onHandleError: handleError, - onHandleSuccess: handleSuccess, onHideOverlay: hideOverlays, onNewFile: newFile, onLoadFile: loadFile, @@ -67,8 +61,8 @@ class FileStore { } workspace.deleteFile(workspace.filename) - .tap(() => this.onHandleSuccess(`'${name}' deleted successfully`)) - .catch(this.onHandleError) + .tap(() => this._handleSuccess(`'${name}' deleted successfully`)) + .catch((err) => this._handleError(err)) .finally(() => this.onNewFile()); } @@ -92,8 +86,8 @@ class FileStore { this.onLoadFile(this.loadQueue.shift()); } }) - .tap(() => this.onHandleSuccess(`'${name}' created successfully`)) - .catch(this.onHandleError); + .tap(() => this._handleSuccess(`'${name}' created successfully`)) + .catch((err) => this._handleError(err)); } onCancelSave(status){ @@ -120,8 +114,8 @@ class FileStore { // TODO: these should transparently accept cursors for all non-function params workspace.saveFile(name, workspace.current) - .tap(() => this.onHandleSuccess(`'${name}' saved successfully`)) - .catch(this.onHandleError); + .tap(() => this._handleSuccess(`'${name}' saved successfully`)) + .catch((err) => this._handleError(err)); } onNewFile() { @@ -187,7 +181,7 @@ class FileStore { workspace.loadFile(filename, (err) => { if(err){ - this.onHandleError(err); + this._handleError(err); return; } @@ -203,21 +197,16 @@ class FileStore { }); } - onHandleError(err){ - // leaving this in for better debugging of errors - console.log(err); - const { toast } = this.getInstance(); + _handleError(err){ + const { toasts } = this.getInstance(); - toast.show(err.message, { style: styles.errorToast }); - if(err && err.errorLength){ - highlight(err.errorPosition, err.errorLength); - } + toasts.error(err); } - onHandleSuccess(msg){ - const { toast } = this.getInstance(); + _handleSuccess(msg){ + const { toasts } = this.getInstance(); - toast.show(msg, { style: styles.successToast, timeout: 5000 }); + toasts.success(msg); } } From 031c16e25dea1385e630d58f5be4cc65d794e447 Mon Sep 17 00:00:00 2001 From: Matthew Shepard Date: Thu, 2 Jul 2015 15:29:25 -0700 Subject: [PATCH 06/11] Scroll highlighted text to center of screen. --- plugins/editor/index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/editor/index.js b/plugins/editor/index.js index 2e0cec1..7475258 100644 --- a/plugins/editor/index.js +++ b/plugins/editor/index.js @@ -51,7 +51,13 @@ function editor(app, opts, done){ const anchor = doc.posFromIndex(position); const head = doc.posFromIndex(position + length); - doc.setSelection(anchor, head); + doc.setSelection(anchor, head, { + scroll: false + }); + + var top = codeEditor.charCoords(anchor, 'local').top; + var halfHeight = codeEditor.getScrollerElement().offsetHeight / 2; + codeEditor.scrollTo(null, top - halfHeight - 5); } consoleStore.listen(refreshConsole); From 4bd312f14ae898a09d35df07fac1b581aeeff268 Mon Sep 17 00:00:00 2001 From: Matthew Shepard Date: Thu, 2 Jul 2015 15:30:48 -0700 Subject: [PATCH 07/11] Var :P --- plugins/editor/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/editor/index.js b/plugins/editor/index.js index 7475258..a4f4106 100644 --- a/plugins/editor/index.js +++ b/plugins/editor/index.js @@ -55,8 +55,8 @@ function editor(app, opts, done){ scroll: false }); - var top = codeEditor.charCoords(anchor, 'local').top; - var halfHeight = codeEditor.getScrollerElement().offsetHeight / 2; + const top = codeEditor.charCoords(anchor, 'local').top; + const halfHeight = codeEditor.getScrollerElement().offsetHeight / 2; codeEditor.scrollTo(null, top - halfHeight - 5); } From 8cd1605e0b7055faacc473afa8a0afc41fee3856 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Thu, 2 Jul 2015 15:31:27 -0700 Subject: [PATCH 08/11] cleanup --- plugins/editor/index.js | 4 +--- src/actions/editor.js | 7 +------ 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/plugins/editor/index.js b/plugins/editor/index.js index a4f4106..e0406dc 100644 --- a/plugins/editor/index.js +++ b/plugins/editor/index.js @@ -51,9 +51,7 @@ function editor(app, opts, done){ const anchor = doc.posFromIndex(position); const head = doc.posFromIndex(position + length); - doc.setSelection(anchor, head, { - scroll: false - }); + doc.setSelection(anchor, head, { scroll: false }); const top = codeEditor.charCoords(anchor, 'local').top; const halfHeight = codeEditor.getScrollerElement().offsetHeight / 2; diff --git a/src/actions/editor.js b/src/actions/editor.js index 29bbd30..15c337b 100644 --- a/src/actions/editor.js +++ b/src/actions/editor.js @@ -6,12 +6,7 @@ class EditorActions { handleInput(inst) { this.dispatch(inst); } - highlight(position, len) { - this.dispatch({ - position: position, - length: len - }); - } + syntaxCheck(){ this.dispatch(); } From 9d9079ea6e2e7afdd666f801797660b07b2e72dd Mon Sep 17 00:00:00 2001 From: Matthew Shepard Date: Thu, 2 Jul 2015 15:38:55 -0700 Subject: [PATCH 09/11] Calculate lineheight from char rect --- plugins/editor/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/editor/index.js b/plugins/editor/index.js index e0406dc..92ef975 100644 --- a/plugins/editor/index.js +++ b/plugins/editor/index.js @@ -53,9 +53,10 @@ function editor(app, opts, done){ doc.setSelection(anchor, head, { scroll: false }); - const top = codeEditor.charCoords(anchor, 'local').top; + const charRect = codeEditor.charCoords(anchor, 'local'); const halfHeight = codeEditor.getScrollerElement().offsetHeight / 2; - codeEditor.scrollTo(null, top - halfHeight - 5); + const halfTextHeight = Math.floor((charRect.bottom - charRect.top) / 2); + codeEditor.scrollTo(null, charRect.top - halfHeight - halfTextHeight); } consoleStore.listen(refreshConsole); From ad3732fca494be3739ec86405a671dd005962bd1 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Thu, 2 Jul 2015 15:48:20 -0700 Subject: [PATCH 10/11] always have highlighter --- plugins/editor/index.js | 5 +++++ plugins/sidebar/index.js | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/editor/index.js b/plugins/editor/index.js index 92ef975..3250499 100644 --- a/plugins/editor/index.js +++ b/plugins/editor/index.js @@ -17,6 +17,7 @@ const keyExtension = require('./key-extension'); const consoleStore = require('../../src/stores/console'); const editorStore = require('../../src/stores/editor'); +const deviceStore = require('../../src/stores/device'); const fileStore = require('../../src/stores/file'); const { handleInput } = require('../../src/actions/editor'); @@ -71,6 +72,10 @@ function editor(app, opts, done){ editorStore.compile = compile; editorStore.workspace = space; + // really stinks to attach these in here + fileStore.toasts = toasts; + deviceStore.toasts = toasts; + app.view('editor', function(el, cb){ console.log('editor render'); diff --git a/plugins/sidebar/index.js b/plugins/sidebar/index.js index 207ff4e..b3cf045 100644 --- a/plugins/sidebar/index.js +++ b/plugins/sidebar/index.js @@ -23,8 +23,6 @@ function sidebar(app, opts, done){ const getBoard = app.getBoard.bind(app); const scanBoards = app.scanBoards.bind(app); - const toasts = makeToasts(app.toast); - function refreshDirectory(){ // TODO: expose a method to refresh directory without changing it space.changeDir(space.cwd.deref()); @@ -58,13 +56,11 @@ function sidebar(app, opts, done){ // Store bindings deviceStore.workspace = space; - deviceStore.toasts = toasts; deviceStore.getBoard = getBoard; deviceStore.scanBoards = scanBoards; fileStore.workspace = space; fileStore.userConfig = userConfig; - fileStore.toasts = toasts; done(); } From 7d7e72001a341d36d95451251ad1cc393f47f6c1 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Thu, 2 Jul 2015 15:50:26 -0700 Subject: [PATCH 11/11] cleanup --- plugins/sidebar/styles.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/plugins/sidebar/styles.js b/plugins/sidebar/styles.js index 21831a6..bdbb26c 100644 --- a/plugins/sidebar/styles.js +++ b/plugins/sidebar/styles.js @@ -31,12 +31,6 @@ const styles = { }, fileHasTemp: { backgroundColor: red - }, - errorToast: { - backgroundColor: red - }, - successToast: { - backgroundColor: green } };