コード例 #1
0
ファイル: status_bar.c プロジェクト: cbrp/profanity
void
status_bar_clear(void)
{
    if (message != NULL) {
        free(message);
        message = NULL;
    }
    
    int i;
    for (i = 0; i < 9; i++) {
        is_active[i] = FALSE;
        is_new[i] = FALSE;
    }

    wclear(status_bar);

    int rows, cols;
    getmaxyx(stdscr, rows, cols);
    wattron(status_bar, COLOR_PAIR(4));
    mvwprintw(status_bar, 0, cols - 29, _active);
    wattroff(status_bar, COLOR_PAIR(4));

    dirty = TRUE;
}
コード例 #2
0
ファイル: winio.cpp プロジェクト: pgengler/pinot
/* Highlight the current word being replaced or spell checked.  We
 * expect word to have tabs and control characters expanded. */
void do_replace_highlight(bool highlight, const char *word)
{
	size_t y = xplustabs(), word_len = strlenpt(word);

	y = get_page_start(y) + COLS - y;
	/* Now y is the number of columns that we can display on this
	 * line. */

	assert(y > 0);

	if (word_len > y) {
		y--;
	}

	reset_cursor();
	wnoutrefresh(edit);

	if (highlight) {
		wattron(edit, highlight_attribute);
	}

	/* This is so we can show zero-length matches. */
	if (word_len == 0) {
		waddch(edit, ' ');
	} else {
		waddnstr(edit, word, actual_x(word, y));
	}

	if (word_len > y) {
		waddch(edit, '$');
	}

	if (highlight) {
		wattroff(edit, highlight_attribute);
	}
}
コード例 #3
0
void		print_game_info(t_all *all)
{
  unsigned int	i;
  unsigned int	j;

  i = -1;
  mvwprintw(all->game.board, 1, 1, "Hight Score %d", all->game.h_score);
  mvwprintw(all->game.board, 2, 1, "Score %d", all->game.score);
  wrefresh(all->game.board);
  wborder(all->game.tetris, '|', '|', '-', '-', '-', '-', '-', '-');
  wrefresh(all->game.tetris);
  while (++i < all->param.rows)
    {
      j = -1;
      while (++j != all->param.cols)
	{
	      wattron(all->game.tetris, COLOR_PAIR(all->param.map[i][j]));
	      mvwprintw(all->game.tetris, i + 1, j + 1, (all->param.map[i][j]
							 == '0') ? " " : " ");
	      wattroff(all->game.tetris, COLOR_PAIR(all->param.map[i][j]));
	}
    }
  wrefresh(all->game.tetris);
}
コード例 #4
0
ファイル: Curses.c プロジェクト: RajasekharBhumi/L4Re
/** Show the progress bar window. */
static void show_progress_bar(void)
{
  int nLength = 0;
  int nIndex = 0;
  int nStart = strlen(f_szProgress);
  int nColorID = 0;

  if (0 == (f_uiTestsRun + f_uiTestsSkipped)) {
    nLength = f_nWidth - f_nLeft - nStart - 6;
    nColorID = PROGRESS_BACKGROUND_COLOR;
  }
  else {
    nLength = (f_nWidth - f_nLeft - nStart - 6) * ((double)(f_uiTestsRun + f_uiTestsSkipped) / f_uiTotalTests);
    nColorID = (!f_uiTestsSkipped && f_uiTestsRun == f_uiTestsRunSuccessful)
            ? PROGRESS_SUCCESS_COLOR
            : PROGRESS_FAILURE_COLOR;
  }

  wattron(application_windows.pProgressWin, A_BOLD | COLOR_PAIR(nColorID));
  for (nIndex = 0; nIndex < nLength; nIndex++) {
    mvwprintw(application_windows.pProgressWin, 0, nStart + nIndex, " ");
  }
  wattroff(application_windows.pProgressWin, COLOR_PAIR(nColorID));
}
コード例 #5
0
ファイル: nc.c プロジェクト: LgJianzhao/httping
void status_line(char *fmt, ...)
{
	char *line = NULL;
        va_list ap;

	wattron(w_line2, A_REVERSE);

	wmove(w_line2, 0, 0);

        va_start(ap, fmt);

	vasprintf(&line, fmt, ap);
        myprint(w_line2, line);
	free(line);

        va_end(ap);

	wattroff(w_line2, A_REVERSE);

	wnoutrefresh(w_line2);

	if (win_resize)
		recreate_terminal();
}
コード例 #6
0
ファイル: este_va.c プロジェクト: canicue/Seminario
void
imprimir_centrao (WINDOW * win, int starty, int startx, int width,
		  char *string, chtype color)
{
  int length, x, y;
  float temp;

  if (win == NULL)
    win = stdscr;
  getyx (win, y, x);
  if (startx != 0)
    x = startx;
  if (starty != 0)
    y = starty;
  if (width == 0)
    width = 80;
  length = strlen (string);
  temp = (width - length) / 2;
  x = startx + (int) temp;
  wattron (win, color);
  mvwprintw (win, y, x, "%s", string);
  wattroff (win, color);
  refresh ();
}
コード例 #7
0
ファイル: chatbox.c プロジェクト: Sarcasm/luasoul
/*
  chatbox:print_colored(s, {
  bold = true,
  foreground = 3,
  ...
  })

  Stack:
  2nd the string to display
  3rd argument is a table who can contain all the attributes above

  TODO: Optimisation ?
*/
int		lui_print_colored_chatbox(lua_State *L)
{
  CHATBOX	*c = check_chatbox(L, 1);
  const char	*s = luaL_checkstring(L, 2); /* string to display */
  attr_t	attr;
  short		pair;
  t_style	style;

  /* save current state */
  wattr_get(c->pad, &attr, &pair, NULL);

  get_style(L, 3, style);
  wattron(c->pad, style.on);
  wattroff(c->pad, style.off);

  /* put the string */
  c->scroll = 0;
  waddstr(c->pad, s);

  /* restore old attr */
  wattr_set(c->pad, attr, pair, NULL);

  return 0;
}
コード例 #8
0
/* Draw a border arround the window.  */
void
box_win (struct tui_gen_win_info * win_info, int highlight_flag)
{
  if (win_info && win_info->handle)
    {
      WINDOW *win;
      int attrs;

      win = win_info->handle;
      if (highlight_flag == HILITE)
        attrs = tui_active_border_attrs;
      else
        attrs = tui_border_attrs;

      wattron (win, attrs);
      wborder (win, tui_border_vline, tui_border_vline,
               tui_border_hline, tui_border_hline,
               tui_border_ulcorner, tui_border_urcorner,
               tui_border_llcorner, tui_border_lrcorner);
      if (win_info->title)
        mvwaddstr (win, 0, 3, win_info->title);
      wattroff (win, attrs);
    }
}
コード例 #9
0
ファイル: visual-list.c プロジェクト: yzzyx/mimic
void vl_int_draw_list(WINDOW *win, 
	unsigned int width, dl_list *sel_entry, dl_list *start_entry,
	dl_list *stop_entry)
{
	vl_entry *ent;
	int line;
	int tmp_attr;
	int utf8_len;

	short std_color_pair;
	attr_t std_attr;

	wattr_get(win, &std_attr, &std_color_pair, NULL);
	line = 0;

	do{
		ent = (vl_entry *)start_entry->data;
		if( ent->attributes)
			tmp_attr = wattrset(win, ent->attributes);

		if(start_entry == sel_entry )
			wattron(win,A_STANDOUT);
		
		mvwaddstr(win, line, 0, ent->str);
		utf8_len = utf8_strlen(ent->str);
		mvwhline(win, line, utf8_len, ' ', width - utf8_len);

		if( ent->attributes)
			tmp_attr = wattrset(win, std_attr);
		if(start_entry == sel_entry )
			wattroff(win,A_STANDOUT);

		line ++;
		start_entry = start_entry->next;
	}while( start_entry != NULL && start_entry != stop_entry->next );
}
コード例 #10
0
ファイル: hunter_ghost.c プロジェクト: anthony1810/pacman2
void movexy(WINDOW *game_window, struct ghost_char_2 *my_ghost_char,struct pacman_char *my_pacman_char,struct Item_Struct *my_item_struct, int des_x, int des_y){

	my_ghost_char->ghost_col+=des_x;
	my_ghost_char->ghost_row+=des_y;
	mvwaddch(game_window, my_item_struct->y_pos, my_item_struct->x_pos, my_item_struct->value);
			

	my_item_struct->x_pos = my_ghost_char->ghost_col;
	my_item_struct->y_pos = my_ghost_char->ghost_row;

	int characters = (int)mvwinch(game_window, my_item_struct->y_pos, my_item_struct->x_pos);

	if(my_item_struct->x_pos == my_pacman_char->pac_row && my_item_struct->y_pos == my_pacman_char->pac_col){
		my_item_struct->value = ' ';
	}else{
		my_item_struct->value = characters;
	}
	wattron(game_window,COLOR_PAIR(5));
	mvwaddch(game_window, my_ghost_char->ghost_row, my_ghost_char->ghost_col, ACS_CKBOARD);
	wattroff(game_window,COLOR_PAIR(5));
	wrefresh(game_window);

	wrefresh(game_window);
}
コード例 #11
0
ファイル: bold.c プロジェクト: boothj5/ncurses_bold
int main(void)
{
    initscr();
    curs_set(0);
    noecho();

    use_default_colors();
    start_color();

    init_pair(1, COLOR_GREEN, COLOR_BLACK);
    init_pair(2, COLOR_GREEN, COLOR_RED);
    init_pair(3, COLOR_BLACK, COLOR_WHITE);

    wattron(stdscr, COLOR_PAIR(1));
    wprintw(stdscr, "GREEN ON BLACK\n");
    wattroff(stdscr, COLOR_PAIR(1));

    wattron(stdscr, COLOR_PAIR(1) | A_BOLD);
    wprintw(stdscr, "BOLD GREEN ON BLACK\n");
    wattroff(stdscr, COLOR_PAIR(1) | A_BOLD);

    wattron(stdscr, COLOR_PAIR(2));
    wprintw(stdscr, "GREEN ON RED\n");
    wattroff(stdscr, COLOR_PAIR(2));

    wattron(stdscr, COLOR_PAIR(2) | A_BOLD);
    wprintw(stdscr, "BOLD GREEN ON RED\n");
    wattroff(stdscr, COLOR_PAIR(2) | A_BOLD);

    wattron(stdscr, COLOR_PAIR(3));
    wprintw(stdscr, "BLACK ON WHITE\n");
    wattroff(stdscr, COLOR_PAIR(2));

    wattron(stdscr, COLOR_PAIR(3) | A_BOLD);
    wprintw(stdscr, "BOLD BLACK ON WHITE\n");
    wattroff(stdscr, COLOR_PAIR(2) | A_BOLD);
    refresh();
    getch();

    endwin();
    return 0;
}
コード例 #12
0
ファイル: prompt.c プロジェクト: ris21/yoda
int do_dictionary_prompt(bool all, const char *msg, char *str)
{
    s_list l;
    s_node *p;
    int ok = -2, width = 16;
    const char *yesstr;		/* String of Yes characters accepted. */
    const char *nostr;		/* Same for No. */
    const char *allstr;		/* And All, surprise! */
    int u;
    char **thisarray = (char **)malloc(sizeof(char)*5);
	for(u = 0; u < 5; u++)
		thisarray[u] = (char *)malloc(sizeof(char)*16);
    thisarray = thisfunc(str);
    int oldmenu = currmenu;
    char but[16];
    int i, j = 0;
    int count = 0;
    int t = 0;
    int bs = 0;
    char buf[16];
    strcpy(buf, str);
    int tp;
    int we = 0, wc = 0;
    
    tp = typepos();
    
    assert(msg != NULL);
    
    s_init(&l);
    u = 0;
    while(u < 5) {
	s_append(&l, thisarray[u]);
	u++;
    }
    /*Now partial matched list is prepared*/
           p = l.head;
           

    if(str == NULL){
 
        count = 0;

        
        while(p){
            count++;
            p = p->next;
        }
    }
    
    //count=5;

    p = l.head;


    do {
	int kbinput;
	functionptrtype func;
        i = 0;
#ifndef DISABLE_MOUSE
	int mouse_x, mouse_y;
#endif

	if (!ISSET(NO_HELP)) {
	    char shortstr[3];
		/* Temporary string for (translated) " Y", " N" and " A". */

	    if (COLS < 32)
		width = COLS / 2;

	    /* Clear the shortcut list from the bottom of the screen. */
	    blank_bottombars();

	    /* Now show the ones for "Yes", "No", "Cancel" and maybe "All". */


	    if (all) {
		shortstr[1] = allstr[0];
		wmove(bottomwin, 1, width);
		onekey(shortstr, _("All"), width);
	    }

            for(i = 0; i < count && i < 5; i++){
                sprintf(but, "%d", i + 1);
                if(i == 0) wmove(bottomwin, 1, 0);
                else wmove(bottomwin, 1, i * width);
                if(p){
                    onekey(but, p->word, width);
                    p = p->next;
                }
                j++;
            }

	    wmove(bottomwin, 1, i * width);
	    onekey("^C", _("Cancel"), width);
	}

	if (interface_color_pair[TITLE_BAR].bright)
	    wattron(bottomwin, A_BOLD);
	wattron(bottomwin, interface_color_pair[TITLE_BAR].pairnum);

	blank_statusbar();
	mvwaddnstr(bottomwin, 0, 0, msg, actual_x(msg, COLS - 1));

	wattroff(bottomwin, A_BOLD);
	wattroff(bottomwin, interface_color_pair[TITLE_BAR].pairnum);

	/* Refresh edit window and statusbar before getting input. */
	wnoutrefresh(edit);
	wnoutrefresh(bottomwin);

	currmenu = MYESNO;
	kbinput = get_kbinput(bottomwin);

#ifndef NANO_TINY
	if (kbinput == KEY_WINCH)
	    continue;
#endif
        /*49 is 1, 50 is 2 and so on*/

	func = func_from_key(&kbinput);

	if (func == do_cancel){
	    ok = 0;
            return ok;
        }
  
        if(kbinput == 's'){
            if(i == 5) {
                continue;
            }
        }
        if(kbinput <= '0' || kbinput > '0' + count) return -1;
        
        if(kbinput > '0' && kbinput <= '0' + count){
            p = l.head;
            i = kbinput - '0' - 1;
            if(j > 5) t = j - 5 + i;
            else t = i;

            while(t--) if(p){
                        p = p->next;
                        }
            
            if(tp == 1 || tp == 2){
                bs = strlen(str);
                while(bs--) do_backspace();
            }
            

            if(tp == 6 || tp == 7){
                if(str != NULL){


                    we = openfile->current_x;

                    while(openfile->current->data[we] != ' ' && openfile->current->data[we] != '\00'){
                     we++;
                        wc++;
                        do_right();
                    }

                    we--;
                    while(openfile->current->data[we] != ' ' && openfile->current->data[we] != '\00'){

                        do_backspace();
                        we--;
                    }
                }
            }
            
            
            do_output(p->word, strlen(p->word), FALSE);
            return tp;
        }


	else if (func == total_refresh) {
	    total_redraw();
	    continue;
	} else {
		/* Look for the kbinput in the Yes, No and (optionally)
		 * All strings. */
		if (strchr(yesstr, kbinput) != NULL)
		    ok = 1;
		else if (strchr(nostr, kbinput) != NULL)
		    ok = 0;
		else if (all && strchr(allstr, kbinput) != NULL)
		    ok = 2;
	}
        i = 0;
        p = l.head;
        
    } while (ok == -2);

    currmenu = oldmenu;
    return ok;
}
コード例 #13
0
ファイル: prompt.c プロジェクト: ris21/yoda
/* Ask a simple Yes/No (and optionally All) question, specified in msg,
 * on the statusbar.  Return 1 for Yes, 0 for No, 2 for All (if all is
 * TRUE when passed in), and -1 for Cancel. */
int do_yesno_prompt(bool all, const char *msg)
{
    int ok = -2, width = 16;
    const char *yesstr;		/* String of Yes characters accepted. */
    const char *nostr;		/* Same for No. */
    const char *allstr;		/* And All, surprise! */
    int oldmenu = currmenu;

    assert(msg != NULL);

    /* yesstr, nostr, and allstr are strings of any length.  Each string
     * consists of all single-byte characters accepted as valid
     * characters for that value.  The first value will be the one
     * displayed in the shortcuts. */
    /* TRANSLATORS: For the next three strings, if possible, specify
     * the single-byte shortcuts for both your language and English.
     * For example, in French: "OoYy" for "Oui". */
    yesstr = _("Yy");
    nostr = _("Nn");
    allstr = _("Aa");

    do {
	int kbinput;
	functionptrtype func;
#ifndef DISABLE_MOUSE
	int mouse_x, mouse_y;
#endif

	if (!ISSET(NO_HELP)) {
	    char shortstr[3];
		/* Temporary string for (translated) " Y", " N" and " A". */

	    if (COLS < 32)
		width = COLS / 2;

	    /* Clear the shortcut list from the bottom of the screen. */
	    blank_bottombars();

	    /* Now show the ones for "Yes", "No", "Cancel" and maybe "All". */
	    sprintf(shortstr, " %c", yesstr[0]);
	    wmove(bottomwin, 1, 0);
	    onekey(shortstr, _("Yes"), width);

	    if (all) {
		shortstr[1] = allstr[0];
		wmove(bottomwin, 1, width);
		onekey(shortstr, _("All"), width);
	    }

	    shortstr[1] = nostr[0];
	    wmove(bottomwin, 2, 0);
	    onekey(shortstr, _("No"), width);

	    wmove(bottomwin, 2, width);
	    onekey("^C", _("Cancel"), width);
	}

	if (interface_color_pair[TITLE_BAR].bright)
	    wattron(bottomwin, A_BOLD);
	wattron(bottomwin, interface_color_pair[TITLE_BAR].pairnum);

	blank_statusbar();
	mvwaddnstr(bottomwin, 0, 0, msg, actual_x(msg, COLS - 1));

	wattroff(bottomwin, A_BOLD);
	wattroff(bottomwin, interface_color_pair[TITLE_BAR].pairnum);

	/* Refresh edit window and statusbar before getting input. */
	wnoutrefresh(edit);
	wnoutrefresh(bottomwin);

	currmenu = MYESNO;
	kbinput = get_kbinput(bottomwin);

#ifndef NANO_TINY
	if (kbinput == KEY_WINCH)
	    continue;
#endif

	func = func_from_key(&kbinput);

	if (func == do_cancel)
	    ok = -1;
#ifndef DISABLE_MOUSE
	else if (kbinput == KEY_MOUSE) {
		/* We can click on the Yes/No/All shortcut list to
		 * select an answer. */
		if (get_mouseinput(&mouse_x, &mouse_y, FALSE) == 0 &&
			wmouse_trafo(bottomwin, &mouse_y, &mouse_x,
			FALSE) && mouse_x < (width * 2) &&
			mouse_y > 0) {
		    int x = mouse_x / width;
			/* Calculate the x-coordinate relative to the
			 * two columns of the Yes/No/All shortcuts in
			 * bottomwin. */
		    int y = mouse_y - 1;
			/* Calculate the y-coordinate relative to the
			 * beginning of the Yes/No/All shortcuts in
			 * bottomwin, i.e. with the sizes of topwin,
			 * edit, and the first line of bottomwin
			 * subtracted out. */

		    assert(0 <= x && x <= 1 && 0 <= y && y <= 1);

		    /* x == 0 means they clicked Yes or No.  y == 0
		     * means Yes or All. */
		    ok = -2 * x * y + x - y + 1;

		    if (ok == 2 && !all)
			ok = -2;
		}
	}
#endif /* !DISABLE_MOUSE */
	else if (func == total_refresh) {
	    total_redraw();
	    continue;
	} else {
		/* Look for the kbinput in the Yes, No and (optionally)
		 * All strings. */
		if (strchr(yesstr, kbinput) != NULL)
		    ok = 1;
		else if (strchr(nostr, kbinput) != NULL)
		    ok = 0;
		else if (all && strchr(allstr, kbinput) != NULL)
		    ok = 2;
	}
    } while (ok == -2);

    currmenu = oldmenu;
    return ok;
}
コード例 #14
0
ファイル: interface.c プロジェクト: albertoCaroM/cgdb
/* Updates the status bar */
static void update_status_win(void)
{
    int pos;
    char filename[FSUTIL_PATH_MAX];
    int attr;

    if (hl_groups_get_attr(hl_groups_instance, HLG_STATUS_BAR, &attr) == -1)
        return;

    /* Update the tty status bar */
    if (tty_win_on) {
        wattron(tty_status_win, attr);
        for (pos = 0; pos < WIDTH; pos++)
            mvwprintw(tty_status_win, 0, pos, " ");

        mvwprintw(tty_status_win, 0, 0, (char *) tgdb_tty_name(tgdb));
        wattroff(tty_status_win, attr);
    }

    /* Print white background */
    wattron(status_win, attr);
    for (pos = 0; pos < WIDTH; pos++)
        mvwprintw(status_win, 0, pos, " ");
    if (tty_win_on)
        wattron(tty_status_win, attr);
    /* Show the user which window is focused */
    if (focus == GDB)
        mvwprintw(status_win, 0, WIDTH - 1, "*");
    else if (focus == TTY && tty_win_on)
        mvwprintw(tty_status_win, 0, WIDTH - 1, "*");
    else if (focus == CGDB || focus == CGDB_STATUS_BAR)
        mvwprintw(status_win, 0, WIDTH - 1, " ");
    wattroff(status_win, attr);
    if (tty_win_on)
        wattroff(tty_status_win, attr);

    /* Print the regex that the user is looking for Forward */
    if (focus == CGDB_STATUS_BAR && sbc_kind == SBC_REGEX
            && regex_direction_cur) {
        if_display_message("/", WIDTH - 1, "%s", ibuf_get(regex_cur));
        curs_set(1);
    }
    /* Regex backwards */
    else if (focus == CGDB_STATUS_BAR && sbc_kind == SBC_REGEX) {
        if_display_message("?", WIDTH - 1, "%s", ibuf_get(regex_cur));
        curs_set(1);
    }
    /* A colon command typed at the status bar */
    else if (focus == CGDB_STATUS_BAR && sbc_kind == SBC_NORMAL) {
        char *command = ibuf_get(cur_sbc);

        if (!command)
            command = "";
        if_display_message(":", WIDTH - 1, "%s", command);
        curs_set(1);
    }
    /* Default: Current Filename */
    else {
        /* Print filename */
        if (src_win != NULL && source_current_file(src_win, filename) != NULL)
            if_display_message("", WIDTH - 1, "%s", filename);
    }

    wrefresh(status_win);
}
コード例 #15
0
ファイル: prompt.c プロジェクト: h4ck3rm1k3/toxic
static void prompt_onDraw(ToxWindow *self, Tox *m)
{
    int x2, y2;
    getmaxyx(self->window, y2, x2);

    ChatContext *ctx = self->chatwin;

    line_info_print(self);
    wclear(ctx->linewin);

    curs_set(1);

    if (ctx->len > 0)
        mvwprintw(ctx->linewin, 1, 0, "%ls", &ctx->line[ctx->start]);

    StatusBar *statusbar = self->stb;
    mvwhline(statusbar->topline, 1, 0, ACS_HLINE, x2);
    wmove(statusbar->topline, 0, 0);

    if (statusbar->is_online) {
        int colour = WHITE;
        const uint8_t *status_text = "Unknown";

        switch (statusbar->status) {
            case TOX_USERSTATUS_NONE:
                status_text = "Online";
                colour = GREEN;
                break;

            case TOX_USERSTATUS_AWAY:
                status_text = "Away";
                colour = YELLOW;
                break;

            case TOX_USERSTATUS_BUSY:
                status_text = "Busy";
                colour = RED;
                break;

            case TOX_USERSTATUS_INVALID:
                status_text = "ERROR";
                colour = MAGENTA;
                break;
        }

        wattron(statusbar->topline, COLOR_PAIR(colour) | A_BOLD);
        wprintw(statusbar->topline, " [%s]", status_text);
        wattroff(statusbar->topline, COLOR_PAIR(colour) | A_BOLD);

        wattron(statusbar->topline, A_BOLD);
        wprintw(statusbar->topline, " %s", statusbar->nick);
        wattroff(statusbar->topline, A_BOLD);
    } else {
        wprintw(statusbar->topline, "[Offline]");
        wattron(statusbar->topline, A_BOLD);
        wprintw(statusbar->topline, " %s ", statusbar->nick);
        wattroff(statusbar->topline, A_BOLD);
    }

    if (statusbar->statusmsg[0])
        wprintw(statusbar->topline, " - %s", statusbar->statusmsg);

    mvwhline(self->window, y2 - CHATBOX_HEIGHT, 0, ACS_HLINE, x2);

    int y, x;
    getyx(self->window, y, x);
    int new_x = ctx->start ? x2 - 1 : ctx->pos;
    wmove(self->window, y + 1, new_x);

    if (self->help->active) {
        wrefresh(self->window);
        help_onDraw(self);
    }
}
コード例 #16
0
int sel_dest(void)
{
	int c, r;
	char h, l;
	unsigned int k_ch;
	
	c = (curchar / 16);
	r = (curchar % 16);

	for(;;)
	{

		curchar = r + (c*16);
		
		display(curchar);
		
		h = ((mvwinch(set_win,(r+1),((c*2)+1))) & A_CHARTEXT);
		l = ((mvwinch(set_win,(r+1),((c*2)+2))) & A_CHARTEXT);
		wattron(set_win,A_UNDERLINE);
		mvwprintw(set_win,(r+1),((c*2)+1),"%c%c",h,l);
		wattroff(set_win,A_UNDERLINE);		
		wmove(set_win,(r+1),((c*2)+1));
		wrefresh(set_win);

		k_ch = wgetch(set_win);
		
		switch(k_ch)
		{
			case K_LEFT:
			case KEY_LEFT:
				if(c > 0)
				{
					normal_uset(r,c);
					c--;
				}
				break;

			case K_DOWN:
			case KEY_DOWN:
				if(r < 15)
				{
					normal_uset(r,c);
					r++;
				}
				break;

			case K_UP:
			case KEY_UP:
				if(r > 0)
				{
					normal_uset(r,c);
					r--;
				}
				break;

			case K_RIGHT:
			case KEY_RIGHT:
				if(c < 15)
				{
					normal_uset(r,c);
					c++;
				}
				break;
				
			case '\r':
			case '\n':
				normal_uset(r,c);
				return(r + (c*16));

			case 0x0c:
				wrefresh(curscr);
				break;
			
			default:
				normal_uset(r,c);			
				return(-1);
		}
	}
}
コード例 #17
0
ファイル: trilobite.cpp プロジェクト: kirbyUK/trilobite
//Creates an input box that allows the user to enter a string and returns it:
std::string inputBox()
{
    //Initialises the colour pairs:
    init_pair(4, COLOR_WHITE, COLOUR);
    init_pair(5, COLOR_WHITE, COLOR_RED);

    //Resize the input box:
    inputbox.width = screenX / 2;
    inputbox.height = screenY / 4;
    inputbox.x = ((screenX / 2) - (inputbox.width / 2));
    inputbox.y = ((screenY / 2) - (inputbox.height / 2));
    inputbox.window = newwin(inputbox.height, inputbox.width, inputbox.y, inputbox.x);

    //Set the background:
    wbkgd(inputbox.window, COLOR_PAIR(4));

    //The start position of the text entry box:
    unsigned int boxX = 2;
    unsigned int boxY = 2;
    unsigned int boxWidth = inputbox.width - 4;

    //The position of the buttons:
    unsigned int button1X = (inputbox.width / 4) - 2;
    unsigned int button2X = ((inputbox.width / 4) * 3) - 3;
    unsigned int buttonY = inputbox.height - 2;

    int input = 0, selection = 0;
    std::string inputStr = "";

    //The loop is indefinite, and ends when the user
    //presses '<OK>' or '<CANCEL>':
    while(1)
    {
        //Colours the text entry box red:
        mvwchgat(inputbox.window, boxX, boxY, boxWidth, A_NORMAL, 5, NULL);

        //Prints the text the user has entered:
        wattron(inputbox.window, COLOR_PAIR(5));
        mvwprintw(inputbox.window, boxY, boxX, "%s", inputStr.c_str());
        wattroff(inputbox.window, COLOR_PAIR(5));

        //Checks and highlights what area is currently selected:
        switch(selection)
        {
        //The text box:
        case 0:
            curs_set(1);
            mvwprintw(inputbox.window, buttonY, button1X, "%s", "<OK>");
            mvwprintw(inputbox.window, buttonY, button2X, "%s", "<CANCEL>");
            wmove(inputbox.window, boxY, (boxX + inputStr.size()));
            break;

        //The '<OK>' button:
        case 1:
            curs_set(0);
            wattron(inputbox.window, COLOR_PAIR(5));
            mvwprintw(inputbox.window, buttonY, button1X, "%s", "<OK>");
            wattroff(inputbox.window, COLOR_PAIR(5));
            mvwprintw(inputbox.window, buttonY, button2X, "%s", "<CANCEL>");
            break;

        //The '<CANCEL>' button:
        case 2:
            curs_set(0);
            wattron(inputbox.window, COLOR_PAIR(5));
            mvwprintw(inputbox.window, buttonY, button2X, "%s", "<CANCEL>");
            wattroff(inputbox.window, COLOR_PAIR(5));
            mvwprintw(inputbox.window, buttonY, button1X, "%s", "<OK>");
            break;
        }

        //Refreshes the inputbox:
        wrefresh(inputbox.window);

        //Gets the input to check for the Tab key:
        input = getch();

        //If the input is tab, change the selection:
        if(char(input) == '\t')
        {
            switch(selection)
            {
            case 0:
                selection = 1;
                break;
            case 1:
                selection = 2;
                break;
            case 2:
                selection = 0;
                break;
            default:
                selection = 0;
            }
        }
        //If the input is Enter, close the box and
        //return a value based on the selection:
        else if(char(input) == '\n')
        {
            switch(selection)
            {
            //The user has clicked '<OK>', return the
            //contents of the text box:
            case 1:
                wclear(inputbox.window);
                wrefresh(inputbox.window);
                if(inputStr.size() == 0) return NULL;
                else return inputStr;
                break;

            //The user has clicked '<CANCEL>', return
            //nothing:
            case 2:
                wclear(inputbox.window);
                wrefresh(inputbox.window);
                return "";
                break;
            }
        }
        //If the user has pressed backspace, attempt to delete some of the input:
        else if((input == KEY_BACKSPACE) || (input == KEY_DC))
        {
            //If we're editing the input, backspace deletes a character off the end:
            if((selection == 0) && (inputStr.length() > 0))
            {
                inputStr.erase(inputStr.length() - 1);

                //Clear the box and redraw it:
                wclear(inputbox.window);
                wbkgd(inputbox.window, COLOR_PAIR(4));
            }
        }
        else
            //Otherwise, check if the input is an alphanumeric character, and if so,
            //add it to the end of our input string:
            if(isValidInput(input) && (selection == 0))
                inputStr += input;
    }
}
コード例 #18
0
ファイル: friendlist.c プロジェクト: Jman012/toxic
static void friendlist_onDraw(ToxWindow *self, Tox *m)
{
    curs_set(0);
    werase(self->window);
    int x2, y2;
    getmaxyx(self->window, y2, x2);

    bool fix_statuses = x2 != self->x;    /* true if window x axis has changed */

    wattron(self->window, COLOR_PAIR(CYAN));
    wprintw(self->window, " Open a chat window with the");
    wattron(self->window, A_BOLD);
    wprintw(self->window, " Enter ");
    wattroff(self->window, A_BOLD);
    wprintw(self->window, "key. Delete a friend with the");
    wattron(self->window, A_BOLD);
    wprintw(self->window, " Delete ");
    wattroff(self->window, A_BOLD);
    wprintw(self->window, "key.\n\n");
    wattroff(self->window, COLOR_PAIR(CYAN));

    wattron(self->window, A_BOLD);
    wprintw(self->window, " Online: %d/%d \n\n", tox_get_num_online_friends(m), num_friends);
    wattroff(self->window, A_BOLD);

    if ((y2 - FLIST_OFST) <= 0)    /* don't allow division by zero */
        return;

    /* Determine which portion of friendlist to draw based on current position */
    int page = num_selected / (y2 - FLIST_OFST);
    int start = (y2 - FLIST_OFST) * page;
    int end = y2 - FLIST_OFST + start;

    int i;

    for (i = start; i < num_friends && i < end; ++i) {
        int f = friendlist_index[i];
        bool f_selected = false;

        if (friends[f].active) {
            if (i == num_selected) {
                wattron(self->window, A_BOLD);
                wprintw(self->window, " > ");
                wattroff(self->window, A_BOLD);
                f_selected = true;
            } else {
                wprintw(self->window, "   ");
            }
            
            if (friends[f].online) {
                TOX_USERSTATUS status = friends[f].status;
                int colour = WHITE;

                switch (status) {
                case TOX_USERSTATUS_NONE:
                    colour = GREEN;
                    break;
                case TOX_USERSTATUS_AWAY:
                    colour = YELLOW;
                    break;
                case TOX_USERSTATUS_BUSY:
                    colour = RED;
                    break;
                }

                wprintw(self->window, "[");
                wattron(self->window, COLOR_PAIR(colour) | A_BOLD);
                wprintw(self->window, "O");
                wattroff(self->window, COLOR_PAIR(colour) | A_BOLD);
                wprintw(self->window, "]");

                if (f_selected)
                    wattron(self->window, A_BOLD);

                wprintw(self->window, "%s", friends[f].name);

                if (f_selected)
                    wattroff(self->window, A_BOLD);

                /* Reset friends[f].statusmsg on window resize */
                if (fix_statuses) {
                    uint8_t statusmsg[TOX_MAX_STATUSMESSAGE_LENGTH] = {'\0'};
                    tox_get_status_message(m, friends[f].num, statusmsg, TOX_MAX_STATUSMESSAGE_LENGTH);
                    snprintf(friends[f].statusmsg, sizeof(friends[f].statusmsg), "%s", statusmsg);
                    friends[f].statusmsg_len = tox_get_status_message_size(m, f);
                }

                /* Truncate note if it doesn't fit on one line */
                uint16_t maxlen = x2 - getcurx(self->window) - 4;
                if (friends[f].statusmsg_len > maxlen) {
                    friends[f].statusmsg[maxlen-3] = '\0';
                    strcat(friends[f].statusmsg, "...");
                    friends[f].statusmsg[maxlen] = '\0';
                    friends[f].statusmsg_len = maxlen;
                }

                wprintw(self->window, " (%s)\n", friends[f].statusmsg);
            } else {
                wprintw(self->window, "[");
                wattron(self->window, A_BOLD);
                wprintw(self->window, "O");
                wattroff(self->window, A_BOLD);
                wprintw(self->window, "]");

                if (f_selected)
                    wattron(self->window, A_BOLD);

                wprintw(self->window, "%s\n", friends[f].name);

                if (f_selected)
                    wattroff(self->window, A_BOLD);
            }
        }
    }

    self->x = x2;
    wrefresh(self->window);
    draw_popup(self, m);
}
コード例 #19
0
ファイル: main.c プロジェクト: d5h/gah
static void
show_hex(void)
{
  size_t histart = absoff, histop = histart + cursan->len;
  size_t a = offset;
  size_t r;
  int hi = 0;

  if (cursan == top)
    histart = histop = 0;

  wmove(whex, 1, 1);
  for (r = 0; r < rows; ++r)
    {
      size_t start = a;
      size_t c;

      if (start < data_size)
	wprintw(whex, "%08X", start);
      else
	wprintw(whex, "        ");

      for (c = 0; c < columns; ++a, ++c)
	{
	  if (hi && histop <= a)
	    {
	      wattroff(whex, COLOR_PAIR(HIGHLIGHT));
	      hi = 0;
	    }

	  if (c % 4 == 0)
	    wprintw(whex, " ");

	  wprintw(whex, " ");
	  if (a == offset + cursor)
	    wattron(whex, A_REVERSE);
	  if (! hi && histart <= a && a < histop)
	    {
	      wattron(whex, COLOR_PAIR(HIGHLIGHT));
	      hi = 1;
	    }

	  if (a < data_size)
	    wprintw(whex, "%02X", data[a]);
	  else
	    wprintw(whex, "  ");

	  if (a == offset + cursor)
	    wattroff(whex, A_REVERSE);
	}

      if (hi)
	{
	  wattroff(whex, COLOR_PAIR(HIGHLIGHT));
	  hi = 0;
	}
      wprintw(whex, "  ");
      a = start;
      for (c = 0; c < columns; ++a, ++c)
	{
	  if (hi && histop <= a)
	    {
	      wattroff(whex, COLOR_PAIR(HIGHLIGHT));
	      hi = 0;
	    }

	  if (a == offset + cursor)
	    wattron(whex, A_REVERSE);
	  if (! hi && histart <= a && a < histop)
	    {
	      wattron(whex, COLOR_PAIR(HIGHLIGHT));
	      hi = 1;
	    }

	  if (data_size < start)
	    wprintw(whex, " ");
	  else if (a < data_size)
	    wprintw(whex, "%c", isprint(data[a]) ? data[a] : unprintable);
	  else
	    wprintw(whex, "%c", nodata);

	  if (a == offset + cursor)
	    wattroff(whex, A_REVERSE);
	}

      if (hi)
	{
	  wattroff(whex, COLOR_PAIR(HIGHLIGHT));
	  hi = 0;
	}

      wmove(whex, r + 2, 1);
    }

  curs_set(0);
  wrefresh(whex);
}
コード例 #20
0
ファイル: curses++.cpp プロジェクト: lycantrophe/Curses--
cursesxx::Format::~Format() {
    wattroff( this->win, this->bitmask );
}
コード例 #21
0
ファイル: ui.c プロジェクト: nwaldispuehl/goaccess
/* render general statistics */
void
display_general (WINDOW * win, char *ifile, GLog * logger)
{
  char *bw, *size, *log_file;
  char *failed, *not_found, *process, *ref, *req;
  char *static_files, *now, *visitors, *exclude_ip;

  int x_field = 2, x_value = 0;
  size_t n, i, j, max_field = 0, max_value = 0, mod_val, y;

  typedef struct Field_
  {
    const char *field;
    char *value;                /* char due to log, bw, log_file */
    int color;
  } Field;

  Field fields[] = {
    {T_REQUESTS, NULL, COL_CYAN},
    {T_UNIQUE_VIS, NULL, COL_CYAN},
    {T_REFERRER, NULL, COL_CYAN},
    {T_LOG, NULL, COL_CYAN},
    {T_F_REQUESTS, NULL, COL_CYAN},
    {T_UNIQUE_FIL, NULL, COL_CYAN},
    {T_UNIQUE404, NULL, COL_CYAN},
    {T_BW, NULL, COL_CYAN},
    {T_GEN_TIME, NULL, COL_CYAN},
    {T_EXCLUDE_IP, NULL, COL_CYAN},
    {T_STATIC_FIL, NULL, COL_CYAN},
    {T_LOG_PATH, NULL, COL_YELLOW}
  };

  werase (win);
  draw_header (win, T_HEAD, " %s", 0, 0, getmaxx (stdscr), 1, 0);

  if (!logger->piping && ifile != NULL) {
    size = filesize_str (file_size (ifile));
    log_file = alloc_string (ifile);
  } else {
    size = alloc_string ("N/A");
    log_file = alloc_string ("STDIN");
  }
  bw = filesize_str ((float) logger->resp_size);

  /* *INDENT-OFF* */
  failed       = int_to_str (logger->invalid);
  not_found    = int_to_str (get_ht_size (ht_not_found_requests));
  process      = int_to_str (logger->process);
  ref          = int_to_str (get_ht_size (ht_referrers));
  req          = int_to_str (get_ht_size(ht_requests));
  static_files = int_to_str (get_ht_size(ht_requests_static));
  now          = int_to_str (((long long) end_proc - start_proc));
  visitors     = int_to_str (get_ht_size(ht_unique_visitors));
  exclude_ip    = int_to_str (logger->exclude_ip);

  fields[0].value = process;
  fields[1].value = visitors;
  fields[2].value = ref;
  fields[3].value = size;
  fields[4].value = failed;
  fields[5].value = req;
  fields[6].value = not_found;
  fields[7].value = bw;
  fields[8].value = now;
  fields[9].value = exclude_ip;
  fields[10].value = static_files;
  fields[11].value = log_file;

  n = ARRAY_SIZE (fields);

  /* *INDENT-ON* */
  for (i = 0, y = 2; i < n; i++) {
    mod_val = i % 4;
    if (i > 0 && mod_val == 0) {
      max_field = 0;
      max_value = 0;
      x_field = 2;
      x_value = 2;
      y++;
    }

    x_field += max_field;
    mvwprintw (win, y, x_field, "%s", fields[i].field);

    max_field = 0;
    for (j = 0; j < n; j++) {
      size_t len = strlen (fields[j].field);
      if (j % 4 == mod_val && len > max_field)
        max_field = len;
    }

    max_value = 0;
    for (j = 0; j < n; j++) {
      size_t len = strlen (fields[j].value);
      if (j % 4 == mod_val && len > max_value)
        max_value = len;
    }
    x_value = max_field + x_field + 1;
    max_field += max_value + 2;

    wattron (win, A_BOLD | COLOR_PAIR (fields[i].color));
    mvwprintw (win, y, x_value, "%s", fields[i].value);
    wattroff (win, A_BOLD | COLOR_PAIR (fields[i].color));
  }
  for (i = 0; i < n; i++) {
    free (fields[i].value);
  }
}
コード例 #22
0
ファイル: intrface.c プロジェクト: dennyfeng/testdisk
static list_part_t *ask_structure_ncurses(disk_t *disk_car,list_part_t *list_part, const int verbose, char **current_cmd)
{
  int offset=0;
  int pos_num=0;
  list_part_t *pos=list_part;
  int rewrite=1;
  int old_LINES=LINES;
  while(1)
  {
    int i;
    int command;
    list_part_t *parts;
    int structure_status;
    if(old_LINES!=LINES)
    {
      rewrite=1;
      old_LINES=LINES;
    }
    if(rewrite)
    {
      aff_copy(stdscr);
      wmove(stdscr,4,0);
      wprintw(stdscr,"%s",disk_car->description(disk_car));
      mvwaddstr(stdscr,5,0,msg_PART_HEADER);
      rewrite=0;
    }
    structure_status=disk_car->arch->test_structure(list_part);
    for(i=0,parts=list_part;
	parts!=NULL && i<offset+INTER_STRUCTURE;
	i++, parts=parts->next)
    {
      if(i<offset)
	continue;
      wmove(stdscr,6+i-offset,0);
      wclrtoeol(stdscr);	/* before addstr for BSD compatibility */
      if(parts==pos)
	wattrset(stdscr, A_REVERSE);
      if(structure_status==0 && parts->part->status!=STATUS_DELETED && has_colors())
	wbkgdset(stdscr,' ' | COLOR_PAIR(2));
      if(parts==pos)
	waddstr(stdscr, ">");
      else
	waddstr(stdscr, " ");
      aff_part(stdscr, AFF_PART_STATUS, disk_car, parts->part);
      if(structure_status==0 && parts->part->status!=STATUS_DELETED && has_colors())
	wbkgdset(stdscr,' ' | COLOR_PAIR(0));
      if(parts==pos)
      {
	char buffer_part_size[100];
	wattroff(stdscr, A_REVERSE);
	wmove(stdscr,LINES-1,0);
	wclrtoeol(stdscr);	/* before addstr for BSD compatibility */
	if(parts->part->info[0]!='\0')
	{
	  wprintw(stdscr,"%s, ",parts->part->info);
	}
	size_to_unit(parts->part->part_size, buffer_part_size);
	wprintw(stdscr,"%s", buffer_part_size);
      }
    }
    if(structure_status==0)
    {
      if(list_part!=NULL)
	mvwaddstr(stdscr,LINES-6,0,msg_STRUCT_OK);
    }
    else
    {
      if(has_colors())
	wbkgdset(stdscr,' ' | A_BOLD | COLOR_PAIR(1));
      mvwaddstr(stdscr,LINES-6,0,msg_STRUCT_BAD);
      if(has_colors())
	wbkgdset(stdscr,' ' | COLOR_PAIR(0));
    }
    if(list_part!=NULL && disk_car->arch->msg_part_type!=NULL)
    {
      mvwaddstr(stdscr,LINES-6,16,"Use ");
      if(has_colors())
	wbkgdset(stdscr,' ' | A_BOLD | COLOR_PAIR(0));
      waddstr(stdscr,"Up");
      if(has_colors())
	wbkgdset(stdscr,' ' | COLOR_PAIR(0));
      waddstr(stdscr,"/");
      if(has_colors())
	wbkgdset(stdscr,' ' | A_BOLD | COLOR_PAIR(0));
      waddstr(stdscr,"Down");
      if(has_colors())
	wbkgdset(stdscr,' ' | COLOR_PAIR(0));
      waddstr(stdscr," Arrow keys to select partition.");
      mvwaddstr(stdscr,LINES-5,0,"Use ");
      if(has_colors())
	wbkgdset(stdscr,' ' | A_BOLD | COLOR_PAIR(0));
      waddstr(stdscr,"Left");
      if(has_colors())
	wbkgdset(stdscr,' ' | COLOR_PAIR(0));
      waddstr(stdscr,"/");
      if(has_colors())
	wbkgdset(stdscr,' ' | A_BOLD | COLOR_PAIR(0));
      waddstr(stdscr,"Right");
      if(has_colors())
	wbkgdset(stdscr,' ' | COLOR_PAIR(0));
      waddstr(stdscr," Arrow keys to CHANGE partition characteristics:");
      mvwaddstr(stdscr,LINES-4,0,disk_car->arch->msg_part_type);
    }
    wmove(stdscr,LINES-3,0);
    wclrtoeol(stdscr);	/* before addstr for BSD compatibility */
    waddstr(stdscr,"Keys ");
    /* If the disk can't be partionned, there is no partition to add and no partition to save */
    if(disk_car->arch != &arch_none)
    {
      if(has_colors())
	wbkgdset(stdscr,' ' | A_BOLD | COLOR_PAIR(0));
      waddstr(stdscr,"A");
      if(has_colors())
	wbkgdset(stdscr,' ' | COLOR_PAIR(0));
      waddstr(stdscr,": add partition, ");
      if(has_colors())
	wbkgdset(stdscr,' ' | A_BOLD | COLOR_PAIR(0));
      waddstr(stdscr,"L");
      if(has_colors())
	wbkgdset(stdscr,' ' | COLOR_PAIR(0));
      waddstr(stdscr,": load backup, ");
    }
    if(list_part==NULL)
    {
      waddstr(stdscr,"Enter: to continue");
    }
    else
    {
      if(pos->part->arch==NULL || pos->part->arch==disk_car->arch)
      {
	if(has_colors())
	  wbkgdset(stdscr,' ' | A_BOLD | COLOR_PAIR(0));
	waddstr(stdscr,"T");
	if(has_colors())
	  wbkgdset(stdscr,' ' | COLOR_PAIR(0));
	waddstr(stdscr,": change type, ");
      }
      switch(pos->part->upart_type)
      {
	case UP_EXFAT:
	case UP_EXT2:
	case UP_EXT3:
	case UP_EXT4:
	case UP_RFS:
	case UP_RFS2:
	case UP_RFS3:
	case UP_FAT12:
	case UP_FAT16:
	case UP_FAT32:
	case UP_NTFS:
	  if(has_colors())
	    wbkgdset(stdscr,' ' | A_BOLD | COLOR_PAIR(0));
	  waddstr(stdscr,"P");
	  if(has_colors())
	    wbkgdset(stdscr,' ' | COLOR_PAIR(0));
	  waddstr(stdscr,": list files, ");
	  break;
	default:
	  break;
      }
      if(has_colors())
	wbkgdset(stdscr,' ' | A_BOLD | COLOR_PAIR(0));
      mvwaddstr(stdscr,LINES-2,5, "Enter");
      if(has_colors())
	wbkgdset(stdscr,' ' | COLOR_PAIR(0));
      waddstr(stdscr,": to continue");
    }
    wrefresh(stdscr);
    command=wgetch(stdscr);
    switch(command)
    {
      case KEY_UP:
	if(list_part!=NULL)
	{
	  only_one_bootable(list_part,pos);
	  if(pos->prev!=NULL)
	  {
	    pos=pos->prev;
	    pos_num--;
	  }
	}
	break;
      case KEY_DOWN:
	if(list_part!=NULL)
	{
	  only_one_bootable(list_part,pos);
	  if(pos->next!=NULL)
	  {
	    pos=pos->next;
	    pos_num++;
	  }
	}
	break;
      case KEY_PPAGE:
	if(list_part!=NULL)
	{
	  only_one_bootable(list_part,pos);
	  for(i=0; i<INTER_STRUCTURE && pos->prev!=NULL; i++)
	  {
	    pos=pos->prev;
	    pos_num--;
	  }
	}
	break;
      case KEY_NPAGE:
	if(list_part!=NULL)
	{
	  only_one_bootable(list_part,pos);
	  for(i=0; i<INTER_STRUCTURE && pos->next!=NULL; i++)
	  {
	    pos=pos->next;
	    pos_num++;
	  }
	}
	break;
      case KEY_RIGHT:
      case '+':
      case ' ':
	if(list_part!=NULL)
	{
	  if(pos->part->arch==NULL || pos->part->arch==disk_car->arch)
	    disk_car->arch->set_next_status(disk_car,pos->part);
	}
	break;
      case KEY_LEFT:
      case '-':
	if(list_part!=NULL)
	{
	  if(pos->part->arch==NULL || pos->part->arch==disk_car->arch)
	    disk_car->arch->set_prev_status(disk_car,pos->part);
	}
	break;
      case 'a':
      case 'A':
	if(disk_car->arch != &arch_none)
	{
	  list_part=add_partition_ncurses(disk_car, list_part);
	  rewrite=1;
	  offset=0;
	  pos_num=0;
	  pos=list_part;
	}
	break;
      case 't':
      case 'T':
	if(list_part!=NULL)
	{
	  rewrite=1;
	  change_part_type_ncurses(disk_car, pos->part);
	}
	break;
      case 'p':
      case 'P':
	if(list_part!=NULL)
        {
          const partition_t *partition=pos->part;
          if(partition->sb_offset==0 || partition->sb_size==0)
            dir_partition(disk_car,partition,verbose, current_cmd);
          else
          {
            io_redir_add_redir(disk_car,
                partition->part_offset+partition->sborg_offset,
                partition->sb_size,
                partition->part_offset+partition->sb_offset,
                NULL);
            dir_partition(disk_car,partition,verbose, current_cmd);
            io_redir_del_redir(disk_car, partition->part_offset+partition->sborg_offset);
          }
	  rewrite=1;
        }
	break;
      case 'b':
      case 'B':
	if(partition_save(disk_car,list_part,verbose)<0)
	  display_message("Can't create backup.log.\n");
	else
	  display_message("Results saved in backup.log.\n");
	rewrite=1;
        break;
      case 'l':
      case 'L':
	if(disk_car->arch != &arch_none)
	{
	  list_part=interface_load(disk_car,list_part,verbose);
	  rewrite=1;
	  offset=0;
	  pos_num=0;
	  pos=list_part;
	}
        break;
      case 'q':
      case '\r':
      case '\n':
      case KEY_ENTER:
#ifdef PADENTER
      case PADENTER:
#endif
      case 'M':
	return list_part;
      default:
/*	log_trace("ask_structure command=%x\n",command); */
	break;
    }
    if(pos_num<offset)
      offset=pos_num;
    if(pos_num>=offset+INTER_STRUCTURE)
      offset=pos_num-INTER_STRUCTURE+1;
  }
}
コード例 #23
0
ファイル: line_info.c プロジェクト: fars/toxic
void line_info_print(ToxWindow *self)
{
    ChatContext *ctx = self->chatwin;

    if (ctx == NULL)
        return;

    struct history *hst = ctx->hst;

    /* Only allow one new item to be added to chat window per call to this function */
    line_info_check_queue(self);

    WINDOW *win = ctx->history;
    wclear(win);
    int y2, x2;
    getmaxyx(self->window, y2, x2);

    if (x2 <= SIDEBAR_WIDTH)
        return;

    if (self->is_groupchat)
        wmove(win, 0, 0);
    else
        wmove(win, 2, 0);

    struct line_info *line = hst->line_start->next;
    int numlines = 0;

    while (line && numlines++ <= y2) {
        uint8_t type = line->type;

        switch (type) {
            case OUT_MSG:
            case IN_MSG:
                wattron(win, COLOR_PAIR(BLUE));
                wprintw(win, "%s", line->timestamp);
                wattroff(win, COLOR_PAIR(BLUE));

                int nameclr = GREEN;

                if (line->colour)
                    nameclr = line->colour;
                else if (type == IN_MSG)
                    nameclr = CYAN;

                wattron(win, COLOR_PAIR(nameclr));
                wprintw(win, "%s: ", line->name1);
                wattroff(win, COLOR_PAIR(nameclr));

                if (line->msg[0] == '>')
                    wattron(win, COLOR_PAIR(GREEN));

                wprintw(win, "%s\n", line->msg);

                if (line->msg[0] == '>')
                    wattroff(win, COLOR_PAIR(GREEN));

                break;

            case ACTION:
                wattron(win, COLOR_PAIR(BLUE));
                wprintw(win, "%s", line->timestamp);
                wattroff(win, COLOR_PAIR(BLUE));

                wattron(win, COLOR_PAIR(YELLOW));
                wprintw(win, "* %s %s\n", line->name1, line->msg);
                wattroff(win, COLOR_PAIR(YELLOW));

                break;

            case SYS_MSG:
                if (line->timestamp[0]) {
                    wattron(win, COLOR_PAIR(BLUE));
                    wprintw(win, "%s", line->timestamp);
                    wattroff(win, COLOR_PAIR(BLUE));
                }

                if (line->bold)
                    wattron(win, A_BOLD);

                if (line->colour)
                    wattron(win, COLOR_PAIR(line->colour));

                wprintw(win, "%s\n", line->msg);

                if (line->bold)
                    wattroff(win, A_BOLD);

                if (line->colour)
                    wattroff(win, COLOR_PAIR(line->colour));

                break;

            case PROMPT:
                wattron(win, COLOR_PAIR(GREEN));
                wprintw(win, "$ ");
                wattroff(win, COLOR_PAIR(GREEN));

                if (line->msg[0])
                    wprintw(win, "%s", line->msg);

                wprintw(win, "\n");
                break;

            case CONNECTION:
                wattron(win, COLOR_PAIR(BLUE));
                wprintw(win, "%s", line->timestamp);
                wattroff(win, COLOR_PAIR(BLUE));

                wattron(win, COLOR_PAIR(line->colour));
                wattron(win, A_BOLD);
                wprintw(win, "* %s ", line->name1);
                wattroff(win, A_BOLD);
                wprintw(win, "%s\n", line->msg);
                wattroff(win, COLOR_PAIR(line->colour));

                break;

            case NAME_CHANGE:
                wattron(win, COLOR_PAIR(BLUE));
                wprintw(win, "%s", line->timestamp);
                wattroff(win, COLOR_PAIR(BLUE));

                wattron(win, COLOR_PAIR(MAGENTA));
                wattron(win, A_BOLD);
                wprintw(win, "* %s", line->name1);
                wattroff(win, A_BOLD);

                wprintw(win, "%s", line->msg);

                wattron(win, A_BOLD);
                wprintw(win, "%s\n", line->name2);
                wattroff(win, A_BOLD);
                wattroff(win, COLOR_PAIR(MAGENTA));

                break;
        }

        line = line->next;
    }

    /* keep calling until queue is empty */
    if (hst->queue_sz > 0)
        line_info_print(self);
}
コード例 #24
0
ファイル: tdisksel.c プロジェクト: Tom9X/TestDisk
static int testdisk_disk_selection_ncurses(int verbose,int dump_ind, const list_disk_t *list_disk, const int saveheader, char **current_cmd)
{
  int command='Q';
  unsigned int menu=0;
  int offset=0;
  int pos_num=0;
  int use_sudo=0;
  const list_disk_t *element_disk;
  const list_disk_t *current_disk;
  static struct MenuItem menuMain[]=
  {
    { 'P', "Previous", ""},
    { 'N', "Next", "" },
    { 'O', "Proceed", ""},
    { 'S', "Sudo", "Use the sudo command to restart as root"},
    { 'Q', "Quit", "Quit program"},
    {  0,  NULL, NULL}
  };
  if(list_disk==NULL)
  {
    log_critical("No disk found\n");
    return intrf_no_disk_ncurses("TestDisk");
  }
  current_disk=list_disk;
  /* ncurses interface */
  while(1)
  {
    const char *options;
    int i;
#ifdef HAVE_NCURSES
    aff_copy(stdscr);
    wmove(stdscr,4,0);
    wprintw(stdscr,"  TestDisk is free software, and");
    wmove(stdscr,5,0);
    wprintw(stdscr,"comes with ABSOLUTELY NO WARRANTY.");
    wmove(stdscr,7,0);
    wprintw(stdscr,"Select a media (use Arrow keys, then press Enter):");
#endif
    for(i=0,element_disk=list_disk;
	element_disk!=NULL && i<offset+NBR_DISK_MAX;
	i++, element_disk=element_disk->next)
    {
      if(i<offset)
	continue;
      wmove(stdscr,8+i-offset,0);
      if(element_disk!=current_disk)
	wprintw(stdscr," %s\n",element_disk->disk->description_short(element_disk->disk));
      else
      {
	wattrset(stdscr, A_REVERSE);
	wprintw(stdscr,">%s\n",element_disk->disk->description_short(element_disk->disk));
	wattroff(stdscr, A_REVERSE);
      }
    }
    {
      int line=INTER_NOTE_Y;
      mvwaddstr(stdscr,line++,0,"Note: ");
#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(DJGPP)
#else
#ifdef HAVE_GETEUID
      if(geteuid()!=0)
      {
        if(has_colors())
          wbkgdset(stdscr,' ' | A_BOLD | COLOR_PAIR(1));
        waddstr(stdscr,"Some disks won't appear unless you are root user.");
        if(has_colors())
          wbkgdset(stdscr,' ' | COLOR_PAIR(0));
        wmove(stdscr,line++,0);
#ifdef SUDO_BIN
	use_sudo=1;
#endif
      }
#endif
#endif
      waddstr(stdscr,"Disk capacity must be correctly detected for a successful recovery.");
      wmove(stdscr,line++,0);
      wprintw(stdscr,"If a disk listed above has incorrect size, check HD jumper settings, BIOS");
      wmove(stdscr,line,0);
      wprintw(stdscr,"detection, and install the latest OS patches and disk drivers."); 
    }
    if(use_sudo > 0)
    {
      if(i<=NBR_DISK_MAX && element_disk==NULL)
	options="OSQ";
      else
	options="PNOSQ";
    }
    else
    {
      if(i<=NBR_DISK_MAX && element_disk==NULL)
	options="OQ";
      else
	options="PNOQ";
    }
    command = wmenuSelect_ext(stdscr, INTER_NOTE_Y-1, INTER_DISK_Y, INTER_DISK_X, menuMain, 8,
	options, MENU_HORIZ | MENU_BUTTON | MENU_ACCEPT_OTHERS, &menu,NULL);
    switch(command)
    {
      case 'p':
      case 'P':
      case KEY_UP:
	if(current_disk->prev!=NULL)
	{
	  current_disk=current_disk->prev;
	  pos_num--;
	}
	break;
      case 'n':
      case 'N':
      case KEY_DOWN:
	if(current_disk->next!=NULL)
	{
	  current_disk=current_disk->next;
	  pos_num++;
	}
	break;
      case KEY_PPAGE:
	for(i=0;i<NBR_DISK_MAX-1 && current_disk->prev!=NULL;i++)
	{
	  current_disk=current_disk->prev;
	  pos_num--;
	}
	break;
      case KEY_NPAGE:
	for(i=0;i<NBR_DISK_MAX-1 && current_disk->next!=NULL;i++)
	{
	  current_disk=current_disk->next;
	  pos_num++;
	}
	break;
      case 'o':
      case 'O':
	{
	  disk_t *disk=current_disk->disk;
	  const int hpa_dco=is_hpa_or_dco(disk);
	  autodetect_arch(disk, NULL);
	  autoset_unit(disk);
	  if(interface_check_disk_capacity(disk)==0 &&
              interface_check_disk_access(disk, current_cmd)==0 &&
	      (hpa_dco==0 || interface_check_hidden_ncurses(disk, hpa_dco)==0) &&
	      interface_partition_type(disk, verbose, current_cmd)==0)
	  {
	    if(menu_disk(disk, verbose, dump_ind, saveheader, current_cmd))
	      return 0;
	  }
	}
	break;
      case 's':
      case 'S':
	return 1;
      case 'q':
      case 'Q':
	return 0;
    }
    if(pos_num<offset)
      offset=pos_num;
    if(pos_num>=offset+NBR_DISK_MAX)
      offset=pos_num-NBR_DISK_MAX+1;
  }
}
コード例 #25
0
ファイル: main(3).c プロジェクト: Bencepapa/CymonsGames
void newGame() {
    int i;
    int key;
    int accepted;

    player.x = 2;
    player.y = 2;
    player.level = 1;
    player.race = 0;
    player.is_dead = FALSE;
    player.avatar = "@";
    player.slain = 0;
    player.xp = 0;
    player.xp_earned = 0;
    player.attack_bonus = 1;
    player.armor = 5;

    wclear(win);
    if (has_colors()) {
		init_pair(2, COLOR_WHITE, COLOR_BLUE);
		wbkgd(win, COLOR_PAIR(2) | A_BOLD);
	} else
        wbkgd(win, A_BOLD);

    wclear(win);
	box(win, ACS_VLINE, ACS_HLINE);
	refresh();
    echo();
	mvwaddstr(win, 2, 2, "Character Name (8 letter max): ");
	wgetnstr(win, player.player_name, 8);

    wrefresh(win);
    noecho();
    mvwaddstr(win,3,2,"Race: ");
    for (i = 0; i < MAX_RACES; i++) {
        mvwprintw(win,4+i,4,"[%i] - %s",i+1,races[i].race_name);
    }

    player.race = wgetch(win);
    while (player.race < 49 || player.race > 51) {
        player.race = wgetch(win);
    }

    /*
        Convert the ASCII character number to an index
        by shifting down 49 (makes 1 = 0, 2 = 1, etc.)
    */
    player.race -= 49;
    // Set up basic player data
    player.hp = (int)(races[player.race].start_hp + (player.level / 2));

    // Do the stat rolls now.  If the player doesn't like the
    // rolls with modifiers applied, they can do them over again

    accepted = 0;
    while (accepted == 0) {
        player.str = statRoll(races[player.race].max_str);
        player.def = statRoll(races[player.race].max_def);
        player.agi = statRoll(races[player.race].max_agi);

        wclear(win);
        box(win, ACS_VLINE, ACS_HLINE);
        mvwprintw(win,2,2,"%s - %s", player.player_name,races[player.race].race_name);

        mvwprintw(win,4,15,"STR: %i",player.str);
        mvwprintw(win,5,15,"DEF: %i",player.def);
        mvwprintw(win,6,15,"AGI: %i",player.agi);

        wattrset(win,A_REVERSE);
        mvwprintw(win,10,15,"Enter/Space: Roll Again\tA - Accept Character");
        wattroff(win,A_REVERSE);

        flushinp();
        wrefresh(win);
        noecho();
        keypad(win, TRUE);
        raw();

        key = wgetch(win);

        switch(key) {
            case 10:
            case 13:
            case ' ':
            case KEY_ENTER:
                accepted = 0;
                break;
            case 'a':
            case 'A':
                accepted = 1;
                break;
        }

    }

    clearPlay();
    mvwprintw(win,4,15,"Generating Dungeon...");
    wrefresh(win);
    buildMap();

    /*
        Resize the main window so we can use it
        as the gameplay area.
    */
    resize_window(win,20,60);

    drawPlayArea();
    drawStatsArea();
    gameLoop();
}
コード例 #26
0
void print_menu(WINDOW *menu_win, int highlight, int nphighlight)
{
	int x, y, i=0,z=0,start;
	char name[200];
	x = 0;
	y = 2;
	for(i=0;i<n_choices;i++)
	{	
		start_color();
		init_pair(1,COLOR_CYAN, COLOR_BLACK);
		for (z=0;z<strlen(choices[i]);z++)
		{
			if (choices[i][z]=='/')
				start =z+1;
		}
		for(z=0;z<200;z++)
		{
			while(choices[i][z]!='\0')
			{
				name[z]=choices[i][start++];
				z++;
			}
			name[z]='\0';
		}
		if(i == curr_song)  /* High light the present choice */
		{	
			if(highlight != i+1)
			{
				wattron(menu_win, A_BOLD | COLOR_PAIR(1));
				mvwprintw(menu_win, y, 0, "> %s",name);
				wattroff(menu_win, A_BOLD | COLOR_PAIR(1));
			}
			else
			{
				wattron(menu_win, A_BOLD | A_REVERSE | COLOR_PAIR(1));
				mvwprintw(menu_win, y, 0, "> %s",name);
				wattroff(menu_win, A_BOLD | A_REVERSE | COLOR_PAIR(1));
			}

		}
		else if (highlight == i+1)
		{
			wattron(menu_win, A_REVERSE);
			mvwprintw(menu_win, y, 0, "  %s", name);
			wattroff(menu_win, A_REVERSE);
		}
		else
				mvwprintw(menu_win, y, 0, "  %s", name);
		++y;
	}
	y+=6;
	for(i = 0; i < npn_choices; ++i)
	{	
		if (i>0)
		{
			x += strlen(npchoices[i-1])+2;
		}
		if(nphighlight == i + 1) /* High light the present choice */
		{	
			wattron(menu_win, A_REVERSE);
			mvwprintw(menu_win,y,x, "%s", npchoices[i]);
			wattroff(menu_win, A_REVERSE);
		}
		else
			mvwprintw(menu_win,y,x, "%s", npchoices[i]);

}

wrefresh(menu_win);
}
コード例 #27
0
ファイル: filedlg.c プロジェクト: ArnaudValensi/cgdb
int filedlg_display(struct filedlg *fd)
{
    char fmt[5];
    int width, height;
    int lwidth;
    int file;
    int i;
    int attr;
    static char *label = "Select a file or press q to cancel.";

    curs_set(0);

    /* Check that a file is loaded */
    if (fd == NULL || fd->buf == NULL || fd->buf->files == NULL) {
        wrefresh(fd->win);
        return 0;
    }

    /* Initialize variables */
    getmaxyx(fd->win, height, width);

    /* The status bar and display line 
     * Fake the display function to think the height is 2 lines less */
    height -= 2;

    /* Set starting line number (center source file if it's small enough) */
    if (fd->buf->length < height)
        file = (fd->buf->length - height) / 2;
    else {
        file = fd->buf->sel_line - height / 2;
        if (file > fd->buf->length - height)
            file = fd->buf->length - height;
        else if (file < 0)
            file = 0;
    }

    /* Print 'height' lines of the file, starting at 'file' */
    lwidth = (int) log10(fd->buf->length) + 1;
    sprintf(fmt, "%%%dd", lwidth);

    print_in_middle(fd->win, 0, width, label);
    wmove(fd->win, 0, 0);

    for (i = 1; i < height + 1; i++, file++) {
        wmove(fd->win, i, 0);
        if (has_colors()) {
            /* Outside of filename, just finish drawing the vertical file */
            if (file < 0 || file >= fd->buf->length) {
                int j;

                for (j = 1; j < lwidth; j++)
                    waddch(fd->win, ' ');
                waddch(fd->win, '~');
                wattron(fd->win, A_BOLD);
                waddch(fd->win, VERT_LINE);
                wattroff(fd->win, A_BOLD);
                for (j = 2 + lwidth; j < width; j++)
                    waddch(fd->win, ' ');
            }
            /* Mark the current file with an arrow */
            else if (file == fd->buf->sel_line) {
                wattron(fd->win, A_BOLD);
                wprintw(fd->win, fmt, file + 1);
                wattroff(fd->win, A_BOLD);
                if (hl_groups_get_attr(hl_groups_instance, HLG_ARROW,
                                &attr) == -1)
                    return -1;
                wattron(fd->win, attr);
                waddch(fd->win, '-');
                waddch(fd->win, '>');
                wattroff(fd->win, attr);
                if (fd->buf->cur_line != NULL)
                    hl_wprintw(fd->win, fd->buf->cur_line, width - lwidth - 2,
                            fd->buf->sel_col);
                else
                    hl_wprintw(fd->win, fd->buf->files[file],
                            width - lwidth - 2, fd->buf->sel_col);
            }
            /* Ordinary file */
            else {
                wprintw(fd->win, fmt, file + 1);
                wattron(fd->win, A_BOLD);
                waddch(fd->win, VERT_LINE);
                wattroff(fd->win, A_BOLD);
                waddch(fd->win, ' ');

                /* No special file information */
                if (file == fd->buf->sel_line && fd->buf->cur_line != NULL)
                    hl_wprintw(fd->win, fd->buf->cur_line, width - lwidth - 2,
                            fd->buf->sel_col);
                else
                    hl_wprintw(fd->win, fd->buf->files[file],
                            width - lwidth - 2, fd->buf->sel_col);
            }
        } else {
            wprintw(fd->win, "%s\n", fd->buf->files[file]);
        }
    }

    /* Add the 2 lines back in so the status bar can be drawn */
    height += 2;

    /* Update status bar */
    wmove(fd->win, height, 0);

    /* Print white background */
    if (hl_groups_get_attr(hl_groups_instance, HLG_STATUS_BAR, &attr) == -1)
        return -1;
    wattron(fd->win, attr);

    for (i = 0; i < width; i++)
        mvwprintw(fd->win, height - 1, i, " ");

    if (regex_search && regex_direction)
        mvwprintw(fd->win, height - 1, 0, "Search:%s", regex_line);
    else if (regex_search)
        mvwprintw(fd->win, height - 1, 0, "RSearch:%s", regex_line);

    wattroff(fd->win, attr);

    wmove(fd->win, height - (file - fd->buf->sel_line) - 1, lwidth + 2);
    wrefresh(fd->win);

    return 0;
}
コード例 #28
0
ファイル: ui_call_raw.c プロジェクト: jungle-boogie/sngrep
int
call_raw_print_msg(PANEL *panel, sip_msg_t *msg)
{
    call_raw_info_t *info;
    int payload_lines, i, column, height, width;
    // Message ngrep style Header
    char header[256];
    char payload[2048];
    int color = 0;

    // Get panel information
    if (!(info = call_raw_info(panel)))
        return -1;

    // Get the pad window
    WINDOW *pad = info->pad;

    // Get current pad dimensions
    getmaxyx(pad, height, width);

    // Get message payload
    strcpy(payload, msg_get_payload(msg));

    // Check how many lines we well need to draw this message
    payload_lines = 0;
    column = 0;
    for (i = 0; i < strlen(payload); i++) {
        if (column == width || payload[i] == '\n') {
            payload_lines++;
            column = 0;
            continue;
        }
        column++;
    }

    // Check if we have enough space in our huge pad to store this message
    if (info->padline + payload_lines > height) {
        // Create a new pad with more lines!
        pad = newpad(height + 500, COLS);
        // And copy all previous information
        overwrite(info->pad, pad);
        // Delete previous pad
        delwin(info->pad);
        // And store the new pad
        info->pad = pad;
    }

    // Color the message {
    if (setting_has_value(SETTING_COLORMODE, "request")) {
        // Determine arrow color
        if (msg_is_request(msg)) {
            color = CP_RED_ON_DEF;
        } else {
            color = CP_GREEN_ON_DEF;
        }
    } else if (info->group && setting_has_value(SETTING_COLORMODE, "callid")) {
        // Color by call-id
        color = call_group_color(info->group, msg->call);
    } else if (setting_has_value(SETTING_COLORMODE, "cseq")) {
        // Color by CSeq within the same call
        color = msg->cseq % 7 + 1;
    }

    // Turn on the message color
    wattron(pad, COLOR_PAIR(color));

    // Print msg header
    wattron(pad, A_BOLD);
    mvwprintw(pad, info->padline++, 0, "%s", sip_get_msg_header(msg, header));
    wattroff(pad, A_BOLD);

    // Print msg payload
    info->padline += draw_message_pos(pad, msg, info->padline);
    // Extra line between messages
    info->padline++;

    // Set this as the last printed message
    info->last = msg;

    return 0;
}
コード例 #29
0
int selectc()
{
	int c, r;
	int ret;
	char h, l;
	unsigned int k_ch;
	
	c = (curchar / 16);
	r = (curchar % 16);

	for(;;)
	{
		dis_cmd("   Select Character");
		
		sel_mode();

		curchar = r + (c*16);

		display(curchar);

		h = ((mvwinch(set_win,(r+1),((c*2)+1))) & A_CHARTEXT);
		l = ((mvwinch(set_win,(r+1),((c*2)+2))) & A_CHARTEXT);
		wattron(set_win,A_REVERSE);
		mvwprintw(set_win,(r+1),((c*2)+1),"%c%c",h,l);
		wattroff(set_win,A_REVERSE);		
		wmove(set_win,(r+1),((c*2)+1));
		wrefresh(set_win);
		
		k_ch = wgetch(set_win);
		
		switch(k_ch)
		{
			case K_LEFT:
			case KEY_LEFT:
				if(c > 0)
				{
					normal_set(r,c);
					c--;
				}
				break;

			case K_DOWN:
			case KEY_DOWN:
				if(r < 15)
				{
					normal_set(r,c);
					r++;
				}
				break;

			case K_UP:
			case KEY_UP:
				if(r > 0)
				{
					normal_set(r,c);
					r--;
				}
				break;

			case K_RIGHT:
			case KEY_RIGHT:
				if(c < 15)
				{
					normal_set(r,c);
					c++;
				}
				break;

			case 'e':
			case 'E':			
				edit_mode();
				dis_cmd("   Edit Character");
				display(curchar);
				ret = edit();
				if(ret == 1)
					save_ch();
				break;

			case 'g':
			case 'G':
				dis_cmd("   Exchange: select Destination, then press RETURN or any other Key to ABORT");
				sr = r;
				sc = c;
				scurchar = curchar;
				if((curchar = sel_dest()) == -1)
				{ /* failsafe */
					r = sr;
					c = sc;
					curchar = scurchar;
				}
				else
				{ /* valid return */
					normal_set(r,c);
					c = (curchar / 16);
					r = (curchar % 16);
					xchg_ch(scurchar,curchar);
				}
				break;

			case 'm':
			case 'M':
				dis_cmd("   Move: select Destination, then press RETURN or any other Key to ABORT");
				sr = r;
				sc = c;
				scurchar = curchar;
				if((curchar = sel_dest()) == -1)
				{ /* failsafe */
					r = sr;
					c = sc;
					curchar = scurchar;
				}
				else
				{ /* valid return */
					normal_set(r,c);
					c = (curchar / 16);
					r = (curchar % 16);
					move_ch(scurchar,curchar);
				}
				break;

			case 'q':
			case 'Q':
				normal_set(r,c);
				wrefresh(set_win);			
				return(1);
				break;
			
			case 'x':
			case 'X':
				normal_set(r,c);
				wrefresh(set_win);			
				return(0);
				break;

			case 0x0c:
				wrefresh(curscr);
				break;
			
			default:
				beep();
				break;
				
		}
	}
}
コード例 #30
0
static int pfind_sectors_per_cluster(disk_t *disk, partition_t *partition, const int verbose, unsigned int *sectors_per_cluster, uint64_t *offset_org, alloc_data_t *list_search_space)
{
  uint64_t offset=0;
  unsigned int nbr_subdir=0;
  sector_cluster_t sector_cluster[10];
  alloc_data_t *current_search_space;
  unsigned char *buffer_start=(unsigned char *)MALLOC(READ_SIZE);
  unsigned char *buffer=buffer_start;
  current_search_space=td_list_entry(list_search_space->list.next, alloc_data_t, list);
  if(current_search_space!=list_search_space)
    offset=current_search_space->start;
  if(verbose>0)
    info_list_search_space(list_search_space, current_search_space, disk->sector_size, 0, verbose);
#ifdef HAVE_NCURSES
  wmove(stdscr,22,0);
  wattrset(stdscr, A_REVERSE);
  waddstr(stdscr,"  Stop  ");
  wattroff(stdscr, A_REVERSE);
#endif
  disk->pread(disk, buffer_start, READ_SIZE, offset);
  while(current_search_space!=list_search_space && nbr_subdir<10)
  {
    const uint64_t old_offset=offset;
#ifdef HAVE_NCURSES
    if((offset&(1024*disk->sector_size-1))==0)
    {
      wmove(stdscr,9,0);
      wclrtoeol(stdscr);
      wprintw(stdscr,"Search subdirectory %10lu/%lu %u",(unsigned long)(offset/disk->sector_size),(unsigned long)(partition->part_size/disk->sector_size),nbr_subdir);
      wrefresh(stdscr);
    }
#endif
    if(memcmp(buffer,         ".          ", 8+3)==0 &&
	memcmp(&buffer[0x20], "..         ", 8+3)==0)
    {
      const unsigned long int cluster=(buffer[0*0x20+0x15]<<24) + (buffer[0*0x20+0x14]<<16) +
	(buffer[0*0x20+0x1B]<<8) + buffer[0*0x20+0x1A];
      log_info("sector %lu, cluster %lu\n",
	  (unsigned long)(offset/disk->sector_size), cluster);
      sector_cluster[nbr_subdir].cluster=cluster;
      sector_cluster[nbr_subdir].sector=offset/disk->sector_size;
      log_flush();
      nbr_subdir++;
    }
    get_next_sector(list_search_space, &current_search_space, &offset, 512);
    buffer+=512;
    if( old_offset+512!=offset ||
        buffer+512>buffer_start+READ_SIZE)
    {
      buffer=buffer_start;
      if(verbose>1)
      {
        log_verbose("Reading sector %10llu/%llu\n",
	    (unsigned long long)((offset-partition->part_offset)/disk->sector_size),
	    (unsigned long long)((partition->part_size-1)/disk->sector_size));
      }
      if(disk->pread(disk, buffer_start, READ_SIZE, offset) != READ_SIZE)
      {
      }
    }
  } /* end while(current_search_space!=list_search_space) */
  free(buffer_start);
  return find_sectors_per_cluster_aux(sector_cluster,nbr_subdir,sectors_per_cluster,offset_org,verbose,partition->part_size/disk->sector_size, UP_UNK);
}