int toggle_pause = -1;
int max_center_lines;
-GPtrArray *selected_processes;
pthread_t keyboard_thread;
init_pair(2, COLOR_GREEN, COLOR_BLACK); /* + */
init_pair(3, COLOR_BLACK, COLOR_WHITE); /* keys */
init_pair(4, COLOR_WHITE, COLOR_GREEN); /* keys activated */
- init_pair(5, COLOR_WHITE, COLOR_BLUE); /* select line */
- init_pair(6, COLOR_WHITE, COLOR_GREEN); /* selected process */
+ init_pair(5, COLOR_BLACK, COLOR_YELLOW); /* select line */
+ init_pair(6, COLOR_GREEN, COLOR_BLACK); /* selected process */
+ init_pair(7, COLOR_RED, COLOR_YELLOW); /* selected process + line*/
}
termtype = getenv("TERM");
if (!strcmp(termtype, "xterm") || !strcmp(termtype, "xterm-color") ||
int process_selected(struct processtop *process)
{
- int i;
- struct processtop *stored_process;
-
- for (i = 0; i < selected_processes->len; i++) {
- stored_process = g_ptr_array_index(selected_processes, i);
- if (!stored_process)
- return 0;
- if (stored_process->tid == process->tid)
- return 1;
- }
+ if (lookup_filter_tid_list(process->tid))
+ return 1;
return 0;
}
void update_selected_processes()
{
- int i;
- struct processtop *stored_process;
-
if (process_selected(selected_process)) {
- for (i = 0; i < selected_processes->len; i++) {
- stored_process = g_ptr_array_index(selected_processes, i);
- if (!stored_process)
- return;
- if (stored_process->tid == selected_process->tid)
- g_ptr_array_remove(selected_processes,
- stored_process);
- print_log("Process removed");
- }
+ remove_filter_tid_list(selected_process->tid);
} else {
- g_ptr_array_add(selected_processes, selected_process);
- print_log("Process added");
+ add_filter_tid_list(selected_process->tid, selected_process);
}
}
nblinedisplayed < max_center_lines; i++) {
tmp = g_ptr_array_index(data->process_table, i);
current_row_offset = 1;
- if (!opt_tid && (opt_hostname && !lookup_hostname_list(tmp->hostname)))
- continue;
- if (!opt_hostname && (opt_tid && !lookup_tid_list(tmp->pid)))
- continue;
- if ((opt_tid && !lookup_tid_list(tmp->tid)) &&
- (opt_hostname && !lookup_hostname_list(tmp->hostname)))
+ if (toggle_filter > 0 && !lookup_filter_tid_list(tmp->tid))
continue;
if (tmp->pid != tmp->tid)
if (toggle_threads == -1)
continue;
- if (process_selected(tmp)) {
- wattron(center, COLOR_PAIR(6));
- mvwhline(center, current_line + header_offset, 1, ' ', COLS-3);
- }
+ /* line */
if (current_line == selected_line) {
selected_process = tmp;
wattron(center, COLOR_PAIR(5));
mvwhline(center, current_line + header_offset, 1, ' ', COLS-3);
}
+ /* filtered process */
+ if (process_selected(tmp)) {
+ if (current_line == selected_line)
+ wattron(center, COLOR_PAIR(7));
+ else
+ wattron(center, COLOR_PAIR(6));
+ }
/* CPU(%) */
mvwprintw(center, current_line + header_offset,
current_row_offset, "%1.2f",
/* NAME */
mvwprintw(center, current_line + header_offset,
current_row_offset, "%s", tmp->comm);
+ wattroff(center, COLOR_PAIR(7));
wattroff(center, COLOR_PAIR(6));
wattroff(center, COLOR_PAIR(5));
nblinedisplayed++;
nblinedisplayed < max_center_lines; i++) {
tmp = g_ptr_array_index(data->process_table, i);
- if (!opt_tid && (opt_hostname && !lookup_hostname_list(tmp->hostname)))
- continue;
- if (!opt_hostname && (opt_tid && !lookup_tid_list(tmp->pid)))
- continue;
- if ((opt_tid && !lookup_tid_list(tmp->tid)) &&
- (opt_hostname && !lookup_hostname_list(tmp->hostname)))
+ if (toggle_filter > 0 && !lookup_filter_tid_list(tmp->tid))
continue;
if (tmp->pid != tmp->tid)
continue;
if (process_selected(tmp)) {
- wattron(center, COLOR_PAIR(6));
- mvwhline(center, current_line + header_offset, 1, ' ', COLS-3);
+ if (current_line == selected_line)
+ wattron(center, COLOR_PAIR(7));
+ else
+ wattron(center, COLOR_PAIR(6));
}
if (current_line == selected_line) {
selected_process = tmp;
nblinedisplayed < max_center_lines; i++) {
tmp = g_ptr_array_index(data->process_table, i);
- if (!opt_tid && (opt_hostname && !lookup_hostname_list(tmp->hostname)))
- continue;
- if (!opt_hostname && (opt_tid && !lookup_tid_list(tmp->pid)))
- continue;
- if ((opt_tid && !lookup_tid_list(tmp->tid)) &&
- (opt_hostname && !lookup_hostname_list(tmp->hostname)))
+ if (toggle_filter > 0 && !lookup_filter_tid_list(tmp->tid))
continue;
if (tmp->pid != tmp->tid)
continue;
if (process_selected(tmp)) {
- wattron(center, COLOR_PAIR(6));
- mvwhline(center, current_line + header_offset, 1, ' ', COLS-3);
+ if (current_line == selected_line)
+ wattron(center, COLOR_PAIR(7));
+ else
+ wattron(center, COLOR_PAIR(6));
}
if (current_line == selected_line) {
selected_process = tmp;
update_preference_panel(&pref_line_selected, 1, 0);
} else {
update_selected_processes();
+ if (toggle_filter > 0) {
+ max_elements = g_hash_table_size(global_filter_list);
+ fprintf(stderr, "select : %d, max : %d\n",
+ selected_line, max_elements);
+ if (selected_line >= max_elements)
+ selected_line = max_elements - 1;
+ }
update_current_view();
}
break;
/* exit keyboard thread */
pthread_exit(0);
break;
+ case 'f':
+ toggle_filter *= -1;
+ selected_line = 0;
+ if (toggle_filter > 0)
+ max_elements = g_hash_table_size(global_filter_list);
+ else
+ max_elements = data->process_table->len;
+ update_current_view();
+ break;
case 't':
toggle_threads *= -1;
update_current_view();
void init_ncurses()
{
- selected_processes = g_ptr_array_new();
sem_init(&update_display_sem, 0, 1);
init_view_headers();
init_screen();