本文整理汇总了C++中CTRL函数的典型用法代码示例。如果您正苦于以下问题:C++ CTRL函数的具体用法?C++ CTRL怎么用?C++ CTRL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CTRL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getguess
/*
* getguess:
* Get another guess
*/
void
getguess(void)
{
int i;
int ch, uch;
bool correct;
leaveok(stdscr, FALSE);
for (;;) {
move(PROMPTY, PROMPTX + sizeof("Guess: "));
refresh();
ch = readch();
if (isalpha(ch)) {
if (isupper(ch))
ch = tolower(ch);
if (Guessed[ch - 'a'])
mvprintw(MESGY, MESGX, "Already guessed '%c'", ch);
else
break;
}
else if (ch == CTRL('D'))
die(0);
else
mvprintw(MESGY, MESGX, "Not a valid guess: '%s'",
unctrl(ch));
}
leaveok(stdscr, TRUE);
move(MESGY, MESGX);
clrtoeol();
Guessed[ch - 'a'] = TRUE;
correct = FALSE;
uch = toupper(ch);
for (i = 0; Word[i] != '\0'; i++) {
if (Word[i] == ch) {
Known[i] = ch;
correct = TRUE;
} else if (Word[i] == uch) {
Known[i] = uch;
correct = TRUE;
}
}
if (!correct)
Errors++;
}
示例2: get_line
/*
* get_line:
* Reads the next line up to '\n' or EOF. Multiple spaces are
* compressed to one space; a space is inserted before a ','
*/
char *
get_line(void)
{
size_t pos;
int c, oy, ox;
WINDOW *oscr;
oscr = stdscr;
stdscr = Msgwin;
getyx(stdscr, oy, ox);
refresh();
/* loop reading in the string, and put it in a temporary buffer */
for (pos = 0; (c = readchar()) != '\n'; clrtoeol(), refresh()) {
if (c == erasechar()) { /* process erase character */
if (pos > 0) {
int i;
pos--;
for (i = strlen(unctrl(linebuf[pos])); i; i--)
addch('\b');
}
continue;
} else
if (c == killchar()) { /* process kill
* character */
pos = 0;
move(oy, ox);
continue;
} else
if (pos == 0 && c == ' ')
continue;
if (pos >= LINESIZE - 1 || !(isprint(c) || c == ' '))
putchar(CTRL('G'));
else {
if (islower(c))
c = toupper(c);
linebuf[pos++] = c;
addstr(unctrl(c));
Mpos++;
}
}
linebuf[pos] = '\0';
stdscr = oscr;
return (linebuf);
}
示例3: wdg_file_get_msg
/*
* called by the messages dispatcher when the file dialog is focused
*/
static int wdg_file_get_msg(struct wdg_object *wo, int key, struct wdg_mouse_event *mouse)
{
WDG_WO_EXT(struct wdg_file_handle, ww);
/* handle the message */
switch (key) {
case KEY_MOUSE:
/* is the mouse event within our edges ? */
if (wenclose(ww->win, mouse->y, mouse->x)) {
wdg_set_focus(wo);
/* pass it to the menu */
if (wdg_file_driver(wo, key, mouse) != WDG_E_SUCCESS)
wdg_file_redraw(wo);
} else
return -WDG_E_NOTHANDLED;
break;
case KEY_RETURN:
case KEY_DOWN:
case KEY_UP:
case KEY_PPAGE:
case KEY_NPAGE:
/* move only if focused */
if (wo->flags & WDG_OBJ_FOCUSED) {
if (wdg_file_driver(wo, key, mouse) != WDG_E_SUCCESS)
wdg_file_redraw(wo);
} else
return -WDG_E_NOTHANDLED;
break;
case KEY_ESC:
case CTRL('Q'):
wdg_destroy_object(&wo);
wdg_redraw_all();
break;
/* message not handled */
default:
return -WDG_E_NOTHANDLED;
break;
}
return WDG_E_SUCCESS;
}
示例4: readch
/*
* readch;
* Read a character from the input
*/
int
readch(void)
{
int cnt;
char ch;
cnt = 0;
for (;;) {
if (read(STDIN_FILENO, &ch, sizeof ch) <= 0) {
if (++cnt > 100)
die(0);
} else
if (ch == CTRL('L')) {
wrefresh(curscr);
mvcur(0, 0, curscr->_cury, curscr->_curx);
} else
return ch;
}
}
示例5: curses_manage_filters
static void curses_manage_filters(void)
{
if (!wdg_filters) {
wdg_create_object(&wdg_filters, WDG_LIST, WDG_OBJ_WANT_FOCUS);
}
wdg_set_size(wdg_filters, 1, 2, -1, SYSMSG_WIN_SIZE - 1);
wdg_set_title(wdg_filters, "Select a filter...", WDG_ALIGN_LEFT);
wdg_set_color(wdg_filters, WDG_COLOR_SCREEN, EC_COLOR);
wdg_set_color(wdg_filters, WDG_COLOR_WINDOW, EC_COLOR);
wdg_set_color(wdg_filters, WDG_COLOR_BORDER, EC_COLOR_BORDER);
wdg_set_color(wdg_filters, WDG_COLOR_FOCUS, EC_COLOR_FOCUS);
wdg_set_color(wdg_filters, WDG_COLOR_TITLE, EC_COLOR_TITLE);
wdg_list_select_callback(wdg_filters, curses_select_filter);
wdg_add_destroy_key(wdg_filters, CTRL('Q'), NULL);
wdg_draw_object(wdg_filters);
wdg_set_focus(wdg_filters);
refresh_filter_list();
}
示例6: readch
/*
* readch;
* Read a character from the input
*/
readch()
{
register int cnt, r;
auto char ch;
cnt = 0;
for (;;) {
if (read(0, &ch, sizeof ch) <= 0)
{
if (++cnt > 100)
die();
}
else if (ch == CTRL(L)) {
wrefresh(curscr);
mvcur(0, 0, curscr->_cury, curscr->_curx);
}
else
return ch;
}
}
示例7: readch
/*
* readch;
* Read a character from the input
*/
char
readch(void)
{
int cnt;
char ch;
int x, y;
cnt = 0;
for (;;) {
if (read(STDIN_FILENO, &ch, sizeof(ch)) <= 0) {
if (++cnt > 100)
die(0);
} else if (ch == CTRL('L')) {
wrefresh(curscr);
getyx(curscr, y, x);
mvcur(0, 0, y, x);
} else
return ch;
}
}
示例8: CPropertyPage
CPaymentsPage::CPaymentsPage(CFCMDB& oDB, int nMemberID)
: CPropertyPage(IDD_PAYMENTS_PAGE)
, m_oDB(oDB)
, m_nMemberID(nMemberID)
, m_oTmpSubs(m_oDB.m_oMembers, true)
, m_lvGrid(this)
{
DEFINE_CTRL_TABLE
CTRL(IDC_PAYMENTS, &m_lvGrid)
END_CTRL_TABLE
DEFINE_GRAVITY_TABLE
CTRLGRAV(IDC_PAYMENTS, LEFT_EDGE, TOP_EDGE, RIGHT_EDGE, BOTTOM_EDGE)
END_GRAVITY_TABLE
// Find all the payments for this member.
CResultSet oRS = m_oDB.m_oSubs.Select(CWhereCmp(CSubs::MEMBER_ID, CWhereCmp::EQUALS, m_nMemberID));
for (size_t i = 0; i < oRS.Count(); i++)
{
CRow& oCurRow = oRS[i];
CRow& oCpyRow = m_oTmpSubs.CreateRow();
CRow* pItmRow = m_oDB.m_oBalSheet.SelectRow(CBalSheet::ID, oCurRow[CSubs::ITEM_ID].ToValue());
ASSERT(pItmRow != NULL);
// Copy data.
oCpyRow[CTmpSubs::ITEM_ID] = oCurRow[CSubs::ITEM_ID];
oCpyRow[CTmpSubs::MEMBER_ID] = oCurRow[CSubs::MEMBER_ID];
oCpyRow[CTmpSubs::FEE] = oCurRow[CSubs::FEE];
oCpyRow[CTmpSubs::PAID] = oCurRow[CSubs::PAID];
oCpyRow[CTmpSubs::ITEM_DATE] = pItmRow->Field(CBalSheet::DATE);
oCpyRow[CTmpSubs::ITEM_NAME] = pItmRow->Field(CBalSheet::NAME);
// Insert into tmp table.
m_oTmpSubs.InsertRow(oCpyRow, false);
}
// Initialise the grid.
m_lvGrid.Columns(NUM_COLUMNS, Columns);
}
示例9: mon_execute
/*
* mon_execute:
* Execute a single monitor command
*/
void
mon_execute(PLAYER *pp)
{
char ch;
ch = pp->p_cbuf[pp->p_ncount++];
switch (ch) {
case CTRL('L'):
/* Redraw messed-up screen */
sendcom(pp, REDRAW);
break;
case 'q':
/* Quit client */
(void) strlcpy(pp->p_death, "| Quit |", sizeof pp->p_death);
break;
default:
/* Ignore everything else */
;
}
}
示例10: gdb_getc
static int
gdb_getc(void)
{
int c;
do
c = gdb_cur->gdb_getc();
while (c == -1);
if (c == CTRL('C')) {
printf("Received ^C; trying to switch back to ddb.\n");
if (kdb_dbbe_select("ddb") != 0)
printf("The ddb backend could not be selected.\n");
else {
printf("using longjmp, hope it works!\n");
kdb_reenter();
}
}
return (c);
}
示例11: curses_show_connections
/*
* the auto-refreshing list of connections
*/
void curses_show_connections(void)
{
DEBUG_MSG("curses_show_connections");
/* if the object already exist, set the focus to it */
if (wdg_connections) {
wdg_set_focus(wdg_connections);
return;
}
wdg_create_object(&wdg_connections, WDG_DYNLIST, WDG_OBJ_WANT_FOCUS);
wdg_set_title(wdg_connections, "Live connections:", WDG_ALIGN_LEFT);
wdg_set_size(wdg_connections, 1, 2, -1, SYSMSG_WIN_SIZE - 1);
wdg_set_color(wdg_connections, WDG_COLOR_SCREEN, EC_COLOR);
wdg_set_color(wdg_connections, WDG_COLOR_WINDOW, EC_COLOR);
wdg_set_color(wdg_connections, WDG_COLOR_BORDER, EC_COLOR_BORDER);
wdg_set_color(wdg_connections, WDG_COLOR_FOCUS, EC_COLOR_FOCUS);
wdg_set_color(wdg_connections, WDG_COLOR_TITLE, EC_COLOR_TITLE);
wdg_draw_object(wdg_connections);
wdg_set_focus(wdg_connections);
/* set the list print callback */
wdg_dynlist_print_callback(wdg_connections, conntrack_print);
/* set the select callback */
wdg_dynlist_select_callback(wdg_connections, curses_connection_data);
/* add the callback on idle to refresh the profile list */
wdg_add_idle_callback(refresh_connections);
/* add the destroy callback */
wdg_add_destroy_key(wdg_connections, CTRL('Q'), curses_kill_connections);
wdg_dynlist_add_callback(wdg_connections, 'd', curses_connection_detail);
wdg_dynlist_add_callback(wdg_connections, 'k', curses_connection_kill);
wdg_dynlist_add_callback(wdg_connections, 'x', curses_connection_purge);
wdg_dynlist_add_callback(wdg_connections, ' ', curses_connection_help);
}
示例12: main
int
main()
{
fd_set fds;
/* Adjust the terminal slightly before the handler is installed. Disable
* canonical mode processing and set the input character time flag to be
* non-blocking.
*/
if( tcgetattr(STDIN_FILENO, &term) < 0 ) {
perror("tcgetattr");
exit(1);
}
old_lflag = term.c_lflag;
old_vtime = term.c_cc[VTIME];
term.c_lflag &= ~ICANON;
term.c_cc[VTIME] = 1;
/* COMMENT LINE BELOW - see above */
if( tcsetattr(STDIN_FILENO, TCSANOW, &term) < 0 ) {
perror("tcsetattr");
exit(1);
}
rl_add_defun("change-prompt", change_prompt, CTRL('t'));
rl_callback_handler_install(get_prompt(), process_line);
while(1) {
FD_ZERO(&fds);
FD_SET(fileno(stdin), &fds);
if( select(FD_SETSIZE, &fds, NULL, NULL, NULL) < 0) {
perror("select");
exit(1);
}
if( FD_ISSET(fileno(stdin), &fds) ) {
rl_callback_read_char();
}
}
}
示例13: wdg_input_get_msg
/*
* called by the messages dispatcher when the menu is focused
*/
static int wdg_input_get_msg(struct wdg_object *wo, int key, struct wdg_mouse_event *mouse)
{
WDG_WO_EXT(struct wdg_input_handle, ww);
WDG_DEBUG_MSG("keypress get msg: %d", key);
/* handle the message */
switch (key) {
case KEY_MOUSE:
/* is the mouse event within our edges ? */
if (wenclose(ww->win, mouse->y, mouse->x)) {
wdg_set_focus(wo);
/* redraw the menu */
wdg_input_redraw(wo);
} else {
return -WDG_E_NOTHANDLED;
}
break;
case KEY_ESC:
case CTRL('Q'):
wdg_destroy_object(&wo);
wdg_redraw_all();
return WDG_EFINISHED;
break;
/* message not handled */
default:
if (wo->flags & WDG_OBJ_FOCUSED) {
return wdg_input_driver(wo, key, mouse);
} else {
return -WDG_E_NOTHANDLED;
}
break;
}
return WDG_E_SUCCESS;
}
示例14: readchar
/*
* readchar:
* Reads and returns a character, checking for gross input errors
*/
int
readchar(void)
{
int cnt;
char c;
over:
cnt = 0;
while (read(STDIN_FILENO, &c, sizeof(char)) <= 0)
if (cnt++ > 100) { /* if we are getting infinite EOFs */
bye(); /* quit the game */
exit(1);
}
if (c == CTRL('L')) {
wrefresh(curscr);
goto over;
}
if (c == '\r')
return ('\n');
else
return (c);
}
示例15: curses_plugin_mgmt
/*
* plugin management
*/
static void curses_plugin_mgmt(void)
{
DEBUG_MSG("curses_plugin_mgmt");
/* create the array for the list widget */
curses_create_plug_array();
/* if the object already exist, set the focus to it */
if (wdg_plugin) {
/* set the new array */
wdg_list_set_elements(wdg_plugin, wdg_plugin_elements);
return;
}
wdg_create_object(&wdg_plugin, WDG_LIST, WDG_OBJ_WANT_FOCUS);
wdg_set_size(wdg_plugin, 1, 2, -1, SYSMSG_WIN_SIZE - 1);
wdg_set_title(wdg_plugin, "Select a plugin...", WDG_ALIGN_LEFT);
wdg_set_color(wdg_plugin, WDG_COLOR_SCREEN, EC_COLOR);
wdg_set_color(wdg_plugin, WDG_COLOR_WINDOW, EC_COLOR);
wdg_set_color(wdg_plugin, WDG_COLOR_BORDER, EC_COLOR_BORDER);
wdg_set_color(wdg_plugin, WDG_COLOR_FOCUS, EC_COLOR_FOCUS);
wdg_set_color(wdg_plugin, WDG_COLOR_TITLE, EC_COLOR_TITLE);
/* set the elements */
wdg_list_set_elements(wdg_plugin, wdg_plugin_elements);
/* add the destroy callback */
wdg_add_destroy_key(wdg_plugin, CTRL('Q'), curses_plug_destroy);
/* add the callback */
wdg_list_select_callback(wdg_plugin, curses_select_plugin);
wdg_list_add_callback(wdg_plugin, ' ', curses_plugin_help);
wdg_draw_object(wdg_plugin);
wdg_set_focus(wdg_plugin);
}