Skip to contentSkip to conversation

tuninig: resize scaling support (v1)

PATCH In review Sergey Senozhatsky 3 participants 9 messages Aug 22, 2012 – Sep 11, 2012

lore
Share & tools
lore

Sergey Senozhatsky

author
#0 lore raw

PATCH 1/1 tuninig: resize scaling support (v1)

tuninig: resize scaling support v1

Initial version of terminal window resize support for tuning tab. Supports both X and Y scalings:
-- X scaling: truncation (*)
* tunable result and description strings are now stored in dynamic array, limited in size to current window X (mod MAX_LEN).

-- Y scaling: paging and scrolling

Signed-off-by Sergey Senozhatsky <sergey.senozhatsky(a)gmail.com>

---

 src/tuning/tuning.cpp | 87 +++++++++++++++++++++++++++++++++++----------------
 1 file changed, 60 insertions(+), 27 deletions(-)
src/tuning/tuning.cpp +60 -27
index 4893597..541e9e0 100644
@@ -28,7 +28,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <ncurses.h>
-
+#include <math.h>
 
 #include "tuning.h"
 #include "tuningsysfs.h"
@@ -79,48 +79,81 @@ void initialize_tuning(void)
 	create_tab("Tunables", _("Tunables"), w, _(" <ESC> Exit | <Enter> Toggle tunable | <r> Window refresh"));
 
 	init_tuning();
-
 	w->cursor_max = all_tunables.size() - 1;
 }
 
+#define XINDENT	3
+#define YINDENT	4
+#define MAX_LEN	4096
 
+static void redraw_window(WINDOW *win, int begin, int end, int cursor_pos)
+{
+	int x, y, i;
+	getmaxyx(stdscr, y, x);
+	
+	wclrtoeol(win);
+	wmove(win, 1, 0);
+	x %= MAX_LEN;
+
+	for (y = 0, i = begin; i < end; i++, y++) {
+		char truncate = 0;
+		size_t sz = 0;
+		char line[x + 1];
+		if ((int)(y) != cursor_pos) {
+			wattrset(win, A_NORMAL);
+			sz = snprintf(line, x, "   ");
+		} else {
+			wattrset(win, A_REVERSE);
+			sz = snprintf(line, x, ">> ");
+		}
+		sz += snprintf(line + sz, x, "%s", all_tunables[i]->result_string());
+		while (sz < 12)
+			sz += snprintf(line + sz, x, " ");
+		sz += snprintf(line + sz, x, "%s", all_tunables[i]->description());
+		if ((int)sz > x - XINDENT)
+			truncate = 1;
+		while ((int)sz < x - XINDENT)
+			sz += snprintf(line + sz, x, " ");
+		if (truncate)
+			sz += snprintf(line + x - XINDENT - 1, x, "~\n");
+		else
+			sz += snprintf(line + sz, x, "\n");
+
+		waddnstr(win, line, sz);
+	}
+}
 
 static void __tuning_update_display(int cursor_pos)
 {
+	static int last_frame_nr = 0;
+	int x, y, begin, end, frame_nr;
 	WINDOW *win;
-	unsigned int i;
-
+        
 	win = get_ncurses_win("Tunables");
-
 	if (!win)
 		return;
+	getmaxyx(stdscr, y, x);
+
+	y -= YINDENT;
+	frame_nr = ceil(cursor_pos / y);
+	end = (frame_nr + 1) * y;
+	if (end > (int)all_tunables.size())
+		end = all_tunables.size();
+
+	begin = frame_nr * y;
+	/* actual cursor position is frame-dependent */
+	cursor_pos -= frame_nr * y;
+	if (frame_nr != last_frame_nr)
+		should_clear = TRUE;
+	last_frame_nr = frame_nr;
 
 	if (should_clear) {
-		should_clear = false;
+		should_clear = FALSE;
 		wclear(win);
 	}
 
-	wmove(win, 2,0);
-
-	for (i = 0; i < all_tunables.size(); i++) {
-		char res[128];
-		char desc[4096];
-		strcpy(res, all_tunables[i]->result_string());
-		strcpy(desc, all_tunables[i]->description());
-		while (strlen(res) < 12)
-			strcat(res, " ");
-
-		while (strlen(desc) < 103)
-			strcat(desc, " ");
-		if ((int)i != cursor_pos) {
-			wattrset(win, A_NORMAL);
-			wprintw(win, "   ");
-		} else {
-			wattrset(win, A_REVERSE);
-			wprintw(win, ">> ");
-		}
-		wprintw(win, "%s  %s\n", _(res), _(desc));
-	}
+	redraw_window(win, begin, end, cursor_pos);
+	wnoutrefresh(win);
 }
 
 void tuning_update_display(void)
#1 lore raw
Quoted 9 lines · Sergey Senozhatsky

tuninig: resize scaling support v1

Initial version of terminal window resize support for tuning tab. Supports both X and Y scalings:
-- X scaling: truncation (*)
* tunable result and description strings are now stored in dynamic array, limited in size to current window X (mod MAX_LEN).

-- Y scaling: paging and scrolling

Have you tested this patch in a locale that are using multibyte characters?

The len argument to snprintf is the number of bytes in the result string and strlen also returns the number of bytes in the string.

/MF

Quoted 134 lines
Signed-off-by Sergey Senozhatsky <sergey.senozhatsky(a)gmail.com>

---

 src/tuning/tuning.cpp | 87 +++++++++++++++++++++++++++++++++++----------------
 1 file changed, 60 insertions(+), 27 deletions(-)
src/tuning/tuning.cpp +60 -27
index 4893597..541e9e0 100644
@@ -28,7 +28,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <ncurses.h>
-
+#include <math.h>
 
 #include "tuning.h"
 #include "tuningsysfs.h"
@@ -79,48 +79,81 @@ void initialize_tuning(void)
 	create_tab("Tunables", _("Tunables"), w, _(" <ESC> Exit | <Enter> Toggle tunable | <r> Window refresh"));
 
 	init_tuning();
-
 	w->cursor_max = all_tunables.size() - 1;
 }
 
+#define XINDENT	3
+#define YINDENT	4
+#define MAX_LEN	4096
 
+static void redraw_window(WINDOW *win, int begin, int end, int cursor_pos)
+{
+	int x, y, i;
+	getmaxyx(stdscr, y, x);
+	
+	wclrtoeol(win);
+	wmove(win, 1, 0);
+	x %= MAX_LEN;
+
+	for (y = 0, i = begin; i < end; i++, y++) {
+		char truncate = 0;
+		size_t sz = 0;
+		char line[x + 1];
+		if ((int)(y) != cursor_pos) {
+			wattrset(win, A_NORMAL);
+			sz = snprintf(line, x, "   ");
+		} else {
+			wattrset(win, A_REVERSE);
+			sz = snprintf(line, x, ">> ");
+		}
+		sz += snprintf(line + sz, x, "%s", all_tunables[i]->result_string());
+		while (sz < 12)
+			sz += snprintf(line + sz, x, " ");
+		sz += snprintf(line + sz, x, "%s", all_tunables[i]->description());
+		if ((int)sz > x - XINDENT)
+			truncate = 1;
+		while ((int)sz < x - XINDENT)
+			sz += snprintf(line + sz, x, " ");
+		if (truncate)
+			sz += snprintf(line + x - XINDENT - 1, x, "~\n");
+		else
+			sz += snprintf(line + sz, x, "\n");
+
+		waddnstr(win, line, sz);
+	}
+}
 
 static void __tuning_update_display(int cursor_pos)
 {
+	static int last_frame_nr = 0;
+	int x, y, begin, end, frame_nr;
 	WINDOW *win;
-	unsigned int i;
-
+        
 	win = get_ncurses_win("Tunables");
-
 	if (!win)
 		return;
+	getmaxyx(stdscr, y, x);
+
+	y -= YINDENT;
+	frame_nr = ceil(cursor_pos / y);
+	end = (frame_nr + 1) * y;
+	if (end > (int)all_tunables.size())
+		end = all_tunables.size();
+
+	begin = frame_nr * y;
+	/* actual cursor position is frame-dependent */
+	cursor_pos -= frame_nr * y;
+	if (frame_nr != last_frame_nr)
+		should_clear = TRUE;
+	last_frame_nr = frame_nr;
 
 	if (should_clear) {
-		should_clear = false;
+		should_clear = FALSE;
 		wclear(win);
 	}
 
-	wmove(win, 2,0);
-
-	for (i = 0; i < all_tunables.size(); i++) {
-		char res[128];
-		char desc[4096];
-		strcpy(res, all_tunables[i]->result_string());
-		strcpy(desc, all_tunables[i]->description());
-		while (strlen(res) < 12)
-			strcat(res, " ");
-
-		while (strlen(desc) < 103)
-			strcat(desc, " ");
-		if ((int)i != cursor_pos) {
-			wattrset(win, A_NORMAL);
-			wprintw(win, "   ");
-		} else {
-			wattrset(win, A_REVERSE);
-			wprintw(win, ">> ");
-		}
-		wprintw(win, "%s  %s\n", _(res), _(desc));
-	}
+	redraw_window(win, begin, end, cursor_pos);
+	wnoutrefresh(win);
 }
 
 void tuning_update_display(void)

_______________________________________________
PowerTop mailing list
PowerTop(a)lists.01.org
https://lists.01.org/mailman/listinfo/powertop

author
#2 lore raw
Quoted 9 lines · Magnus Fromreide
Quoted 8 lines · Sergey Senozhatsky

tuninig: resize scaling support v1

Initial version of terminal window resize support for tuning tab. Supports both X and Y scalings:
-- X scaling: truncation (*)
* tunable result and description strings are now stored in dynamic array, limited in size to current window X (mod MAX_LEN).

Quoted 8 lines
Quoted 1 line

-- Y scaling: paging and scrolling

Have you tested this patch in a locale that are using multibyte characters?

The len argument to snprintf is the number of bytes in the result string and strlen also returns the number of bytes in the string.

well, line is just a stream of bytes limited in size. it was never intended to be a stream of characters. at this point we just work with bytes, it's waddnstr() who should care. the same way as "strcpy()/strlen()/strcat()-->wprintw()" worked before.

probably, we should truncate carefully, I need to think how. any input is welcome.

	-ss
Quoted 138 lines

/MF

Quoted 134 lines
Signed-off-by Sergey Senozhatsky <sergey.senozhatsky(a)gmail.com>

---

 src/tuning/tuning.cpp | 87 +++++++++++++++++++++++++++++++++++----------------
 1 file changed, 60 insertions(+), 27 deletions(-)
src/tuning/tuning.cpp +60 -27
index 4893597..541e9e0 100644
@@ -28,7 +28,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <ncurses.h>
-
+#include <math.h>
 
 #include "tuning.h"
 #include "tuningsysfs.h"
@@ -79,48 +79,81 @@ void initialize_tuning(void)
 	create_tab("Tunables", _("Tunables"), w, _(" <ESC> Exit | <Enter> Toggle tunable | <r> Window refresh"));
 
 	init_tuning();
-
 	w->cursor_max = all_tunables.size() - 1;
 }
 
+#define XINDENT	3
+#define YINDENT	4
+#define MAX_LEN	4096
 
+static void redraw_window(WINDOW *win, int begin, int end, int cursor_pos)
+{
+	int x, y, i;
+	getmaxyx(stdscr, y, x);
+	
+	wclrtoeol(win);
+	wmove(win, 1, 0);
+	x %= MAX_LEN;
+
+	for (y = 0, i = begin; i < end; i++, y++) {
+		char truncate = 0;
+		size_t sz = 0;
+		char line[x + 1];
+		if ((int)(y) != cursor_pos) {
+			wattrset(win, A_NORMAL);
+			sz = snprintf(line, x, "   ");
+		} else {
+			wattrset(win, A_REVERSE);
+			sz = snprintf(line, x, ">> ");
+		}
+		sz += snprintf(line + sz, x, "%s", all_tunables[i]->result_string());
+		while (sz < 12)
+			sz += snprintf(line + sz, x, " ");
+		sz += snprintf(line + sz, x, "%s", all_tunables[i]->description());
+		if ((int)sz > x - XINDENT)
+			truncate = 1;
+		while ((int)sz < x - XINDENT)
+			sz += snprintf(line + sz, x, " ");
+		if (truncate)
+			sz += snprintf(line + x - XINDENT - 1, x, "~\n");
+		else
+			sz += snprintf(line + sz, x, "\n");
+
+		waddnstr(win, line, sz);
+	}
+}
 
 static void __tuning_update_display(int cursor_pos)
 {
+	static int last_frame_nr = 0;
+	int x, y, begin, end, frame_nr;
 	WINDOW *win;
-	unsigned int i;
-
+        
 	win = get_ncurses_win("Tunables");
-
 	if (!win)
 		return;
+	getmaxyx(stdscr, y, x);
+
+	y -= YINDENT;
+	frame_nr = ceil(cursor_pos / y);
+	end = (frame_nr + 1) * y;
+	if (end > (int)all_tunables.size())
+		end = all_tunables.size();
+
+	begin = frame_nr * y;
+	/* actual cursor position is frame-dependent */
+	cursor_pos -= frame_nr * y;
+	if (frame_nr != last_frame_nr)
+		should_clear = TRUE;
+	last_frame_nr = frame_nr;
 
 	if (should_clear) {
-		should_clear = false;
+		should_clear = FALSE;
 		wclear(win);
 	}
 
-	wmove(win, 2,0);
-
-	for (i = 0; i < all_tunables.size(); i++) {
-		char res[128];
-		char desc[4096];
-		strcpy(res, all_tunables[i]->result_string());
-		strcpy(desc, all_tunables[i]->description());
-		while (strlen(res) < 12)
-			strcat(res, " ");
-
-		while (strlen(desc) < 103)
-			strcat(desc, " ");
-		if ((int)i != cursor_pos) {
-			wattrset(win, A_NORMAL);
-			wprintw(win, "   ");
-		} else {
-			wattrset(win, A_REVERSE);
-			wprintw(win, ">> ");
-		}
-		wprintw(win, "%s  %s\n", _(res), _(desc));
-	}
+	redraw_window(win, begin, end, cursor_pos);
+	wnoutrefresh(win);
 }
 
 void tuning_update_display(void)

_______________________________________________
PowerTop mailing list
PowerTop(a)lists.01.org
https://lists.01.org/mailman/listinfo/powertop

author
#3 lore raw
In reply to Sergey Senozhatsky
Quoted 54 lines · Sergey Senozhatsky

tuninig: resize scaling support v1

Initial version of terminal window resize support for tuning tab. Supports both X and Y scalings:
-- X scaling: truncation (*)
* tunable result and description strings are now stored in dynamic array, limited in size to current window X (mod MAX_LEN).

-- Y scaling: paging and scrolling

Signed-off-by Sergey Senozhatsky <sergey.senozhatsky(a)gmail.com>

---

 src/tuning/tuning.cpp | 87 +++++++++++++++++++++++++++++++++++----------------
 1 file changed, 60 insertions(+), 27 deletions(-)
src/tuning/tuning.cpp +15 -2
index 4893597..541e9e0 100644
@@ -28,7 +28,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <ncurses.h>
-
+#include <math.h>
 
 #include "tuning.h"
 #include "tuningsysfs.h"
@@ -79,48 +79,81 @@ void initialize_tuning(void)
 	create_tab("Tunables", _("Tunables"), w, _(" <ESC> Exit | <Enter> Toggle tunable | <r> Window refresh"));
 
 	init_tuning();
-
 	w->cursor_max = all_tunables.size() - 1;
 }
 
+#define XINDENT	3
+#define YINDENT	4
+#define MAX_LEN	4096
 
+static void redraw_window(WINDOW *win, int begin, int end, int cursor_pos)
+{
+	int x, y, i;
+	getmaxyx(stdscr, y, x);
+	
+	wclrtoeol(win);
+	wmove(win, 1, 0);
+	x %= MAX_LEN;
+
+	for (y = 0, i = begin; i < end; i++, y++) {
+		char truncate = 0;

src/tuning/tuning.cpp void initialize_tuning(void) · line 109

Quoted 10 lines
src/tuning/tuning.cpp +10 -0
+		size_t sz = 0;
+		char line[x + 1];
+		if ((int)(y) != cursor_pos) {
+			wattrset(win, A_NORMAL);
+			sz = snprintf(line, x, "   ");
+		} else {
+			wattrset(win, A_REVERSE);
+			sz = snprintf(line, x, ">> ");
+		}
+		sz += snprintf(line + sz, x, "%s", all_tunables[i]->result_string());

Hm, I guess the correct way is

	_(all_tunables[i]->result_string())

src/tuning/tuning.cpp void initialize_tuning(void) · line 112

Quoted 3 lines
src/tuning/tuning.cpp +3 -0
+		while (sz < 12)
+			sz += snprintf(line + sz, x, " ");
+		sz += snprintf(line + sz, x, "%s", all_tunables[i]->description());

the same

	_(all_tunables[i]->description())
Quoted 73 lines
src/tuning/tuning.cpp +32 -25
+		if ((int)sz > x - XINDENT)
+			truncate = 1;
+		while ((int)sz < x - XINDENT)
+			sz += snprintf(line + sz, x, " ");
+		if (truncate)
+			sz += snprintf(line + x - XINDENT - 1, x, "~\n");
+		else
+			sz += snprintf(line + sz, x, "\n");
+
+		waddnstr(win, line, sz);
+	}
+}
 
 static void __tuning_update_display(int cursor_pos)
 {
+	static int last_frame_nr = 0;
+	int x, y, begin, end, frame_nr;
 	WINDOW *win;
-	unsigned int i;
-
+        
 	win = get_ncurses_win("Tunables");
-
 	if (!win)
 		return;
+	getmaxyx(stdscr, y, x);
+
+	y -= YINDENT;
+	frame_nr = ceil(cursor_pos / y);
+	end = (frame_nr + 1) * y;
+	if (end > (int)all_tunables.size())
+		end = all_tunables.size();
+
+	begin = frame_nr * y;
+	/* actual cursor position is frame-dependent */
+	cursor_pos -= frame_nr * y;
+	if (frame_nr != last_frame_nr)
+		should_clear = TRUE;
+	last_frame_nr = frame_nr;
 
 	if (should_clear) {
-		should_clear = false;
+		should_clear = FALSE;
 		wclear(win);
 	}
 
-	wmove(win, 2,0);
-
-	for (i = 0; i < all_tunables.size(); i++) {
-		char res[128];
-		char desc[4096];
-		strcpy(res, all_tunables[i]->result_string());
-		strcpy(desc, all_tunables[i]->description());
-		while (strlen(res) < 12)
-			strcat(res, " ");
-
-		while (strlen(desc) < 103)
-			strcat(desc, " ");
-		if ((int)i != cursor_pos) {
-			wattrset(win, A_NORMAL);
-			wprintw(win, "   ");
-		} else {
-			wattrset(win, A_REVERSE);
-			wprintw(win, ">> ");
-		}
-		wprintw(win, "%s  %s\n", _(res), _(desc));
-	}
+	redraw_window(win, begin, end, cursor_pos);
+	wnoutrefresh(win);
 }
 
 void tuning_update_display(void)
#4 lore raw
Quoted 148 lines · Sergey Senozhatsky
Quoted 54 lines · Sergey Senozhatsky

tuninig: resize scaling support v1

Initial version of terminal window resize support for tuning tab. Supports both X and Y scalings:
-- X scaling: truncation (*)
* tunable result and description strings are now stored in dynamic array, limited in size to current window X (mod MAX_LEN).

-- Y scaling: paging and scrolling

Signed-off-by Sergey Senozhatsky <sergey.senozhatsky(a)gmail.com>

---

  src/tuning/tuning.cpp | 87 +++++++++++++++++++++++++++++++++++----------------
  1 file changed, 60 insertions(+), 27 deletions(-)
src/tuning/tuning.cpp +15 -2
index 4893597..541e9e0 100644
@@ -28,7 +28,7 @@
  #include <stdio.h>
  #include <string.h>
  #include <ncurses.h>
-
+#include <math.h>
 
  #include "tuning.h"
  #include "tuningsysfs.h"
@@ -79,48 +79,81 @@ void initialize_tuning(void)
  	create_tab("Tunables", _("Tunables"), w, _(" <ESC> Exit | <Enter> Toggle tunable | <r> Window refresh"));
 
  	init_tuning();
-
  	w->cursor_max = all_tunables.size() - 1;
  }
 
+#define XINDENT	3
+#define YINDENT	4
+#define MAX_LEN	4096
 
+static void redraw_window(WINDOW *win, int begin, int end, int cursor_pos)
+{
+	int x, y, i;
+	getmaxyx(stdscr, y, x);
+	
+	wclrtoeol(win);
+	wmove(win, 1, 0);
+	x %= MAX_LEN;
+
+	for (y = 0, i = begin; i < end; i++, y++) {
+		char truncate = 0;

src/tuning/tuning.cpp void initialize_tuning(void) · line 109

Quoted 10 lines
src/tuning/tuning.cpp +10 -0
+		size_t sz = 0;
+		char line[x + 1];
+		if ((int)(y) != cursor_pos) {
+			wattrset(win, A_NORMAL);
+			sz = snprintf(line, x, "   ");
+		} else {
+			wattrset(win, A_REVERSE);
+			sz = snprintf(line, x, ">> ");
+		}
+		sz += snprintf(line + sz, x, "%s", all_tunables[i]->result_string());

Hm, I guess the correct way is

	_(all_tunables[i]->result_string())

src/tuning/tuning.cpp void initialize_tuning(void) · line 112

Quoted 3 lines
src/tuning/tuning.cpp +3 -0
+		while (sz < 12)
+			sz += snprintf(line + sz, x, " ");
+		sz += snprintf(line + sz, x, "%s", all_tunables[i]->description());

the same

	_(all_tunables[i]->description())
Quoted 71 lines
src/tuning/tuning.cpp +32 -25
+		if ((int)sz > x - XINDENT)
+			truncate = 1;
+		while ((int)sz < x - XINDENT)
+			sz += snprintf(line + sz, x, " ");
+		if (truncate)
+			sz += snprintf(line + x - XINDENT - 1, x, "~\n");
+		else
+			sz += snprintf(line + sz, x, "\n");
+
+		waddnstr(win, line, sz);
+	}
+}
 
  static void __tuning_update_display(int cursor_pos)
  {
+	static int last_frame_nr = 0;
+	int x, y, begin, end, frame_nr;
  	WINDOW *win;
-	unsigned int i;
-
+
  	win = get_ncurses_win("Tunables");
-
  	if (!win)
  		return;
+	getmaxyx(stdscr, y, x);
+
+	y -= YINDENT;
+	frame_nr = ceil(cursor_pos / y);
+	end = (frame_nr + 1) * y;
+	if (end > (int)all_tunables.size())
+		end = all_tunables.size();
+
+	begin = frame_nr * y;
+	/* actual cursor position is frame-dependent */
+	cursor_pos -= frame_nr * y;
+	if (frame_nr != last_frame_nr)
+		should_clear = TRUE;
+	last_frame_nr = frame_nr;
 
  	if (should_clear) {
-		should_clear = false;
+		should_clear = FALSE;
  		wclear(win);
  	}
 
-	wmove(win, 2,0);
-
-	for (i = 0; i < all_tunables.size(); i++) {
-		char res[128];
-		char desc[4096];
-		strcpy(res, all_tunables[i]->result_string());
-		strcpy(desc, all_tunables[i]->description());
-		while (strlen(res) < 12)
-			strcat(res, " ");
-
-		while (strlen(desc) < 103)
-			strcat(desc, " ");
-		if ((int)i != cursor_pos) {
-			wattrset(win, A_NORMAL);
-			wprintw(win, "   ");
-		} else {
-			wattrset(win, A_REVERSE);
-			wprintw(win, ">> ");
-		}
-		wprintw(win, "%s  %s\n", _(res), _(desc));
-	}
+	redraw_window(win, begin, end, cursor_pos);
+	wnoutrefresh(win);
  }
 
Quoted 2 lines

src/tuning/tuning.cpp void initialize_tuning(void) · line 159

Quoted 2 lines
src/tuning/tuning.cpp +0 -0
  void tuning_update_display(void)

So this may be nice for the tuning tab, but we have an overall issue with other tabs as well.
Maybe we should change the controls around, and just move the pad. That way we could scroll all tabs and not have to truncate strings. ?
-Chris

Quoted 4 lines

_______________________________________________
PowerTop mailing list
PowerTop(a)lists.01.org
https://lists.01.org/mailman/listinfo/powertop

author
#5 lore raw
Quoted 8 lines · Chris Ferron
Quoted 1 line
Quoted 1 line

So this may be nice for the tuning tab, but we have an overall issue with other tabs as well.
Maybe we should change the controls around, and just move the pad. That way we could scroll all tabs and not have to truncate strings. ?
-Chris

That was the first one in a upcoming series of patches. Because we have separate display logic on every tab, I was moving in a direction of teaching each tabs honour resize.

Quoted 2 lines

Maybe we should change the controls around, and just move the pad. That way we could scroll all tabs and not have to truncate strings.

Sorry, I'm not sure I got this one, could you please elaborate?

We can't avaoid string truncation (unless we introduce support for horizontal scrolling as well) when X becomes smaller than the longest string in tab (we actually can just ignore it and print beyond the sceen, but I think the common behaviour in that case is to let user notice that text has been truncated via ~ for example). I don't know what to do with C, P states tab when we only have space for "Package" and "Core", or when half of currently required X space for "Frequency stats" tab is available -- dynamic re-arrange looks a bit complex at the moment.

As of Y scroll, well, we can come up with a common interface:
-- for tab w/ cursor
scrolling happens on every n*Y cursor position, because cursor step is 1.

-- for tab w/o cursor
scroling happens every cursor step (which is Y in this case).

Schematically, what we need is a common method which will tell the number of lines particular tab is going to print, flag that indecates cursor step and common method (similar to one that used in tuning tab) to print tab content from BEGIN position to END (BEGIN and END depends on current frame).

	-ss
#6 lore raw
Quoted 30 lines · Sergey Senozhatsky
Quoted 7 lines · Chris Ferron

So this may be nice for the tuning tab, but we have an overall issue with other tabs as well.
Maybe we should change the controls around, and just move the pad. That way we could scroll all tabs and not have to truncate strings. ?
-Chris

That was the first one in a upcoming series of patches. Because we have separate display logic on every tab, I was moving in a direction of teaching each tabs honour resize.

Quoted 2 lines

Maybe we should change the controls around, and just move the pad. That way we could scroll all tabs and not have to truncate strings.

Sorry, I'm not sure I got this one, could you please elaborate?

We can't avaoid string truncation (unless we introduce support for horizontal scrolling as well) when X becomes smaller than the longest string in tab (we actually can just ignore it and print beyond the sceen, but I think the common behaviour in that case is to let user notice that text has been truncated via ~ for example). I don't know what to do with C, P states tab when we only have space for "Package" and "Core", or when half of currently required X space for "Frequency stats" tab is available -- dynamic re-arrange looks a bit complex at the moment.

As of Y scroll, well, we can come up with a common interface:
-- for tab w/ cursor
scrolling happens on every n*Y cursor position, because cursor step is 1.

Quoted 7 lines

-- for tab w/o cursor
scroling happens every cursor step (which is Y in this case).

Schematically, what we need is a common method which will tell the number of lines particular tab is going to print, flag that indecates cursor step and common method (similar to one that used in tuning tab) to print tab content from BEGIN positiothen to END (BEGIN and END depends on current frame).

I will have to take another look this weekend, but if I remember correctly. We create a large pad and then place windows on for viewing. If we change the controls a bit, I think we can use the arrow keys to scroll the viewable window around the pad for all tab windows.

Refresh or a tab change would reset the viewable window. Then we could scroll x y.

I think you may be right about truncating strings, but maybe only if the string is bigger then the base pad.

Instead of arrow keys navigating tabs, we could use the "TAB" key.

Just a thought
-Chris

Quoted 2 lines
	-ss
#7 lore raw
In reply to Sergey Senozhatsky
Quoted 33 lines · Sergey Senozhatsky
Quoted 7 lines · Chris Ferron

So this may be nice for the tuning tab, but we have an overall issue with other tabs as well.
Maybe we should change the controls around, and just move the pad. That way we could scroll all tabs and not have to truncate strings. ?
-Chris

That was the first one in a upcoming series of patches. Because we have separate display logic on every tab, I was moving in a direction of teaching each tabs honour resize.

Quoted 2 lines

Maybe we should change the controls around, and just move the pad. That way we could scroll all tabs and not have to truncate strings.

Sorry, I'm not sure I got this one, could you please elaborate?

We can't avaoid string truncation (unless we introduce support for horizontal scrolling as well) when X becomes smaller than the longest string in tab (we actually can just ignore it and print beyond the sceen, but I think the common behaviour in that case is to let user notice that text has been truncated via ~ for example). I don't know what to do with C, P states tab when we only have space for "Package" and "Core", or when half of currently required X space for "Frequency stats" tab is available -- dynamic re-arrange looks a bit complex at the moment.

As of Y scroll, well, we can come up with a common interface:
-- for tab w/ cursor
scrolling happens on every n*Y cursor position, because cursor step is 1.

-- for tab w/o cursor
scroling happens every cursor step (which is Y in this case).

Quoted 7 lines

Schematically, what we need is a common method which will tell the number of lines particular tab is going to print, flag that indecates cursor step and common method (similar to one that used in tuning tab) to print tab content from BEGIN position to END (BEGIN and END depends on current frame).

	-ss

I just sent a patch attachment as "PowerTOP UI navigation enhancement". Check it out???
Sorry for the slow response.
-Chris

author
#8 lore raw
Quoted 4 lines · Chris Ferron

I just sent a patch attachment as "PowerTOP UI navigation enhancement". Check it out???
Sorry for the slow response.

sure, no problems. will take a look later this day.

	-ss