mad.engineer wrote:Thanks for the code. I tried it and it seem to work, but noticed that often it won't re-wrap the paragraph correctly. What I'm looking for is similar to the Justify/Re-wrap in the UNIX Pico command.
Try
Code: Select all
var editor = GetCurrentEditor();
var selection = editor.selection;
var wrapWidth = gPrefs.getIntPref("mailnews.wraplength") - 1;
if(IsHTMLEditor())
function getEditorSelection() {
if(editor.selection.getRangeAt(0).toString().charAt(0) == "\n")
return editor.selection.toString().substr(1);
else
return editor.selection.toString()
}
else
function getEditorSelection() { return editor.outputToString("text/plain",1 | 16) }
var startRange;
goDoCommand("cmd_beginLine");
do {
goDoCommand("cmd_beginLine"); goDoCommand("cmd_selectEndLine");
start = selection.getRangeAt(0);
if(!start.toString().match(/^[\s>]*$/))
break;
goDoCommand("cmd_lineNext");
} while(selection.getRangeAt(0).compareBoundaryPoints(Range.END_TO_END,start) > 0);
if(selection == "") return;
var re = new RegExp("^"+getEditorSelection().match(/^[\s>]*/)+"([^\\s>])");
do {
goDoCommand("cmd_beginLine"); goDoCommand("cmd_selectEndLine");
if(!re.test(getEditorSelection()))
break;
startRange = selection.getRangeAt(0);
goDoCommand("cmd_linePrevious");
} while(selection.getRangeAt(0).compareBoundaryPoints(Range.START_TO_START,startRange) < 0);
goDoCommand("cmd_lineNext");
var endRange = start;
do {
goDoCommand("cmd_beginLine"); goDoCommand("cmd_selectEndLine");
if(!re.test(getEditorSelection()))
break;
endRange = selection.getRangeAt(0);
goDoCommand("cmd_lineNext");
} while(selection.getRangeAt(0).compareBoundaryPoints(Range.END_TO_END,endRange) > 0);
selection.getRangeAt(0).setStart(startRange.startContainer, startRange.startOffset);
selection.getRangeAt(0).setEnd(endRange.endContainer, endRange.endOffset);
var words = getEditorSelection().replace(/^[\s>]*/gm," ").split(/\s+/);
var text = [];
var lineStart = getEditorSelection().match(/^[\s>]*/);
var line = [];
for(var i = 1, l = words.length; i < l; i++) {
if(lineStart[0].length + line.join(" ").length + words[i].length > wrapWidth) {
text.push(lineStart + line.join(" "));
line = [];
}
line.push(words[i]);
}
text.push(lineStart + line.join(" "));
editor.insertText(text.join("\n"));
emil9216 wrote:Is it possible to make "space+T" key combination for opening a new tab? I can assign "space" for opening a new tab but i can't assign this combination "space+T".
Add a new key containing the following and assign space to it
Code: Select all
if(keyconfig.spaceMod)
return;
keyconfig.spaceMod = {
handleEvent: function(event){
switch(event.type) {
case "keyup":
if(event.keyCode == 32 && !(event.altKey || event.metaKey || event.shiftKey || event.ctrlKey)) {
window.removeEventListener("keypress", this, true);
window.removeEventListener("keyup", this, true);
delete keyconfig.spaceMod;
}
break;
case "keypress": {
event.preventDefault();
if(!(event.altKey || event.metaKey || event.shiftKey || event.ctrlKey)
&& String.fromCharCode(event.charCode).toUpperCase() == "T")
BrowserOpenTab();
}
}
}
}
window.addEventListener("keyup", keyconfig.spaceMod, true);
window.addEventListener("keypress", keyconfig.spaceMod, true);
mad.engineer wrote:Is it possible to update the compatibility info of keyconfig for TB 3.3a2?. I tried disabling the compatibility check but it still would not work in TB. Thanks
See the
reply to stevvie.
ballyhairs wrote:I'm using 2 keys from you to copy address and another to run link from clipoard, but I recently switched to FF4 and I hide the address bar, these keys don't work when that bar is hidden, anyway you can make it smarter in getting the address and running the one from clipboard?
Try
Code: Select all
var ClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
.getService(Components.interfaces.nsIClipboardHelper);
ClipboardHelper.copyString(content.location);
nameanyone wrote:Hi dorando, In Fx4, the old "Close Tab and Focus to the left Tab" code is not compatible wih Tab Groups. Closing a tab can lead to a switch to a different tab group. Can you suggest an updated code?
Try
Code: Select all
var tab = gBrowser.mCurrentTab; gBrowser.tabContainer.advanceSelectedTab(-1, false); tab.owner = null; gBrowser.removeTab(tab);
fhoshino wrote:I'm trying to get ShortcutKey2URL to work, I want to use ShortcutKey2URL with a single key to launch (F-keys), [...]
Try
Code: Select all
gShortcutKey2URL.startKeyReceive();
PrimaFacie wrote:I don't have anything to edit the file myself.
.xpi = .zip
.manifest = .txt
.js = .txt