mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-26 04:22:30 -10:00
In a following patch, all DevTools moz.build files will use DevToolsModules to install JS modules at a path that corresponds directly to their source tree location. Here we rewrite all require and import calls to match the new location that these files are installed to.
106 lines
2.9 KiB
JavaScript
106 lines
2.9 KiB
JavaScript
/* -*- 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);
|