diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /devtools/client/projecteditor/lib/plugins/status-bar | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/client/projecteditor/lib/plugins/status-bar')
-rw-r--r-- | devtools/client/projecteditor/lib/plugins/status-bar/moz.build | 9 | ||||
-rw-r--r-- | devtools/client/projecteditor/lib/plugins/status-bar/plugin.js | 105 |
2 files changed, 114 insertions, 0 deletions
diff --git a/devtools/client/projecteditor/lib/plugins/status-bar/moz.build b/devtools/client/projecteditor/lib/plugins/status-bar/moz.build new file mode 100644 index 000000000..87ce21584 --- /dev/null +++ b/devtools/client/projecteditor/lib/plugins/status-bar/moz.build @@ -0,0 +1,9 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +DevToolsModules( + 'plugin.js', +) diff --git a/devtools/client/projecteditor/lib/plugins/status-bar/plugin.js b/devtools/client/projecteditor/lib/plugins/status-bar/plugin.js new file mode 100644 index 000000000..9450baef3 --- /dev/null +++ b/devtools/client/projecteditor/lib/plugins/status-bar/plugin.js @@ -0,0 +1,105 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +const { Cu } = require("chrome"); +const { Class } = require("sdk/core/heritage"); +const promise = require("promise"); +const { registerPlugin, Plugin } = require("devtools/client/projecteditor/lib/plugins/core"); + +/** + * Print information about the currently opened file + * and the state of the current editor + */ +var StatusBarPlugin = Class({ + extends: Plugin, + + init: function () { + this.box = this.host.createElement("hbox", { + parent: "#projecteditor-toolbar-bottom" + }); + + this.activeMode = this.host.createElement("label", { + parent: this.box, + class: "projecteditor-basic-display" + }); + + this.cursorPosition = this.host.createElement("label", { + parent: this.box, + class: "projecteditor-basic-display" + }); + + this.fileLabel = this.host.createElement("label", { + parent: "#plugin-toolbar-left", + class: "projecteditor-file-label" + }); + }, + + destroy: function () { + }, + + /** + * Print information about the current state of the editor + * + * @param Editor editor + */ + render: function (editor, resource) { + if (!resource || resource.isDir) { + this.fileLabel.textContent = ""; + this.cursorPosition.value = ""; + return; + } + + this.fileLabel.textContent = resource.basename; + this.activeMode.value = editor.toString(); + if (editor.editor) { + let cursorStart = editor.editor.getCursor("start"); + let cursorEnd = editor.editor.getCursor("end"); + if (cursorStart.line === cursorEnd.line && cursorStart.ch === cursorEnd.ch) { + this.cursorPosition.value = cursorStart.line + " " + cursorStart.ch; + } else { + this.cursorPosition.value = cursorStart.line + " " + cursorStart.ch + " | " + + cursorEnd.line + " " + cursorEnd.ch; + } + } else { + this.cursorPosition.value = ""; + } + }, + + + /** + * Print the current file name + * + * @param Resource resource + */ + onTreeSelected: function (resource) { + if (!resource || resource.isDir) { + this.fileLabel.textContent = ""; + return; + } + this.fileLabel.textContent = resource.basename; + }, + + onEditorDeactivated: function (editor) { + this.fileLabel.textContent = ""; + this.cursorPosition.value = ""; + }, + + onEditorChange: function (editor, resource) { + this.render(editor, resource); + }, + + onEditorCursorActivity: function (editor, resource) { + this.render(editor, resource); + }, + + onEditorActivated: function (editor, resource) { + this.render(editor, resource); + }, + +}); + +exports.StatusBarPlugin = StatusBarPlugin; +registerPlugin(StatusBarPlugin); |