ReactOS 0.4.15-dev-7788-g1ad9096
pager.h File Reference

Console/terminal paging functionality. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _CON_PAGER
 

Macros

#define CON_PAGER_EXPAND_TABS   (1 << 0)
 
#define CON_PAGER_EXPAND_FF   (1 << 1)
 
#define CON_PAGER_CACHE_INCOMPLETE_LINE   (1 << 2)
 
#define INIT_CON_PAGER(pScreen)   {(pScreen), 0}
 
#define InitializeConPager(pPager, pScreen)
 

Typedefs

typedef BOOL(__stdcallCON_PAGER_LINE_FN) (IN OUT struct _CON_PAGER *Pager, IN PCTCH line, IN DWORD cch)
 
typedef struct _CON_PAGER CON_PAGER
 
typedef struct _CON_PAGERPCON_PAGER
 
typedef BOOL(__stdcallPAGE_PROMPT) (IN PCON_PAGER Pager, IN DWORD Done, IN DWORD Total)
 

Functions

BOOL ConWritePaging (IN PCON_PAGER Pager, IN PAGE_PROMPT PagePrompt, IN BOOL StartPaging, IN PCTCH szStr, IN DWORD len)
 
BOOL ConPutsPaging (IN PCON_PAGER Pager, IN PAGE_PROMPT PagePrompt, IN BOOL StartPaging, IN PCTSTR szStr)
 
BOOL ConResPagingEx (IN PCON_PAGER Pager, IN PAGE_PROMPT PagePrompt, IN BOOL StartPaging, IN HINSTANCE hInstance OPTIONAL, IN UINT uID)
 
BOOL ConResPaging (IN PCON_PAGER Pager, IN PAGE_PROMPT PagePrompt, IN BOOL StartPaging, IN UINT uID)
 

Detailed Description

Console/terminal paging functionality.

Definition in file pager.h.

Macro Definition Documentation

◆ CON_PAGER_CACHE_INCOMPLETE_LINE

#define CON_PAGER_CACHE_INCOMPLETE_LINE   (1 << 2)

Definition at line 43 of file pager.h.

◆ CON_PAGER_EXPAND_FF

#define CON_PAGER_EXPAND_FF   (1 << 1)

Definition at line 41 of file pager.h.

◆ CON_PAGER_EXPAND_TABS

#define CON_PAGER_EXPAND_TABS   (1 << 0)

Definition at line 40 of file pager.h.

◆ INIT_CON_PAGER

#define INIT_CON_PAGER (   pScreen)    {(pScreen), 0}

Definition at line 73 of file pager.h.

◆ InitializeConPager

#define InitializeConPager (   pPager,
  pScreen 
)
Value:
do { \
ZeroMemory((pPager), sizeof(*(pPager))); \
(pPager)->Screen = (pScreen); \
} while (0)
@ Screen
Definition: console.h:34

Definition at line 75 of file pager.h.

Typedef Documentation

◆ CON_PAGER

◆ CON_PAGER_LINE_FN

typedef BOOL(__stdcall * CON_PAGER_LINE_FN) (IN OUT struct _CON_PAGER *Pager, IN PCTCH line, IN DWORD cch)

Definition at line 33 of file pager.h.

◆ PAGE_PROMPT

typedef BOOL(__stdcall * PAGE_PROMPT) (IN PCON_PAGER Pager, IN DWORD Done, IN DWORD Total)

Definition at line 82 of file pager.h.

◆ PCON_PAGER

Function Documentation

◆ ConPutsPaging()

BOOL ConPutsPaging ( IN PCON_PAGER  Pager,
IN PAGE_PROMPT  PagePrompt,
IN BOOL  StartPaging,
IN PCTSTR  szStr 
)

Definition at line 646 of file pager.c.

651{
652 DWORD len;
653
654 /* Return if no string has been given */
655 if (szStr == NULL)
656 return TRUE;
657
658 len = wcslen(szStr);
659 return ConWritePaging(Pager, PagePrompt, StartPaging, szStr, len);
660}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
static BOOL __stdcall PagePrompt(PCON_PAGER Pager, DWORD Done, DWORD Total)
Definition: more.c:160
BOOL ConWritePaging(IN PCON_PAGER Pager, IN PAGE_PROMPT PagePrompt, IN BOOL StartPaging, IN PCTCH szStr, IN DWORD len)
Definition: pager.c:549

◆ ConResPaging()

BOOL ConResPaging ( IN PCON_PAGER  Pager,
IN PAGE_PROMPT  PagePrompt,
IN BOOL  StartPaging,
IN UINT  uID 
)

Definition at line 681 of file pager.c.

686{
687 return ConResPagingEx(Pager, PagePrompt, StartPaging,
688 NULL /*GetModuleHandleW(NULL)*/, uID);
689}
BOOL ConResPagingEx(IN PCON_PAGER Pager, IN PAGE_PROMPT PagePrompt, IN BOOL StartPaging, IN HINSTANCE hInstance OPTIONAL, IN UINT uID)
Definition: pager.c:663

Referenced by ConOutResPaging().

◆ ConResPagingEx()

BOOL ConResPagingEx ( IN PCON_PAGER  Pager,
IN PAGE_PROMPT  PagePrompt,
IN BOOL  StartPaging,
IN HINSTANCE hInstance  OPTIONAL,
IN UINT  uID 
)

Definition at line 663 of file pager.c.

669{
670 INT Len;
671 PCWSTR szStr = NULL;
672
673 Len = K32LoadStringW(hInstance, uID, (PWSTR)&szStr, 0);
674 if (szStr && Len)
675 return ConWritePaging(Pager, PagePrompt, StartPaging, szStr, Len);
676 else
677 return TRUE;
678}
HINSTANCE hInstance
Definition: charmap.c:19
#define Len
Definition: deflate.h:82
INT WINAPI K32LoadStringW(IN HINSTANCE hInstance OPTIONAL, IN UINT uID, OUT LPWSTR lpBuffer, IN INT nBufferMax)
Definition: utils.c:173
uint16_t * PWSTR
Definition: typedefs.h:56
const uint16_t * PCWSTR
Definition: typedefs.h:57
int32_t INT
Definition: typedefs.h:58

Referenced by ConResPaging().

◆ ConWritePaging()

BOOL ConWritePaging ( IN PCON_PAGER  Pager,
IN PAGE_PROMPT  PagePrompt,
IN BOOL  StartPaging,
IN PCTCH  szStr,
IN DWORD  len 
)

Definition at line 549 of file pager.c.

555{
557 BOOL bIsConsole;
558
559 /* Parameters validation */
560 if (!Pager)
561 return FALSE;
562
563 /* Get the size of the visual screen that can be printed to */
564 bIsConsole = ConGetScreenInfo(Pager->Screen, &csbi);
565 if (bIsConsole)
566 {
567 /* Calculate the console screen extent */
568 Pager->PageColumns = csbi.dwSize.X;
569 Pager->PageRows = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
570 }
571 else
572 {
573 /* We assume it's a file handle */
574 Pager->PageColumns = 0;
575 Pager->PageRows = 0;
576 }
577
578 if (StartPaging)
579 {
580 if (bIsConsole && (Pager->PageRows >= 2))
581 {
582 /* Reset to display one page by default */
583 Pager->ScrollRows = Pager->PageRows - 1;
584 }
585 else
586 {
587 /* File output, or single line: all lines are displayed at once; reset to a default value */
588 Pager->ScrollRows = 0;
589 }
590
591 /* Reset the internal data buffer */
592 Pager->CachedLine = NULL;
593 Pager->cchCachedLine = 0;
594
595 /* Reset the paging state */
596 Pager->CurrentLine = NULL;
597 Pager->ichCurr = 0;
598 Pager->iEndLine = 0;
599 Pager->nSpacePending = 0;
600 Pager->iColumn = 0;
601 Pager->iLine = 0;
602 Pager->lineno = 0;
603 }
604
605 /* Reset the reading index in the user-provided source buffer */
606 Pager->ich = 0;
607
608 /* Run the pager even when the user-provided source buffer is
609 * empty, in case we need to flush any remaining cached line. */
610 if (!Pager->CachedLine)
611 {
612 /* No cached line, bail out now */
613 if (len == 0 || szStr == NULL)
614 return TRUE;
615 }
616
617 while (ConPagerWorker(Pager, szStr, len))
618 {
619 /* Prompt the user only when we display to a console and the screen
620 * is not too small: at least one line for the actual paged text and
621 * one line for the prompt. */
622 if (bIsConsole && (Pager->PageRows >= 2))
623 {
624 /* Reset to display one page by default */
625 Pager->ScrollRows = Pager->PageRows - 1;
626
627 /* Prompt the user; give him some values for statistics */
628 // FIXME: Doesn't reflect what's currently being displayed.
629 if (!PagePrompt(Pager, Pager->ich, len))
630 return FALSE;
631 }
632
633 /* If we display to a console, recalculate its screen extent
634 * in case the user has redimensioned it during the prompt. */
635 if (bIsConsole && ConGetScreenInfo(Pager->Screen, &csbi))
636 {
637 Pager->PageColumns = csbi.dwSize.X;
638 Pager->PageRows = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
639 }
640 }
641
642 return TRUE;
643}
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL ConPagerWorker(IN PCON_PAGER Pager, IN PCTCH TextBuff, IN DWORD cch)
Does the main paging work: fetching text lines and displaying them.
Definition: pager.c:219
BOOL ConGetScreenInfo(IN PCON_SCREEN Screen, OUT PCONSOLE_SCREEN_BUFFER_INFO pcsbi)
Definition: screen.c:73
SHORT X
Definition: blue.h:26
SHORT Top
Definition: blue.h:33
SHORT Bottom
Definition: blue.h:35

Referenced by ConPrintfVPaging(), ConPutsPaging(), ConResPagingEx(), and wmain().