From: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
To: Namhyung Kim <namhyung.kim@lge.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@elte.hu>,
Namhyung Kim <namhyung@gmail.com>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/5] perf ui browser: Introduce ui_browser__input_window
Date: Fri, 16 Mar 2012 16:40:39 -0300 [thread overview]
Message-ID: <20120316194039.GO9528@infradead.org> (raw)
In-Reply-To: <1331887855-874-2-git-send-email-namhyung.kim@lge.com>
Em Fri, Mar 16, 2012 at 05:50:52PM +0900, Namhyung Kim escreveu:
> The ui_browser__input_window() function is to get user's key input.
> Current implementation can handle maximum 49 characters.
You need to clean the lines with no strings using something like:
SLsmg_write_nstring((char *)" ", max_len);
After gotorcing there, etc. To avoid things like:
+ 1.29% perf [jbd2] [k] do_get_write_access
+ 1.19% init [kernel.kallsyms] [k] native_┌─Symbol to show─────────────────────────────────────────────┐
+ 0.78% swapper [kernel.kallsyms] [k] schedul│Please enter the name of symbol you want to see │
+ 0.63% init [kernel.kallsyms] [k] __hrtim│r_start_range_ns │
+ 0.62% firefox ld-2.12.so [.] __tls_g│t┌────────────────────────────────────────────────────────┐ │
+ 0.44% firefox [kernel.kallsyms] [k] avc_has│p│rm_noaudit │ │
+ 0.44% firefox libglib-2.0.so.0.2200.5 [.] g_slice│f└────────────────────────────────────────────────────────┘ │
+ 0.41% Xorg [kernel.kallsyms] [k] list_de│ │
+ 0.39% firefox [kernel.kallsyms] [k] read_ts│ENTER: OK, ESC: Cancel │
+ 0.38% init [kernel.kallsyms] [k] _spin_l└────────────────────────────────────────────────────────────┘
+ 0.36% firefox [kernel.kallsyms] [k] _spin_unlock_irqrestore
I'm applying this one, please send a fix on top of perf/core later when I ask
Ingo to pull the current backlog,
Thanks,
- Arnaldo
> Signed-off-by: Namhyung Kim <namhyung.kim@lge.com>
> ---
> tools/perf/util/ui/browser.h | 2 +
> tools/perf/util/ui/keysyms.h | 2 +
> tools/perf/util/ui/util.c | 78 ++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 82 insertions(+), 0 deletions(-)
>
> diff --git a/tools/perf/util/ui/browser.h b/tools/perf/util/ui/browser.h
> index 84d761b730c1..6ee82f60feaf 100644
> --- a/tools/perf/util/ui/browser.h
> +++ b/tools/perf/util/ui/browser.h
> @@ -49,6 +49,8 @@ int ui_browser__warning(struct ui_browser *browser, int timeout,
> const char *format, ...);
> int ui_browser__help_window(struct ui_browser *browser, const char *text);
> bool ui_browser__dialog_yesno(struct ui_browser *browser, const char *text);
> +int ui_browser__input_window(const char *title, const char *text, char *input,
> + const char *exit_msg, int delay_sec);
>
> void ui_browser__argv_seek(struct ui_browser *browser, off_t offset, int whence);
> unsigned int ui_browser__argv_refresh(struct ui_browser *browser);
> diff --git a/tools/perf/util/ui/keysyms.h b/tools/perf/util/ui/keysyms.h
> index 3458b1985761..809eca5707fa 100644
> --- a/tools/perf/util/ui/keysyms.h
> +++ b/tools/perf/util/ui/keysyms.h
> @@ -16,6 +16,8 @@
> #define K_TAB '\t'
> #define K_UNTAB SL_KEY_UNTAB
> #define K_UP SL_KEY_UP
> +#define K_BKSPC 0x7f
> +#define K_DEL SL_KEY_DELETE
>
> /* Not really keys */
> #define K_TIMER -1
> diff --git a/tools/perf/util/ui/util.c b/tools/perf/util/ui/util.c
> index 45daa7c41dad..360f43fd5400 100644
> --- a/tools/perf/util/ui/util.c
> +++ b/tools/perf/util/ui/util.c
> @@ -69,6 +69,84 @@ int ui__popup_menu(int argc, char * const argv[])
> return popup_menu__run(&menu);
> }
>
> +int ui_browser__input_window(const char *title, const char *text, char *input,
> + const char *exit_msg, int delay_secs)
> +{
> + int x, y, len, key;
> + int max_len = 60, nr_lines = 0;
> + static char buf[50];
> + const char *t;
> +
> + t = text;
> + while (1) {
> + const char *sep = strchr(t, '\n');
> +
> + if (sep == NULL)
> + sep = strchr(t, '\0');
> + len = sep - t;
> + if (max_len < len)
> + max_len = len;
> + ++nr_lines;
> + if (*sep == '\0')
> + break;
> + t = sep + 1;
> + }
> +
> + max_len += 2;
> + nr_lines += 8;
> + y = SLtt_Screen_Rows / 2 - nr_lines / 2;
> + x = SLtt_Screen_Cols / 2 - max_len / 2;
> +
> + SLsmg_set_color(0);
> + SLsmg_draw_box(y, x++, nr_lines, max_len);
> + if (title) {
> + SLsmg_gotorc(y, x + 1);
> + SLsmg_write_string((char *)title);
> + }
> + SLsmg_gotorc(++y, x);
> + nr_lines -= 7;
> + max_len -= 2;
> + SLsmg_write_wrapped_string((unsigned char *)text, y, x,
> + nr_lines, max_len, 1);
> + y += nr_lines + 1;
> + SLsmg_set_color(0);
> + SLsmg_draw_box(y - 1, x + 1, 3, max_len - 2);
> +
> + SLsmg_gotorc(y + 3, x);
> + SLsmg_write_nstring((char *)exit_msg, max_len);
> + SLsmg_refresh();
> +
> + x += 2;
> + len = 0;
> + key = ui__getch(delay_secs);
> + while (key != K_TIMER && key != K_ENTER && key != K_ESC) {
> + if (key == K_BKSPC) {
> + if (len == 0)
> + goto next_key;
> + SLsmg_gotorc(y, x + --len);
> + SLsmg_write_char(' ');
> + } else {
> + buf[len] = key;
> + SLsmg_gotorc(y, x + len++);
> + SLsmg_write_char(key);
> + }
> + SLsmg_refresh();
> +
> + /* XXX more graceful overflow handling needed */
> + if (len == sizeof(buf) - 1) {
> + ui_helpline__push("maximum size of symbol name reached!");
> + key = K_ENTER;
> + break;
> + }
> +next_key:
> + key = ui__getch(delay_secs);
> + }
> +
> + buf[len] = '\0';
> + strncpy(input, buf, len+1);
> + return key;
> +}
> +
> int ui__question_window(const char *title, const char *text,
> const char *exit_msg, int delay_secs)
> {
> --
> 1.7.9
next prev parent reply other threads:[~2012-03-16 19:40 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-16 8:50 [PATCH v2 1/5] perf hists: Add hists__filter_by_symbol Namhyung Kim
2012-03-16 8:50 ` [PATCH v2 2/5] perf ui browser: Introduce ui_browser__input_window Namhyung Kim
2012-03-16 19:40 ` Arnaldo Carvalho de Melo [this message]
2012-03-19 2:46 ` [PATCH] perf ui browser: Clean lines inside of the input window Namhyung Kim
2012-03-19 20:06 ` [tip:perf/core] " tip-bot for Namhyung Kim
2012-03-19 20:03 ` [tip:perf/core] perf ui browser: Introduce ui_browser__input_window tip-bot for Namhyung Kim
2012-03-16 8:50 ` [PATCH v2 3/5] perf ui browser: Add 's' key to filter by symbol name Namhyung Kim
2012-03-19 20:03 ` [tip:perf/core] " tip-bot for Namhyung Kim
2012-03-16 8:50 ` [PATCH v2 4/5] perf report: Add --symbol-filter option Namhyung Kim
2012-03-16 19:42 ` Arnaldo Carvalho de Melo
2012-03-19 2:53 ` [PATCH] perf report: Document " Namhyung Kim
2012-03-19 20:07 ` [tip:perf/core] " tip-bot for Namhyung Kim
2012-03-19 20:04 ` [tip:perf/core] perf report: Add " tip-bot for Namhyung Kim
2012-03-16 8:50 ` [PATCH v2 5/5] perf report: Treat an argument as a symbol filter Namhyung Kim
2012-03-19 20:05 ` [tip:perf/core] " tip-bot for Namhyung Kim
2012-03-19 20:02 ` [tip:perf/core] perf hists: Add hists__filter_by_symbol tip-bot for Namhyung Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120316194039.GO9528@infradead.org \
--to=acme@ghostprotocols.net \
--cc=a.p.zijlstra@chello.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=namhyung.kim@lge.com \
--cc=namhyung@gmail.com \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox