Example #1
0
void scr_restore(const screen_backup_t *old)
{
    int i;
    size_t offset=0;
    void *buf = old->raw_memory;
    screenline_t* bp = big_picture;
    const int len = MIN(old->row, t_lines);

    // XXX simple step to solve scrolling issue...
    roll = old->roll;

    for(i = 0; i < len; i++) {
	/* restore header */
	memcpy(&bp[i], (char*)buf + offset, ((char*)&bp[i].data - (char*)&bp[i]));
	offset += ((char*)&bp[i].data - (char*)&bp[i]);

	/* restore body */
	memcpy(&bp[i].data, (char*)buf + offset, bp[i].len);
	offset += bp[i].len;
    }

    free(old->raw_memory);
    move(old->y, old->x);
    redrawwin();
}
Example #2
0
File: bar.c Project: debolk/mjs
void gui_draw_bar(void) {
	char version_str[128];
	struct tm *currentTime;
	
	time_t now2;
	int x = bar_window->width - 2;
	now2 = time(NULL);
	currentTime = localtime(&now2);
	gui_clear_bar();
	wattrset(bar_window->win, conf->colors[MENU_TEXT]);
	mvwaddstr(bar_window->win, 0, ((x - strlen(bar_window->title_dfl)) / 2), bar_window->title_dfl);
	snprintf(version_str, 128, "%.2d-%.2d-%.4d %.2d:%.2d %s",
			currentTime->tm_mday,
			currentTime->tm_mon + 1,
			currentTime->tm_year + 1900,
			currentTime->tm_hour,
			currentTime->tm_min,
			VERSION);
	mvwaddstr(bar_window->win, 0, x - strlen(version_str) + 2, version_str);

	update_panels();
	if (conf->c_flags & C_FIX_BORDERS)
		redrawwin(bar_window->win);
	doupdate();
}
Example #3
0
void term_resize(int w, int h)
{
    int dorefresh = 0;
    Signal(SIGWINCH, SIG_IGN);	/* Don't bother me! */


    /* make sure reasonable size */
    h = MAX(24, MIN(100, h));
    w = MAX(80, MIN(200, w));

    if (w != t_columns || h != t_lines)
    {
	// invoke terminal system resize
	resizeterm(h, w);

	t_lines = h;
	t_columns = w;
	dorefresh = 1;
    }
    b_lines = t_lines - 1;
    p_lines = t_lines - 4;

    Signal(SIGWINCH, sig_term_resize);
    if (dorefresh)
    {
	redrawwin();
	refresh();
    }
}
Example #4
0
/* 
 * Destroy subwindow.
 */
static inline void pad_destroy(void)
{
	if(delwin(main_pad->wd) == ERR) prg_exit("Cannot delete details window.");
	if(delwin(border_wd) == ERR) prg_exit("Cannot delete details window.");
	main_pad->wd = 0;
	redrawwin(main_win);
}
Example #5
0
void helpscreen() {
    char c;
	WINDOW * win;
	win=newwin(0,0,0,0);
	mvwprintw(win,0,0,"HILFE --- drücke 'q' zum verlassen");
	mvwprintw(win,2,0,"Der Roboter wird immer mit voller Geschwindigkeit bewegt");
	mvwprintw(win,3,0,"Der Anpressdruck der Hand ist ebenfalls fest vorgegeben");
	mvwprintw(win,5,0,"Die Steuerung erfolgt mittels Tasten. Welches Element des Arms");
	mvwprintw(win,6,0,"zu welchen Tasten gehört, kann man im Hauptbildschirm sehen");
	mvwprintw(win,8,0,"+ -                     : Schrittweite ändern");
	mvwprintw(win,9,0,"Leertaste               : Arm in Grundstellung");
	mvwprintw(win,10,0,"R                       : Hardware-Reset des Arms");
	mvwprintw(win,12,0,"--- Speichern der Positionen");
	mvwprintw(win,13,0,"Pfeiltasten links-rechts: Speicherposition auswählen");
	mvwprintw(win,14,0,", .                     : Speicherposition in 50er Schritten auswählen");
	mvwprintw(win,15,0,"Pfeiltaste  unten       : Position speichern");
	mvwprintw(win,16,0,"Pfeiltaste  oben        : Position laden");
	mvwprintw(win,17,0,"SHIFT-D                 : aktuelle Position auf NULL setzen");
	mvwprintw(win,18,0,"STRG-Pfeil-unten        : alle Positionen in Datei sichern");
	mvwprintw(win,19,0,"STRG-Pfeil-oben         : alle Positionen aus Datei laden");
	mvwprintw(win,21,0,"--- Roboterprogramm");
	mvwprintw(win,22,0,"STRG-G                  : alle Positionen als Programm an Roboter senden");
	mvwprintw(win,23,0,"SHIFT-G                 : Programm im Roboter starten");
	wrefresh(win);
	while (c!='q') { c=getch(); }
	wclear(win);
	wrefresh(win);
	delwin(win);
	redrawwin(mainwin);
}
Example #6
0
File: display.c Project: JakeSc/tig
int
get_input(int prompt_position, struct key *key, bool modifiers)
{
    struct view *view;
    int i, key_value, cursor_y, cursor_x;

    if (prompt_position)
        input_mode = TRUE;

    memset(key, 0, sizeof(*key));

    while (TRUE) {
        int delay = -1;

        if (opt_refresh_mode == REFRESH_MODE_PERIODIC) {
            delay = watch_periodic(opt_refresh_interval);
            foreach_displayed_view (view, i) {
                if (view_can_refresh(view) &&
                        watch_dirty(&view->watch))
                    refresh_view(view);
            }
        }

        foreach_view (view, i) {
            update_view(view);
            if (view_is_displayed(view) && view->has_scrolled &&
                    use_scroll_redrawwin)
                redrawwin(view->win);
            view->has_scrolled = FALSE;
            if (view->pipe)
                delay = 0;
        }
Example #7
0
static void *
do_curses(void *arg)
{
	int i;

	(void)arg;
	for (i = 0; i < 256; i++) {
		if (VSL_tags[i] == NULL)
			continue;
		if (maxfieldlen < strlen(VSL_tags[i]))
			maxfieldlen = strlen(VSL_tags[i]);
	}

	(void)initscr();
	AC(raw());
	AC(noecho());
	AC(nonl());
	AC(intrflush(stdscr, FALSE));
	(void)curs_set(0);
	AC(erase());
	for (;;) {
		AZ(pthread_mutex_lock(&mtx));
		update(period);
		AZ(pthread_mutex_unlock(&mtx));

		timeout(1000);
		switch (getch()) {
		case ERR:
			break;
#ifdef KEY_RESIZE
		case KEY_RESIZE:
			AC(erase());
			break;
#endif
		case '\014': /* Ctrl-L */
		case '\024': /* Ctrl-T */
			AC(redrawwin(stdscr));
			AC(refresh());
			break;
		case '\032': /* Ctrl-Z */
			AC(endwin());
			AZ(raise(SIGTSTP));
			break;
		case '\003': /* Ctrl-C */
		case '\021': /* Ctrl-Q */
		case 'Q':
		case 'q':
			AZ(raise(SIGINT));
			AC(endwin());
			return NULL;
		default:
			AC(beep());
			break;
		}
	}
	return NULL;

}
Example #8
0
// redraw the whole snake
void redraw_snake(SNAKE *snake) {
  int i;
  // iterate through each part of the snake
  for(i = 0; i < snake->length; i++) {
    // redraw the current part
    redrawwin(snake->parts[i]);
    wrefresh(snake->parts[i]);
  }
}
Example #9
0
void
askforreturn(void)
{
    fprintf(stderr, "Press the RETURN key to continue: ");
    getchar();
    /* HBB 20060419: message probably messed up the screen --- redraw */
    if (incurses == YES) {
	redrawwin(curscr);
    }
}
Example #10
0
// redraw all the fruits on the screen
void redraw_fruits(FRUITS *fruits) {
  int i;

  // iterate through each fruit.
  for(i = 0; i < fruits->length; i++) {
    // redraw it!
    redrawwin(fruits->fruits[i].win);
    wrefresh(fruits->fruits[i].win);
  }
}
Example #11
0
static void redraw_view_from(struct view *view, int lineno)
{
	assert(0 <= lineno && lineno < view->height);

	for (; lineno < view->height; lineno++) {
		view->render(view, lineno);
	}

	redrawwin(view->win);
	wrefresh(view->win);
}
Example #12
0
void tui_dlogdie (int w)
{
    if (currwin == winstack[w])
	currwin = stdscr;
    delwin (winstack[w]);
    winstack[w] = NULL;
    while (winstack[winnr-1] == NULL)
	winnr--;

    for (w = 0; w < winnr; w++)
	redrawwin (winstack[w]), wrefresh (winstack[w]);
}
Example #13
0
File: game.c Project: posva/msnake
// redraw the whole screen
void redraw_game(GAME *game) {
  // redraw the main window (containg the border and stuff)
  clear();
  draw_border(game);
  redrawwin(stdscr);
  refresh();
  
  // redraw the fruits
  redraw_fruits(&game->fruits);

  // redraw the snake
  redraw_snake(&game->snake);
}
Example #14
0
File: nchgdc.c Project: Eeketh/hgd
void
hgd_refresh_ui(struct ui *u)
{
	redrawwin(u->content_wins[u->active_content_win]);
	wnoutrefresh(u->content_wins[u->active_content_win]);

	hgd_update_titlebar(u);
	wnoutrefresh(u->title);

	hgd_update_statusbar(u);
	wnoutrefresh(u->status);

	doupdate();
}
Example #15
0
void
menu_redraw(void)
{
	was_redraw = 1;
	redraw_menu(menu);

	if(curr_stats.errmsg_shown)
	{
		redraw_error_msg_window();
		redrawwin(error_win);
		wnoutrefresh(error_win);
		doupdate();
	}
}
Example #16
0
/*
 * Fill win_header with a title, state and OfflineMode informations.
 * @param jobj the state object of engine:
 {
	 "State": "ready",
	 "OfflineMode": false,
	 "SessionMode": false
 }
 */
void __renderers_state(struct json_object *jobj)
{
	struct json_object *state, *offline_mode;
	const char *state_str;

	json_object_object_get_ex(jobj, key_serv_state, &state);
	state_str = json_object_get_string(state);
	json_object_object_get_ex(jobj, "OfflineMode", &offline_mode);

	mvwprintw(win_header, 0, 1, "Connman ncurses UI");
	// 38 = len(string) + 1
	mvwprintw(win_header, 0, COLS-38, "State: %-6s%-6sOfflineMode: %-5s\n",
			state_str, "", json_object_get_string(offline_mode));
	redrawwin(win_header);
	wrefresh(win_header);
}
Example #17
0
/*
 *This function is use to update the line
 * which will show in highlight.
 * The render function is depend on the 
 * command_type
 * */
void 
Redraw_view(void)
{
	switch(command_type){
		case IS_LS:
			Draw_LS_OutPut();
			break;
		case IS_GREP:
			Draw_Grep_OutPut();
			break;
		case IS_FIND:
			Draw_Find_OutPut();
			break;
		default:
			do_nothing();
			break;
	}
	redrawwin(stdscr);
	wrefresh(stdscr);
}
Example #18
0
static int boot_editor_post(struct nc_scr *scr)
{
	struct boot_editor *boot_editor = boot_editor_from_scr(scr);

	if (boot_editor->need_update) {
		boot_editor_update(boot_editor, boot_editor->cui->sysinfo);
		boot_editor->need_update = false;
	} else {
		widgetset_post(boot_editor->widgetset);
	}

	nc_scr_frame_draw(scr);
	if (boot_editor->need_redraw) {
		redrawwin(scr->main_ncw);
		boot_editor->need_redraw = false;
	}
	wrefresh(boot_editor->scr.main_ncw);
	pad_refresh(boot_editor);
	return 0;
}
Example #19
0
void
Reload_info(void)
{
	switch(command_type){
		case IS_LS:
			RenderLs(ls_type);
			break;
		case IS_GREP:
			RenderGrep();
			break;
		case IS_FIND:
			RenderFind();
			break;
		default:
			do_nothing();
			break;
	}
	redrawwin(stdscr);
	wrefresh(stdscr);
}
Example #20
0
static void move_view(struct view *view, int lines)
{
	/* The rendering expects the new offset. */
	view->offset += lines;

	assert(0 <= view->offset && view->offset < view->lines);
	assert(lines);

    int line = lines > 0 ? view->height - lines : 0;
    int end = line + (lines > 0 ? lines : -lines);

    wscrl(view->win, lines);

    for (; line < end; line++) 
    {
        if (!view->render(view, line))
            break;
    }

	/* Move current line into the view. */
	if (view->lineno < view->offset) 
    {
		view->lineno = view->offset;
		view->render(view, 0);

	} 
    else if (view->lineno >= view->offset + view->height) 
    {
		view->lineno = view->offset + view->height - 1;
		view->render(view, view->lineno - view->offset);
	}

	assert(view->offset <= view->lineno && view->lineno < view->lines);

	redrawwin(view->win);
	wrefresh(view->win);

	update_title_win(view);
}
Example #21
0
int
get_input(int prompt_position, struct key *key)
{
	struct view *view;
	int i, key_value, cursor_y, cursor_x;

	if (prompt_position > 0)
		input_mode = true;

	memset(key, 0, sizeof(*key));

	while (true) {
		int delay = -1;

		if (opt_refresh_mode == REFRESH_MODE_PERIODIC) {
			delay = watch_periodic(opt_refresh_interval);
			bool refs_refreshed = false;
			foreach_displayed_view (view, i) {
				if (view_can_refresh(view) &&
					watch_dirty(&view->watch)) {
					if (!refs_refreshed) {
						load_refs(true);
						refs_refreshed = true;
					}
					refresh_view(view);
				}
			}
		}

		foreach_view (view, i) {
			update_view(view);
			if (view_is_displayed(view) && view->has_scrolled &&
			    use_scroll_redrawwin)
				redrawwin(view->win);
			view->has_scrolled = false;
			if (view->pipe)
				delay = 0;
		}
Example #22
0
int cui_run_cmd(struct pmenu_item *item)
{
	int result;
	struct cui *cui = cui_from_item(item);
	const char **cmd_argv = item->data;

	nc_scr_status_printf(cui->current, _("Running %s..."), cmd_argv[0]);

	def_prog_mode();

	result = process_run_simple_argv(item, cmd_argv);

	reset_prog_mode();
	redrawwin(cui->current->main_ncw);

	if (result) {
		pb_log("%s: failed: '%s'\n", __func__, cmd_argv[0]);
		nc_scr_status_printf(cui->current, _("Failed: %s"),
				cmd_argv[0]);
	}

	return result;
}
Example #23
0
WRAP_API int
wrap_redrawwin(WINDOW *win)
{
	return redrawwin(win);
}
Example #24
0
static int
handle_input(int ch)
{
    switch (ch) 
    {
		case 'q':
			quit_mode = quit_mode ? 0 : 1;
			return 1;

		case 0x1b:
			quit_mode = 0;
			print_help = 0;
			return 1;

		case 'y':
			if (quit_mode)
				exit(0);
			break;

		case 'n':
			if (quit_mode) {
				quit_mode = 0;
				return 1;
			}
			break;

		case 'f':
			fold();
			return 1;

		case 12:
		case KEY_CLEAR:
#ifdef HAVE_REDRAWWIN
			redrawwin(stdscr);
#endif
			clear();
			return 1;

		case 'c':
			c_combined_node_list = c_combined_node_list ? 0 : 1;
			return 1;

        case 'S':
            clear();
			set_x_unit("s", 1);
            return 1;

        case 'M':
            clear();
			set_x_unit("m", 1);
            return 1;

        case 'H':
            clear();
			set_x_unit("h", 1);
            return 1;

		case 'D':
			clear();
			set_x_unit("d", 1);
			return 1;

		case 'R':
			clear();
			set_x_unit("r", 1);
			return 1;

        case '?':
            clear();
			print_help = print_help ? 0 : 1;
			return 1;

        case 'g':
			c_graphical_in_list = c_graphical_in_list ? 0 : 1;
			return 1;

		case 'd':
			c_detailed_in_list = c_detailed_in_list ? 0 : 1;
			return 1;

		case 'l':
			c_list_in_list = c_list_in_list ? 0 : 1;
			return 1;

		case KEY_LEFT:
			prev_node();
			return 1;

		case KEY_RIGHT:
			next_node();
			return 1;

		case KEY_DOWN:
			if (next_intf() == END_OF_LIST) {
				if (next_node() != END_OF_LIST)
					first_intf();
			}
			return 1;

		case KEY_UP:
			if (prev_intf() == END_OF_LIST) {
				if (prev_node() != END_OF_LIST)
					last_intf();
			}
			return 1;
		default:
			if (get_current_intf())
				if (handle_bindings(ch, get_current_intf()->i_name))
					return 1;
			break;
    }

    return 0;
}
EIF_INTEGER c_ecurses_redrawwin (EIF_POINTER w)
{
    return  redrawwin (((WINDOW *) w)) ;
};
Example #26
0
static void
test_redraw(WINDOW *win)
{
    WINDOW *win1;
    WINDOW *win2;
    bool done = FALSE;
    int ch, y, x;
    int max_y, max_x;
    int beg_y, beg_x;

    assert(win != 0);

    scrollok(win, TRUE);
    keypad(win, TRUE);
    getmaxyx(win, max_y, max_x);
    getbegyx(win, beg_y, beg_x);
    while (!done && win != 0) {
	ch = wgetch(win);
	getyx(win, y, x);
	switch (ch) {
	case 'q':
	    /* FALLTHRU */
	case ESCAPE:
	    done = TRUE;
	    break;
	case 'w':
	    win1 = newwin(max_y, max_x,
			  beg_y, beg_x);
	    win2 = newwin(max_y - 2, max_x - 2,
			  beg_y + 1, beg_x + 1);
	    box(win1, 0, 0);
	    wrefresh(win1);

	    test_redraw(win2);

	    delwin(win2);
	    delwin(win1);

	    touchwin(win);
	    break;

	case '!':
	    /*
	     * redrawwin() and wredrawln() do not take into account the
	     * possibility that the cursor may have moved.  That makes them
	     * cumbersome for using with a shell command.  So we simply
	     * trash the current line of the window using backspace/overwrite.
	     */
	    trash(beg_x, max_x, x + beg_x);
	    break;

#ifdef NCURSES_VERSION
	case '@':
	    /*
	     * For a shell command, we can work around the problem noted above
	     * using mvcur().  It is ifdef'd for NCURSES, since X/Open does
	     * not define the case where the old location is unknown. 
	     */
	    IGNORE_RC(system("date"));
	    mvcur(-1, -1, y, x);
	    break;
#endif

	case CTRL('W'):
	    redrawwin(win);
	    break;

	case CTRL('L'):
	    wredrawln(win, y, 1);
	    break;

	case KEY_UP:
	    if (y > 0)
		wmove(win, y - 1, x);
	    break;

	case KEY_DOWN:
	    if (y < max_y)
		wmove(win, y + 1, x);
	    break;

	case KEY_LEFT:
	    if (x > 0)
		wmove(win, y, x - 1);
	    break;

	case KEY_RIGHT:
	    if (x < max_x)
		wmove(win, y, x + 1);
	    break;

	default:
	    if (ch > KEY_MIN) {
		waddstr(win, keyname(ch));
	    } else {
		waddstr(win, unctrl(UChar(ch)));
	    }
	    break;
	}
	wnoutrefresh(win);
	doupdate();
    }
}
Example #27
0
int main(int argc, char* argv[])
{
	int is_running = 1;
	int x_terminal_size, y_terminal_size;
        int is_lurking = 0;
        int is_yelling = 0;
        int in_deepsix = 0;
        int sending_im = 0;
        int i;

	/* josh-note:
			These need to be uncommented for the client connection to work. */
/*	int client_id = init_client("Henry");                   create a client. */
/*      init_user_list(client_id);                      init the client size user list. */

	log_init();
	log_writeln(" --------------------------- ");
	log_writeln(" > Starting BlackChat");

        signal(SIGALRM, scroll_ended_handler);

        for(i = 0; i < 26; i ++) {   /* set our message to null */
                memset(yell_messages[i], '\0', MAX_MESSAGE_LENGTH * sizeof(wchar_t)); 
        }

	transcript_buffer   = (wchar_t*)malloc(sizeof(wchar_t)*transcript_buffer_size);
	f_transcript_buffer = (wchar_t*)malloc(sizeof(wchar_t)*f_transcript_buffer_size);
    memset(client_buffer, '\0', sizeof(client_buffer));
	memset(transcript_buffer, '\0', sizeof(transcript_buffer));

	get_terminal_size(&x_terminal_size, &y_terminal_size);
	log_writeln(" > ... detecting current terminal size xy:(%d,%d)", x_terminal_size, y_terminal_size);

	log_writeln(" > ... initializing ncurses screen in raw mode");
	initscr();
//	start_color();
	init_pair(0, COLOR_WHITE,   COLOR_BLACK);
	init_pair(1, COLOR_GREEN,   COLOR_BLACK);
	init_pair(2, COLOR_YELLOW,  COLOR_BLACK);
        init_pair(3, COLOR_CYAN,    COLOR_BLACK);
        init_pair(4, COLOR_MAGENTA, COLOR_BLACK);
	raw();
	keypad(stdscr, TRUE);
	noecho();

	color_set(0, NULL);
	
	log_writeln(" > ... creating transcript and client window");
	transcript_window  				= newwin(TRANSCRIPT_MAX_ROWS,TRANSCRIPT_MAX_COLUMNS,   0,0);
	fullscreen_transcript_window	= newwin(TRANSCRIPT_MAX_ROWS,TRANSCRIPT_MAX_COLUMNS*2, 0,0);
	client_chat_window 				= newwin(MAX_ROWS,MAX_COLUMNS,24,0);
        lurk_win           			= newwin(MAX_ROWS,MAX_COLUMNS,24,0);
        yell_win           			= newwin(23,40,0,0);
        deepsix_win        			= newwin(23,40,0,0);
        im_win						= newwin(TRANSCRIPT_MAX_ROWS,TRANSCRIPT_MAX_COLUMNS,   0,0);
        status_win					= newwin(3,40,21,40);
        info_win					= newwin(3,40,0,40);
   //     box(yell_win, '|', '-');

        set_yell_message(0, L"Hello World");
        set_yell_message(1, L"Yo dog!");
        set_yell_message(2, L"Hey everyone!");
        set_yell_message(3, L"Whats up?");
        set_yell_message(12,L"I agree.");

        wcolor_set(lurk_win,           4, NULL);
        wcolor_set(transcript_window,  3, NULL);
        wcolor_set(client_chat_window, 4, NULL);
        wcolor_set(yell_win,           2, NULL);
        wprintw(lurk_win, "Lurking... Use CTRL-L to unLurk or CTRL-Q to quit.");
	log_writeln(" > ... creating other 9 windows");
	init_other_windows();

	log_writeln(" > ... [beginning transcript]");
	write_to_transcript_window(L"***************************************");
	write_to_transcript_window(L"******** Wecome to BlackChat! *********");
	write_to_transcript_window(L"***************************************");
        
	set_window_user_name(0, L"chris");
	set_window_user_name(1, L"sue");
	set_window_user_name(2, L"dan");
	set_window_user_name(3, L"joe");
	append_text_to_window(0, L"Sup!");
	append_text_to_window(1, L"yo everyone, I'm in love with blackchat!");
	append_text_to_window(2, L"hey, my name is Dan!");
	append_text_to_window(3, L"Hey!?");

	can_deepsix_user(0, 0);
	set_user_status(1, 'L');
	set_user_status(2, 'L');
	
	/* Set our info window text. */
	wprintw(info_win, "       Black Chat  v1.0\n");
	wprintw(info_win, "UI: Henry Stratmann|Client: Josh Hartman\n");
	wprintw(info_win, "Server: Tyler Reid |Protocol: Tim Rhoads\n");
	

	while(is_running) {
		int ch = getch();
/*		wchar_t buf[512];          //get wchar_ts

		sprintf(buf, "key pressed: '%c'  int value: %d\n", ch, ch);
		write_to_transcript_window(buf);
  */                                      //end get wchar_t

            /* Check if were in "Lurk" mode. */
            if(is_lurking) {
                    switch(ch) {
                            case 12: /* lurk-off */
                                    is_lurking = 0;
                                    print_client_chat_buffer();
                                    break;
                            case 17: /* quit */
                                    is_running = 0;
                                    break;
                            default:
                                    wrefresh(lurk_win);
                    }
            }
            /* Check if were in IM mode. */
            else if(sending_im) {
            		/*
            		 TODO: Display list of users (like deepsix) to send IM to.
            		 	All IM's will be displayed on the main transcript with some type of "marker"
            		 	indicating that this was an IM.
            		 */
            		if(ch >= 48 && ch <= 57) {
            				/* josh-note:
            					Have josh send IM based on "ch" */
            		}
            
            
            		/* quit */
                    if(ch == 17) {
                    		is_running = 0;
                    }
                    
                    /* exit IM */
                    sending_im = 0;
                    window_page_up(transcript_window,            &transcript_current_line, TRANSCRIPT_MAX_COLUMNS,   transcript_buffer);
                    window_page_up(fullscreen_transcript_window, &transcript_current_line, TRANSCRIPT_MAX_COLUMNS*2, f_transcript_buffer);
            }
            /* Check if were in deepsix mode. */
            else if(in_deepsix) {
            		/* kick user */
            		if(ch >= 48 && ch <= 57) {
            				/* josh-note:
            					Have josh make a "kick_user(ch-48)" command. 
            					Also, have josh keep track of who user voted for and display message on transcript as to how user voted
            					and/or if they already voted for the user. */		
            		}
            
            		/* quit */
                    if(ch == 17) {
                    		is_running = 0;
                    }
                    
                    /* exit deepsix */
                    in_deepsix = 0;
                    window_page_up(transcript_window,            &transcript_current_line, TRANSCRIPT_MAX_COLUMNS,   transcript_buffer);
                    window_page_up(fullscreen_transcript_window, &transcript_current_line, TRANSCRIPT_MAX_COLUMNS*2, f_transcript_buffer);
            }
            /* Check if were yelling. */
            else if(is_yelling) {
                    // redrawwin(yell_win);
                    // wrefresh(yell_win);
                    int index = ch - 97;
        

                    /* Write our comment to our transcript window.  */
                    if(index >= 0 && index < 26) {
                            if( yell_messages[index][0] != '\0' ) {
                                    write_to_transcript_window( yell_messages[index] );
                            }
                    }
                    
                    is_yelling = 0;
                    redrawwin(client_chat_window);
                    wrefresh(client_chat_window);
                    redrawwin(transcript_window);
                    wrefresh(transcript_window);
            } else {
		/* Check what keys we pressed. */
		switch(ch) {
		        /*
			 * Check if we pressed a control key. */
			if(iscntrl(ch)) {
				case 7:  /* CTRL-G */
					gaudy_mode_on = (gaudy_mode_on == 1) ? 0 : 1;
					if(gaudy_mode_on) {
						client_buffer[ client_cursor_position++ ] = 2;
					} else {
						client_buffer[ client_cursor_position++ ] = 3;
					}

					/* Print out updates to the window. */
					print_client_chat_buffer();
					break;

				case 127:/* Backsapce Key (grok hack) */
				case 8:  /* CTRL-H */
					client_buffer[ wcslen(client_buffer)-1 ] = '\0';
					print_client_chat_buffer();
					break;
					
				case 9:  /* CTRL-I   /   TAB */
					if(!sending_im) {
						sending_im = 1;
						draw_im_window();
					}
					break;
					
				case 10: /* CTRL-J and CTRL-M */
		/* UNCOMMENT ME FOR USE WITH SERVER */
					{
						wchar_t *buf = NULL;


						/* If we had gaudy mode on, we need to disable it. */
						if(gaudy_mode_on) {
							client_buffer[ client_cursor_position++ ] = 3;
                                                	client_buffer[ client_cursor_position++ ] = ' ';
							gaudy_mode_on = 0;
						}


						/* Get our buffer togther to write to the transcript window. */
						buf = (wchar_t*)malloc( (wcslen(L"[Client Says]: ")+wcslen(client_buffer)+1) * sizeof(wchar_t) );
						write_to_transcript_window(L"[Client Says]: ");
						write_to_transcript_window(client_buffer);
						
					//	sprintf(buf, "[Client Says]: %ls", client_buffer);
					//	write_to_transcript_window(buf);
					}
					clear_text_from_client_typing_window();
				/*	write_out(client_id);                    enter key is pressed so send a message to the server. */
						    break;

				case 11: /* CTRL-K */
					{
						int i;
						for(i = client_cursor_position+1; i < wcslen(client_buffer); i ++) {
							client_buffer[i] = '\0';
						}
					}
					break;

					    case 12: /* CTRL-L */
							if(!is_lurking) {
							    redrawwin(lurk_win);
							    wrefresh(lurk_win);
							    is_lurking = 1;
							}
						    break;

				case 14: /* CTRL-N */
                                        alarm(5);
					user_is_scrolling = 1;
					transcript_current_line ++;

					window_page_down( transcript_window,
							  &transcript_current_line,
							  TRANSCRIPT_MAX_COLUMNS,
							  transcript_buffer );
							  
					window_page_down( fullscreen_transcript_window,
							  &transcript_current_line,
							  TRANSCRIPT_MAX_COLUMNS*2,
							  f_transcript_buffer );
					break;
				case 16: /* CTRL-P */
                                        alarm(5);
					user_is_scrolling = 1;
					transcript_current_line --;

					window_page_up( transcript_window,
						    	&transcript_current_line,
							TRANSCRIPT_MAX_COLUMNS,
							transcript_buffer );
							
					window_page_up( fullscreen_transcript_window,
							  &transcript_current_line,
							  TRANSCRIPT_MAX_COLUMNS*2,
							  f_transcript_buffer );
					break;
		
				case 17: /* CTRL-Q */ 
					log_writeln(" > ... recived quit signal from client");
					is_running = 0;
					break;
		
				case 20: /* CTRL-T */
					if(transcript_maxed) {
						transcript_maxed = 0;
						window_page_up(transcript_window, &transcript_current_line, TRANSCRIPT_MAX_COLUMNS, transcript_buffer);
						wclear(fullscreen_transcript_window);
						wrefresh(fullscreen_transcript_window);
					} else {
						transcript_maxed = 1;
						window_page_up(fullscreen_transcript_window, &transcript_current_line, TRANSCRIPT_MAX_COLUMNS*2, f_transcript_buffer);
						wclear(transcript_window);
						wrefresh(transcript_window);
					}
					break;
		
				case 21: /* CTRL-U */
					client_current_line = 0;
					client_cursor_position = 0;
					memset(client_buffer, '\0', wcslen(client_buffer)+1);	
					print_client_chat_buffer();
					break;

				case 23: /* CTRL-W */
					delete_last_word_in_buffer(client_buffer);
					print_client_chat_buffer();
					break;
                                case 25: /* CTRL-Y */
                                        {
                                            if(!is_yelling)
                                            {
                                                redrawwin(yell_win);
                                                wrefresh(yell_win);
                                                is_yelling = 1;
                                            }
                                        }
                                        break; 
				case 29: /* CTRL-] */
                                        alarm(0);
					user_is_scrolling = 0;
					print_transcript_chat_buffer();
					break;
                                case 30: /* CTRL-6 */
                                        if(!in_deepsix)
                                        {
                                            draw_deepsix_window();
                                            in_deepsix = 1;
                                        }
                                        break;

                                /*
                                 * If we encountered an unkown escape wchar_tcter, break out of here so we don't
                                 * print it. */
                                break;              /* TODO: Fix me! */
			}
#if 0
			/* Scroll the clients typing window down. */
			case KEY_DOWN:
				client_current_line ++;
				if(client_current_line*MAX_COLUMNS > wcslen(client_buffer)) client_current_line --;

					    wclear(client_chat_window);
					    wprintw(client_chat_window, &client_buffer[client_current_line*MAX_COLUMNS]);
					    break;
			/* Scroll the clients typing window up. */
			case KEY_UP:
				client_current_line --;
				if(client_current_line < 0) client_current_line = 0;

					    wclear(client_chat_window);
					    wprintw(client_chat_window, &client_buffer[client_current_line*MAX_COLUMNS]);
					    break;
#endif
			/* Delete the previous chracter. */
			case KEY_BACKSPACE:
				/* Check if were deleting the last wchar_tacter. */
				if( client_cursor_position == wcslen(client_buffer) ) {
					client_buffer[ client_cursor_position-1 ] = '\0';
					client_cursor_position --;
					print_client_chat_buffer();
				} else {
					/* If were here, that means were NOT deleting the last wchar_tacter. */
					int i;
					for(i = client_cursor_position-1; i < wcslen(client_buffer); i ++) {
						client_buffer[i] = client_buffer[i+1];
					}
					client_cursor_position --;
					print_client_chat_buffer();
				}
				break;

			/* If were here, that means we didn't press any "special" keys so that means were
			 * trying to write some generic wchar_tacters to our chat window. */
			default:
				/* Make sure we don't print a control wchar_tacter. */
				if(!iscntrl(ch)) {
					/* Check if were inserting a wchar_tacter before the end of our client
					 * typing buffer. */
					if( client_cursor_position != wcslen(client_buffer) ) {
	
						/* Move all wchar_tacters in front of the cursor up one. */
						int i;
						for(i = wcslen(client_buffer)+1; i > client_cursor_position; i --) {
							client_buffer[i] = client_buffer[i-1];
						}
					}

					/* Add the wchar_tacter to our buffer. */
					client_buffer[ client_cursor_position++ ] = ch;

					/* Print our new/updated buffer. */
					print_client_chat_buffer();
					break;
				}
			}
		}

        	/* Read from the server. */
        	/* josh-note
        			Uncomment this! */
/*      	read_from_server(client_id); */

        	refresh_all_windows(is_lurking);
	}

	log_writeln(" > ... [ending transcript]");
	log_writeln(" > ... freeing resources");
	free_other_windows();
	free(transcript_buffer);

	delwin(transcript_window);
	delwin(fullscreen_transcript_window);
	delwin(client_chat_window);
	delwin(status_win);
	delwin(info_win);
	delwin(im_win);
	delwin(deepsix_win);
	delwin(yell_win);
	endwin();
        
    /* josh-note
    		This should be uncommented to close down the client socket. */
/*  close_client(client_id); */

	log_writeln(" > ... closing client log");
	log_writeln(" > ... bye bye for now!");
	log_close();
	return 0;
}
Example #28
0
static void
test_redraw(WINDOW *win)
{
    static const char *help[] =
    {
	"Commands:",
	"  ^Q/ESC/q   - quit",
	"  w          - recur in a new window",
	"  !          - overwrite current line using stdio outside curses.",
#ifdef NCURSES_VERSION
	"  @          - run \"date\" command, to put its output on screen.",
#endif
	"  ^L         - call redrawwin() for current window.",
	"  ^W         - call wredrawln() for current line/current window.",
	"  arrow-keys - move cursor on the screen",
	"",
	"Other control characters are added to the screen in printable form.",
	"Other printable characters are added to the screen as is.",
	0
    };

    WINDOW *win1;
    WINDOW *win2;
    bool done = FALSE;
    int ch, y, x;
    int max_y, max_x;
    int beg_y, beg_x;

    assert(win != 0);

    scrollok(win, TRUE);
    keypad(win, TRUE);
    getmaxyx(win, max_y, max_x);
    getbegyx(win, beg_y, beg_x);
    while (!done) {
	ch = wgetch(win);
	getyx(win, y, x);
	switch (ch) {
	case 'q':
	    /* FALLTHRU */
	case QUIT:
	case ESCAPE:
	    done = TRUE;
	    break;
	case 'w':
	    win1 = newwin(max_y, max_x,
			  beg_y, beg_x);
	    win2 = newwin(max_y - 2, max_x - 2,
			  beg_y + 1, beg_x + 1);
	    box(win1, 0, 0);
	    wrefresh(win1);

	    test_redraw(win2);

	    delwin(win2);
	    delwin(win1);

	    touchwin(win);
	    break;

	case '!':
	    /*
	     * redrawwin() and wredrawln() do not take into account the
	     * possibility that the cursor may have moved.  That makes them
	     * cumbersome for using with a shell command.  So we simply
	     * trash the current line of the window using backspace/overwrite.
	     */
	    trash(beg_x, max_x, x + beg_x);
	    break;

#ifdef NCURSES_VERSION
	case '@':
	    /*
	     * For a shell command, we can work around the problem noted above
	     * using mvcur().  It is ifdef'd for NCURSES, since X/Open does
	     * not define the case where the old location is unknown. 
	     */
	    IGNORE_RC(system("date"));
	    mvcur(-1, -1, y, x);
	    break;
#endif

	case CTRL('W'):
	    redrawwin(win);
	    break;

	case CTRL('L'):
	    wredrawln(win, y, 1);
	    break;

	case KEY_UP:
	    if (y > 0)
		wmove(win, y - 1, x);
	    break;

	case KEY_DOWN:
	    if (y < max_y)
		wmove(win, y + 1, x);
	    break;

	case KEY_LEFT:
	    if (x > 0)
		wmove(win, y, x - 1);
	    break;

	case KEY_RIGHT:
	    if (x < max_x)
		wmove(win, y, x + 1);
	    break;

	case HELP_KEY_1:
	    popup_msg(win, help);
	    break;

	default:
	    if (ch > KEY_MIN) {
		waddstr(win, keyname(ch));
		waddch(win, '\n');
	    } else {
		waddstr(win, unctrl(UChar(ch)));
	    }
	    break;
	}
	wnoutrefresh(win);
	doupdate();
    }
}
Example #29
0
/* 
 * called to redraw the file dialog
 */
static int wdg_file_redraw(struct wdg_object *wo)
{
   WDG_WO_EXT(struct wdg_file_handle, ww);
   size_t c, l, x, y;
   
   WDG_DEBUG_MSG("wdg_file_redraw");
   
   /* default dimentions */
   wo->x1 = (current_screen.cols - ww->x) / 2;
   wo->y1 = (current_screen.lines - ww->y) / 2;
   wo->x2 = -wo->x1;
   wo->y2 = -wo->y1;
   
   c = wdg_get_ncols(wo);
   l = wdg_get_nlines(wo);
   x = wdg_get_begin_x(wo);
   y = wdg_get_begin_y(wo);

   /* deal with rouding */
   if (l != ww->y) l = ww->y;
   if (c != ww->x) c = ww->x;

   /* the window already exist */
   if (ww->win) {
      /* erase the border */
      wbkgd(ww->win, COLOR_PAIR(wo->screen_color));
      werase(ww->win);
      /* destroy the file list */ 
      wdg_file_menu_destroy(wo);
      
      touchwin(ww->win);
      wnoutrefresh(ww->win);
      
      /* resize the window and draw the new border */
      mvwin(ww->win, y, x);
      wresize(ww->win, l, c);

      wbkgd(ww->win, COLOR_PAIR(wo->window_color));
      werase(ww->win);
      
      /* create the file list */
      wdg_file_menu_create(wo);

      touchwin(ww->win);

      wdg_file_borders(wo);
     

   /* the first time we have to allocate the window */
   } else {

      /* create the menu window (fixed dimensions) */
      if ((ww->win = newwin(l, c, y, x)) == NULL)
         return -WDG_E_FATAL;

      /* create the file list */
      wdg_file_menu_create(wo);

      /* set the window color */
      wbkgd(ww->win, COLOR_PAIR(wo->window_color));
      redrawwin(ww->win);
      
      /* draw the titles */
      wdg_file_borders(wo);

      /* no scrolling */
      scrollok(ww->win, FALSE);
   }
   
   /* refresh the window */
   touchwin(ww->win);
   wnoutrefresh(ww->win);

   touchwin(ww->mwin);
   wnoutrefresh(ww->mwin);
   
   wo->flags |= WDG_OBJ_VISIBLE;

   return WDG_E_SUCCESS;
}
Example #30
0
static void *
do_curses(void *arg)
{
	int ch;
	(void)arg;

	initscr();
	raw();
	noecho();
	nonl();
	intrflush(stdscr, FALSE);
	curs_set(0);
	erase();
	while (!quit) {
		AZ(pthread_mutex_lock(&mtx));
		update();
		AZ(pthread_mutex_unlock(&mtx));

		timeout(delay * 1000);
		switch ((ch = getch())) {
		case ERR:
			break;
#ifdef KEY_RESIZE
		case KEY_RESIZE:
			erase();
			break;
#endif
		case '\014':	/* Ctrl-L */
		case '\024':	/* Ctrl-T */
			redrawwin(stdscr);
			refresh();
			break;
		case '\032':	/* Ctrl-Z */
			endwin();
			raise(SIGTSTP);
			break;
		case '\003':	/* Ctrl-C */
		case '\021':	/* Ctrl-Q */
		case 'Q':
		case 'q':
			raise(SIGINT);
			endwin();
			return (NULL);
		case '0':
		case '1':
		case '2':
		case '3':
		case '4':
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			delay = 1 << (ch - '0');
			break;
		case '+':
			delay /= 2;
			if (delay < 1e-3)
				delay = 1e-3;
			break;
		case '-':
			delay *= 2;
			break;
		case '>':
		case '<':
			/* see below */
			break;
		default:
			beep();
			break;
		}

		if (ch == '<' || ch == '>') {
			AZ(pthread_mutex_lock(&mtx));
			vsl_to = vsl_t0 = vsl_ts;
			t0 = VTIM_mono();
			if (timebend == 0)
				timebend = 1;
			else if (ch == '<')
				timebend /= 2;
			else
				timebend *= 2;
			AZ(pthread_cond_broadcast(&timebend_cv));
			AZ(pthread_mutex_unlock(&mtx));
		}
	}
	endwin();
	return (NULL);
}