-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnio.cpp
170 lines (152 loc) · 3.77 KB
/
nio.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
//*****************************************************************
// Copyright (c) 1998-2023 Daniel D. Miller
// nio.cpp - Console I/O functions, interface to conio32.cpp
// This file mostly manages color settings
//*****************************************************************
#undef __STRICT_ANSI__
#ifdef USE_64BIT
#define _WIN32_WINNT 0x0600
#endif
#include <windows.h>
#include <stdio.h>
#ifdef _lint
#include <stdlib.h> // PATH_MAX
#endif
#ifdef USE_64BIT
#include <fileapi.h>
#endif
#include "common.h"
#include "ndir32.h"
#include "conio32.h"
static unsigned linecnt = 0 ; // non-color display line counter
//*********************************************************
void nclrscr(void)
{
linecnt = 0 ;
dclrscr();
}
//*********************************************************
// this handles full-screen in NON-COLOR mode.
//*********************************************************
static void testpause (void)
{
if (!n.pause)
return;
if (is_redirected ())
return;
if (++linecnt >= lines - 1) {
nputs (n.colornhead, "Press any key to continue (or ESC to exit)");
unsigned inkey = get_scode ();
if (inkey == ESC) {
// if ((curlines != lines) && (!(n.ega_keep))) {
// set_lines (25);
// }
error_exit (DATA_OKAY, NULL);
}
if (n.color) {
dreturn (); // CR only!!
dclreol ();
}
else {
printf ("\n");
}
linecnt = 1;
}
}
/******************************************************************/
void ncrlf_raw(void)
{
if (n.color) {
dnewline ();
}
else {
printf ("\n");
}
testpause ();
}
/******************************************************************/
void ncrlf (void)
{
if (n.color) {
dnewline ();
}
else {
printf ("\n");
}
// testpause ();
if (!n.pause)
return;
if (is_redirected ())
return;
if (++linecnt >= lines - 1) {
nputs (n.colornhead, "Press any key to continue (or ESC to exit)");
unsigned inkey = get_scode ();
if (inkey == ESC) {
error_exit (DATA_OKAY, NULL);
}
if (n.color) {
dreturn (); // CR only!!
dclreol ();
}
else {
printf ("\n");
}
linecnt = 1;
}
}
/******************************************************************/
void nputc (uchar attr, const uchar outchr)
{
// unsigned hattr ;
if (n.color) {
set_text_attr (attr);
dputc (outchr);
}
else
printf ("%c", outchr);
}
/******************************************************************/
void nputs (uchar attr, const char *outstr)
{
if (n.color) {
set_text_attr (attr);
dputs (outstr);
}
else
printf ("%s", outstr);
}
/******************************************************************/
void nputsw(uchar attr, const char *outstr, int wlen, int clen)
{
if (n.color) {
set_text_attr (attr);
dputsiw(outstr, wlen, clen);
}
else {
dputsiw(outstr, wlen, clen);
}
}
/******************************************************************/
void nput_char (uchar attr, char chr, int count)
{
if (n.color) {
dputnchar (chr, attr, count);
}
else {
for (int j = 0; j < count; j++)
putchar (chr);
}
}
/******************************************************************/
void nput_line (uchar attr, char chr)
{
int j, wincols = get_window_cols() - 1 ;
if (n.color) {
dputnchar (chr, attr, wincols);
}
else {
for (j = 0; j < wincols; j++)
putchar (chr);
}
ncrlf ();
}