|
1 | 1 | "use strict"; |
2 | | -var fs_1 = require('fs'); |
3 | | -var exists_1 = require('../services/exists'); |
4 | | -var getEditorCount = 0; |
5 | | -function save() { |
6 | | - var editor = findEditor(); |
7 | | - editor.save(); |
8 | | -} |
9 | | -exports.save = save; |
10 | | -function findEditor() { |
11 | | - var editor = atom.workspace.getActiveTextEditor(); |
12 | | - var max = 1000; |
13 | | - if (!editor) { |
14 | | - getEditorCount += 1; |
15 | | - setTimeout(function () { |
16 | | - return findEditor(); |
17 | | - }, 10); |
18 | | - } |
19 | | - else if (getEditorCount > max) { |
20 | | - console.log('Failed to find active editor'); |
21 | | - return null; |
22 | | - } |
23 | | - else { |
24 | | - getEditorCount = 0; |
25 | | - return editor; |
26 | | - } |
27 | | -} |
28 | | -exports.findEditor = findEditor; |
29 | | -function getEditor() { |
30 | | - return new Promise(function (resolve, reject) { |
31 | | - resolve(findEditor()); |
32 | | - }); |
33 | | -} |
34 | | -exports.getEditor = getEditor; |
35 | | -function open(filePath, options) { |
36 | | - if (options === void 0) { 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 | | -function set(text) { |
44 | | - return getEditor().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 | | -function insert(text, options) { |
54 | | - if (options === void 0) { options = {}; } |
55 | | - options = Object.assign(options, { |
56 | | - autoIndent: true, |
57 | | - }); |
58 | | - return (getEditor().then(function insertWithEditor(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 | | -var cursor = /::\s?>/g; |
69 | | -function setCursorPosition(editor) { |
70 | | - editor.scan(cursor, function (scanned) { |
71 | | - editor.setCursorScreenPosition(scanned.range.start); |
72 | | - scanned.replace(''); |
73 | | - scanned.stop(); |
74 | | - }); |
75 | | -} |
| 2 | +var file_1 = require('./actions/file'); |
| 3 | +exports.save = file_1.save; |
| 4 | +exports.open = file_1.open; |
| 5 | +exports.openFolder = file_1.openFolder; |
| 6 | +var write_1 = require('./actions/write'); |
| 7 | +exports.set = write_1.set; |
| 8 | +exports.insert = write_1.insert; |
| 9 | +var console_1 = require('./actions/console'); |
| 10 | +exports.openDevTools = console_1.openDevTools; |
| 11 | +exports.toggleDevTools = console_1.toggleDevTools; |
| 12 | +var terminal_1 = require('./actions/terminal'); |
| 13 | +exports.openTerminal = terminal_1.openTerminal; |
| 14 | +var tabs_1 = require('./actions/tabs'); |
| 15 | +exports.closeAllPanels = tabs_1.closeAllPanels; |
| 16 | +var quit_1 = require('./actions/quit'); |
| 17 | +exports.quit = quit_1.quit; |
0 commit comments