• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

修订版6f1cb6eac2f28c6e1cb49c011f2b916afb90b4ff (tree)
时间2015-08-21 12:06:47
作者Patrick Palka <patrick@parc...>
CommiterPatrick Palka

Log Message

Remove fields curch and cur_line from TUI_CMD_WIN

These fields are currently used to track the location of the cursor
inside the command window. But their usefulness is questionable because
ncurses already internally keeps track of the location of the cursor,
whose coordinates we can query using the functions getyx(), getcurx() or
getcury(). It is an unnecessary pain to keep these fields in sync with
ncurses, and their meaning is not well-defined anyway. For instance, it
is not clear whether the coordinates held in these fields are
authoritative, or whether the coordinates reported by ncurses are.

So to keep things simple, this patch removes these fields and replaces
existing reads of these fields with calls to the appropriate ncurses
querying functions, and replaces writes to these fields with calls to
wmove() (when necessary and applicable).

In the function tui_cont_sig(), I removed the call to wmove() entirely
because moving to (start_line, curch) makes no sense. The move should
have been to (cur_line, curch) -- which would now be a no-op.

Tested on x86_64 Fedora 22, no obvious regressions.

gdb/ChangeLog:

* tui/tui-data.h (tui_command_info): Remove fields cur_line and
curch.
* tui/tui-data.c (tui_clear_win_detail) [CMD_WIN]: Don't set
cur_line or curch, instead call wmove().
(init_win_info) [CMD_WIN]: Likewise.
* tui/tui-io.c (tui_puts): Likewise. Don't read cur_line,
instead call getcury().
(tui_redisplay_readline): Don't set cur_line or curch.
(tui_mld_erase_entire_line): Don't read cur_line, instead call
getcury().
(tui_cont_sig): Remove call to wmove.
(tui_getc): Don't read cur_line or curch, instead call getcury()
or getyx(). Don't set curch.
* tui/tui-win.c (make_visible_with_new_height) [CMD_WIN]: Don't
set cur_line or curch. Always move cursor to (0,0).

更改概述

差异

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,21 @@
1+2015-08-21 Patrick Palka <patrick@parcs.ath.cx>
2+
3+ * tui/tui-data.h (tui_command_info): Remove fields cur_line and
4+ curch.
5+ * tui/tui-data.c (tui_clear_win_detail) [CMD_WIN]: Don't set
6+ cur_line or curch, instead call wmove().
7+ (init_win_info) [CMD_WIN]: Likewise.
8+ * tui/tui-io.c (tui_puts): Likewise. Don't read cur_line,
9+ instead call getcury().
10+ (tui_redisplay_readline): Don't set cur_line or curch.
11+ (tui_mld_erase_entire_line): Don't read cur_line, instead call
12+ getcury().
13+ (tui_cont_sig): Remove call to wmove.
14+ (tui_getc): Don't read cur_line or curch, instead call getcury()
15+ or getyx(). Don't set curch.
16+ * tui/tui-win.c (make_visible_with_new_height) [CMD_WIN]: Don't
17+ set cur_line or curch. Always move cursor to (0,0).
18+
119 2015-08-20 Pedro Alves <palves@redhat.com>
220
321 * infrun.c (print_target_wait_results): Make extern.
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -212,8 +212,7 @@ tui_clear_win_detail (struct tui_win_info *win_info)
212212 win_info->detail.source_info.horizontal_offset = 0;
213213 break;
214214 case CMD_WIN:
215- win_info->detail.command_info.cur_line =
216- win_info->detail.command_info.curch = 0;
215+ wmove (win_info->generic.handle, 0, 0);
217216 break;
218217 case DATA_WIN:
219218 win_info->detail.data_display_info.data_content =
@@ -546,8 +545,6 @@ init_win_info (struct tui_win_info *win_info)
546545 win_info->detail.data_display_info.current_group = 0;
547546 break;
548547 case CMD_WIN:
549- win_info->detail.command_info.cur_line = 0;
550- win_info->detail.command_info.curch = 0;
551548 break;
552549 default:
553550 win_info->detail.opaque = NULL;
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -265,8 +265,6 @@ struct tui_source_info
265265
266266 struct tui_command_info
267267 {
268- int cur_line; /* The current line position. */
269- int curch; /* The current cursor position. */
270268 int start_line;
271269 };
272270
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -187,10 +187,7 @@ tui_puts (const char *string)
187187 else if (c == '\n')
188188 tui_skip_line = -1;
189189 }
190- getyx (w, TUI_CMD_WIN->detail.command_info.cur_line,
191- TUI_CMD_WIN->detail.command_info.curch);
192- TUI_CMD_WIN->detail.command_info.start_line
193- = TUI_CMD_WIN->detail.command_info.cur_line;
190+ TUI_CMD_WIN->detail.command_info.start_line = getcury (w);
194191 }
195192
196193 /* Readline callback.
@@ -271,24 +268,16 @@ tui_redisplay_readline (void)
271268 waddch (w, c);
272269 }
273270 if (c == '\n')
274- {
275- getyx (w, TUI_CMD_WIN->detail.command_info.start_line,
276- TUI_CMD_WIN->detail.command_info.curch);
277- }
271+ TUI_CMD_WIN->detail.command_info.start_line = getcury (w);
278272 getyx (w, line, col);
279273 if (col < prev_col)
280274 height++;
281275 prev_col = col;
282276 }
283277 wclrtobot (w);
284- getyx (w, TUI_CMD_WIN->detail.command_info.start_line,
285- TUI_CMD_WIN->detail.command_info.curch);
278+ TUI_CMD_WIN->detail.command_info.start_line = getcury (w);
286279 if (c_line >= 0)
287- {
288- wmove (w, c_line, c_pos);
289- TUI_CMD_WIN->detail.command_info.cur_line = c_line;
290- TUI_CMD_WIN->detail.command_info.curch = c_pos;
291- }
280+ wmove (w, c_line, c_pos);
292281 TUI_CMD_WIN->detail.command_info.start_line -= height - 1;
293282
294283 wrefresh (w);
@@ -371,10 +360,11 @@ static void
371360 tui_mld_erase_entire_line (const struct match_list_displayer *displayer)
372361 {
373362 WINDOW *w = TUI_CMD_WIN->generic.handle;
363+ int cur_y = getcury (w);
374364
375- wmove (w, TUI_CMD_WIN->detail.command_info.cur_line, 0);
365+ wmove (w, cur_y, 0);
376366 wclrtoeol (w);
377- wmove (w, TUI_CMD_WIN->detail.command_info.cur_line, 0);
367+ wmove (w, cur_y, 0);
378368 }
379369
380370 /* TUI version of displayer.beep. */
@@ -521,10 +511,6 @@ tui_cont_sig (int sig)
521511 /* Force a refresh of the screen. */
522512 tui_refresh_all_win ();
523513
524- /* Update cursor position on the screen. */
525- wmove (TUI_CMD_WIN->generic.handle,
526- TUI_CMD_WIN->detail.command_info.start_line,
527- TUI_CMD_WIN->detail.command_info.curch);
528514 wrefresh (TUI_CMD_WIN->generic.handle);
529515 }
530516 signal (sig, tui_cont_sig);
@@ -601,7 +587,7 @@ tui_getc (FILE *fp)
601587 user we recognized the command. */
602588 if (rl_end == 0)
603589 {
604- wmove (w, TUI_CMD_WIN->detail.command_info.cur_line, 0);
590+ wmove (w, getcury (w), 0);
605591
606592 /* Clear the line. This will blink the gdb prompt since
607593 it will be redrawn at the same line. */
@@ -614,8 +600,8 @@ tui_getc (FILE *fp)
614600 /* Move cursor to the end of the command line before emitting the
615601 newline. We need to do so because when ncurses outputs a newline
616602 it truncates any text that appears past the end of the cursor. */
617- int px = TUI_CMD_WIN->detail.command_info.curch;
618- int py = TUI_CMD_WIN->detail.command_info.cur_line;
603+ int px, py;
604+ getyx (w, py, px);
619605 px += rl_end - rl_point;
620606 py += px / TUI_CMD_WIN->generic.width;
621607 px %= TUI_CMD_WIN->generic.width;
@@ -627,8 +613,6 @@ tui_getc (FILE *fp)
627613 /* Handle prev/next/up/down here. */
628614 ch = tui_dispatch_ctrl_char (ch);
629615
630- if (ch == '\n' || ch == '\r' || ch == '\f')
631- TUI_CMD_WIN->detail.command_info.curch = 0;
632616 if (ch == KEY_BACKSPACE)
633617 return '\b';
634618
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -1525,8 +1525,6 @@ make_visible_with_new_height (struct tui_win_info *win_info)
15251525 tui_display_all_data ();
15261526 break;
15271527 case CMD_WIN:
1528- win_info->detail.command_info.cur_line = 0;
1529- win_info->detail.command_info.curch = 0;
15301528 #ifdef HAVE_WRESIZE
15311529 wresize (TUI_CMD_WIN->generic.handle,
15321530 TUI_CMD_WIN->generic.height,
@@ -1535,9 +1533,7 @@ make_visible_with_new_height (struct tui_win_info *win_info)
15351533 mvwin (TUI_CMD_WIN->generic.handle,
15361534 TUI_CMD_WIN->generic.origin.y,
15371535 TUI_CMD_WIN->generic.origin.x);
1538- wmove (win_info->generic.handle,
1539- win_info->detail.command_info.cur_line,
1540- win_info->detail.command_info.curch);
1536+ wmove (win_info->generic.handle, 0, 0);
15411537 break;
15421538 default:
15431539 break;