int line_width, nlines;
ret = TUI_SUCCESS;
- tui_alloc_source_buffer (win_info);
line_width = win_info->width - 1;
/* Take hilite (window border) into account, when
calculating the number of lines. */
bool
tui_source_window::showing_source_p (const char *fullname) const
{
- return (content_in_use
+ return (!content.empty ()
&& (filename_cmp (tui_locator_win_info_ptr ()->full_name,
fullname) == 0));
}
l.loa = LOA_LINE;
l.u.line_no = content[0].line_or_addr.u.line_no
+ num_to_scroll;
- if (l.u.line_no > s->nlines)
+ const std::vector<off_t> *offsets;
+ if (g_source_cache.get_line_charpos (s, &offsets)
+ && l.u.line_no > offsets->size ())
/* line = s->nlines - win_info->content_size + 1; */
/* elz: fix for dts 23398. */
l.u.line_no = content[0].line_or_addr.u.line_no;
&& filename_cmp (fullname,
symtab_to_fullname (loc->symtab)) == 0);
}
+
+/* See tui-source.h. */
+
+bool
+tui_source_window::line_is_displayed (int line) const
+{
+ bool is_displayed = false;
+ int threshold = SCROLL_THRESHOLD;
+ int i = 0;
+ while (i < content.size () - threshold && !is_displayed)
+ {
+ is_displayed
+ = (content[i].line_or_addr.loa == LOA_LINE
+ && content[i].line_or_addr.u.line_no == line);
+ i++;
+ }
+
+ return is_displayed;
+}
+
+void
+tui_source_window::maybe_update (struct frame_info *fi, symtab_and_line sal,
+ int line_no, CORE_ADDR addr)
+{
+ int start_line = (line_no - (viewport_height / 2)) + 1;
+ if (start_line <= 0)
+ start_line = 1;
+
+ bool source_already_displayed = (sal.symtab != 0
+ && showing_source_p (fullname));
+
+ struct tui_line_or_address l;
+
+ l.loa = LOA_LINE;
+ l.u.line_no = start_line;
+ if (!(source_already_displayed
+ && line_is_displayed (line_no)))
+ tui_update_source_window (this, get_frame_arch (fi),
+ sal.symtab, l, TRUE);
+ else
+ {
+ l.u.line_no = line_no;
+ set_is_exec_point_at (l);
+ }
+}