ReactOS 0.4.16-dev-2491-g3dc6630
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 SIZE_T 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 SIZE_T 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 SIZE_T 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 645 of file pager.c.

650{
651 SIZE_T len;
652
653 /* Return if no string has been given */
654 if (szStr == NULL)
655 return TRUE;
656
657 len = wcslen(szStr);
658 return ConWritePaging(Pager, PagePrompt, StartPaging, szStr, len);
659}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2983
GLenum GLsizei len
Definition: glext.h:6722
static BOOL __stdcall PagePrompt(PCON_PAGER Pager, DWORD Done, DWORD Total)
Definition: more.c:159
BOOL ConWritePaging(IN PCON_PAGER Pager, IN PAGE_PROMPT PagePrompt, IN BOOL StartPaging, IN PCTCH szStr, IN SIZE_T len)
Definition: pager.c:548
ULONG_PTR SIZE_T
Definition: typedefs.h:80

◆ ConResPaging()

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

Definition at line 679 of file pager.c.

684{
685 return ConResPagingEx(Pager, PagePrompt, StartPaging, NULL, uID);
686}
_In_ UINT uID
Definition: shlwapi.h:156
BOOL ConResPagingEx(IN PCON_PAGER Pager, IN PAGE_PROMPT PagePrompt, IN BOOL StartPaging, IN HINSTANCE hInstance OPTIONAL, IN UINT uID)
Definition: pager.c:662

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 662 of file pager.c.

668{
669 INT Len;
670 PCWSTR szStr = NULL;
671
672 Len = K32LoadStringW(hInstance, uID, (PWSTR)&szStr, 0);
673 if (szStr && Len)
674 return ConWritePaging(Pager, PagePrompt, StartPaging, szStr, Len);
675 return TRUE;
676}
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:183
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 SIZE_T  len 
)

Definition at line 548 of file pager.c.

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