ReactOS  0.4.14-dev-49-gfb4591c
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 INIT_CON_PAGER(pScreen)   {(pScreen), 0}
 
#define InitializeConPager(pPager, pScreen)
 

Typedefs

typedef struct _CON_PAGER CON_PAGER
 
typedef struct _CON_PAGERPCON_PAGER
 
typedef BOOL(__stdcallPAGE_PROMPT) (IN PCON_PAGER, IN DWORD, IN DWORD)
 

Functions

BOOL ConWritePaging (IN PCON_PAGER Pager, IN PAGE_PROMPT PagePrompt, IN BOOL StartPaging, IN PTCHAR szStr, IN DWORD len)
 
BOOL ConPutsPaging (IN PCON_PAGER Pager, IN PAGE_PROMPT PagePrompt, IN BOOL StartPaging, IN LPTSTR 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

◆ INIT_CON_PAGER

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

Definition at line 44 of file pager.h.

◆ InitializeConPager

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

Definition at line 46 of file pager.h.

Typedef Documentation

◆ CON_PAGER

◆ PAGE_PROMPT

typedef BOOL(__stdcall * PAGE_PROMPT) (IN PCON_PAGER, IN DWORD, IN DWORD)

Definition at line 54 of file pager.h.

◆ PCON_PAGER

Function Documentation

◆ ConPutsPaging()

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

Definition at line 120 of file pager.c.

125 {
126  DWORD len;
127 
128  /* Return if no string has been given */
129  if (szStr == NULL)
130  return TRUE;
131 
132  len = wcslen(szStr);
133  return ConWritePaging(Pager, PagePrompt, StartPaging, szStr, len);
134 }
#define TRUE
Definition: types.h:120
static BOOL __stdcall PagePrompt(PCON_PAGER Pager, DWORD Done, DWORD Total)
Definition: more.c:51
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
BOOL ConWritePaging(IN PCON_PAGER Pager, IN PAGE_PROMPT PagePrompt, IN BOOL StartPaging, IN PTCHAR szStr, IN DWORD len)
Definition: pager.c:38
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by wmain().

◆ ConResPaging()

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

Definition at line 155 of file pager.c.

160 {
161  return ConResPagingEx(Pager, PagePrompt, StartPaging,
162  NULL /*GetModuleHandleW(NULL)*/, uID);
163 }
static BOOL __stdcall PagePrompt(PCON_PAGER Pager, DWORD Done, DWORD Total)
Definition: more.c:51
smooth NULL
Definition: ftsmooth.c:416
BOOL ConResPagingEx(IN PCON_PAGER Pager, IN PAGE_PROMPT PagePrompt, IN BOOL StartPaging, IN HINSTANCE hInstance OPTIONAL, IN UINT uID)
Definition: pager.c:137

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

143 {
144  INT Len;
145  PWCHAR szStr = NULL;
146 
147  Len = K32LoadStringW(hInstance, uID, (PWSTR)&szStr, 0);
148  if (szStr && Len)
149  return ConWritePaging(Pager, PagePrompt, StartPaging, szStr, Len);
150  else
151  return TRUE;
152 }
#define TRUE
Definition: types.h:120
static BOOL __stdcall PagePrompt(PCON_PAGER Pager, DWORD Done, DWORD Total)
Definition: more.c:51
uint16_t * PWSTR
Definition: typedefs.h:54
INT WINAPI K32LoadStringW(IN HINSTANCE hInstance OPTIONAL, IN UINT uID, OUT LPWSTR lpBuffer, IN INT nBufferMax)
Definition: utils.c:173
uint16_t * PWCHAR
Definition: typedefs.h:54
int32_t INT
Definition: typedefs.h:56
HINSTANCE hInstance
Definition: charmap.c:20
smooth NULL
Definition: ftsmooth.c:416
#define Len
Definition: deflate.h:82
BOOL ConWritePaging(IN PCON_PAGER Pager, IN PAGE_PROMPT PagePrompt, IN BOOL StartPaging, IN PTCHAR szStr, IN DWORD len)
Definition: pager.c:38

Referenced by ConResPaging().

◆ ConWritePaging()

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

Definition at line 38 of file pager.c.

44 {
46 
47  /* Used to see how big the screen is */
48  DWORD ScreenLines = 0;
49 
50  /* Chars since start of line */
51  DWORD CharSL;
52 
53  DWORD from = 0, i = 0;
54 
55  /* Parameters validation */
56  if (!Pager)
57  return FALSE;
58 
59  /* Reset LineCount and return if no string has been given */
60  if (StartPaging == TRUE)
61  Pager->LineCount = 0;
62  if (szStr == NULL)
63  return TRUE;
64 
65  /* Get the size of the visual screen that can be printed to */
66  if (!ConGetScreenInfo(Pager->Screen, &csbi))
67  {
68  /* We assume it's a file handle */
69  CON_STREAM_WRITE(Pager->Screen->Stream, szStr, len);
70  return TRUE;
71  }
72 
73  /*
74  * Get the number of lines currently displayed on screen, minus 1
75  * to account for the "press any key..." prompt from PagePrompt().
76  */
77  ScreenLines = (csbi.srWindow.Bottom - csbi.srWindow.Top);
78  CharSL = csbi.dwCursorPosition.X;
79 
80  /* Make sure the user doesn't have the screen too small */
81  if (ScreenLines < 4)
82  {
83  CON_STREAM_WRITE(Pager->Screen->Stream, szStr, len);
84  return TRUE;
85  }
86 
87  while (i < len)
88  {
89  /* Search until the end of a line is reached */
90  if (szStr[i++] != TEXT('\n') && ++CharSL < csbi.dwSize.X)
91  continue;
92 
93  Pager->LineCount++;
94  CharSL = 0;
95 
96  if (Pager->LineCount >= ScreenLines)
97  {
98  CON_STREAM_WRITE(Pager->Screen->Stream, &szStr[from], i-from);
99  from = i;
100 
101  /* Prompt the user; give him some values for statistics */
102  // FIXME TODO: The prompt proc can also take ScreenLines ??
103  if (!PagePrompt(Pager, from, len))
104  return FALSE;
105 
106  // TODO: Recalculate 'ScreenLines' in case the user redimensions
107  // the window during the prompt.
108 
109  /* Reset the number of lines being printed */
110  Pager->LineCount = 0;
111  }
112  }
113  if (i > from)
114  CON_STREAM_WRITE(Pager->Screen->Stream, &szStr[from], i-from);
115 
116  return TRUE;
117 }
#define TRUE
Definition: types.h:120
static BOOL __stdcall PagePrompt(PCON_PAGER Pager, DWORD Done, DWORD Total)
Definition: more.c:51
int ScreenLines
Definition: ctm.c:78
#define CON_STREAM_WRITE
Definition: pager.c:32
BOOL ConGetScreenInfo(IN PCON_SCREEN Screen, OUT PCONSOLE_SCREEN_BUFFER_INFO pcsbi)
Definition: screen.c:73
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
ULONG X
Definition: bl.h:1340
SHORT Bottom
Definition: blue.h:28
unsigned long DWORD
Definition: ntddk_ex.h:95
SHORT Top
Definition: blue.h:26
GLenum GLsizei len
Definition: glext.h:6722
#define TEXT(s)
Definition: k32.h:26
CardRegion * from
Definition: spigame.cpp:19

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