bugGNU Screen - Bugs: bug #14484, RFE: add escape to show number of...

 
 

bug #14484: RFE: add escape to show number of currently open windows in hardstatus

Submitter:  None
Submitted:  Sat 10 Sep 2005 12:48:40 AM UTC
   
 
Category:  Feature Request Severity:  1 - Wish
Priority:  * 5 - Normal Status:  Fixed
Privacy:  Public Assigned to:  eneville
Open/Closed:  Closed Release:  None
Fixed Release:  None Planned Release:  5.0.0
Work Required:  0 - Hours
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 03 Feb 2020 10:46:24 PM UTC, comment #8: 

Thanks, applied to master.

Amadeusz Sławiński <amade>
Group administrator
Mon 20 Jan 2020 07:07:53 PM UTC, comment #7: 

Hopefully what I've just attached should be in a workable format.

It would be nice to keep authorship/blame of issues :)


ed neville <eneville>
Group Member
Sun 19 Jan 2020 10:38:57 PM UTC, comment #6: 

Hi Ed,

sorry for delay! That looks a lot better. If you want to be showed as author of a patch in git history, you should also learn a bit of git if you are not already familiar with it.

Seeing as it is against master, you probably already have a git checkout, so just cd to it and then:
$ git add src/doc/screen.1 src/winmsg.c src/winmsg.h
$ git commit -s

And then write a commit message.

$ git format-patch -1

and it will produce a patch with your authorship and commit message. You can then attach it here ;)

Amadeusz Sławiński <amade>
Group administrator
Tue 31 Dec 2019 10:29:39 PM UTC, comment #5: 

Hello,

Thanks for taking the time to review and comment, much appreciated.

I've attached the patch again, you're right about the code, it could be simplified.

Please let me know your thoughts.

Ed

ed neville <eneville>
Group Member
Tue 31 Dec 2019 10:55:31 AM UTC, comment #4: 

There is some things that can be improved.

First there is a change in display.c, which shouldn't be part of this patch.

There is also some weird white space problems (usually I would correct those myself when applying, but as there are other parts of patch that need to be corrected, you can fix them ;)

+    int count=1;
is intended with 4 spaces instead of tab and there are spaces missing around '='

+        case WINESC_WIN_COUNT:
is intended with 8 spaces instead of 2 tabs

+ wmbc_printf(wmbc, "%*d", esc->num, count );
There is unnecessary space before closing bracket.

+winmsg_esc_ex(WinCount, Window *win)
+{
+    int count=1;
+
+ if (esc->num == 0)
+ esc->num = 1;
+
+ if (!win) {
+ wmbc_printf(wmbc, "%*s", esc->num, esc->num > 1 ? "--" : "-");
+ } else {
+ Window *count_ptr = win;
+
+ for (;; count++) {
+ if (count_ptr->w_prev_mru == NULL) {
+ break;
+ }
+
+ count_ptr = count_ptr->w_prev_mru;
+ if (count_ptr == win) {
+ break;
+ }
+ }
+ wmbc_printf(wmbc, "%*d", esc->num, count );
+ }
+
+ wmc_set(cond);
+}

The function itself can be a lot simpler.
Check how screen loops through window list in almost all files, it can be done with 2 lines of code.
One for looping and other one for counting.

int count, can be moved into else part to reduce scope.

And as mentioned in comment by Sadrul we may also want to consider something like %-C to only show current group count (see esc->flags.minus), which will add few more lines.

Amadeusz Sławiński <amade>
Group administrator
Mon 30 Dec 2019 11:03:31 PM UTC, comment #3: 

Hello,

Please find attached '14484_escape_to_show_number_of_currently_open_windows' patch to add a new escape character to show the count of windows.

Let me know if there's any issues please or if pushing the branch would be preferred?

Ed

ed neville <eneville>
Group Member
Wed 09 Jul 2008 03:42:49 AM UTC, comment #2: 

How about '%N' to show the count of the total number of windows, with '-' qualifier to show the count of the windows in the current group only (if the window doesn't belong to any group, then the qualifier will not do anything, and the count of total number of windows will be displayed)?

Sadrul Habib Chowdhury <sadrul>
Group administrator
  Spam posted by anonymous
Sat 10 Sep 2005 12:48:40 AM UTC, original submission:  

It would be nice to show total number of currently open windows w/o their names and flags, something like "0/5 zsh ..." , where 0 - is current window's number, and 5 - total number of open windows.

Showing their names and flags occupies too much space if one wants to incorporate applications hardstatus line into that of screen.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by amade (Posted a comment)
  • -email is unavailable- added by eneville (Posted a comment)
  • -email is unavailable- added by sadrul (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 13 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-02-03 amade StatusConfirmed Fixed
        Open/ClosedOpen Closed
        Planned ReleaseLater 5.0.0
    2020-01-20 eneville Attached File- Added 0001-Add-escape-to-show-number-of-currently-open-windows-.patch, #48260
    2020-01-19 amade Assigned toNone eneville
    2019-12-31 eneville Attached File- Added 14484_escape_to_show_number_of_currently_open_windows_2, #48150
    2019-12-31 micahcowan Carbon-CopyRemoved 60294 -
    2019-12-30 eneville Attached File- Added 14484_escape_to_show_number_of_currently_open_windows, #48142
    2008-06-23 micahcowan CategoryNone Feature Request
        Planned ReleaseNone Later
        Work RequiredNone 0 - Hours
    2008-06-13 micahcowan Severity3 - Normal 1 - Wish
        StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code