-
Notifications
You must be signed in to change notification settings - Fork 479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TUI (text user interface) support using ncurses library #326
Comments
It looks great. Thanks for doing this work! But I wonder why my terminal shows the lines in a strange way.
|
Could you please make vim users happy by adding |
I found the reason of broken output. I need to use diff --git a/check-deps/Makefile b/check-deps/Makefile
index 59ce19c..44dba78 100644
--- a/check-deps/Makefile
+++ b/check-deps/Makefile
@@ -7,6 +7,7 @@ CHECK_LIST += have_libpython2.7
CHECK_LIST += perf_clockid
CHECK_LIST += perf_context_switch
CHECK_LIST += arm_has_hardfp
+CHECK_LIST += have_libncursesw
CHECK_LIST += have_libncurses
#
@@ -21,6 +22,7 @@ LDFLAGS_cxa_demangle = -lstdc++
LDFLAGS_have_libelf = -lelf
CFLAGS_cc_has_mno_sse2 = -mno-sse2
LDFLAGS_have_libpython2.7 = -lpython2.7
+LDFLAGS_have_libncursesw = -lncursesw
LDFLAGS_have_libncurses = -lncurses
check-build: check-tstamp $(CHECK_LIST)
diff --git a/check-deps/Makefile.check b/check-deps/Makefile.check
index 23241d6..20ca1b7 100644
--- a/check-deps/Makefile.check
+++ b/check-deps/Makefile.check
@@ -31,7 +31,12 @@ ifneq ($(wildcard $(srcdir)/check-deps/arm_has_hardfp),)
COMMON_CFLAGS += -DHAVE_ARM_HARDFP
endif
+ifneq ($(wildcard $(srcdir)/check-deps/have_libncursesw),)
+ COMMON_CFLAGS += -DHAVE_LIBNCURSESW
+ UFTRACE_LDFLAGS += -lncursesw -ltinfo
+else
ifneq ($(wildcard $(srcdir)/check-deps/have_libncurses),)
COMMON_CFLAGS += -DHAVE_LIBNCURSES
UFTRACE_LDFLAGS += -lncurses -ltinfo
endif
+endif
diff --git a/check-deps/__have_libncursesw.c b/check-deps/__have_libncursesw.c
new file mode 100644
index 0000000..4bbaedd
--- /dev/null
+++ b/check-deps/__have_libncursesw.c
@@ -0,0 +1,8 @@
+#include <ncursesw/curses.h>
+
+int main(void)
+{
+ initscr();
+ endwin();
+ return 0;
+}
diff --git a/cmd-tui.c b/cmd-tui.c
index 022b135..a99c78c 100644
--- a/cmd-tui.c
+++ b/cmd-tui.c
@@ -1,13 +1,18 @@
-#ifdef HAVE_LIBNCURSES
+#if defined(HAVE_LIBNCURSESW) || defined(HAVE_LIBNCURSES)
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
-#include <ncurses.h>
#include <locale.h>
#include <inttypes.h>
+#ifdef HAVE_LIBNCURSESW
+#include <ncursesw/curses.h>
+#elif HAVE_LIBNCURSES
+#include <ncurses.h>
+#endif
+
#include "uftrace.h"
#include "utils/utils.h"
#include "utils/fstack.h" Now it works fine. |
The screenshot looks mostly nice. I have spot areas where further fine-tuning is possible.
I am also curious on further software evolution around implementation details. |
@honggyukim thanks, my system uses ncursesw by default. Maybe I need to change it link with ncursesw explicitly. And my system doesn't have the @elfring I don't plan to add menu bar but popup menu can be added later. AFAIK there's no column contains colon. And I'm thinking of color customization as a low-priority work item. |
@namhyung I also think that ncurses has some version difference in terms of header path. #if defined HAVE_NCURSESW_CURSES_H
# include <ncursesw/curses.h>
#elif defined HAVE_NCURSESW_H
# include <ncursesw.h>
#elif defined HAVE_NCURSES_CURSES_H
# include <ncurses/curses.h>
#elif defined HAVE_NCURSES_H
# include <ncurses.h>
#elif defined HAVE_CURSES_H
# include <curses.h>
#else
#ifdef WARN_MISSING_CURSES_CONFIGURATION
# warning SysV or X/Open-compatible Curses installation is required.
# warning Will assume Curses is found in default include and library path.
# warning To fix any build issues please use autotools to configure Curses.
# warning See INSTALL.adoc file for instructions.
#endif
# include <curses.h>
#endif So we can handle it in a similar way. |
OMG what a mess.. |
I suggest to check the relevance of the identifier “ How do you think about to move the time unit display below the column header so that it would be printed only once? |
The And time unit can be different for each line, why do you want to print it only once? |
Do you prefer any other description for the display “
This can be the default configuration.
I propose to offer a slightly different report layout when the duration values can fit to a single time unit. |
@honggyukim maybe we can use diff --git a/check-deps/Makefile b/check-deps/Makefile
index 59ce19c..9c57702 100644
--- a/check-deps/Makefile
+++ b/check-deps/Makefile
@@ -21,7 +21,8 @@ LDFLAGS_cxa_demangle = -lstdc++
LDFLAGS_have_libelf = -lelf
CFLAGS_cc_has_mno_sse2 = -mno-sse2
LDFLAGS_have_libpython2.7 = -lpython2.7
-LDFLAGS_have_libncurses = -lncurses
+CFLAGS_have_libncurses = $(shell pkg-config --cflags ncursesw)
+LDFLAGS_have_libncurses = $(shell pkg-config --libs ncursesw)
check-build: check-tstamp $(CHECK_LIST)
diff --git a/check-deps/Makefile.check b/check-deps/Makefile.check
index 23241d6..ee3b935 100644
--- a/check-deps/Makefile.check
+++ b/check-deps/Makefile.check
@@ -32,6 +32,6 @@ ifneq ($(wildcard $(srcdir)/check-deps/arm_has_hardfp),)
endif
ifneq ($(wildcard $(srcdir)/check-deps/have_libncurses),)
- COMMON_CFLAGS += -DHAVE_LIBNCURSES
- UFTRACE_LDFLAGS += -lncurses -ltinfo
+ COMMON_CFLAGS += -DHAVE_LIBNCURSES $(shell pkg-config --cflags ncursesw)
+ UFTRACE_LDFLAGS += $(shell pkg-config --libs ncursesw)
endif
diff --git a/check-deps/__have_libncurses.c b/check-deps/__have_libncurses.c
index 0c1ef2d..499f79f 100644
--- a/check-deps/__have_libncurses.c
+++ b/check-deps/__have_libncurses.c
@@ -1,4 +1,4 @@
-#include <ncurses.h>
+#include <curses.h>
int main(void)
{
diff --git a/cmd-tui.c b/cmd-tui.c
index 022b135..236e100 100644
--- a/cmd-tui.c
+++ b/cmd-tui.c
@@ -4,7 +4,7 @@
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
-#include <ncurses.h>
+#include <curses.h>
#include <locale.h>
#include <inttypes.h>
|
Thanks @namhyung! It has been a lot simpler now. :) |
Pushed review/tui-support-v2 Changelog:
|
|
Yep it's on the todo list. |
Thanks a lot for the update. I have a few more requests.
|
Pushed review/tui-support-v3 Changelog:
|
Thanks a lot for doing this. I have one more favor on it.
It's a matter of preference, but can it be Except for that, it's really great so I would like to use it very soon. So would it be possible to merge it soon then enhance it one by one later? |
I know but I'd keep as is since I see a value in moving to next/prev siblings. I think it's good to have same keys ('n' and 'p') for same directions. And I'm an emacs user. :) |
Ah.. There are |
Just FYI, emacs search keys are different but it uses |
Thanks a lot! |
Add a new command "tui" to implement user interface on a text console. This new command can do same thing with "graph" and "report" command. Also it can change the mode, fold/unfold graph nodes, and search functions dynamically. Following keys are used:
UP
/DOWN
,PAGE-UP
/-DOWN
,HOME
/END
- navigationn
/p
- move to next or previous sibling (in graph mode)u
- move to parent node (in graph mode)ENTER
- fold/unfold current node (in graph mode), or show function call graph (in report mode)c
/e
- recursively fold/unfold child node (in graph mode)g
/r
- change to graph or report mode respectively/
- start search<
/>
- move next/previous node searchedESC
- end searchv
- toggle debug modeq
- quit the tuiHere's a screenshot:
The code is available on the review/tui-support-v1 branch. Please give it a try! :)
The text was updated successfully, but these errors were encountered: