本文整理汇总了C++中CTRL函数的典型用法代码示例。如果您正苦于以下问题:C++ CTRL函数的具体用法?C++ CTRL怎么用?C++ CTRL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CTRL函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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++;
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:49,代码来源:getguess.c
示例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);
}
开发者ID:ajinkya93,项目名称:netbsd-src,代码行数:50,代码来源:io.c
示例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;
}
开发者ID:AntonioCollarino,项目名称:ettercap,代码行数:48,代码来源:wdg_file.c
示例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;
}
}
开发者ID:mikekmv,项目名称:aeriebsd-src,代码行数:23,代码来源:getguess.c
示例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();
}
开发者ID:mfer,项目名称:ettercap,代码行数:19,代码来源:ec_curses_filters.c
示例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;
}
}
开发者ID:AtomSoftTech,项目名称:retrobsd,代码行数:24,代码来源:getguess.c
示例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;
}
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:24,代码来源:getguess.c
示例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);
}
开发者ID:chrisoldwood,项目名称:FCManager,代码行数:41,代码来源:PaymentsPage.cpp
示例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 */
;
}
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:25,代码来源:execute.c
示例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);
}
开发者ID:FreeBSDFoundation,项目名称:freebsd,代码行数:21,代码来源:gdb_packet.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);
}
开发者ID:barak,项目名称:ettercap,代码行数:43,代码来源:ec_curses_view_connections.c
示例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();
}
}
}
开发者ID:0265727207,项目名称:evandrix.github.com,代码行数:40,代码来源:excallback.c
示例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;
}
开发者ID:AntonioCollarino,项目名称:ettercap,代码行数:42,代码来源:wdg_input.c
示例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);
}
开发者ID:lattera,项目名称:openbsd,代码行数:26,代码来源:io.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);
}
开发者ID:0x0mar,项目名称:ettercap,代码行数:42,代码来源:ec_curses_plugins.c
示例16: tty_init
void
tty_init (gboolean mouse_enable, gboolean is_xterm)
{
initscr ();
#ifdef HAVE_ESCDELAY
/*
* If ncurses exports the ESCDELAY variable, it should be set to
* a low value, or you'll experience a delay in processing escape
* sequences that are recognized by mc (e.g. Esc-Esc). On the other
* hand, making ESCDELAY too small can result in some sequences
* (e.g. cursor arrows) being reported as separate keys under heavy
* processor load, and this can be a problem if mc hasn't learned
* them in the "Learn Keys" dialog. The value is in milliseconds.
*/
ESCDELAY = 200;
#endif /* HAVE_ESCDELAY */
/* use Ctrl-g to generate SIGINT */
cur_term->Nttyb.c_cc[VINTR] = CTRL ('g'); /* ^g */
/* disable SIGQUIT to allow use Ctrl-\ key */
cur_term->Nttyb.c_cc[VQUIT] = NULL_VALUE;
tcsetattr (cur_term->Filedes, TCSANOW, &cur_term->Nttyb);
tty_start_interrupt_key ();
if (!mouse_enable)
use_mouse_p = MOUSE_DISABLED;
tty_init_xterm_support (is_xterm); /* do it before do_enter_ca_mode() call */
init_mouse ();
do_enter_ca_mode ();
tty_raw_mode ();
noecho ();
keypad (stdscr, TRUE);
nodelay (stdscr, FALSE);
tty_setup_sigwinch (sigwinch_handler);
}
开发者ID:rutsky,项目名称:mc,代码行数:38,代码来源:tty-ncurses.c
示例17: curses_sniff_offline
void curses_sniff_offline(void)
{
wdg_t *menu;
DEBUG_MSG("curses_sniff_offline");
wdg_create_object(&menu, WDG_MENU, WDG_OBJ_WANT_FOCUS | WDG_OBJ_ROOT_OBJECT);
wdg_set_title(menu, GBL_VERSION, WDG_ALIGN_RIGHT);
wdg_set_color(menu, WDG_COLOR_SCREEN, EC_COLOR);
wdg_set_color(menu, WDG_COLOR_WINDOW, EC_COLOR_MENU);
wdg_set_color(menu, WDG_COLOR_FOCUS, EC_COLOR_FOCUS);
wdg_set_color(menu, WDG_COLOR_TITLE, EC_COLOR_TITLE);
/* add the menu from the external files */
wdg_menu_add(menu, menu_start);
wdg_menu_add(menu, menu_targets);
wdg_menu_add(menu, menu_view);
wdg_menu_add(menu, menu_filters);
wdg_menu_add(menu, menu_logging);
wdg_menu_add(menu, menu_help);
wdg_draw_object(menu);
/* repaint the whole screen */
wdg_redraw_all();
wdg_set_focus(menu);
/* add the message flush callback */
wdg_add_idle_callback(curses_flush_msg);
/*
* give the control to the event dispatcher
* with the emergency exit CTRL + X
*/
wdg_events_handler(CTRL('X'));
wdg_destroy_object(&menu);
}
开发者ID:0x0mar,项目名称:ettercap,代码行数:38,代码来源:ec_curses_offline.c
示例18: getyn
/*
* Get a yes or no answer to the given question. Saves are
* also allowed. Return TRUE if the answer was yes, FALSE if no.
*/
int
getyn(int promptno)
{
char c;
Saved = FALSE;
for (;;) {
leaveok(Board, FALSE);
prompt(promptno);
clrtoeol();
refresh();
switch (c = readch()) {
case 'n': case 'N':
addch('N');
refresh();
leaveok(Board, TRUE);
return FALSE;
case 'y': case 'Y':
addch('Y');
refresh();
leaveok(Board, TRUE);
return TRUE;
case 's': case 'S':
addch('S');
refresh();
Saved = save();
continue;
case CTRL('L'):
wrefresh(curscr);
break;
default:
addstr(unctrl(c));
refresh();
putchar('\07');
break;
}
}
}
开发者ID:ajinkya93,项目名称:netbsd-src,代码行数:42,代码来源:misc.c
示例19: kaif_enter_mon
/*
* Called during normal debugger operation and during debugger faults.
*/
static void
kaif_enter_mon(void)
{
char c;
for (;;) {
mdb_iob_printf(mdb.m_out,
"%s: Do you really want to reboot? (y/n) ",
mdb.m_pname);
mdb_iob_flush(mdb.m_out);
mdb_iob_clearlines(mdb.m_out);
c = kmdb_getchar();
if (c == 'n' || c == 'N' || c == CTRL('c'))
return;
else if (c == 'y' || c == 'Y') {
mdb_iob_printf(mdb.m_out, "Rebooting...\n");
kmdb_dpi_reboot();
}
}
}
开发者ID:jasonbking,项目名称:illumos-gate,代码行数:26,代码来源:kaif.c
示例20: setup_tty_attributes
void setup_tty_attributes (int tty_fd)
{
struct termios tm;
/* set up tty attribute */
if (tcgetattr(tty_fd, &tm) < 0)
perror("Faild to tcgetattr");
else {
/* setup values from child_setup_tty() in emacs/src/sysdep.c */
tm.c_iflag &= ~(IUCLC | ISTRIP);
tm.c_iflag |= IGNCR;
tm.c_oflag &= ~(ONLCR | OLCUC | TAB3);
tm.c_oflag |= OPOST;
tm.c_lflag &= ~ECHO;
tm.c_lflag |= ISIG | ICANON;
tm.c_cc[VERASE] = _POSIX_VDISABLE;
tm.c_cc[VKILL] = _POSIX_VDISABLE;
tm.c_cc[VEOF] = CTRL('D');
if (tcsetattr(tty_fd, TCSANOW, &tm) < 0)
perror("Failed to tcsetattr");
}
}
开发者ID:d5884,项目名称:fakecygpty,代码行数:23,代码来源:fakecygpty.c
注:本文中的CTRL函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论