Esempio n. 1
0
File: ui.c Progetto: unixwitch/pwman
static void
ui_win_changed(int i)
{
	if (can_resize) {
		ui_resize();
		ui_refresh_windows();	/* dunno why i need this but it wont
					 * work without it */
	} else {
		should_resize = TRUE;
	}
}
Esempio n. 2
0
void
ui_handle_special_keys(const wint_t * const ch, const char * const inp,
    const int size)
{
    _win_handle_switch(ch);
    _win_handle_page(ch);
    if (*ch == KEY_RESIZE) {
        ui_resize(*ch, inp, size);
    }

}
Esempio n. 3
0
static void ui_update(Ui *ui) {
    UiCurses *uic = (UiCurses*)ui;
    if (need_resize) {
        need_resize = false;
        ui_resize(ui);
        vis_update(uic->vis);
        return;
    }
    for (UiCursesWin *win = uic->windows; win; win = win->next)
        ui_window_update(win);
    debug("ui-doupdate\n");
    doupdate();
}
Esempio n. 4
0
static void ui_update(Ui *ui) {
	UiCurses *uic = (UiCurses*)ui;
	if (need_resize) {
		ui_resize(ui);
		need_resize = false;
	}
	for (UiCursesWin *win = uic->windows; win; win = win->next) {
		if (win != uic->selwin)
			ui_window_update(win);
	}

	if (uic->selwin)
		ui_window_update(uic->selwin);
	doupdate();
}
Esempio n. 5
0
static void processevents(int wait, int *mx, int *my, int *mb, int *k)
{
    int c = -1;
    *mb = 0;
    *k = 0;
    Processevents(wait, mx, my, mb, k, &c);
    if (c > -1) {
	ui_key(c);
    }

    if (c == -2)
	ui_quit();		// -2 signals program exit

    if (resized) {
	ui_resize();		// tell Xaos to resize

    }
}
Esempio n. 6
0
void
ui_handle_login_account_success(ProfAccount *account, gboolean secured)
{
    if (account->theme) {
        if (theme_load(account->theme)) {
            ui_load_colours();
            if (prefs_get_boolean(PREF_ROSTER)) {
                ui_show_roster();
            } else {
                ui_hide_roster();
            }
            if (prefs_get_boolean(PREF_OCCUPANTS)) {
                ui_show_all_room_rosters();
            } else {
                ui_hide_all_room_rosters();
            }
            ui_resize();
        } else {
            cons_show("Couldn't find account theme: %s", account->theme);
        }
    }

    resource_presence_t resource_presence = accounts_get_login_presence(account->name);
    contact_presence_t contact_presence = contact_presence_from_resource_presence(resource_presence);
    cons_show_login_success(account, secured);
    title_bar_set_presence(contact_presence);
    title_bar_set_connected(TRUE);
    title_bar_set_tls(secured);

    GString *fulljid = g_string_new(account->jid);
    g_string_append(fulljid, "/");
    g_string_append(fulljid, account->resource);
    status_bar_print_message(fulljid->str);
    g_string_free(fulljid, TRUE);
    status_bar_update_virtual();
}
Esempio n. 7
0
File: ui.c Progetto: unixwitch/pwman
int
ui_run()
{
int		ch;
int		load_worked = 0;

#ifdef DEBUG
int		debug_i = 0;

#endif

	time_base = time(NULL);

	while (1) {
		can_resize = TRUE;
		if (should_resize) {
			ui_resize();
		}
		ch = getch();
		ui_statusline_clear();
		can_resize = FALSE;

		if ((time_base < (time(NULL) - (options->passphrase_timeout * 60)))
		    && options->passphrase_timeout != 0 && tolower(ch) != 'q') {
			folder_write_file();
			folder_free_all();

			ui_statusline_msg("Passphrase has timed out and you must enter it again.");
			getch();

			load_worked = folder_read_file();
			if (load_worked != 0) {
				ui_statusline_msg("Error - unable to re-load the password file!");
				break;
			}
			if (search_results != NULL)
				search_remove();

			time_base = time(NULL);
			continue;
		}
		switch (ch) {
		case 'Q':
		case 'q':
			if (search_results != NULL)
				search_remove();
			else if (action_list_at_top_level())
				return 0;
			break;

		case '?':
			ui_display_help();
			break;

		case KEY_PPAGE:
			uilist_page_up();
			break;

		case KEY_NPAGE:
			uilist_page_down();
			break;

		case KEY_UP:
		case 'k':
			uilist_up();
			break;

		case KEY_DOWN:
		case 'j':
			uilist_down();
			break;

		case 'A':
			if (!options->readonly)
				action_list_add_sublist();
			else
				statusline_readonly();
			break;

		case 'U':
			action_list_up_one_level();
			break;

		case 'r':
			if (!options->readonly) {
				action_list_rename();
				folder_write_file();
			} else {
				statusline_readonly();
			}
			break;

		case 'a':
			if (!options->readonly) {
				action_list_add_pw();
				folder_write_file();
			} else {
				statusline_readonly();
			}
			break;

		case 'e':
		case ' ':
		case 13:	/* return/enter key */
			action_list_select_item();
			break;

		case 'x':
			action_list_mark();
			break;

		case 'B':
			action_list_copy_username();
			break;

		case 'C':
			action_list_copy_pw();
			break;

		case 'd':
		case 0x14A:	/* DEL key */
			if (!options->readonly)
				action_list_delete_item();
			else 
				statusline_readonly();
			break;

		case 'm':
			if (!options->readonly)
				action_list_move_item();
			else
				statusline_readonly();
			break;

		case 'o':
			action_edit_options();
			break;

		case 0x17:	/* control-w */
			if (!options->readonly)
				folder_write_file();
			else
				statusline_readonly();
			break;

		case 0x12:	/* control-r */
			action_list_read_file();
			break;

		case 0x07:	/* control-g */
			pwgen_indep();
			break;

		case 0x06:	/* control-f */
			gnupg_forget_passphrase();
			break;

		case 0x0C:	/* control-l */
			ui_refresh_windows();
			break;

		case '/':
		case 'F':
			search_get();
			break;

		case 'f':
			filter_get();
			break;

		case 'E':
			action_list_export();
			break;

		case 'I':
			if (!options->readonly) {
				folder_import_passwd();
				uilist_refresh();
			} else {
				statusline_readonly();
			}
			break;

		case 'L':
			action_list_locate();
			break;

		case 'l':
			action_list_launch();
			break;

		case 0x0B:	/* control-k (up) */
		case '[':
			action_list_move_item_up();
			break;

		case 0x0A:	/* control-j (down) */
		case ']':
			action_list_move_item_down();
			break;

#ifdef DEBUG
		case '$':
			debug_i++;
			snprintf(msg, 80, "Name %d", debug_i);

			folder_add(current_pw_sublist, msg, "myhost", "myuser", "mypasswd", "mylaucnh");
			uilist_refresh();
			break;
#endif

		default:
			break;
		}
	}
	return 0;
}
Esempio n. 8
0
int
cmd_set(int argc, char *argv[])
{
   const char *err;
   char *property;
   char *value;
   bool  tf;
   int   max_w, max_h, new_width;   /* lwidth */
   bool  player_is_setup;

   if (argc != 2) {
      paint_error("usage: %s <property>=<value>", argv[0]);
      return 1;
   }

   /* determine if the player has been setup (needed for redraws below) */
   player_is_setup = (player.name  != NULL)
                  && (*player.name != NULL);

   /* extract property and value */
   property = argv[1];
   if ((value = strchr(property, '=')) == NULL) {
      paint_error("usage: %s <property>=<value>", argv[0]);
      return 2;
   }
   *value = '\0';
   value++;

   /* handle property */

   if (strcasecmp(property, "lwidth") == 0) {
      /* get max width and height */
      getmaxyx(stdscr, max_h, max_w);

      /* validate and convert width user provided */
      new_width = (int)strtonum(value, 1, max_w, &err);
      if (err != NULL) {
         paint_error("%s %s: bad width: '%s' %s",
            argv[0], property, value, err);
         return 3;
      }

      /* resize & redraw (if we're past setup & curses is running) */
      ui.lwidth = new_width;
      ui_resize();
      if(player_is_setup && ui_is_init()) {
         ui_clear();
         paint_all();
      }

   } else if (strcasecmp(property, "lhide") == 0) {
      if (str2bool(value, &tf) < 0) {
         paint_error("%s %s: value must be boolean",
            argv[0], property);
         return 4;
      }
      ui.lhide = tf;
      if (ui.lhide) {
         if (ui.active == ui.playlist)
            ui_hide_library();
         if (player_is_setup && ui_is_init()) {
            ui_clear();
            paint_all();
            paint_message("library window hidden");
         }
      } else {
         if (ui.library->cwin == NULL) ui_unhide_library();
         if (player_is_setup && ui_is_init()) paint_all();
         paint_message("library window un-hidden");
      }

   } else if (strcasecmp(property, "match-fname") == 0) {
      if (str2bool(value, &tf) < 0) {
         paint_error("%s %s: value must be boolean",
            argv[0], property);
         return 5;
      }
      mi_query_match_filename = tf;
      if (mi_query_match_filename)
         paint_message("filenames will be matched against");
      else
         paint_message("filenames will NOT be matched against");

   } else if (strcasecmp(property, "save-sorts") == 0) {
      if (str2bool(value, &tf) < 0) {
         paint_error("%s %s: value must be boolean",
            argv[0], property);
         return 6;
      }
      sorts_need_saving = tf;
      if (sorts_need_saving)
         paint_message("changing sort will be prompted for saving");
      else
         paint_message("changing sort will NOT be prompted for saving");

   } else {
      paint_error("%s: unknown property '%s'", argv[0], property);
      return 7;
   }

   return 0;
}
Esempio n. 9
0
Ui *ui_curses_new(void) {

	UiCurses *uic = calloc(1, sizeof(UiCurses));
	Ui *ui = (Ui*)uic;
	if (!uic)
		return NULL;
	if (!(uic->termkey = termkey_new(STDIN_FILENO, TERMKEY_FLAG_UTF8)))
		goto err;
	termkey_set_canonflags(uic->termkey, TERMKEY_CANON_DELBS);
	setlocale(LC_CTYPE, "");
	if (!getenv("ESCDELAY"))
		set_escdelay(50);
	char *term = getenv("TERM");
	if (!term)
		term = "xterm";
	if (!newterm(term, stderr, stdin)) {
		snprintf(uic->info, sizeof(uic->info), "Warning: unknown term `%s'", term);
		if (!newterm(strstr(term, "-256color") ? "xterm-256color" : "xterm", stderr, stdin))
			goto err;
	}
	start_color();
	use_default_colors();
	raw();
	noecho();
	nonl();
	keypad(stdscr, TRUE);
	meta(stdscr, TRUE);
	curs_set(0);
	/* needed because we use getch() which implicitly calls refresh() which
	   would clear the screen (overwrite it with an empty / unused stdscr */
	refresh();

	*ui = (Ui) {
		.init = ui_init,
		.start = ui_start,
		.free = ui_curses_free,
		.termkey_get = ui_termkey_get,
		.suspend = ui_suspend,
		.resize = ui_resize,
		.update = ui_update,
		.window_new = ui_window_new,
		.window_free = ui_window_free,
		.window_focus = ui_window_focus,
		.window_swap = ui_window_swap,
		.draw = ui_draw,
		.redraw = ui_redraw,
		.arrange = ui_arrange,
		.die = ui_die,
		.info = ui_info,
		.info_hide = ui_info_hide,
		.haskey = ui_haskey,
		.getkey = ui_getkey,
		.terminal_save = ui_terminal_save,
		.terminal_restore = ui_terminal_restore,
	};

	struct sigaction sa;
	sa.sa_flags = 0;
	sigemptyset(&sa.sa_mask);
	sa.sa_handler = sigwinch_handler;
	sigaction(SIGWINCH, &sa, NULL);
	sigaction(SIGCONT, &sa, NULL);

	ui_resize(ui);

	return ui;
err:
	ui_curses_free(ui);
	return NULL;
}