#10 status bar virtual column (%v, %V) and selected chars (%n)

Unstable (example)
closed-fixed
nobody
None
5
2015-03-08
2011-08-27
No

As you may have noticed, when cursor is in the "virtual space" (beyond eoln), our status bar always shows the last "real" column. This small patch adds a new %v (and %V) format specification, which displays a "virtual" column number, as if the line extends to the cursor position.

sci_get_cursor_virtual_space() isn't included the plugins interface for now, though it may be useful.

Since the virtual position normally requires 3 SSM()-s, and is less likely to be used than the line and column, the calls to sci_get_cursor_virtual_space() are into add_statusbar_statistics() instead of ui_update_statusbar().

Related

Patches: #10

Discussion

  • Dimitar Zhekov

    Dimitar Zhekov - 2012-08-07
    • summary: status bar virtual column (%v, %V) --> status bar virtual column (%v, %V) and selected chars (%n)
     
  • Dimitar Zhekov

    Dimitar Zhekov - 2012-08-07

    Added %n for selected chars, since %s now shows the selected chars-or-lines.

     
  • Dimitar Zhekov

    Dimitar Zhekov - 2012-12-22

    Added %n for selected characters.

     
  • Lex Trotman

    Lex Trotman - 2013-10-04

    Hi Dimitar, that looks ok, can you add doco in geany.txt to the patch as well.

     
  • Colomban Wendling

    Looks mostly good, but:

    • subject in the patch is wrong;
    • shouldn't we simply alter how %c and %C work so they behave like your %v and %V? I don't see no real use case where they wouldn't agree and someone wouldn't prefer the virtual space value?
     
    • Lex Trotman

      Lex Trotman - 2015-02-25

      On 25 February 2015 at 11:57, Colomban Wendling colombanw@users.sf.net wrote:

      Looks mostly good, but:

      subject in the patch is wrong;
      shouldn't we simply alter how %c and %C work so they behave like your %v and
      %V? I don't see no real use case where they wouldn't agree and someone
      wouldn't prefer the virtual space value?

      We have three virtual space options:

      • off - %c and %v are the same

      • rectangular selections only (default) - %c and %v are different, %v
        is indeed useful for ensuring your selection is wide enough if you
        can't see the first line in the range, at all other times %c and %v
        are the same

      • always - %c and %v are different if the cursor is in virtual
        territory, I don't use this mode but I am not sure why you would want
        %c as well as %v

      So to me just having %c being the column the cursor is in, virtual or
      real is fine, and it makes better logical sense too.

      And finally a warning that Scintilla gets it wrong in the case of
      combining chars, compare (assuming the utf-8 gets through correctly):

      Trögar
      Trögar

      Cheers
      Lex


      [patches:#10] status bar virtual column (%v, %V) and selected chars (%n)

      Status: open
      Group:
      Created: Sat Aug 27, 2011 05:55 PM UTC by Dimitar Zhekov
      Last Updated: Sun Feb 22, 2015 05:25 PM UTC
      Owner: nobody

      As you may have noticed, when cursor is in the "virtual space" (beyond
      eoln), our status bar always shows the last "real" column. This small patch
      adds a new %v (and %V) format specification, which displays a "virtual"
      column number, as if the line extends to the cursor position.

      sci_get_cursor_virtual_space() isn't included the plugins interface for now,
      though it may be useful.

      Since the virtual position normally requires 3 SSM()-s, and is less likely
      to be used than the line and column, the calls to
      sci_get_cursor_virtual_space() are into add_statusbar_statistics() instead
      of ui_update_statusbar().


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/geany/patches/10/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       

      Related

      Patches: #10

      • Dimitar Zhekov

        Dimitar Zhekov - 2015-02-26

        I'm working under Windows now, and have trouble pasting the sample "Trogar" texts. Did you mean that the SCI column fails generally, or only when displaying position in the virtual space?

         
        • Lex Trotman

          Lex Trotman - 2015-02-27

          On 27 February 2015 at 05:34, Dimitar Zhekov sheckley@users.sf.net wrote:

          I'm working under Windows now, and have trouble pasting the sample "Trogar"
          texts. Did you mean that the SCI column fails generally, or only when
          displaying position in the virtual space?

          Thought that might happen :)

          Scintilla gets the column count different between the two since the
          first uses U+00F6 while the second uses U+006F U+0308 for the o with
          diaresis

          I don't think there is anything we can do with it, it was just a note
          that Scintilla does not handle it properly. Also not sure it handles
          double wide chars properly.

          Cheers
          Lex


          [patches:#10] status bar virtual column (%v, %V) and selected chars (%n)

          Status: open
          Group:
          Created: Sat Aug 27, 2011 05:55 PM UTC by Dimitar Zhekov
          Last Updated: Wed Feb 25, 2015 12:57 AM UTC
          Owner: nobody

          As you may have noticed, when cursor is in the "virtual space" (beyond
          eoln), our status bar always shows the last "real" column. This small patch
          adds a new %v (and %V) format specification, which displays a "virtual"
          column number, as if the line extends to the cursor position.

          sci_get_cursor_virtual_space() isn't included the plugins interface for now,
          though it may be useful.

          Since the virtual position normally requires 3 SSM()-s, and is less likely
          to be used than the line and column, the calls to
          sci_get_cursor_virtual_space() are into add_statusbar_statistics() instead
          of ui_update_statusbar().


          Sent from sourceforge.net because you indicated interest in
          https://sourceforge.net/p/geany/patches/10/

          To unsubscribe from further messages, please visit
          https://sourceforge.net/auth/subscriptions/

           

          Related

          Patches: #10

    • Dimitar Zhekov

      Dimitar Zhekov - 2015-02-26

      Hmm, yes, I got the subject from another patch.

      I, too, do not see a case where somebody will work with virtual space, but want the current %c and %C instead.

      Though whoever altered %s to display the # of selected lines if entire lines are selected must thought the same, and that's why this patch contains %n... :)

      Anyway, I'll post a newer version sometime after I finish with the spawn effort...

       
  • Colomban Wendling

    Looks nice, but as I'm a very annoying people, I'll ask you if you don't think that as now %v is in %c, the column should be computed only once (e.g. revert the argument you had in the 1st message here, as it's now always used):

    diff --git a/src/ui_utils.c b/src/ui_utils.c
    index 4600de8..512bb11 100644
    --- a/src/ui_utils.c
    +++ b/src/ui_utils.c
    @@ -185,7 +185,7 @@ void ui_set_statusbar(gboolean log, const gchar *format, ...)
    
     /* note: some comments below are for translators */
     static gchar *create_statusbar_statistics(GeanyDocument *doc,
    -   guint line, guint col, guint pos)
    +   guint line, guint vcol, guint pos)
     {
        const gchar *cur_tag;
        const gchar *fmt;
    @@ -216,12 +216,10 @@ static gchar *create_statusbar_statistics(GeanyDocument *doc,
                        sci_get_line_count(doc->editor->sci));
                    break;
                case 'c':
    -               g_string_append_printf(stats_str, "%d",
    -                   col + sci_get_cursor_virtual_space(doc->editor->sci));
    +               g_string_append_printf(stats_str, "%d", vcol);
                    break;
                case 'C':
    -               g_string_append_printf(stats_str, "%d",
    -                   col + sci_get_cursor_virtual_space(doc->editor->sci) + 1);
    +               g_string_append_printf(stats_str, "%d", vcol + 1);
                    break;
                case 'p':
                    g_string_append_printf(stats_str, "%u", pos);
    @@ -334,7 +332,7 @@ void ui_update_statusbar(GeanyDocument *doc, gint pos)
    
        if (doc != NULL)
        {
    -       guint line, col;
    +       guint line, vcol;
            gchar *stats_str;
    
            if (pos == -1)
    @@ -345,11 +343,12 @@ void ui_update_statusbar(GeanyDocument *doc, gint pos)
             * when current pos is beyond document end (can occur when removing
             * blocks of selected lines especially esp. brace sections near end of file). */
            if (pos <= sci_get_length(doc->editor->sci))
    -           col = sci_get_col_from_position(doc->editor->sci, pos);
    +           vcol = sci_get_col_from_position(doc->editor->sci, pos);
            else
    -           col = 0;
    +           vcol = 0;
    +       vcol += sci_get_cursor_virtual_space(doc->editor->sci);
    
    -       stats_str = create_statusbar_statistics(doc, line, col, pos);
    +       stats_str = create_statusbar_statistics(doc, line, vcol, pos);
    
            /* can be overridden by status messages */
            set_statusbar(stats_str, TRUE);
    
     
  • Dimitar Zhekov

    Dimitar Zhekov - 2015-03-03

    Looks better to me, and since and create_statusbar_statistics() is static, why not? Please drop me a note whether I should recreate the patch, or you will do so.

     
  • Colomban Wendling

    I'll merge it in your patch, that's not a problem. (unless you're not happy with this)

     
  • Colomban Wendling

    • status: open --> closed-fixed
    • Group: --> Unstable (example)
     
  • Dimitar Zhekov

    Dimitar Zhekov - 2015-03-08

    OK, thanks.

     

Log in to post a comment.