xaizek / vifm-pdcurses (License: mostly public domain) (since 2019-03-20)
PDCurses 3.4 with vifm-specific patches applied (a couple were upstreamed)
Commit 47e510e053ecf7e00ad923fdb65b5894ad442d9b

Resizing detection and manual handling for Windows
Author: xaizek
Author date (UTC): 2019-03-20 12:26
Committer name: xaizek
Committer date (UTC): 2019-03-20 12:26
Parent(s): d33039912919f9aec760f611cb205c23e4712b0d
Signing key: 99DC5E4DB05F6BE2
Tree: 8e8ec2b9cfe61737c26193ec65eddf52f140dc35
File Lines added Lines deleted
win32/pdckbd.c 33 4
win32/pdcscrn.c 12 0
File win32/pdckbd.c changed (mode: 100644) (index 9d4f73c2..f4ca7c27)
... ... int PDC_get_key(void)
606 606 key_count = 1; key_count = 1;
607 607 else if (save_ip.EventType == KEY_EVENT) else if (save_ip.EventType == KEY_EVENT)
608 608 key_count = _get_key_count(); key_count = _get_key_count();
609 else if (save_ip.EventType == WINDOW_BUFFER_SIZE_EVENT)
610 key_count = 1;
609 611 } }
610 612
611 613 if (key_count) if (key_count)
 
... ... int PDC_get_key(void)
619 621
620 622 case MOUSE_EVENT: case MOUSE_EVENT:
621 623 return _process_mouse_event(); return _process_mouse_event();
624
625 case WINDOW_BUFFER_SIZE_EVENT:
626 if (save_ip.Event.WindowBufferSizeEvent.dwSize.Y != LINES ||
627 save_ip.Event.WindowBufferSizeEvent.dwSize.X != COLS)
628 {
629 INPUT_RECORD ip;
630 DWORD count;
631 bool have_click = FALSE;
632
633 /* Drain whole sequence of resize events. */
634 while (PeekConsoleInput(pdc_con_in, &ip, 1, &count) &&
635 count == 1 && ip.EventType == WINDOW_BUFFER_SIZE_EVENT)
636 {
637 ReadConsoleInput(pdc_con_in, &ip, 1, &count);
638 if(event_count > 0)
639 {
640 --event_count;
641 }
642 }
643
644 if (!SP->resized)
645 {
646 SP->resized = TRUE;
647 return KEY_RESIZE;
648 }
649 }
650 break;
622 651 } }
623 652 } }
624 653
 
... ... void PDC_flushinp(void)
638 667 int PDC_mouse_set(void) int PDC_mouse_set(void)
639 668 { {
640 669 /* If turning on mouse input: Set ENABLE_MOUSE_INPUT, and clear /* If turning on mouse input: Set ENABLE_MOUSE_INPUT, and clear
641 all other flags, including the extended flags;
670 all other flags except window resize event, including the extended flags;
642 671 If turning off the mouse: Set QuickEdit Mode to the status it If turning off the mouse: Set QuickEdit Mode to the status it
643 had on startup, and clear all other flags */
672 had on startup, and clear all other flags but window resize event */
644 673
645 SetConsoleMode(pdc_con_in, SP->_trap_mbe ?
646 (ENABLE_MOUSE_INPUT|0x0080) : (pdc_quick_edit|0x0080));
674 SetConsoleMode(pdc_con_in, ENABLE_WINDOW_INPUT | (SP->_trap_mbe ?
675 (ENABLE_MOUSE_INPUT|0x0080) : (pdc_quick_edit|0x0080)));
647 676
648 677 memset(&old_mouse_status, 0, sizeof(old_mouse_status)); memset(&old_mouse_status, 0, sizeof(old_mouse_status));
649 678
File win32/pdcscrn.c changed (mode: 100644) (index 4d9ce510..05d84108)
... ... int PDC_resize_screen(int nlines, int ncols)
468 468 SMALL_RECT rect; SMALL_RECT rect;
469 469 COORD size, max; COORD size, max;
470 470
471 /* Treat this combination as a request to resize to window size. Note that
472 * this is window size, not screen buffer size, thus scrolling won't be
473 * available. */
474 if (nlines == 0 && ncols == 0)
475 {
476 CONSOLE_SCREEN_BUFFER_INFO csbi;
477 GetConsoleScreenBufferInfo(pdc_con_out, &csbi);
478 nlines = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
479 ncols = csbi.srWindow.Right - csbi.srWindow.Left + 1;
480 }
481
471 482 if (nlines < 2 || ncols < 2) if (nlines < 2 || ncols < 2)
472 483 return ERR; return ERR;
473 484
 
... ... int PDC_resize_screen(int nlines, int ncols)
493 504 SetConsoleScreenBufferSize(pdc_con_out, size); SetConsoleScreenBufferSize(pdc_con_out, size);
494 505 SetConsoleActiveScreenBuffer(pdc_con_out); SetConsoleActiveScreenBuffer(pdc_con_out);
495 506
507 SP->resized = FALSE;
496 508 return OK; return OK;
497 509 } }
498 510
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/vifm-pdcurses

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/vifm-pdcurses

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master