|
1 | 1 | "use strict";
|
2 |
| -varfs_1=require('fs'); |
3 |
| -varexists_1=require('../services/exists'); |
4 |
| -vargetEditorCount=0; |
5 |
| -functionsave(){ |
6 |
| -vareditor=findEditor(); |
7 |
| -editor.save(); |
8 |
| -} |
9 |
| -exports.save=save; |
10 |
| -functionfindEditor(){ |
11 |
| -vareditor=atom.workspace.getActiveTextEditor(); |
12 |
| -varmax=1000; |
13 |
| -if(!editor){ |
14 |
| -getEditorCount+=1; |
15 |
| -setTimeout(function(){ |
16 |
| -returnfindEditor(); |
17 |
| -},10); |
18 |
| -} |
19 |
| -elseif(getEditorCount>max){ |
20 |
| -console.log('Failed to find active editor'); |
21 |
| -returnnull; |
22 |
| -} |
23 |
| -else{ |
24 |
| -getEditorCount=0; |
25 |
| -returneditor; |
26 |
| -} |
27 |
| -} |
28 |
| -exports.findEditor=findEditor; |
29 |
| -functiongetEditor(){ |
30 |
| -returnnewPromise(function(resolve,reject){ |
31 |
| -resolve(findEditor()); |
32 |
| -}); |
33 |
| -} |
34 |
| -exports.getEditor=getEditor; |
35 |
| -functionopen(filePath,options){ |
36 |
| -if(options===void0){options={};} |
37 |
| -if(exists_1.fileExists(filePath)){ |
38 |
| -fs_1.unlink(filePath); |
39 |
| -} |
40 |
| -atom.workspace.open(filePath,options); |
41 |
| -} |
42 |
| -exports.open=open; |
43 |
| -functionset(text){ |
44 |
| -returngetEditor().then(function(editor){ |
45 |
| -editor.setText(text); |
46 |
| -editor.insertNewline(); |
47 |
| -editor.moveToBottom(); |
48 |
| -editor.save(); |
49 |
| -setCursorPosition(editor); |
50 |
| -}); |
51 |
| -} |
52 |
| -exports.set=set; |
53 |
| -functioninsert(text,options){ |
54 |
| -if(options===void0){options={};} |
55 |
| -options=Object.assign(options,{ |
56 |
| -autoIndent:true, |
57 |
| -}); |
58 |
| -return(getEditor().then(functioninsertWithEditor(editor){ |
59 |
| -editor.moveToBottom(); |
60 |
| -editor.insertText(text,options); |
61 |
| -editor.insertNewline(); |
62 |
| -editor.moveToBottom(); |
63 |
| -editor.save(); |
64 |
| -setCursorPosition(editor); |
65 |
| -})); |
66 |
| -} |
67 |
| -exports.insert=insert; |
68 |
| -varcursor=/::\s?>/g; |
69 |
| -functionsetCursorPosition(editor){ |
70 |
| -editor.scan(cursor,function(scanned){ |
71 |
| -editor.setCursorScreenPosition(scanned.range.start); |
72 |
| -scanned.replace(''); |
73 |
| -scanned.stop(); |
74 |
| -}); |
75 |
| -} |
| 2 | +varfile_1=require('./actions/file'); |
| 3 | +exports.save=file_1.save; |
| 4 | +exports.open=file_1.open; |
| 5 | +exports.openFolder=file_1.openFolder; |
| 6 | +varwrite_1=require('./actions/write'); |
| 7 | +exports.set=write_1.set; |
| 8 | +exports.insert=write_1.insert; |
| 9 | +varconsole_1=require('./actions/console'); |
| 10 | +exports.openDevTools=console_1.openDevTools; |
| 11 | +exports.toggleDevTools=console_1.toggleDevTools; |
| 12 | +varterminal_1=require('./actions/terminal'); |
| 13 | +exports.openTerminal=terminal_1.openTerminal; |
| 14 | +vartabs_1=require('./actions/tabs'); |
| 15 | +exports.closeAllPanels=tabs_1.closeAllPanels; |
| 16 | +varquit_1=require('./actions/quit'); |
| 17 | +exports.quit=quit_1.quit; |