Skip to content

Commit e10616f

Browse files
committed
Add icon to the bottom bar
1 parent bb944a5 commit e10616f

File tree

13 files changed

+272
-31
lines changed

13 files changed

+272
-31
lines changed

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pythonfiles/parso linguist-vendored
1+
pythonfiles/parso linguist-vendored=true

PyStatus.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* global define, $ */
2+
define(function (require, exports, module) {
3+
"use strict";
4+
var status;
5+
6+
function PyStatus (handler) {
7+
status = $('<div id="python-tools-status">');
8+
$("#status-overwrite").after(status);
9+
status.after($('<div id="python-tools-status-dummy">'));
10+
status.on("click", handler);
11+
}
12+
13+
PyStatus.prototype.update = function (cls, title) {
14+
status.removeClass();
15+
status.addClass(cls);
16+
17+
title = title || null;
18+
if (title)
19+
status.attr("title", title);
20+
else
21+
status.removeAttr("title");
22+
}
23+
24+
module.exports = PyStatus;
25+
});

icons/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
These icons are taken from [Public Icons Project](https://github.com/davidmerfield/Public-Icons) and edited to match Brackets' UX.
2+
Python logos are trademarks of the Python Software Foundation.

icons/denied.svg

Lines changed: 56 additions & 0 deletions
Loading

icons/gear.svg

Lines changed: 49 additions & 0 deletions
Loading

icons/python-logo.svg

Lines changed: 73 additions & 0 deletions
Loading

main.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,19 @@ define(function (require, exports, module) {
6363

6464
var SETTINGS_CMD_ID = EXTENSION_NAME + ".settings";
6565

66-
var PyHints = require("PyHints"),
67-
PyDocs = require("PyDocs"),
68-
PyLint = require("PyLint"),
69-
PyGoto = require("PyGoto");
66+
var PyHints = require("PyHints"),
67+
PyDocs = require("PyDocs"),
68+
PyLint = require("PyLint"),
69+
PyGoto = require("PyGoto"),
70+
PyStatus = require("PyStatus");
7071

7172
var SCRIPT_FULL_PATH = ExtensionUtils.getModulePath(module, 'pythonfiles/python_utils.py');
7273
var PYTHON_DIRECTORY = ExtensionUtils.getModulePath(module, 'pythonfiles/');
7374

7475
var pythonDomain = new NodeDomain("python-tools", ExtensionUtils.getModulePath(module, "node/PythonDomain"));
7576

77+
var status = new PyStatus(handleSettings);
78+
7679
preferences.definePreference("pathToPython", "string", "python", {
7780
description: LocalStrings.PATH_TO_PYTHON_TITLE,
7881
validator: function (value) {
@@ -180,6 +183,7 @@ define(function (require, exports, module) {
180183
}
181184

182185
function setUpPythonShell () {
186+
status.update("loading", LocalStrings.SHELL_CONNECTING);
183187
pythonDomain.exec("setSettings", {
184188
pythonPath: preferences.get("pathToPython"),
185189
pythonScript: SCRIPT_FULL_PATH,
@@ -193,7 +197,7 @@ define(function (require, exports, module) {
193197
"is_case_sensitive": preferences.get("isCaseSensitive")
194198
}
195199
}).done(function (data) {
196-
console.log("Established connnection with Python Shell…");
200+
status.update("connected", LocalStrings.SHELL_CONNECTED);
197201
}).fail(function(error) {
198202
internalError(error);
199203
});
@@ -208,6 +212,7 @@ define(function (require, exports, module) {
208212
* @param {string} error error text
209213
*/
210214
function internalError (error) {
215+
status.update("error", LocalStrings.SHELL_ERROR);
211216
Dialogs.showModalDialog(
212217
"python-tools-error",
213218
LocalStrings.ERROR_TITLE,
@@ -230,7 +235,6 @@ define(function (require, exports, module) {
230235
python_goto = new PyGoto(pythonAPI).goto;
231236
// NOTICE: EditorManager requires jump to definition provider to be a function.
232237
// Thus, passing method to EditorManager.
233-
234238
CodeHintManager.registerHintProvider(python_hints, ["python"], 9);
235239
EditorManager.registerInlineDocsProvider(python_docs);
236240
EditorManager.registerJumpToDefProvider(python_goto);
@@ -252,8 +256,11 @@ define(function (require, exports, module) {
252256
menu.addMenuDivider();
253257
menu.addMenuItem(SETTINGS_CMD_ID, "Ctrl-Alt-Y");
254258

255-
ExtensionUtils.loadStyleSheet(module, "styles/hints.less");
256-
ExtensionUtils.loadStyleSheet(module, "styles/docs.less");
257-
ExtensionUtils.loadStyleSheet(module, "styles/modals.css");
259+
["hints.less",
260+
"docs.less",
261+
"modals.css",
262+
"spinner.css"].forEach(function (stylesheet) {
263+
ExtensionUtils.loadStyleSheet(module, "styles/" + stylesheet);
264+
});
258265
});
259266
});

nls/root/strings.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ define({
33
PATH_TO_PYTHON_TITLE: "Path to Python executable",
44
IS_CASE_SENSITIVE_TITLE: "Use case sensitive completion",
55
MAX_LINE_LENGTH_TITLE: "Maximum line length in Python files",
6-
IGNORED_ERRORS_TITLE: "Array of errors which should be ignored by Python Linter",
6+
IGNORED_ERRORS_TITLE: "Array of errors ignored by Python Linter",
77
ERROR_TITLE: "Python Tools Error",
88
ERROR_TEXT: "Error text",
9-
ERROR_NOTICE: "Python Tools requires python shell and <code>jedi</code> module to work. Make sure you've provided correct path for Python executable and installed <code>jedi</code>. See <a href='{{ HOMEPAGE_REF }}'>Project home</a> for support."
9+
ERROR_NOTICE: "Python Tools requires python shell and <code>jedi</code> module to work. Make sure you've provided correct path for Python executable and installed <code>jedi</code>. See <a href='{{ HOMEPAGE_REF }}'>Project home</a> for support.",
10+
SHELL_CONNECTING: "Connecting to Python shell…",
11+
SHELL_CONNECTED: "Connected to Python shell",
12+
SHELL_ERROR: "Error in Python shell"
1013
});

nls/ru/strings.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,8 @@ define({
66
IGNORED_ERRORS_TITLE: "Массив ошибок, игнорируемых Линтером Python",
77
ERROR_TITLE: "Ошибка инструментов Python",
88
ERROR_TEXT: "Текст ошибки",
9-
ERROR_NOTICE: "Для нормальной работы инструментов Python требуется работающий Python и модуль <code>jedi</code>. Убедитесь, что в настройках указан правильный путь к интерпретатору Python и установлен модуль <code>jedi</code>. Вы можете найти помощь на <a href='{{ HOMEPAGE_REF }}'>сайте проекта</a>."
9+
ERROR_NOTICE: "Для нормальной работы инструментов Python требуется работающий Python и модуль <code>jedi</code>. Убедитесь, что в настройках указан правильный путь к интерпретатору Python и установлен модуль <code>jedi</code>. Вы можете найти помощь на <a href='{{ HOMEPAGE_REF }}'>сайте проекта</a>.",
10+
SHELL_CONNECTING: "Подключение к оболочке Python…",
11+
SHELL_CONNECTED: "Подключён к оболочке Python",
12+
SHELL_ERROR: "Ошибка в оболочке Python"
1013
});

node/PythonDomain.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,15 @@
2929
};
3030

3131
PythonShell.prototype.handleData = function (buffer) {
32+
var data;
33+
try {
34+
data = JSON.parse(buffer.toString());
35+
} catch (error) {
36+
data = null;
37+
var err = error;
38+
}
3239
if (this.callBack) {
33-
this.callBack(null, JSON.parse(buffer.toString()));
40+
data !== null? this.callBack(null, data) : this.callBack(err, null);
3441
} else {
3542
console.error("Unhandled data");
3643
}
@@ -39,6 +46,8 @@
3946
PythonShell.prototype.handleError = function (errorBuffer) {
4047
var error = errorBuffer.toString();
4148
// should not restart the process there, may continue infinitely
49+
this.needsRestart = true;
50+
4251
if (this.callBack) {
4352
this.callBack(error, null);
4453
} else {
@@ -57,7 +66,10 @@
5766
};
5867

5968
PythonShell.prototype.start = function (callBack) {
60-
if (this.process) {
69+
if (this.process && this.process.connected
70+
&& (!this.process.killed) && (!this.needsRestart)) {
71+
callBack(null, true); // cache normal process
72+
} else if (this.process) {
6173
this.process.kill();
6274
this.needsRestart = false;
6375
}

0 commit comments

Comments
 (0)