[hg] main-silver: #191499 - Patch for: Display count of selected...

  • From: Milutin Kristofic < >
  • To: ,
  • Subject: [hg] main-silver: #191499 - Patch for: Display count of selected...
  • Date: Wed, 18 Sep 2013 10:35:18 -0700

changeset 5cddca26fd62 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/5cddca26fd62
description:
        #191499 - Patch for: Display count of selected characters/lines in 
status bar - markiewb contribution

diffstat:

 editor.lib/src/org/netbeans/editor/StatusBar.java                    |  22 
++++++++-
 editor/src/org/netbeans/modules/editor/impl/StatusLineComponent.java |   4 +-
 2 files changed, 21 insertions(+), 5 deletions(-)

diffs (71 lines):

diff --git a/editor.lib/src/org/netbeans/editor/StatusBar.java 
b/editor.lib/src/org/netbeans/editor/StatusBar.java
--- a/editor.lib/src/org/netbeans/editor/StatusBar.java
+++ b/editor.lib/src/org/netbeans/editor/StatusBar.java
@@ -86,12 +86,14 @@
 import javax.swing.event.DocumentListener;
 import javax.swing.UIManager;
 import javax.swing.text.AttributeSet;
+import javax.swing.text.BadLocationException;
 import org.netbeans.api.editor.EditorRegistry;
 import org.netbeans.api.editor.mimelookup.MimeLookup;
 import org.netbeans.api.editor.settings.FontColorNames;
 import org.netbeans.api.editor.settings.FontColorSettings;
 import org.netbeans.api.editor.settings.SimpleValueNames;
 import org.netbeans.modules.editor.lib2.EditorPreferencesDefaults;
+import org.openide.util.Exceptions;
 import org.openide.util.NbBundle;
 import org.openide.util.WeakListeners;
 
@@ -123,9 +125,9 @@
 
     public static final String OVERWRITE_LOCALE = "status-bar-overwrite"; // 
NOI18N
 
-    private static final String[] POS_MAX_STRINGS = new String[] { "99999 | 
999" }; // NOI18N
+    private static final String[] POS_MAX_STRINGS = new String[] { 
"99999:999/9999:9999" }; // NOI18N
 
-    private static final String[] POS_MAX_STRINGS_OFFSET = new String[] { 
"99999 | 999 <99999999>" }; // NOI18N
+    private static final String[] POS_MAX_STRINGS_OFFSET = new String[] { 
"99999:999/9999:9999 <99999999>" }; // NOI18N
 
     private static final Insets NULL_INSETS = new Insets(0, 0, 0, 0);
 
@@ -644,10 +646,24 @@
                     BaseDocument doc = Utilities.getDocument(component);
                     if (doc != null && 
doc.getDefaultRootElement().getElementCount()>0) {
                         int pos = c.getDot();
-                        String s = Utilities.debugPosition(doc, pos, " | ");
+                        String s = Utilities.debugPosition(doc, pos, ":");
                         if (CARET_OFFSET_LOG.isLoggable(Level.FINE)) { // 
Possibly add caret offset info
                             s += " <" + pos + ">"; // NOI18N
                         }
+                        int countOfSelectedChars = 
component.getSelectionEnd() - component.getSelectionStart();
+                        final boolean hasSelection = countOfSelectedChars > 
0;
+                        if (hasSelection) {
+                            try {
+                                //count of selected lines
+                                int lineEnd = Utilities.getLineOffset(doc, 
component.getSelectionEnd());
+                                int lineStart = Utilities.getLineOffset(doc, 
component.getSelectionStart());
+                                s += "/" + (lineEnd - lineStart + 1);
+                            } catch (BadLocationException ex) {
+                            }
+                            //count of selected characters
+                            s += ":" + countOfSelectedChars;
+                        }
+                        //rows:cols/countRows:countCols
                         setText(CELL_POSITION, s);
                     }
                 }
diff --git 
a/editor/src/org/netbeans/modules/editor/impl/StatusLineComponent.java 
b/editor/src/org/netbeans/modules/editor/impl/StatusLineComponent.java
--- a/editor/src/org/netbeans/modules/editor/impl/StatusLineComponent.java
+++ b/editor/src/org/netbeans/modules/editor/impl/StatusLineComponent.java
@@ -72,9 +72,9 @@
 
     private static final Insets NULL_INSETS = new Insets(0, 0, 0, 0);
 
-    private static final String MAX_LINE_COLUMN_STRING = "99999 | 999";
+    private static final String MAX_LINE_COLUMN_STRING = 
"99999:999/9999:9999";
 
-    private static final String MAX_LINE_COLUMN_OFFSET_STRING = "99999 | 999 
<99999999>";
+    private static final String MAX_LINE_COLUMN_OFFSET_STRING = 
"99999:999/9999:9999 <99999999>";
 
     private static final String INSERT_LOCALE = "status-bar-insert"; // 
NOI18N
 

[hg] main-silver: #191499 - Patch for: Display count of selected...

Milutin Kristofic 09/18/2013

Project Features

About this Project

Editor was started in November 2009, is owned by Martin Ryzl, and has 147 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close