コード例 #1
0
ファイル: actions.c プロジェクト: evaryont/src
int
action_list_move_item_up_level()
{
	Pw* curpw;
	PWList *curpwl, *iter;
	int i;
	char str[STRING_LONG];
	char answer[STRING_MEDIUM];

	switch(uilist_get_highlighted_type()){
		case PW_ITEM:
			curpw = uilist_get_highlighted_item();
			if(curpw && current_pw_sublist->parent){
				pwlist_detach_pw(current_pw_sublist, curpw);
				pwlist_add_ptr(current_pw_sublist->parent, curpw);
				uilist_refresh();
			}
			break;
		case PW_SUBLIST:
			curpwl = uilist_get_highlighted_sublist();
			if(curpwl && current_pw_sublist->parent){
				pwlist_detach_sublist(current_pw_sublist, curpwl);
				pwlist_add_sublist(current_pw_sublist->parent, curpwl);
				uilist_refresh();
			}
			break;
		case PW_UPLEVEL:
		case PW_NULL:
		default:
			/* do nothing */
			break;
	}
}
コード例 #2
0
ファイル: actions.c プロジェクト: ab/pwman
int
action_list_move_item()
{
	Pw* curpw;
	PWList *curpwl, *iter;
	int i;
	char str[STRING_LONG];
	char answer[STRING_MEDIUM];

	switch(uilist_get_highlighted_type()){
		case PW_ITEM:
			curpw = uilist_get_highlighted_item();
			if(curpw){
				while(1){
					snprintf(str, STRING_LONG, "Move \"%s\" to where?", curpw->name);
					ui_statusline_ask_str(str, answer, STRING_MEDIUM);
					
					/* if user just enters nothing do nothing */
					if(answer[0] == 0){
						return 0;
					}
					
					for(iter = current_pw_sublist->sublists; iter != NULL; iter = iter->next){
						if( strcmp(iter->name, answer) == 0 ){
							pwlist_detach_pw(current_pw_sublist, curpw);
							pwlist_add_ptr(iter, curpw);
							uilist_refresh();
							return 0;
						}
					}
					ui_statusline_msg("Sublist does not exist, try again");
					getch();
				}
			}
			break;
		case PW_SUBLIST:
			curpwl = uilist_get_highlighted_sublist();
			if(curpwl){
				while(1){
					snprintf(str, STRING_LONG, "Move sublist \"%s\" to where?", curpwl->name);
					ui_statusline_ask_str(str, answer, STRING_MEDIUM);
					
					/* if user just enters nothing, do nothing */
					if(answer[0] == 0){
						return 0;
					}
					if( strcmp(answer, curpwl->name) == 0 ){
						return 0;
					}

					for(iter = current_pw_sublist->sublists; iter != NULL; iter = iter->next){
						if( strcmp(iter->name, answer) == 0 ){
							pwlist_detach_sublist(current_pw_sublist, curpwl);
							pwlist_add_sublist(iter, curpwl);
							uilist_refresh();
							return 0;
						}
					}
					ui_statusline_msg("Sublist does not exist, try again");
					getch();
				}
			}
			break;
		case PW_UPLEVEL:
		case PW_NULL:
		default:
			/* do nothing */
			break;
	}
}