当前位置: 首页>>代码示例>>C++>>正文


C++ echo函数代码示例

本文整理汇总了C++中echo函数的典型用法代码示例。如果您正苦于以下问题:C++ echo函数的具体用法?C++ echo怎么用?C++ echo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了echo函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main() {
	int key, menuitem, ent, id;
	menuitem = 0;
	initscr();
	drawmenu(menuitem);
	keypad(stdscr,TRUE);
	
	noecho();
	do {
		key = getch();
		switch(key) {
			case KEY_DOWN: menuitem++;
			if(menuitem > MENUMAX-1) 
				menuitem = 0;
			break;

			case KEY_UP: menuitem--;
			if(menuitem < 0) 
				menuitem = MENUMAX-1;
			break;

			default: 
			break;

		}

		drawmenu(menuitem);
		
		ent = getch();
	
		if(menuitem == 0 && ent == KEY_RIGHT) { 
			login();
			refresh();
		}
		else if(menuitem == 1 && ent == KEY_RIGHT) {
			register_id();
			refresh();
		}
		else if(menuitem == 2 && ent == KEY_RIGHT) { 
			findtrain();
			refresh();
		}
		else if(menuitem == 3 && ent == KEY_RIGHT) { 
			move(0,0);
			clrtobot();			
			printw("Enter train id\n");			
			scanw("%d", &id);
			CheckAvailibility(id);
			refresh();
		}	
		else if(menuitem == 4 && ent == KEY_RIGHT) { 
			cancelticket();
			refresh();
		}
		else if(menuitem == 5 && ent == KEY_RIGHT) { 
			DisplayQueueac();
			refresh();
		}
		else if(menuitem == 6 && ent == KEY_RIGHT) { 
			DisplayQueuesl();
			refresh();
		}
		else if(menuitem == 7 && ent == KEY_RIGHT) { 
			exit(1);
		}
	}	
	while(key != '\n');
		echo();      /*Shows the text*/
	
	endwin();
	return 0;

}
开发者ID:AnshB,项目名称:111408005_MP_Rail,代码行数:73,代码来源:menuwithncurses.c

示例2: drawStuff

void drawStuff(int** cardToBeDrawn)
{
    WINDOW * mainwin;
    int n, x, y, m;
    int num = 0;

    /*  Initialize ncurses  */

    if ( (mainwin = initscr()) == NULL ) {
        fprintf(stderr, "Error initialising ncurses.\n");
        exit(EXIT_FAILURE);
    }
    
    resizeterm(100,56);
    
    keypad(mainwin, TRUE);
    (void) nonl();         /* tell curses not to do NL->CR/NL on output */
    (void) cbreak();       /* take input chars one at a time, no wait for \n */
    (void) echo();         /* echo input - in color */
    start_color();                    /*  Initialize colours  */

	

    if ( has_colors() && COLOR_PAIRS >= 13 ) {

        init_pair(1,  COLOR_RED,     COLOR_BLACK);
        init_pair(2,  COLOR_GREEN,   COLOR_BLACK);
        init_pair(3,  COLOR_YELLOW,  COLOR_BLACK);
        init_pair(4,  COLOR_BLUE,    COLOR_BLACK);
        init_pair(5,  COLOR_MAGENTA, COLOR_BLACK);
        init_pair(6,  COLOR_CYAN,    COLOR_BLACK);
        init_pair(7,  COLOR_BLUE,    COLOR_WHITE);
        init_pair(8,  COLOR_WHITE,   COLOR_RED);
        init_pair(9,  COLOR_BLACK,   COLOR_GREEN);
        init_pair(10, COLOR_BLUE,    COLOR_YELLOW);
        init_pair(11, COLOR_WHITE,   COLOR_BLUE);
        init_pair(12, COLOR_WHITE,   COLOR_MAGENTA);
        init_pair(13, COLOR_BLACK,   COLOR_BLACK);

        color_set(4, NULL);
        mvaddstr(0, 0,  "--------------------------------------------------------");
        mvaddstr(1, 0,  "|          |          |          |          |          |");
        mvaddstr(2, 0,  "|          |          |          |          |          |");
        mvaddstr(3, 0,  "|          |          |          |          |          |");
        mvaddstr(4, 0,  "|          |          |          |          |          |");
        mvaddstr(5, 0,  "|          |          |          |          |          |");
        mvaddstr(6, 0,  "________________________________________________________");

        mvaddstr(7, 0,  "|          |          |          |          |          |");
        mvaddstr(8, 0,  "|          |          |          |          |          |");
        mvaddstr(9, 0,  "|          |          |          |          |          |");
        mvaddstr(10, 0, "|          |          |          |          |          |");
        mvaddstr(11, 0, "|          |          |          |          |          |");
        mvaddstr(12, 0, "________________________________________________________");
		refresh();
        mvaddstr(13, 0, "|          |          |          |          |          |");
        mvaddstr(14, 0, "|          |          |          |          |          |");
        mvaddstr(15, 0, "|          |          |          |          |          |");
        mvaddstr(16, 0, "|          |          |          |          |          |");
        mvaddstr(17, 0, "|          |          |          |          |          |");
        mvaddstr(18, 0, "________________________________________________________");

        mvaddstr(19, 0, "|          |          |          |          |          |");
        mvaddstr(20, 0, "|          |          |          |          |          |");
        mvaddstr(21, 0, "|          |          |          |          |          |");
        mvaddstr(22, 0, "|          |          |          |          |          |");
        mvaddstr(23, 0, "|          |          |          |          |          |");
        mvaddstr(24, 0, "________________________________________________________");

        mvaddstr(25, 0, "|          |          |          |          |          |");
        mvaddstr(26, 0, "|          |          |          |          |          |");
        mvaddstr(27, 0, "|          |          |          |          |          |");
        mvaddstr(28, 0, "|          |          |          |          |          |");
        mvaddstr(29, 0, "|          |          |          |          |          |");
        mvaddstr(30, 0, "________________________________________________________");
		refresh();
        mvaddstr(31, 0, "|          |          |          |          |          |");
        mvaddstr(32, 0, "|          |          |          |          |          |");
        mvaddstr(33, 0, "|          |          |          |          |          |");
        mvaddstr(34, 0, "|          |          |          |          |          |");
        mvaddstr(35, 0, "|          |          |          |          |          |");
        mvaddstr(36, 0, "________________________________________________________");


        color_set(5, NULL);
        mvaddstr(1, 2,  " BBBBB");
        mvaddstr(2, 2,  " BB  BB");
        mvaddstr(3, 2,  " BBBBB");
        mvaddstr(4, 2,  " BB  BB");
        mvaddstr(5, 2,  " BBBBB");

        mvaddstr(1, 13, " IIIIII");
        mvaddstr(2, 13, "   II  ");
        mvaddstr(3, 13, "   II  ");
        mvaddstr(4, 13, "   II  ");
        mvaddstr(5, 13, " IIIIII");

        mvaddstr(1, 24, "NN    N");
        mvaddstr(2, 24, "N N   N");
        mvaddstr(3, 24, "N  N  N");
//.........这里部分代码省略.........
开发者ID:harrison-n,项目名称:osGameTerminal,代码行数:101,代码来源:game.c

示例3: judge_utility

void judge_utility(char *command, char *args[], int size){
	pid_t pid;
	int i;
	char *argv[1000];
	char value[1050];
	extern char first[1000];

	if(command[0] == '$'){
		showenviron(&command, 1);
		return;
	}

	//若没有指输入,直接返回
	if(strlen(command) == 0) return;

	//若第一个字符串(即command)查询环境变量,调用查看环境变量的函数
	//根据bash的特点,此时只传入command
	if(command[0] == '$'){
		//show_pathname(command);
		return;
	}

	//cd指令
	if(strcmp(command, "cd") == 0){
		cd(args, size);
		return;
	}

	//quit指令
	if(strcmp(command, "quit") == 0){
		exit(0);
	}

	//echo指令
	if(strcmp(command, "echo") == 0){
		echo(args, size);
		return;
	}

	//clear指令
	if(strcmp(command, "clr") == 0){
		//输出一段转义序列清空屏幕
		printf( "\033[H""\033[2J");
		return;
	}

	//dir指令
	if(strcmp(command, "dir") == 0){
		dir(args, size);
		return;
	}

	//environ指令
	if(strcmp(command, "environ") == 0){
		showenviron(args, size);
		return;
	}

	//myshell命令
	if(strcmp(command, "myshell") == 0){
		myshell(args, size);
		return;
	}

	//help指令
	if(strcmp(command, "help") == 0){
		help(args, size);
		return;
	}

	//初始化execvp的第二个参数
	argv[0] = command;
	for(i = 0; i < size; i++)
		argv[i + 1] = args[i];
	argv[i + 1] = 0;

	pid = fork();
	if(pid < 0){
		printf("创建子进程失败!\n");
		return;
	}
	if(pid == 0){
		int ret;
		//增加parent环境变量
		strcpy(value, "parent=");
		strcat(value, first);
		strcat(value, "/myshell");
		putenv(value);
		//创建子进程调用外部指令
		ret = execvp(command, argv);
		if(ret == -1){
			//找不到指令
			printf("%s: 没有这个命令\n", command);
		}
		exit(0);
	}else{
		//等待子进程完成后返回
		int *status;
		wait(status);
		return;
//.........这里部分代码省略.........
开发者ID:000ddd00dd0d,项目名称:A-mini-bash,代码行数:101,代码来源:utility.c

示例4: banner

static void banner(void)
{
    delline();
    echo("Finit version " VERSION " (" WHOAMI ") " __DATE__ " " __TIME__);
}
开发者ID:TP-doc,项目名称:M3_Container,代码行数:5,代码来源:finit.c

示例5: outputTest


//.........这里部分代码省略.........

        mvwin(win1, by, bx);
        overlay(win, win1);
        mvwin(win1, 14, 25);
        wmove(win1, 8, 26);
        wrefresh(win1);
        wgetch(win1);

        delwin(win1);
    }

    clear();
    wclear(win);
    wrefresh(win);
    mvwaddstr(win, 6, 2, "This line shouldn't appear");
    mvwaddstr(win, 4, 2, "Only half of the next line is visible");
    mvwaddstr(win, 5, 2, "Only half of the next line is visible");
    wmove(win, 6, 1);
    wclrtobot(win);
    wmove(win, 5, 20);
    wclrtoeol(win);
    mvwaddstr(win, 8, 2, "This line also shouldn't appear");
    wmove(win, 8, 1);
    winsdelln(win, -1);
    Continue(win);

    wmove(win, 5, 9);
    ch = winch(win);

    wclear(win);
    wmove(win, 6, 2);
    waddstr(win, "The next char should be l:  ");
    winsch(win, ch);
    Continue(win);

    mvwinsstr(win, 6, 2, "A1B2C3D4E5");
    Continue(win);

    wmove(win, 5, 1);
    winsdelln(win, 1);
    mvwaddstr(win, 5, 2, "The lines below should have moved down");
    Continue(win);

    wclear(win);
    wmove(win, 2, 2);
    wprintw(win, "This is a formatted string in a window: %d %s\n",
            42, "is it");
    mvwaddstr(win, 10, 1, "Enter a string: ");
    wrefresh(win);
    echo();
    wscanw(win, "%s", Buffer);

    printw("This is a formatted string in stdscr: %d %s\n", 42, "is it");
    mvaddstr(10, 1, "Enter a string: ");
    scanw("%s", Buffer);

    wclear(win);
    curs_set(2);
    mvwaddstr(win, 1, 1, "The cursor should be in high-visibility mode");
    Continue(win);

    wclear(win);
    curs_set(0);
    mvwaddstr(win, 1, 1, "The cursor should have disappeared");
    Continue(win);

    wclear(win);
    curs_set(1);
    mvwaddstr(win, 1, 1, "The cursor should be normal");
    Continue(win);

#ifdef A_COLOR
    if (has_colors())
    {
        wclear(win);
        mvwaddstr(win, 1, 1, "Colors should change after you press a key");
        Continue(win);

        init_pair(1, COLOR_RED, COLOR_WHITE);
        wrefresh(win);
    }
#endif
    werase(win);
    mvwaddstr(win, 1, 1, "Information About Your Terminal");
    mvwaddstr(win, 3, 1, termname());
    mvwaddstr(win, 4, 1, longname());

    if (termattrs() & A_BLINK)
        mvwaddstr(win, 5, 1, "This terminal claims to support blinking.");
    else
        mvwaddstr(win, 5, 1, "This terminal does NOT support blinking.");

    mvwaddnstr(win, 7, 5, "Have a nice day!ok", 16);
    wrefresh(win);

    mvwinnstr(win, 7, 5, Buffer, 18);
    mvaddstr(LINES - 2, 10, Buffer);
    refresh();
    Continue(win);
}
开发者ID:ttldtor,项目名称:PDCurses,代码行数:101,代码来源:testcurs.c

示例6: ssl_init_info

int ssl_init_info(int *server_fd,ssl_info *sslinfo)
{
    int ret;
    const char *pers = "ssl";
    mbedtls_x509_crt_init(&sslinfo->cacert );
    mbedtls_ctr_drbg_init(&sslinfo->ctr_drbg);
    mbedtls_entropy_init(&sslinfo->entropy );

    if( mbedtls_ctr_drbg_seed( &sslinfo->ctr_drbg, mbedtls_entropy_func, &sslinfo->entropy,
                       (const unsigned char *) pers, strlen( pers ) ) != 0 )
    {
        return  -1;

    }

    mbedtls_ssl_init( &sslinfo->ssl );
    mbedtls_ssl_config_init( &sslinfo->conf );
    if( ( ret = mbedtls_ssl_config_defaults( &sslinfo->conf,
                    MBEDTLS_SSL_IS_CLIENT,
                    MBEDTLS_SSL_TRANSPORT_STREAM,
                    MBEDTLS_SSL_PRESET_DEFAULT ) ) != 0 )
    {
        echo( " failed\n  ! mbedtls_ssl_config_defaults returned %d\n\n", ret );
       return -1;
    }



    mbedtls_ssl_conf_endpoint( &sslinfo->conf, MBEDTLS_SSL_IS_CLIENT );
    mbedtls_ssl_conf_authmode( &sslinfo->conf, MBEDTLS_SSL_VERIFY_OPTIONAL );
    mbedtls_ssl_conf_ca_chain( &sslinfo->conf, &sslinfo->cacert,NULL);
    mbedtls_ssl_conf_rng( &sslinfo->conf, mbedtls_ctr_drbg_random, &sslinfo->ctr_drbg );

    if( ( ret = mbedtls_ssl_setup( &sslinfo->ssl, &sslinfo->conf ) ) != 0 )
    {
        echo( " failed\n  ! mbedtls_ssl_setup returned %d\n\n", ret );
        return -1;
    }

    mbedtls_ssl_set_bio( &sslinfo->ssl, server_fd,mbedtls_net_send, mbedtls_net_recv,NULL );
    mbedtls_ssl_set_session(&sslinfo->ssl, &ssn);
    while((ret = mbedtls_ssl_handshake(&sslinfo->ssl))!=0)
    {
        if( ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE )
        {
            echo( " failed\n  ! ssl_handshake returned -0x%x\n\n", -ret );
            return -1;
        }
        //CPU sleep
        sleeps(1);
    }



    if((ret = mbedtls_ssl_get_verify_result( &sslinfo->ssl ) ) != 0 )
    {
       // echo( "Verifying peer X.509 certificate...failed \r\n" );
    }
    else
    {
        echo( " ok\n" );
    }
    //保存session
    if( ( ret = mbedtls_ssl_get_session( &sslinfo->ssl, &ssn ) ) != 0 )
    {
        //失败初始化
        memset(&ssn, 0, sizeof(mbedtls_ssl_session));
    }
    return 0;
}
开发者ID:MoZhonghua,项目名称:ngrok-c,代码行数:70,代码来源:sslbio.cpp

示例7: moo

// recurs.c was included

#ifndef MY_INCLUDE_GUARD
#define MY_INCLUDE_GUARD
// recurs.c was evaluated


// including itself, how clever...
#include "recurs.c"


// This file shows the use of Include Guards.
// If you remove the guards, you'll get infinite recursion.
//
// Check how it is evaluated - let sdscp compile it and see the output.
moo()
{
	echo("MoOooOooOO!!")
}

#endif
开发者ID:MightyPork,项目名称:sdscp,代码行数:21,代码来源:include_guards.c

示例8: init_player_ui

void
init_player_ui(jeu_s jeu, aff_s aff)
{
    char nomj1[TAILLE_NOM];
    char nomj2[TAILLE_NOM];
    char rolej1;
    char ai;
    int roleint;

    curs_set(1);
    echo();

    do {
    wattron(aff->etat, A_BOLD | A_REVERSE);
    mvwprintw(aff->etat, 1, 2, "Entrez le rôle du joueur 1");
    mvwprintw(aff->etat, 2, 2, "0 pour chèvre, 1 pour tigre :");
    wattroff(aff->etat, A_BOLD | A_REVERSE);
    wattron(aff->etat, A_BOLD);
    mvwscanw(aff->etat, 3, 2, "%c", &rolej1);
    wrefresh(aff->etat);
    wattroff(aff->etat, A_BOLD);

    wmove(aff->etat, 1, 2);
    wclrtoeol(aff->etat);
    wmove(aff->etat, 2, 2);
    wclrtoeol(aff->etat);
    wmove(aff->etat, 3, 2);
    wclrtoeol(aff->etat);
    wrefresh(aff->etat);
    } while ((rolej1 != '0') && (rolej1) != '1');

    if (rolej1 == '0')
        roleint = 0;
    else
        roleint = 1;


    do {
    wattron(aff->etat, A_BOLD | A_REVERSE);
    mvwprintw(aff->etat, 1, 2, "Jouer contre l'AI ?");
    mvwprintw(aff->etat, 2, 2, "0 pour NON, 1 pour OUI:");
    wattroff(aff->etat, A_BOLD | A_REVERSE);
    wattron(aff->etat, A_BOLD);
    mvwscanw(aff->etat, 3, 2, "%c", &ai);
    wrefresh(aff->etat);
    wattroff(aff->etat, A_BOLD);

    wmove(aff->etat, 1, 2);
    wclrtoeol(aff->etat);
    wmove(aff->etat, 2, 2);
    wclrtoeol(aff->etat);
    wmove(aff->etat, 3, 2);
    wclrtoeol(aff->etat);
    wrefresh(aff->etat);
    } while ((ai != '0') && (ai) != '1');

    if (ai == '0')
        init_player(jeu, roleint);
    else
        init_player_ai(jeu, roleint, !roleint);

    curs_set(0);
    noecho();
}
开发者ID:hahahafr,项目名称:ziege,代码行数:64,代码来源:ui.c

示例9: invokeImpl

Variant invokeImpl(void *extra, CArrRef params) {
  const char *function = (const char*)extra;
  // for TestExtFunction
  if (strcasecmp(function, "test") == 0) {
    return params[0];
  }

  // for TestExtPreg::test_preg_replace_callback
  if (strcasecmp(function, "next_year") == 0) {
    Array matches = params[0].toArray();
    return matches[1].toString() + String(matches[2].toInt32() + 1);
  }

  // for TestExtArray::test_array_filter
  if (strcasecmp(function, "odd") == 0) {
    return params[0].toInt32() & 1;
  }
  if (strcasecmp(function, "even") == 0) {
    return !(params[0].toInt32() & 1);
  }

  // for TestExtArray::test_array_map
  if (strcasecmp(function, "cube") == 0) {
    int n = params[0].toInt32();
    return n * n * n;
  }

  // for TestExtArray::test_array_multisort
  if (strcasecmp(function, "strtolower") == 0) {
    return f_strtolower(params[0]);
  }

  // for TestExtArray::test_array_reduce
  if (strcasecmp(function, "rsum") == 0) {
    int v = params[0].toInt32();
    int w = params[1].toInt32();
    v += w;
    return v;
  }
  if (strcasecmp(function, "rmul") == 0) {
    int v = params[0].toInt32();
    int w = params[1].toInt32();
    v *= w;
    return v;
  }

  // for TestExtArray::test_array_walk_recursive
  if (strcasecmp(function, "test_print") == 0) {
    String item = params[0].toString();
    String key = params[1].toString();
    echo(key + ": " + item + "\n");
  }

  // for TestExtArray::test_array_walk
  if (strcasecmp(function, "test_alter") == 0) {
    Variant &item1 = lval(((Array&)params).lvalAt(0));
    String key = params[1];
    String prefix = params[2];
    item1 = prefix + ": " + item1;
  }

  // for TestExtArray::test_array_udiff
  if (strcasecmp(function, "comp_func") == 0) {
    int n1 = params[0].toInt32();
    int n2 = params[1].toInt32();
    if (n1 == n2) return 0;
    return n1 > n2 ? 1 : -1;
  }

  // for TestExtArray::test_usort
  if (strcasecmp(function, "reverse_comp_func") == 0) {
    int n1 = params[0].toInt32();
    int n2 = params[1].toInt32();
    if (n1 == n2) return 0;
    return n1 > n2 ? -1 : 1;
  }

  // for TestExtArray::test_array_uintersect
  if (strcasecmp(function, "strcasecmp") == 0) {
    String s1 = params[0].toString();
    String s2 = params[1].toString();
    return strcasecmp(s1.data(), s2.data());
  }

  // for TestExtArray::test_uasort
  if (strcasecmp(function, "reverse_strcasecmp") == 0) {
    String s1 = params[0].toString();
    String s2 = params[1].toString();
    return strcasecmp(s2.data(), s1.data());
  }

  // for TestExtFbml
  if (strcasecmp(function, "urltr") == 0) {
    String s1 = params[0].toString();
    String s2 = params[1].toString();
    return String("url:") + s1 + "=" + s2;
  }

  // for TestExtCurl::test_curl_exec
  if (strcasecmp(function, "curl_write_func") == 0) {
//.........这里部分代码省略.........
开发者ID:bastiaanzapf,项目名称:hiphop-php,代码行数:101,代码来源:test_externals.cpp

示例10: debugloop

void debugloop() {
    int key;
  a:
    if (!(debugds & 2))
        nextopcode();
    if (!(debugds & 1))
        nextspcopcode();

  b:
    // redrawing the display is always a good idea
    refresh();
    wrefresh(debugwin);

   key = getch();
   if (key >= 0 && key < 256)
       key = toupper(key);

   switch (key) {
   case KEY_F(1): // run
       execut = 1;
       return;

   case KEY_F(2): // debugsavestate
       statesaver();
       goto b;

   case KEY_F(4): // debugloadstate
       debugloadstate();
       goto a;

   case 27:       // exit
       return;

   case '\n':     // step
       goto e;


   /* Ported this but couldn't bring myself to commit it.
      pagefault said to remove it.
   case '-':      // skip opcode
   */

   case 'C':      // clear
       numinst = 0;
       goto a;

   case 'M':      // modify
   {
       WINDOW *w;
       unsigned addr, value, n;

       w = openwindow(7, 33, 11, 24, "    Enter Address : ");
       mvwaddstr(w, 3, 1,            "    Previous Value: ");
       mvwaddstr(w, 5, 1,            "    Enter Value   : ");

       wrefresh(w);

       echo();
       n = mvwscanw(w, 1, 21, "%x", &addr);
       noecho();

       if (n == 1) {
       mvwprintw(w, 3, 21, "%02x", memtabler8_wrapper(addr >> 16, addr));
       wrefresh(w);

       echo();
       n = mvwscanw(w, 5, 21, "%x", &value);
       noecho();

       if (n == 1) {
          memtablew8_wrapper(addr >> 16, addr, value);
       }}

       closewindow(w);
       goto b;
   }
开发者ID:Alcaro,项目名称:ZMZ,代码行数:76,代码来源:debugger.c

示例11: get_command

void get_command(void)
{
	char com[255];

	int text_width, text_startx;
	allocated_block_t *allocated_block = NULL;
	int i = 0;
	int count = 0;

	WINDOW *command_win = NULL;
        List allocated_blocks = NULL;
	ListIterator results_i;

	if (params.commandline && !params.command) {
		printf("Configure won't work with commandline mode.\n");
		printf("Please remove the -c from the commandline.\n");
		bg_configure_ba_fini();
		exit(0);
	}

	if (working_cluster_rec) {
		char *cluster_name = slurm_get_cluster_name();
		if (strcmp(working_cluster_rec->name, cluster_name)) {
			xfree(cluster_name);
			endwin();
			printf("To use the configure option you must be on the "
			       "cluster the configure is for.\nCross cluster "
			       "support doesn't exist today.\nSorry for the "
			       "inconvenince.\n");
			bg_configure_ba_fini();
			exit(0);
		}
		xfree(cluster_name);
	}

	bg_configure_ba_setup_wires();

	color_count = 0;

	allocated_blocks = list_create(_destroy_allocated_block);

	if (params.commandline) {
		snprintf(com, sizeof(com), "%s", params.command);
		goto run_command;
	} else {
		/* make sure we don't get any noisy debug */
		ba_configure_set_ba_debug_flags(0);

		text_width = text_win->_maxx;
		text_startx = text_win->_begx;
		command_win = newwin(3, text_width - 1, LINES - 4,
				     text_startx + 1);
		curs_set(1);
		echo();
	}

	while (strcmp(com, "quit")) {
		clear_window(grid_win);
		print_grid();
		clear_window(text_win);
		box(text_win, 0, 0);
		box(grid_win, 0, 0);

		if (!params.no_header)
			_print_header_command();

		if (error_string != NULL) {
			i = 0;
			while (error_string[i] != '\0') {
				if (error_string[i] == '\n') {
					main_ycord++;
					main_xcord=1;
					i++;
				}
				mvwprintw(text_win,
					  main_ycord,
					  main_xcord,
					  "%c",
					  error_string[i++]);
				main_xcord++;
			}
			main_ycord++;
			main_xcord = 1;
			memset(error_string, 0, 255);
		}
		results_i = list_iterator_create(allocated_blocks);

		count = list_count(allocated_blocks)
			- (LINES-(main_ycord+5));

		if (count<0)
			count=0;
		i=0;
		while ((allocated_block = list_next(results_i)) != NULL) {
			if (i >= count)
				_print_text_command(allocated_block);
			i++;
		}
		list_iterator_destroy(results_i);

//.........这里部分代码省略.........
开发者ID:tpatki,项目名称:slurm_test,代码行数:101,代码来源:configure_functions.c

示例12: curses_line_input_dialog

void curses_line_input_dialog(const char *prompt, char *answer, int buffer)
{
    int map_height, map_width, maxwidth, remaining_buf, winx, winy, count;
    WINDOW *askwin, *bwin;
    char input[buffer];
    char *tmpstr;
    int prompt_width = strlen(prompt) + buffer + 1;
    int prompt_height = 1;
    int height = prompt_height;

    maxwidth = term_cols - 2;

    if (iflags.window_inited) {
        curses_get_window_size(MAP_WIN, &map_height, &map_width);
        if ((prompt_width + 2) > map_width)
            maxwidth = map_width - 2;
    }

    if (prompt_width > maxwidth) {
        prompt_height = curses_num_lines(prompt, maxwidth);
        height = prompt_height;
        prompt_width = maxwidth;
        tmpstr = curses_break_str(prompt, maxwidth, prompt_height);
        remaining_buf = buffer - (strlen(tmpstr) - 1);
        if (remaining_buf > 0 ) {
            height += (remaining_buf / prompt_width);
            if ((remaining_buf % prompt_width) > 0) {
                height++;
            }
        }
    }

    if (iflags.window_inited) {
        bwin = curses_create_window(prompt_width, height, UP);
        wrefresh(bwin);
        getbegyx(bwin, winy, winx);
        askwin = newwin(height, prompt_width, winy + 1, winx + 1);
    } else {
        bwin = curses_create_window(prompt_width, height, CENTER);
        wrefresh(bwin);
        getbegyx(bwin, winy, winx);
        askwin = newwin(height, prompt_width, winy + 1, winx + 1);
    }
    for (count = 0; count < prompt_height; count++) {
        tmpstr = curses_break_str(prompt, maxwidth, count + 1);
        if (count == (prompt_height - 1)) {  /* Last line */
            mvwprintw(askwin, count, 0, "%s ", tmpstr);
        } else {
            mvwaddstr(askwin, count, 0, tmpstr);
        }
        free(tmpstr);
    }

    echo();
    curs_set(1);
    wgetnstr(askwin, input, buffer-1);
    curs_set(0);
    strcpy(answer, input);
    werase(bwin);
    delwin(bwin);
    curses_destroy_win(askwin);
    noecho();
}
开发者ID:chasonr,项目名称:unnethack-i18n,代码行数:63,代码来源:cursdial.c

示例13: erase

/*
 * Erase a character or line
 * FIXME: Needs support for WERASE and ECHOPRT.
 * FIXME: Some of the tests should check for IEXTEN, too.
 */
static void
erase (struct rtems_termios_tty *tty, int lineFlag)
{
	if (tty->ccount == 0)
		return;
	if (lineFlag) {
		if (!(tty->termios.c_lflag & ECHO)) {
			tty->ccount = 0;
			return;
		}
		if (!(tty->termios.c_lflag & ECHOE)) {
			tty->ccount = 0;
			echo (tty->termios.c_cc[VKILL], tty);
			if (tty->termios.c_lflag & ECHOK)
				echo ('\n', tty);
			return;
		}
	}
	while (tty->ccount) {
		unsigned char c = tty->cbuf[--tty->ccount];

		if (tty->termios.c_lflag & ECHO) {
			if (!lineFlag && !(tty->termios.c_lflag & ECHOE)) {
				echo (tty->termios.c_cc[VERASE], tty);
			}
			else if (c == '\t') {
				int col = tty->read_start_column;
				int i = 0;

				/*
				 * Find the character before the tab
				 */
				while (i != tty->ccount) {
					c = tty->cbuf[i++];
					if (c == '\t') {
						col = (col | 7) + 1;
					}
					else if (iscntrl (c)) {
						if (tty->termios.c_lflag & ECHOCTL)
							col += 2;
					}
					else {
						col++;
					}
				}

				/*
				 * Back up over the tab
				 */
				while (tty->column > col) {
					rtems_termios_puts ("\b", 1, tty);
					tty->column--;
				}
			}
			else {
				if (iscntrl (c) && (tty->termios.c_lflag & ECHOCTL)) {
					rtems_termios_puts ("\b \b", 3, tty);
					if (tty->column)
						tty->column--;
				}
				if (!iscntrl (c) || (tty->termios.c_lflag & ECHOCTL)) {
					rtems_termios_puts ("\b \b", 3, tty);
					if (tty->column)
						tty->column--;
				}
			}
		}
		if (!lineFlag)
			break;
	}
}
开发者ID:FullMentalPanic,项目名称:RTEMS_NEW_TOOL_CHAIN,代码行数:76,代码来源:termios.c

示例14: main

main(){
	char *p;
	p = echo();
	printf("return: %s\n",p);
	return 0;
}
开发者ID:vonzhou,项目名称:Coding,代码行数:6,代码来源:func.c

示例15: mod_command

int mod_command(char *q, char *args)
{
        if( q==NULL )
        {
                ;
        }
        else if( strcmp(q, "edit")==0 )
        {
                editmode = editmode ? 0 : 1;
                v_center = editmode ? 0 : 1;
                return 0;
        }
        else if( strcmp(q, "model")==0 )
        {
                setmodel = safe_atoi(tok(args, " ")); // FIXME: lame hack
                return 0;
        }
        else if( strcmp(q, "bounds")==0 || strcmp(q, "blocksize")==0 )
        {
                size_t n = 0;
                int x = safe_atoi(tok(args, " "));
                int y = safe_atoi(tok(args, " "));
                int z = safe_atoi(tok(args, " "));
                char chr = strcmp(q, "bounds")==0 ? 'b' : 'z';

                if( !x || !y || !z )
                {
                        context *co = fr[hotfr%maxframes].objs[mycontext].data; // FIXME is mycontext always set here?
                        if( chr == 'b' )
                                echo("The current bounds are (X,Y,Z): %d %d %d", co->x, co->y, co->z);
                        else
                                echo("The current blocksize is (X,Y,Z): %d %d %d", co->bsx, co->bsy, co->bsz);
                        return 0;
                }

                memset(&magic_c, 0, sizeof magic_c);
                packbytes(magic_c.data, chr, &n, 1);
                packbytes(magic_c.data,   x, &n, 4);
                packbytes(magic_c.data,   y, &n, 4);
                packbytes(magic_c.data,   z, &n, 4);
                magic_c.datasz = n;
                magic_c.flags |= CMDF_DATA;
                magic_c.cmd = CMDT_0CON; // console command
                putcmd(-1, -1, -1);
                return 0;
        }
        else if( strcmp(q, "tilespacing")==0 )
        {
                size_t n = 0;
                int tileuw = safe_atoi(tok(args, " "));
                int tileuh = safe_atoi(tok(args, " "));

                if( !tileuw || !tileuh )
                {
                        context *co = fr[hotfr%maxframes].objs[mycontext].data;
                        echo("The current tilespacing is (W,H): %d %d", co->tileuw, co->tileuh);
                        return 0;
                }

                memset(&magic_c, 0, sizeof magic_c);
                packbytes(magic_c.data,    't', &n, 1);
                packbytes(magic_c.data, tileuw, &n, 4);
                packbytes(magic_c.data, tileuh, &n, 4);
                magic_c.datasz = n;
                magic_c.flags |= CMDF_DATA;
                magic_c.cmd = CMDT_0CON;
                putcmd(-1, -1, -1);
                return 0;
        }
        else if( strcmp(q, "orthographic")==0 || strcmp(q, "dimetric")==0 )
        {
                size_t n = 0;
                memset(&magic_c, 0, sizeof magic_c);
                packbytes(magic_c.data, q[0], &n, 1);
                magic_c.datasz = n;
                magic_c.flags |= CMDF_DATA;
                magic_c.cmd = CMDT_0CON;
                putcmd(-1, -1, -1);
                return 0;
        }
        else if( strcmp(q, "resprite")==0 )
        {
                reload_sprites();
                renumber_sprites();
                echo("Was %d sprites, now %d sprites.", old_spr_count, spr_count);
                unload_sprites(old_sprites, old_spr_count);
                return 0;
        }

        return 1;
}
开发者ID:superjer,项目名称:SPARToR,代码行数:91,代码来源:mod.c


注:本文中的echo函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。