mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-04-11 01:33:33 +02:00
Make substring preview less quirky
This commit is contained in:
@@ -776,7 +776,7 @@ lookup:
|
|||||||
// no need (actually forbidden) to add: js <<EOF ... EOF around those files
|
// no need (actually forbidden) to add: js <<EOF ... EOF around those files
|
||||||
source: function (filename, silent)
|
source: function (filename, silent)
|
||||||
{
|
{
|
||||||
var wasSourcing = ioManager.sourcing;
|
let wasSourcing = ioManager.sourcing;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var file = ioManager.getFile(filename);
|
var file = ioManager.getFile(filename);
|
||||||
@@ -808,7 +808,7 @@ lookup:
|
|||||||
// handle pure javascript files specially
|
// handle pure javascript files specially
|
||||||
if (/\.js$/.test(filename))
|
if (/\.js$/.test(filename))
|
||||||
{
|
{
|
||||||
var loader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
|
let loader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
|
||||||
.getService(Components.interfaces.mozIJSSubScriptLoader);
|
.getService(Components.interfaces.mozIJSSubScriptLoader);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -306,6 +306,30 @@ function CommandLine() //{{{
|
|||||||
promptWidget.setAttributeNS(NS.uri, "highlight", highlightGroup || commandline.HL_NORMAL);
|
promptWidget.setAttributeNS(NS.uri, "highlight", highlightGroup || commandline.HL_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function previewSubstring()
|
||||||
|
{
|
||||||
|
if (!options.get("wildoptions").has("auto"))
|
||||||
|
return;
|
||||||
|
// Kludge. Major kludge.
|
||||||
|
let editor = commandWidget.inputField.editor;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
let node = editor.rootElement;
|
||||||
|
editor.deleteNode(node.firstChild.nextSibling);
|
||||||
|
}
|
||||||
|
catch (e) {}
|
||||||
|
let wildmode = options.get("wildmode");
|
||||||
|
let wildType = wildmode.values[Math.min(wildIndex, wildmode.values.length - 1)];
|
||||||
|
if (wildmode.checkHas(wildType, "longest"))
|
||||||
|
{
|
||||||
|
let start = commandWidget.selectionStart;
|
||||||
|
let substring = completionContext.longestAllSubstring.substr(start - completionContext.allItems.start);
|
||||||
|
removeSuffix = substring;
|
||||||
|
editor.insertNode(util.xmlToDom(<span style="color: gray">{substring}</span>, document), editor.rootElement, 1);
|
||||||
|
commandWidget.selectionStart = commandWidget.selectionEnd = start;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// sets the command - e.g. 'tabopen', 'open http://example.com/'
|
// sets the command - e.g. 'tabopen', 'open http://example.com/'
|
||||||
function setCommand(cmd)
|
function setCommand(cmd)
|
||||||
{
|
{
|
||||||
@@ -827,17 +851,7 @@ function CommandLine() //{{{
|
|||||||
else if (event.type == "input")
|
else if (event.type == "input")
|
||||||
{
|
{
|
||||||
liberator.triggerCallback("change", currentExtendedMode, command);
|
liberator.triggerCallback("change", currentExtendedMode, command);
|
||||||
// Kludge. Major kludge.
|
previewSubstring();
|
||||||
let wildmode = options.get("wildmode");
|
|
||||||
let wildType = wildmode.values[Math.min(wildIndex, wildmode.values.length - 1)];
|
|
||||||
if (wildmode.checkHas(wildType, "longest"))
|
|
||||||
{
|
|
||||||
let start = commandWidget.selectionStart;
|
|
||||||
let substring = completionContext.longestAllSubstring.substr(start - completionContext.allItems.start);
|
|
||||||
removeSuffix = substring;
|
|
||||||
editor.insertNode(util.xmlToDom(<span style="color: gray">{substring}</span>, document), editor.rootElement, 1);
|
|
||||||
commandWidget.selectionStart = commandWidget.selectionEnd = start;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (event.type == "keypress")
|
else if (event.type == "keypress")
|
||||||
{
|
{
|
||||||
@@ -1260,6 +1274,7 @@ function CommandLine() //{{{
|
|||||||
// prefix when wrapping around searches
|
// prefix when wrapping around searches
|
||||||
// with that, we SOMETIMES have problems with <tab> followed by <s-tab> in :open completions
|
// with that, we SOMETIMES have problems with <tab> followed by <s-tab> in :open completions
|
||||||
|
|
||||||
|
previewSubstring();
|
||||||
let command = this.getCommand();
|
let command = this.getCommand();
|
||||||
if (command.substr(command.length - removeSuffix.length) == removeSuffix)
|
if (command.substr(command.length - removeSuffix.length) == removeSuffix)
|
||||||
command = command.substr(0, command.length - removeSuffix.length)
|
command = command.substr(0, command.length - removeSuffix.length)
|
||||||
|
|||||||
Reference in New Issue
Block a user