int cmd_display(int argc, char *argv[]) { const char *errmsg; if (argc != 2) { paint_error("usage: display [ reset | show | <display-description> ]"); return 1; } /* show existng display? */ if (strcasecmp(argv[1], "show") == 0) { paint_message(":display %s", mi_display_tostr()); return 0; } /* reset display to default? */ if (strcasecmp(argv[1], "reset") == 0) { mi_display_reset(); paint_playlist(); return 0; } /* if reached here, setup global display description */ if (mi_display_set(argv[1], &errmsg) != 0) { paint_error("%s: bad display description: %s", argv[0], errmsg); return 1; } if(ui_is_init()) paint_playlist(); return 0; }
int cmd_sort(int argc, char *argv[]) { const char *errmsg; if (argc != 2) { paint_error("usage: sort <sort-description>"); return 1; } /* setup global sort description */ if (mi_sort_set(argv[1], &errmsg) != 0) { paint_error("%s: bad sort description: %s", argv[0], errmsg); return 2; } /* do the actual sort */ qsort(viewing_playlist->files, viewing_playlist->nfiles, sizeof(meta_info*), mi_compare); if (!ui_is_init()) return 0; /* redraw */ paint_playlist(); /* if we sorted a playlist other than library, and user wants to save sorts */ if (viewing_playlist != mdb.library && sorts_need_saving) { viewing_playlist->needs_saving = true; paint_library(); } return 0; }
/* paint all windows */ void paint_all() { paint_borders(); paint_player(); paint_status_bar(); paint_library(); paint_playlist(); }
int cmd_filter(int argc, char *argv[]) { playlist *results; char *search_phrase; bool match; int i; if (argc == 1) { paint_error("usage: filter[!] token [token2 ...]"); return 1; } /* determine what kind of filter we're doing */ match = argv[0][strlen(argv[0]) - 1] != '!'; /* set the raw query */ search_phrase = argv2str(argc - 1, argv + 1); mi_query_setraw(search_phrase); free(search_phrase); /* clear existing global query & set new one */ mi_query_clear(); for (i = 1; i < argc; i++) mi_query_add_token(argv[i]); /* do actual filter */ results = playlist_filter(viewing_playlist, match); /* swap necessary bits of results with filter playlist */ swap(meta_info **, results->files, mdb.filter_results->files); swap(int, results->nfiles, mdb.filter_results->nfiles); swap(int, results->capacity, mdb.filter_results->capacity); playlist_free(results); /* redraw */ setup_viewing_playlist(mdb.filter_results); paint_library(); paint_playlist(); return 0; }