[Pkg-mozext-commits] [nostalgy] 69/252: *** empty log message ***

David Prévot taffit at moszumanska.debian.org
Tue Jun 14 15:24:43 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository nostalgy.

commit 34e8db65068b715cc29c74293ed2a8c0e6b72fd6
Author: frisch <frisch at 56b81dcf-5a2f-0410-9db0-014be2e416ff>
Date:   Tue May 1 10:35:54 2007 +0000

    *** empty log message ***
---
 CHANGES                        |   3 ++
 content/about.xhtml            |  40 ++++++++++------
 content/edit_prefs.js          | 101 ++++++++++++++++++++++++++++++++++-------
 content/edit_prefs.xul         |  33 ++------------
 content/nostalgy.js            |  36 +++++++++++++++
 content/thunderbirdOverlay.xul |  18 +++-----
 install.rdf                    |   2 +-
 7 files changed, 162 insertions(+), 71 deletions(-)

diff --git a/CHANGES b/CHANGES
index c83acc9..0f2bf3e 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+0.2.6
+  - allow the user to configure shortcuts
+
 0.2.5
   - bug fix: esc-M set focus on the message content, not the "subject" field
     (for TB 2.0)
diff --git a/content/about.xhtml b/content/about.xhtml
index a47a995..b67c3d0 100644
--- a/content/about.xhtml
+++ b/content/about.xhtml
@@ -24,7 +24,9 @@
    <p>
    Nostalgy adds several keyboard shortcuts to improve your
    productivity with Thunderbird. A custom preference dialog 
-   for Nostalgy is available through the Tools menu.
+   for Nostalgy is available through the Tools menu. Below we
+   give default values for shortcuts (they can be changed from
+   the preference dialog).
    </p>
 
    <h3>Folder commands</h3>
@@ -164,32 +166,42 @@ opens the file attachment dialog.</p>
 
    <h3>Preferences</h3>
    
-   <p>The preference dialog for Nostalgy is the place where rules are
-   defined. In addition, five switches control the way the completion
-   box (where folder names are proposed) is populated.</p>
+   <p>The preference dialog for Nostalgy has several tabs.
+   The first tab is the place where rules are
+   defined. The second tab has five switches to control the way the completion
+   box (where folder names are proposed) is populated (see below).
+   The third pane allows you to configure Nostalgy's shortcuts
+   (click on the key to change it) or to disable some of them.
+   You might need to restart Thunderbird for changes to shortcuts
+   to take effect.
+   </p>
 
-   <p>The first switch restricts the lookup to folders on the same
+   <p>Here is a description of the completion options:</p>
+ 
+   <ul>
+   <li>The first switch restricts the lookup to folders on the same
    server/account as the currently active folder. In this mode,
    the server name is not displayed (and must not be typed) in
-   the input line and the completion box.</p>
+   the input line and the completion box.</li>
 
-   <p>The second switch forces Nostalgy to interpret differently what
+   <li>The second switch forces Nostalgy to interpret differently what
       is typed in the text. Normally, when the option is disabled, 
       it is interpreted as a regexp which can match an arbitrary substring
       of the complete folder name (including the account name and 
       the name of parent folders). When the option is enabled,
       the regexp must match either a substring of the local folder name
-      (not the full name) or a prefix of the full folder name.</p>
+      (not the full name) or a prefix of the full folder name.</li>
 
-   <p>The third switch sorts folder in the completion box in alphabetical
-   order.</p>
+   <li>The third switch sorts folder in the completion box in alphabetical
+   order.</li>
   
-   <p>The fourth switch controls whether folder names are matched
-   in a case sensitive or insensitive way.</p>
+   <li>The fourth switch controls whether folder names are matched
+   in a case sensitive or insensitive way.</li>
 
-   <p>The fifth switch controls whether the Tab key triggers shell-like
+   <li>The fifth switch controls whether the Tab key triggers shell-like
       completion. If it is unchecked, Tab simply cycles through suggestions,
-      like the down arrow key.</p>
+      like the down arrow key.</li>
+   </ul>
 
    <hr/>
 
diff --git a/content/edit_prefs.js b/content/edit_prefs.js
index 91a2a4f..a43ddd4 100644
--- a/content/edit_prefs.js
+++ b/content/edit_prefs.js
@@ -2,6 +2,9 @@ function gEBI(s) { return document.getElementById(s); }
 
 var gList = null;
 
+var wait_key = null;
+var wait_key_old = "";
+
 var boolPrefs = [ 
  "restrict_to_current_server",
  "match_only_folder_name",
@@ -10,6 +13,16 @@ var boolPrefs = [
  "tab_shell_completion"
 ];
 
+var keys = [
+ ["save","Save message","S"],
+ ["save_suggest","Save as suggested","shift S"],
+ ["copy","Copy message","C"],
+ ["copy_suggest","Copy as suggested","shift C"],
+ ["go","Go to folder","G"],
+ ["hide_folders","Hide folder pane","L"],
+ ["search_sender","Show messages from same sender","`"]
+];
+
 (function () {
    var m = {
             '\b': '\\b',
@@ -155,6 +168,12 @@ function onAcceptChanges() {
     var n = boolPrefs[i];
     prefs.setBoolPref("extensions.nostalgy."+n,	gEBI(n).checked);
   }
+ 
+  if (wait_key) { wait_key.value = wait_key_old; wait_key = null; }
+  for (var i in keys)
+    prefs.setCharPref("extensions.nostalgy.keys."+keys[i][0],
+                      gEBI("key_" + keys[i][0]).value);
+
   window.close();
 }
 
@@ -180,6 +199,25 @@ function getBoolPref(prefs,s) {
  return b;
 }
 
+function createElem(tag,attrs,children) {
+ var x = document.createElement(tag);
+ for (var a in attrs) x.setAttribute(a,attrs[a]);
+ if (children) for (var i in children) x.appendChild(children[i]);
+ return x;
+}
+
+function createKeyRow(id,txt,v) {
+  return createElem("row",{ }, [
+    createElem("label", { value:txt+":" }),
+    createElem("label", { id:"key_" + id, class:"text-link", 
+                          value:v, 
+                          onclick:"WaitKey(this);",
+                          onblur:"Cancel(this);" }),
+    createElem("label", { class:"text-link", value:"disable",
+                   onclick:"this.previousSibling.value = '(disabled)';"} )
+  ]);
+}
+
 function onNostalgyLoad() {
   gList = gEBI("rules");
 
@@ -196,41 +234,70 @@ function onNostalgyLoad() {
    var n = boolPrefs[i];
    gEBI(n).checked = getBoolPref(prefs, n);
  }
+
+ for (var i in keys) {
+  var v = keys[i][2];
+  try {
+    v = prefs.getCharPref("extensions.nostalgy.keys." + keys[i][0]);
+  } catch (ex) { }
+  gEBI("key_rows").appendChild(createKeyRow(keys[i][0],keys[i][1],v));
+ }
 }
 
 function onKeyPress(ev) {
-  if ((ev.keyCode == 46) || (ev.keyCode == 8)) { DoDelete(); }
+  if (!wait_key && ((ev.keyCode == 46) || (ev.keyCode == 8))) DoDelete();
+  // should only to that in the relevant tab
+
+  else if (wait_key && ev.keyCode == KeyEvent.DOM_VK_ESCAPE) {
+    ev.preventDefault();
+    ev.stopPropagation();
+    wait_key.value = wait_key_old;
+    wait_key = null;
+  } else if (wait_key && ev.keyCode != 13) {
+    Recognize(ev,wait_key);
+    wait_key = null;
+  }
 }
 
 
-function Recognize(event) {
- event.preventDefault();
- event.stopPropagation();
+function Recognize(ev, tgt) {
+ ev.preventDefault();
+ ev.stopPropagation();
 
  var gVKNames = [];
 
  for (var property in KeyEvent) {
-  gVKNames[KeyEvent[property]] = property.replace("DOM_","");
+  gVKNames[KeyEvent[property]] = property.replace("DOM_VK_","");
  }
- gVKNames[8] = "VK_BACK";
 
- var gEdit = event.target;
+ var comps = [];
+ if(ev.altKey) comps.push("alt");
+ if(ev.ctrlKey) comps.push("control");
+ if(ev.metaKey) comps.push("meta");
+ if(ev.shiftKey) comps.push("shift");
+
 
- var modifiers = [];
- if(event.altKey) modifiers.push("alt");
- if(event.ctrlKey) modifiers.push("control");
- if(event.metaKey) modifiers.push("meta");
- if(event.shiftKey) modifiers.push("shift");
+ var k = "";
+ if(ev.charCode == 32) k = "SPACE";
+ else if(ev.charCode) k = String.fromCharCode(ev.charCode).toUpperCase();
+ else k = gVKNames[ev.keyCode];
 
- modifiers = modifiers.join(" ");
+ if (!k) return;
+ comps.push(k);
 
- var key = ""; var keycode = "";
- if(event.charCode) key = String.fromCharCode(event.charCode).toUpperCase();
- else { keycode = gVKNames[event.keyCode]; if(!keycode) return;}
+ tgt.value = comps.join(" ");
+}
 
- gEdit.value = modifiers + " " + key + keycode;
+function WaitKey(tgt) {
+  if (wait_key) wait_key.value = wait_key_old;
+  wait_key_old = tgt.value;
+  tgt.value = "key?";
+  wait_key = tgt;
 }
 
+function Cancel(tgt) {
+  if (tgt == wait_key) { wait_key.value = wait_key_old; wait_key = null; }
+}
 
 window.addEventListener("load", onNostalgyLoad, false);
 window.addEventListener("keypress", onKeyPress, false);
diff --git a/content/edit_prefs.xul b/content/edit_prefs.xul
index 720bcea..5d74cef 100644
--- a/content/edit_prefs.xul
+++ b/content/edit_prefs.xul
@@ -14,8 +14,6 @@
  <script src="folders.js"/>
  <script src="edit_prefs.js"/>
 
-<!-- <vbox > -->
-
  <tabbox style="width:800px">
  <tabs>
  <tab label="Rules"/>
@@ -77,32 +75,11 @@ shortcuts to move/copy the message to this folder.</label>
  </tabpanel>
 
  <tabpanel>
- <groupbox>
-   <hbox align="center">
-   <checkbox label="Change folder (Go)"/>
-   <deck align="end">
-   <label onclick="var p = this.parentNode;
-p.selectedIndex=1; p.selectedPanel.value = this.value; 
-p.selectedPanel.focus(); 
-">G</label>
-   <textbox flex="1"
-            onclick="this.select();" 
-            onkeypress="Recognize(event); this.parentNode.selectedIndex=0; this.parentNode.selectedPanel.value = this.value;"
-   />
-   </deck>
-   </hbox>
-<!--
-   <hbox>
-   <checkbox label="Save message"/>
-   <deck>
-   <label onclick="this.parentNode.selectedIndex=1; this.parentNode.selectedPanel.value = this.value; this.parentNode.selectedPanel.focus(); ">xxx</label>
-   <textbox flex="1" value="xxx"
-            onclick="this.select();" 
-            onkeypress="Recognize(event); this.parentNode.selectedIndex=0; this.parentNode.selectedPanel.value = this.value;"
-   />
-   </deck>
-   </hbox>
--->
+ <groupbox style="width:800px">
+   <grid>
+   <columns> <column/> <column width="150"/> <column/> </columns>
+   <rows id="key_rows"/>
+   </grid>
  </groupbox>
  </tabpanel>
  </tabpanels>
diff --git a/content/nostalgy.js b/content/nostalgy.js
index 45758c0..c5cac15 100644
--- a/content/nostalgy.js
+++ b/content/nostalgy.js
@@ -8,6 +8,25 @@ var nostalgy_label = null;
 var nostalgy_th_statusBar = null;
 var nostalgy_cmdLabel = null;
 
+/** Keys **/
+
+function NostalgySetKey(s,k) {
+  k.removeAttribute("modifiers");
+  k.removeAttribute("key");
+  k.removeAttribute("keycode");
+  k.removeAttribute("charcode");
+
+  if (s == "(disabled)") { k.setAttribute("keycode","VK_SHIFT"); return; }
+
+  var comps = s.split(/ /);
+  var mods = comps.slice(0,comps.length - 1).join(" ");
+  s = comps[comps.length-1];
+  
+  if (mods) k.setAttribute("modifiers",mods);
+  if (s.length == 1) k.setAttribute("key",s);
+  else k.setAttribute("keycode","VK_" + s);
+}
+
 /** Rules **/
 
 function match_contains(field,contain) {
@@ -54,6 +73,20 @@ var NostalgyRules =
     } catch (ex) { }
   },
 
+  register_keys: function() {
+    var keys = document.getElementsByTagName("key");
+    for (var i in keys) {
+      if (keys[i].id) {
+       var f = keys[i].id.match(/nostalgy_key_(.+)/);
+       if (f)
+       try {
+         var v = this._branch.getCharPref("keys." + f[1]);
+         NostalgySetKey(v,keys[i]);
+       } catch (ex) { }
+      }
+    }
+  },
+
   unregister: function()
   {
     if(!this._branch2) return;
@@ -107,6 +140,7 @@ var NostalgyRules =
         tab_shell_completion = this._branch.getBoolPref(aData);
         break;
     }
+    if (aData.match("keys.")) this.register_keys();
   },
 
   apply: function(sender,subject,recipients)
@@ -158,6 +192,8 @@ var NostalgyFolderListener = {
 }
 
 function onNostalgyLoad() {
+ NostalgyRules.register_keys();
+
  nostalgy_folderBox = gEBI("nostalgy-folderbox");
  nostalgy_statusBar = gEBI("nostalgy-statusbar");
  nostalgy_label = gEBI("statusbar-nostalgy-label");
diff --git a/content/thunderbirdOverlay.xul b/content/thunderbirdOverlay.xul
index 72ac5d5..f799d3e 100644
--- a/content/thunderbirdOverlay.xul
+++ b/content/thunderbirdOverlay.xul
@@ -18,26 +18,25 @@
 
 
  <keyset id="mailKeys">
-  <key id="NostalgyChangeFolder"
-       nostalgy_key = "Go (change folder)"
+  <key id="nostalgy_key_go"
        key="G" 
        oncommand="NostalgyCmd('&nostalgy.go-memo;', ShowFolder, '');"/>
-  <key id = "NostalgySaveMessage"
+  <key id = "nostalgy_key_save"
        key="S" 
        oncommand="NostalgyCmd('&nostalgy.move-memo;', MoveToFolder, '');"/>
-  <key id = "NostalgySaveMessageSuggested"
+  <key id = "nostalgy_key_save_suggest"
        key="S" modifiers="shift" 
        oncommand="NostalgySuggested('&nostalgy.move-memo;',MoveToFolder);"/>
-  <key id = "NostalgyCopyMessage"
+  <key id = "nostalgy_key_copy"
        key="C" 
        oncommand="NostalgyCmd('&nostalgy.copy-memo;', CopyToFolder, '');"/>
-  <key id = "NostalgyCopyMessageSuggested"
+  <key id = "nostalgy_key_copy_suggest"
        key="C" modifiers="shift" 
        oncommand="NostalgySuggested('&nostalgy.copy-memo;',CopyToFolder);"/>
-  <key id = "NostalgyCollapseFolderPane"
+  <key id = "nostalgy_key_hide_folders"
        key="L" 
        oncommand="NostalgyCollapseFolderPane();"/>
-  <key id = "NostalgySearchSender"
+  <key id = "nostalgy_key_search_sender"
        key="`" 
        oncommand="NostalgySearchSender();"/>
 
@@ -78,9 +77,6 @@
   </statusbarpanel>
  </statusbar>
 
-<!-- <tree id="threadTree" onclick="alert('Click' + NostalgyEscapePressed);">
- </tree> -->
-
 </overlay>
 
 
diff --git a/install.rdf b/install.rdf
index fe5a55b..d7334e0 100644
--- a/install.rdf
+++ b/install.rdf
@@ -5,7 +5,7 @@
   <RDF:Description RDF:about="urn:mozilla:install-manifest"
                    em:id="nostalgy at alain.frisch"
                    em:name="Nostalgy"
-                   em:version="0.2.5"
+                   em:version="0.2.6"
                    em:creator="Alain Frisch"
                    em:description="Adds shortcuts to change folder, move message, with folder completion"
                    em:homepageURL="http://alain.frisch.fr/soft_mozilla.html"

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/nostalgy.git



More information about the Pkg-mozext-commits mailing list