int last_display_index, currently_displayed_index;
struct processtop *selected_process = NULL;
-int selected_tid;
-char *selected_comm;
int selected_ret;
int selected_line = 0; /* select bar position */
int toggle_pause = -1;
int max_center_lines;
+GPtrArray *selected_processes;
pthread_t keyboard_thread;
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 */
}
termtype = getenv("TERM");
if (!strcmp(termtype, "xterm") || !strcmp(termtype, "xterm-color") ||
wrefresh(status);
}
+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->tid == process->tid)
+ return 1;
+ }
+ return 0;
+}
+
+void update_selected_processes()
+{
+ if (process_selected(selected_process)) {
+ g_ptr_array_remove(selected_processes, selected_process);
+ print_log("Process removed");
+ } else {
+ g_ptr_array_add(selected_processes, selected_process);
+ print_log("Process added");
+ }
+}
+
void print_key(WINDOW *win, char *key, char *desc, int toggle)
{
int pair;
print_key(footer, "F3", "PerfTop ", current_view == perf);
print_key(footer, "F4", "IOTop ", current_view == iostream);
print_key(footer, "Enter", "Details ", current_view == process_details);
+ print_key(footer, "Space", "Highlight ", 0);
print_key(footer, "q", "Quit | ", 0);
print_key(footer, "P", "Perf Pref ", 0);
print_key(footer, "p", "Pause ", toggle_pause);
nblinedisplayed < max_center_lines; i++) {
tmp = g_ptr_array_index(data->process_table, i);
+ if (process_selected(tmp)) {
+ wattron(center, COLOR_PAIR(6));
+ mvwhline(center, current_line + header_offset, 1, ' ', COLS-3);
+ }
if (current_line == selected_line) {
selected_process = tmp;
- selected_tid = tmp->tid;
- selected_comm = tmp->comm;
wattron(center, COLOR_PAIR(5));
mvwhline(center, current_line + header_offset, 1, ' ', COLS-3);
}
mvwprintw(center, current_line + header_offset, 22, "%d", tmp->tid);
/* NAME */
mvwprintw(center, current_line + header_offset, 32, "%s", tmp->comm);
+ wattroff(center, COLOR_PAIR(6));
wattroff(center, COLOR_PAIR(5));
nblinedisplayed++;
current_line++;
{
unsigned long elapsed;
double maxcputime;
- struct processtop *tmp = find_process_tid(data, selected_tid, selected_comm);
+ struct processtop *tmp = find_process_tid(data,
+ selected_process->tid,
+ selected_process->comm);
struct files *file_tmp;
int i, j = 0;
maxcputime = elapsed * data->cpu_table->len / 100.0;
print_key_title("Name", 1);
- wprintw(center, "%s", selected_comm);
+ wprintw(center, "%s", tmp->comm);
print_key_title("TID", 2);
- wprintw(center, "%d", selected_tid);
+ wprintw(center, "%d", tmp->tid);
if (!tmp) {
print_key_title("Does not exit at this time", 3);
return;
nblinedisplayed < max_center_lines; i++) {
tmp = g_ptr_array_index(data->process_table, i);
+ if (process_selected(tmp)) {
+ wattron(center, COLOR_PAIR(6));
+ mvwhline(center, current_line + header_offset, 1, ' ', COLS-3);
+ }
if (current_line == selected_line) {
selected_process = tmp;
- selected_tid = tmp->tid;
- selected_comm = tmp->comm;
wattron(center, COLOR_PAIR(5));
mvwhline(center, current_line + header_offset, 1, ' ', COLS-3);
}
}
}
+ wattroff(center, COLOR_PAIR(6));
wattroff(center, COLOR_PAIR(5));
nblinedisplayed++;
current_line++;
nblinedisplayed < max_center_lines; i++) {
tmp = g_ptr_array_index(data->process_table, i);
+ if (process_selected(tmp)) {
+ wattron(center, COLOR_PAIR(6));
+ mvwhline(center, current_line + header_offset, 1, ' ', COLS-3);
+ }
if (current_line == selected_line) {
selected_process = tmp;
- selected_tid = tmp->tid;
- selected_comm = tmp->comm;
wattron(center, COLOR_PAIR(5));
mvwhline(center, current_line + header_offset, 1, ' ', COLS-3);
}
mvwprintw(center, current_line + header_offset, 80, "%d", tmp->tid);
/* NAME */
mvwprintw(center, current_line + header_offset, 92, "%s", tmp->comm);
+ wattroff(center, COLOR_PAIR(6));
wattroff(center, COLOR_PAIR(5));
nblinedisplayed++;
current_line++;
doupdate();
}
-
void toggle_perf_panel(void)
{
if (perf_panel_visible) {
break;
case ' ':
- if (perf_panel_visible)
+ if (perf_panel_visible) {
update_perf_panel(perf_line_selected, 1, 0);
+ } else {
+ update_selected_processes();
+ update_current_view();
+ }
break;
case 's':
if (perf_panel_visible)
void init_ncurses()
{
+ selected_processes = g_ptr_array_new();
sem_init(&update_display_sem, 0, 1);
init_screen();