Exemple #1
0
void
update_stat_window(FileView *view)
{
	char name_buf[20];
	char perm_buf[26];
	char size_buf[56];
	char uid_buf[26];
	struct passwd *pwd_buf;
	int x, y;

	getmaxyx(stat_win, y, x);
	snprintf(name_buf, sizeof(name_buf), "%s", get_current_file_name(view));
	describe_file_size(size_buf, sizeof(size_buf),
			view->dir_entry[view->list_pos].size);
	
	if((pwd_buf = getpwuid(view->dir_entry[view->list_pos].uid)) == NULL)
	{
		snprintf (uid_buf, sizeof(uid_buf), "  %d", 
				(int) view->dir_entry[view->list_pos].uid);
	}
	else
	{
		snprintf(uid_buf, sizeof(uid_buf), "  %s", pwd_buf->pw_name);
	}
	get_perm_string(perm_buf, sizeof(perm_buf), 
			view->dir_entry[view->list_pos].mode);
	werase(stat_win);

	mvwaddstr(stat_win, 0, 2, name_buf);
	mvwaddstr(stat_win, 0, 24, size_buf);
	mvwaddstr(stat_win, 0, 36, perm_buf);
	mvwaddstr(stat_win, 0, 46, uid_buf);
	snprintf(name_buf, sizeof(name_buf), "%d %s filtered", 
			view->filtered, view->filtered == 1 ? "file" : "files");


	if(view->filtered > 0)
		mvwaddstr(stat_win, 0, x - (strlen(name_buf) +2) , name_buf);  


	wnoutrefresh(stat_win);
	update_pos_window(view);
}
Exemple #2
0
static void
leave_cmdline_mode(void)
{
	int attr;

	if(getmaxy(status_bar) > 1)
	{
		curr_stats.need_redraw = 2;
		wresize(status_bar, 1, getmaxx(stdscr) - 19);
		mvwin(status_bar, getmaxy(stdscr) - 1, 0);
		if(prev_mode == MENU_MODE)
		{
			wresize(menu_win, getmaxy(stdscr) - 1, getmaxx(stdscr));
			update_menu();
		}
	}
	else
	{
		wresize(status_bar, 1, getmaxx(stdscr) - 19);
	}

	curs_set(FALSE);
	curr_stats.save_msg = 0;
	free(input_stat.line);
	free(input_stat.line_buf);
	clean_status_bar();

	if(*mode == CMDLINE_MODE)
		*mode = prev_mode;

	if(*mode != MENU_MODE)
		update_pos_window(curr_view);

	attr = cfg.cs.color[CMD_LINE_COLOR].attr;
	wattroff(status_bar, COLOR_PAIR(DCOLOR_BASE + CMD_LINE_COLOR) | attr);

	if(prev_mode != MENU_MODE && prev_mode != VIEW_MODE)
	{
		draw_dir_list(curr_view, curr_view->top_line);
		move_to_list_pos(curr_view, curr_view->list_pos);
	}
}
Exemple #3
0
static void
leave_cmdline_mode(void)
{
	int attr;

	if(getmaxy(status_bar) > 1)
	{
		curr_stats.need_update = UT_FULL;
		wresize(status_bar, 1, getmaxx(stdscr) - FIELDS_WIDTH);
		mvwin(status_bar, getmaxy(stdscr) - 1, 0);
		if(prev_mode == MENU_MODE)
		{
			wresize(menu_win, getmaxy(stdscr) - 1, getmaxx(stdscr));
			update_menu();
		}
	}
	else
	{
		wresize(status_bar, 1, getmaxx(stdscr) - FIELDS_WIDTH);
	}

	curs_set(FALSE);
	curr_stats.save_msg = 0;
	free(input_stat.line);
	free(input_stat.initial_line);
	free(input_stat.line_buf);
	clean_status_bar();

	if(*mode == CMDLINE_MODE)
		*mode = prev_mode;

	if(*mode != MENU_MODE)
		update_pos_window(curr_view);

	attr = cfg.cs.color[CMD_LINE_COLOR].attr;
	wattroff(status_bar, COLOR_PAIR(DCOLOR_BASE + CMD_LINE_COLOR) | attr);

	if(prev_mode != MENU_MODE && prev_mode != VIEW_MODE)
	{
		redraw_current_view();
	}
}
Exemple #4
0
void
redraw_window(void)
{
    int screen_x, screen_y;
    int x, y;
    struct winsize ws;

    curr_stats.freeze = 1;

    ioctl(0, TIOCGWINSZ, &ws);

    // changed for pdcurses
    resize_term(ws.ws_row, ws.ws_col);

    getmaxyx(stdscr, screen_y, screen_x);

    if (screen_y < 10)
        finish("Terminal is too small to run vifm\n");
    if (screen_x < 30)
        finish("Terminal is too small to run vifm\n");

    wclear(stdscr);
    wclear(lwin.title);
    wclear(lwin.win);
    wclear(rwin.title);
    wclear(rwin.win);
    wclear(stat_win);
    wclear(status_bar);
    wclear(pos_win);
    wclear(num_win);
    wclear(rborder);
    wclear(mborder);
    wclear(lborder);

    wclear(change_win);
    wclear(sort_win);

    wresize(stdscr, screen_y, screen_x);
    mvwin(sort_win, (screen_y - 14)/2, (screen_x -30)/2);
    mvwin(change_win, (screen_y - 10)/2, (screen_x -30)/2);
    wresize(menu_win, screen_y - 1, screen_x);
    wresize(error_win, (screen_y -10)/2, screen_x -2);
    mvwin(error_win, (screen_y -10)/2, 1);
    wresize(lborder, screen_y -2, 1);

    if (curr_stats.number_of_windows == 1)
    {
        wresize(lwin.title, 1, screen_x -1);
        wresize(lwin.win, screen_y -3, screen_x -2);
        getmaxyx(lwin.win, y, x);
        lwin.window_width = x -1;
        lwin.window_rows = y -1;

        wresize(rwin.title, 1, screen_x -1);
        mvwin(rwin.title, 0, 1);
        wresize(rwin.win, screen_y -3, screen_x -2);
        mvwin(rwin.win, 1, 1);
        getmaxyx(rwin.win, y, x);
        rwin.window_width = x -1;
        rwin.window_rows = y -1;
    }
    else
    {
        wresize(lwin.title, 1, screen_x/2 -2);
        wresize(lwin.win, screen_y -3, screen_x/2 -2);
        getmaxyx(lwin.win, y, x);
        lwin.window_width = x -1;
        lwin.window_rows = y -1;

        mvwin(mborder, 0, screen_x/2 -1);
        wresize(mborder, screen_y, 2);

        wresize(rwin.title, 1, screen_x/2 -2);
        mvwin(rwin.title, 0, screen_x/2 +1);

        wresize(rwin.win, screen_y -3, screen_x/2 -2);
        mvwin(rwin.win, 1, screen_x/2 +1);
        getmaxyx(rwin.win, y, x);
        rwin.window_width = x -1;
        rwin.window_rows = y -1;
    }



    /* For FreeBSD */
    keypad(lwin.win, TRUE);
    keypad(rwin.win, TRUE);

    if (screen_x % 2)
    {
        wresize(rborder, screen_y -2, 2);
        mvwin(rborder, 0, screen_x -2);
    }
    else
    {
        wresize(rborder, screen_y -2, 1);
        mvwin(rborder, 0, screen_x -1);
    }

    wresize(stat_win, 1, screen_x);
    mvwin(stat_win, screen_y -2, 0);
    wresize(status_bar, 1, screen_x -19);

    /* For FreeBSD */
    keypad(status_bar, TRUE);

    mvwin(status_bar, screen_y -1, 0);
    wresize(pos_win, 1, 13);
    mvwin(pos_win, screen_y -1, screen_x -13);

    wresize(num_win, 1, 6);
    mvwin(num_win, screen_y -1, screen_x -19);

    curs_set(0);

    change_directory(&rwin, rwin.curr_dir);
    load_dir_list(&rwin, 0);
    change_directory(&lwin, lwin.curr_dir);
    load_dir_list(&lwin, 0);

    if(curr_stats.view)
    {
        wclear(other_view->win);

        change_directory(curr_view, curr_view->curr_dir);
        load_dir_list(curr_view, 0);

        quick_view_file(curr_view);
    }
    else
        change_directory(curr_view, curr_view->curr_dir);

    update_stat_window(curr_view);

    if (curr_view->selected_files)
    {
        char status_buf[24];
        snprintf(status_buf, sizeof(status_buf), "%d %s Selected",
                 curr_view->selected_files,
                 curr_view->selected_files == 1 ? "File" : "Files");
        status_bar_message(status_buf);
    }
    else
        status_bar_message(" ");


    update_pos_window(curr_view);

    update_all_windows();

    moveto_list_pos(curr_view, curr_view->list_pos);
    wrefresh(curr_view->win);

    curr_stats.freeze = 0;
    curr_stats.need_redraw = 0;


}