ReactOS  0.4.15-dev-2993-g14fbe80
pager.h
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Console Utilities Library
3  * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4  * PURPOSE: Console/terminal paging functionality.
5  * COPYRIGHT: Copyright 2017-2021 Hermes Belusca-Maito
6  * Copyright 2021 Katayama Hirofumi MZ
7  */
8 
16 #ifndef __PAGER_H__
17 #define __PAGER_H__
18 
19 #pragma once
20 
21 #ifndef _UNICODE
22 #error The ConUtils library at the moment only supports compilation with _UNICODE defined!
23 #endif
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 // #include <wincon.h>
30 
31 struct _CON_PAGER;
32 
33 typedef BOOL
34 (__stdcall *CON_PAGER_LINE_FN)(
35  IN OUT struct _CON_PAGER *Pager,
37  IN DWORD cch);
38 
39 /* Flags for CON_PAGER */
40 #define CON_PAGER_EXPAND_TABS (1 << 0)
41 #define CON_PAGER_EXPAND_FF (1 << 1)
42 // Whether or not the pager will cache the line if it's incomplete (not NEWLINE-terminated).
43 #define CON_PAGER_CACHE_INCOMPLETE_LINE (1 << 2)
44 
45 typedef struct _CON_PAGER
46 {
47  /* Console screen properties */
51 
52  /* Paging parameters */
53  CON_PAGER_LINE_FN PagerLine; /* The line function */
54  DWORD dwFlags; /* The CON_PAGER_... flags */
57 
58  /* Data buffer */
59  PCTCH CachedLine; /* Cached line, HeapAlloc'ated */
60  SIZE_T cchCachedLine; /* Its length (number of characters) */
61  SIZE_T ich; /* The current index of character in TextBuff (a user-provided source buffer) */
62 
63  /* Paging state */
64  PCTCH CurrentLine; /* Pointer to the current line (either within a user-provided source buffer, or to CachedLine) */
65  SIZE_T ichCurr; /* The current index of character in CurrentLine */
66  SIZE_T iEndLine; /* End (length) of CurrentLine */
67  DWORD nSpacePending; /* Pending spaces for TAB expansion */
68  DWORD iColumn; /* The current index of column */
69  DWORD iLine; /* The physical output line count of screen */
70  DWORD lineno; /* The logical line number */
72 
73 #define INIT_CON_PAGER(pScreen) {(pScreen), 0}
74 
75 #define InitializeConPager(pPager, pScreen) \
76 do { \
77  ZeroMemory((pPager), sizeof(*(pPager))); \
78  (pPager)->Screen = (pScreen); \
79 } while (0)
80 
81 
82 typedef BOOL
84  IN PCON_PAGER Pager,
85  IN DWORD Done,
86  IN DWORD Total);
87 
88 BOOL
90  IN PCON_PAGER Pager,
92  IN BOOL StartPaging,
93  IN PCTCH szStr,
94  IN DWORD len);
95 
96 BOOL
98  IN PCON_PAGER Pager,
100  IN BOOL StartPaging,
101  IN PCTSTR szStr);
102 
103 BOOL
105  IN PCON_PAGER Pager,
107  IN BOOL StartPaging,
109  IN UINT uID);
110 
111 BOOL
113  IN PCON_PAGER Pager,
115  IN BOOL StartPaging,
116  IN UINT uID);
117 
118 #ifdef __cplusplus
119 }
120 #endif
121 
122 #endif /* __PAGER_H__ */
123 
124 /* EOF */
SIZE_T cchCachedLine
Definition: pager.h:60
DWORD nSpacePending
Definition: pager.h:67
#define IN
Definition: typedefs.h:39
SIZE_T ichCurr
Definition: pager.h:65
static BOOL __stdcall PagePrompt(PCON_PAGER Pager, DWORD Done, DWORD Total)
Definition: more.c:160
LPCSTR PCTSTR
Definition: ntbasedef.h:488
DWORD PageColumns
Definition: pager.h:49
SIZE_T iEndLine
Definition: pager.h:66
DWORD iLine
Definition: pager.h:69
LPCCH PCTCH
Definition: ntbasedef.h:486
PCON_SCREEN Screen
Definition: pager.h:48
LONG nTabWidth
Definition: pager.h:55
HINSTANCE hInstance
Definition: charmap.c:20
DWORD dwFlags
Definition: pager.h:54
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
CON_PAGER_LINE_FN PagerLine
Definition: pager.h:53
BOOL ConPutsPaging(IN PCON_PAGER Pager, IN PAGE_PROMPT PagePrompt, IN BOOL StartPaging, IN PCTSTR szStr)
Definition: pager.c:646
BOOL(__stdcall * PAGE_PROMPT)(IN PCON_PAGER Pager, IN DWORD Done, IN DWORD Total)
Definition: pager.h:83
unsigned long DWORD
Definition: ntddk_ex.h:95
#define __stdcall
Definition: typedefs.h:25
DWORD ScrollRows
Definition: pager.h:56
GLenum GLsizei len
Definition: glext.h:6722
PCTCH CurrentLine
Definition: pager.h:64
DWORD iColumn
Definition: pager.h:68
IN PCTCH line
Definition: pager.h:36
typedef BOOL(__stdcall *CON_PAGER_LINE_FN)(IN OUT struct _CON_PAGER *Pager
ULONG_PTR SIZE_T
Definition: typedefs.h:80
SIZE_T ich
Definition: pager.h:61
struct _CON_PAGER * PCON_PAGER
DWORD lineno
Definition: pager.h:70
unsigned int UINT
Definition: ndis.h:50
BOOL ConWritePaging(IN PCON_PAGER Pager, IN PAGE_PROMPT PagePrompt, IN BOOL StartPaging, IN PCTCH szStr, IN DWORD len)
Definition: pager.c:549
BOOL ConResPagingEx(IN PCON_PAGER Pager, IN PAGE_PROMPT PagePrompt, IN BOOL StartPaging, IN HINSTANCE hInstance OPTIONAL, IN UINT uID)
Definition: pager.c:663
#define OUT
Definition: typedefs.h:40
PCTCH CachedLine
Definition: pager.h:59
DWORD PageRows
Definition: pager.h:50
IN PCTCH IN DWORD cch
Definition: pager.h:36
struct _CON_PAGER CON_PAGER
BOOL ConResPaging(IN PCON_PAGER Pager, IN PAGE_PROMPT PagePrompt, IN BOOL StartPaging, IN UINT uID)
Definition: pager.c:681
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68