Skip to content

Commit dfd7030

Browse files
committed
Merge pull request #193 from parallaxinc/automaticDownloadNoMatch
Automatic download no match
2 parents 185a2d7 + a343f7c commit dfd7030

File tree

4 files changed

+35
-5
lines changed

4 files changed

+35
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"dependencies": {
1010
"alt": "^0.16.7",
11-
"bs2-serial": "^0.10.0",
11+
"bs2-serial": "^0.10.5",
1212
"codemirror": "^4.13.0",
1313
"frylord": "^0.6.0",
1414
"holovisor": "^0.2.0",

plugins/editor/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,12 @@ function editor(app, opts, done){
106106
'Shift-Tab': false,
107107
'Ctrl-T': false
108108
});
109+
109110
keyExtension.setup(app);
110111
editorStore.cm = codeEditor;
111-
fileStore.documents = new DocumentsStore(codeEditor);
112+
const documents = new DocumentsStore(codeEditor);
113+
fileStore.documents = documents;
114+
deviceStore.documents = documents;
112115
}
113116

114117

src/stores/device.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,24 @@ class DeviceStore {
7676

7777
onUpdateSelected(device) {
7878

79+
const { workspace, documents } = this.getInstance();
80+
const { noneMatched } = this.messages;
81+
82+
if(this.state.message === noneMatched) {
83+
84+
const { name } = device;
85+
const { TargetStart } = device.program.raw;
86+
const source = workspace.current.deref();
87+
const end = source.indexOf('}', TargetStart);
88+
89+
const pre = source.substring(0, TargetStart);
90+
const post = source.substring(end, source.length);
91+
const newSource = pre + name + post;
92+
93+
documents.update(newSource);
94+
workspace.updateContent(newSource);
95+
}
96+
7997
this.setState({
8098
devicePath: device.path,
8199
selectedDevice: device,
@@ -106,7 +124,6 @@ class DeviceStore {
106124

107125
} else if (matchedDevices.length === 0) {
108126

109-
//TODO: setup for part 4 of auto download issue
110127
this.setState({ message: noneMatched });
111128

112129
} else if(matchedDevices.length === 1) {
@@ -134,7 +151,6 @@ class DeviceStore {
134151
this.setState({ progress: progress });
135152
}
136153

137-
138154
const { workspace, getBoard } = this.getInstance();
139155
const { selectedDevice } = this.state;
140156

@@ -153,7 +169,7 @@ class DeviceStore {
153169
board.on('progress', updateProgress.bind(this));
154170
board.on('progress', tx.bind(this));
155171

156-
board.bootload(selectedDevice.program)
172+
board.bootload(workspace.current.deref())
157173
.tap(() => clearOutput())
158174
.then(() => board.on('terminal', output))
159175
.then(() => board.on('terminal', rx))

src/stores/documents.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,22 @@ class DocumentsStore {
88
constructor(editor){
99
this._editor = editor;
1010

11+
this._filename = null;
1112
this._documents = {};
1213
}
1314

1415
focus(){
1516
this._editor.focus();
1617
}
1718

19+
update(text){
20+
if(!this._filename){
21+
return;
22+
}
23+
24+
return this.create(this._filename, text);
25+
}
26+
1827
create(filename, text){
1928
const mode = 'pbasic';
2029

@@ -24,6 +33,8 @@ class DocumentsStore {
2433
}
2534

2635
swap(filename) {
36+
this._filename = filename;
37+
2738
const doc = this._documents[filename];
2839

2940
if(!doc){

0 commit comments

Comments
 (0)