2004-02-07 Andrew Cagney <cagney@redhat.com>
[deliverable/binutils-gdb.git] / gdb / tui / tui-winsource.c
CommitLineData
f377b406 1/* TUI display source/assembly window.
f33c6cbf 2
65f05602
AC
3 Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
4 Foundation, Inc.
f33c6cbf 5
f377b406
SC
6 Contributed by Hewlett-Packard Company.
7
8 This file is part of GDB.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. */
c906108c
SS
24
25#include "defs.h"
26#include <ctype.h>
27#include "symtab.h"
28#include "frame.h"
29#include "breakpoint.h"
fd0407d6 30#include "value.h"
52575520 31#include "source.h"
c906108c 32
d7b2e967
AC
33#include "tui/tui.h"
34#include "tui/tui-data.h"
35#include "tui/tui-stack.h"
36#include "tui/tui-win.h"
37#include "tui/tui-wingeneral.h"
38#include "tui/tui-winsource.h"
39#include "tui/tui-source.h"
40#include "tui/tui-disasm.h"
c906108c 41
96ec9981
DJ
42#ifdef HAVE_NCURSES_H
43#include <ncurses.h>
44#else
45#ifdef HAVE_CURSES_H
46#include <curses.h>
47#endif
48#endif
c906108c 49
1f393769 50/* Function to display the "main" routine. */
c906108c 51void
1f393769 52tui_display_main (void)
c906108c 53{
dd1abb8c 54 if ((tui_source_windows ())->count > 0)
c906108c
SS
55 {
56 CORE_ADDR addr;
57
65f05602 58 addr = tui_get_begin_asm_address ();
c774cec6 59 if (addr != (CORE_ADDR) 0)
c906108c
SS
60 {
61 struct symtab_and_line sal;
62
f80bda8e 63 tui_update_source_windows_with_addr (addr);
c906108c 64 sal = find_pc_line (addr, 0);
2e17b763 65 if (sal.symtab)
47d3492a 66 tui_update_locator_filename (sal.symtab->filename);
2e17b763 67 else
47d3492a 68 tui_update_locator_filename ("??");
c906108c
SS
69 }
70 }
2e17b763 71}
c906108c
SS
72
73
74
f80bda8e
AC
75/* Function to display source in the source window. This function
76 initializes the horizontal scroll to 0. */
c906108c 77void
2a8854a7
AC
78tui_update_source_window (struct tui_win_info * winInfo, struct symtab *s,
79 union tui_line_or_address lineOrAddr, int noerror)
c906108c
SS
80{
81 winInfo->detail.sourceInfo.horizontalOffset = 0;
f80bda8e 82 tui_update_source_window_as_is (winInfo, s, lineOrAddr, noerror);
c906108c
SS
83
84 return;
f80bda8e 85}
c906108c
SS
86
87
f80bda8e
AC
88/* Function to display source in the source/asm window. This function
89 shows the source as specified by the horizontal offset. */
c906108c 90void
2a8854a7
AC
91tui_update_source_window_as_is (struct tui_win_info * winInfo, struct symtab *s,
92 union tui_line_or_address lineOrAddr, int noerror)
c906108c 93{
22940a24 94 enum tui_status ret;
c906108c
SS
95
96 if (winInfo->generic.type == SRC_WIN)
a358af15 97 ret = tui_set_source_content (s, lineOrAddr.lineNo, noerror);
c906108c 98 else
65f05602 99 ret = tui_set_disassem_content (lineOrAddr.addr);
c906108c
SS
100
101 if (ret == TUI_FAILURE)
102 {
f80bda8e
AC
103 tui_clear_source_content (winInfo, EMPTY_SOURCE_PROMPT);
104 tui_clear_exec_info_content (winInfo);
c906108c
SS
105 }
106 else
107 {
00b2bad4 108 tui_update_breakpoint_info (winInfo, 0);
f80bda8e
AC
109 tui_show_source_content (winInfo);
110 tui_update_exec_info (winInfo);
c906108c
SS
111 if (winInfo->generic.type == SRC_WIN)
112 {
52575520
EZ
113 struct symtab_and_line sal;
114
115 sal.line = lineOrAddr.lineNo +
c906108c 116 (winInfo->generic.contentSize - 2);
52575520
EZ
117 sal.symtab = s;
118 set_current_source_symtab_and_line (&sal);
c906108c 119 /*
c5aa993b
JM
120 ** If the focus was in the asm win, put it in the src
121 ** win if we don't have a split layout
122 */
dd1abb8c
AC
123 if (tui_win_with_focus () == disassemWin &&
124 tui_current_layout () != SRC_DISASSEM_COMMAND)
a21fcd8f 125 tui_set_win_focus_to (srcWin);
c906108c
SS
126 }
127 }
128
129
130 return;
f80bda8e 131}
c906108c
SS
132
133
f80bda8e
AC
134/* Function to ensure that the source and/or disassemly windows
135 reflect the input address. */
c906108c 136void
f80bda8e 137tui_update_source_windows_with_addr (CORE_ADDR addr)
c906108c 138{
c774cec6 139 if (addr != 0)
c906108c
SS
140 {
141 struct symtab_and_line sal;
2a8854a7 142 union tui_line_or_address l;
a4b99e53 143
dd1abb8c 144 switch (tui_current_layout ())
c906108c
SS
145 {
146 case DISASSEM_COMMAND:
147 case DISASSEM_DATA_COMMAND:
65f05602 148 tui_show_disassem (addr);
c906108c
SS
149 break;
150 case SRC_DISASSEM_COMMAND:
65f05602 151 tui_show_disassem_and_update_source (addr);
c906108c
SS
152 break;
153 default:
c774cec6 154 sal = find_pc_line (addr, 0);
a4b99e53 155 l.lineNo = sal.line;
a358af15 156 tui_show_symtab_source (sal.symtab, l, FALSE);
c906108c
SS
157 break;
158 }
159 }
160 else
161 {
162 int i;
163
dd1abb8c 164 for (i = 0; i < (tui_source_windows ())->count; i++)
c906108c 165 {
2a8854a7 166 struct tui_win_info * winInfo = (struct tui_win_info *) (tui_source_windows ())->list[i];
c906108c 167
f80bda8e
AC
168 tui_clear_source_content (winInfo, EMPTY_SOURCE_PROMPT);
169 tui_clear_exec_info_content (winInfo);
c906108c
SS
170 }
171 }
172
173 return;
174} /* tuiUpdateSourceWindowsWithAddr */
175
f80bda8e
AC
176/* Function to ensure that the source and/or disassemly windows
177 reflect the input address. */
c906108c 178void
f80bda8e 179tui_update_source_windows_with_line (struct symtab *s, int line)
c906108c 180{
84b1e7c7 181 CORE_ADDR pc;
2a8854a7 182 union tui_line_or_address l;
a4b99e53 183
dd1abb8c 184 switch (tui_current_layout ())
c906108c
SS
185 {
186 case DISASSEM_COMMAND:
187 case DISASSEM_DATA_COMMAND:
84b1e7c7 188 find_line_pc (s, line, &pc);
f80bda8e 189 tui_update_source_windows_with_addr (pc);
c906108c
SS
190 break;
191 default:
a4b99e53 192 l.lineNo = line;
a358af15 193 tui_show_symtab_source (s, l, FALSE);
dd1abb8c 194 if (tui_current_layout () == SRC_DISASSEM_COMMAND)
84b1e7c7
SC
195 {
196 find_line_pc (s, line, &pc);
65f05602 197 tui_show_disassem (pc);
84b1e7c7 198 }
c906108c
SS
199 break;
200 }
201
202 return;
f80bda8e 203}
c906108c 204
c906108c 205void
2a8854a7 206tui_clear_source_content (struct tui_win_info * winInfo, int displayPrompt)
c906108c
SS
207{
208 if (m_winPtrNotNull (winInfo))
209 {
210 register int i;
211
212 winInfo->generic.contentInUse = FALSE;
f80bda8e 213 tui_erase_source_content (winInfo, displayPrompt);
c906108c
SS
214 for (i = 0; i < winInfo->generic.contentSize; i++)
215 {
2a8854a7
AC
216 struct tui_win_element * element =
217 (struct tui_win_element *) winInfo->generic.content[i];
c906108c
SS
218 element->whichElement.source.hasBreak = FALSE;
219 element->whichElement.source.isExecPoint = FALSE;
220 }
221 }
222
223 return;
224} /* tuiClearSourceContent */
225
226
c906108c 227void
2a8854a7 228tui_erase_source_content (struct tui_win_info * winInfo, int displayPrompt)
c906108c
SS
229{
230 int xPos;
231 int halfWidth = (winInfo->generic.width - 2) / 2;
232
233 if (winInfo->generic.handle != (WINDOW *) NULL)
234 {
235 werase (winInfo->generic.handle);
ec7d9e56 236 tui_check_and_display_highlight_if_needed (winInfo);
c906108c
SS
237 if (displayPrompt == EMPTY_SOURCE_PROMPT)
238 {
239 char *noSrcStr;
240
241 if (winInfo->generic.type == SRC_WIN)
242 noSrcStr = NO_SRC_STRING;
243 else
244 noSrcStr = NO_DISASSEM_STRING;
245 if (strlen (noSrcStr) >= halfWidth)
246 xPos = 1;
247 else
248 xPos = halfWidth - strlen (noSrcStr);
249 mvwaddstr (winInfo->generic.handle,
250 (winInfo->generic.height / 2),
251 xPos,
252 noSrcStr);
253
254 /* elz: added this function call to set the real contents of
c5aa993b
JM
255 the window to what is on the screen, so that later calls
256 to refresh, do display
257 the correct stuff, and not the old image */
c906108c 258
f80bda8e 259 tui_set_source_content_nil (winInfo, noSrcStr);
c906108c 260 }
ec7d9e56 261 tui_refresh_win (&winInfo->generic);
c906108c
SS
262 }
263 return;
264} /* tuiEraseSourceContent */
265
266
bc712bbf
SC
267/* Redraw the complete line of a source or disassembly window. */
268static void
2a8854a7 269tui_show_source_line (struct tui_win_info * winInfo, int lineno)
bc712bbf 270{
2a8854a7 271 struct tui_win_element * line;
bc712bbf
SC
272 int x, y;
273
2a8854a7 274 line = (struct tui_win_element *) winInfo->generic.content[lineno - 1];
bc712bbf
SC
275 if (line->whichElement.source.isExecPoint)
276 wattron (winInfo->generic.handle, A_STANDOUT);
277
278 mvwaddstr (winInfo->generic.handle, lineno, 1,
279 line->whichElement.source.line);
280 if (line->whichElement.source.isExecPoint)
281 wattroff (winInfo->generic.handle, A_STANDOUT);
282
283 /* Clear to end of line but stop before the border. */
284 getyx (winInfo->generic.handle, y, x);
285 while (x + 1 < winInfo->generic.width)
286 {
287 waddch (winInfo->generic.handle, ' ');
288 getyx (winInfo->generic.handle, y, x);
289 }
290}
291
c906108c 292void
2a8854a7 293tui_show_source_content (struct tui_win_info * winInfo)
c906108c 294{
c906108c
SS
295 if (winInfo->generic.contentSize > 0)
296 {
bc712bbf
SC
297 int lineno;
298
299 for (lineno = 1; lineno <= winInfo->generic.contentSize; lineno++)
300 tui_show_source_line (winInfo, lineno);
c906108c 301 }
bc712bbf 302 else
f80bda8e 303 tui_erase_source_content (winInfo, TRUE);
bc712bbf 304
ec7d9e56
AC
305 tui_check_and_display_highlight_if_needed (winInfo);
306 tui_refresh_win (&winInfo->generic);
c906108c 307 winInfo->generic.contentInUse = TRUE;
bc712bbf 308}
c906108c
SS
309
310
f80bda8e 311/* Scroll the source forward or backward horizontally. */
c906108c 312void
2a8854a7
AC
313tui_horizontal_source_scroll (struct tui_win_info * winInfo,
314 enum tui_scroll_direction direction,
f80bda8e 315 int numToScroll)
c906108c 316{
22940a24 317 if (winInfo->generic.content != NULL)
c906108c
SS
318 {
319 int offset;
320 struct symtab *s;
52575520 321 struct symtab_and_line cursal = get_current_source_symtab_and_line ();
c906108c 322
52575520 323 if (cursal.symtab == (struct symtab *) NULL)
f70a7d61 324 s = find_pc_symtab (get_frame_pc (deprecated_selected_frame));
c906108c 325 else
52575520 326 s = cursal.symtab;
c906108c
SS
327
328 if (direction == LEFT_SCROLL)
329 offset = winInfo->detail.sourceInfo.horizontalOffset + numToScroll;
330 else
331 {
332 if ((offset =
333 winInfo->detail.sourceInfo.horizontalOffset - numToScroll) < 0)
334 offset = 0;
335 }
336 winInfo->detail.sourceInfo.horizontalOffset = offset;
f80bda8e 337 tui_update_source_window_as_is (winInfo, s,
2a8854a7 338 ((struct tui_win_element *)
f80bda8e
AC
339 winInfo->generic.content[0])->whichElement.source.lineOrAddr,
340 FALSE);
c906108c
SS
341 }
342
343 return;
344} /* tuiHorizontalSourceScroll */
345
346
00b90ae2 347/* Set or clear the hasBreak flag in the line whose line is lineNo. */
c906108c 348void
2a8854a7 349tui_set_is_exec_point_at (union tui_line_or_address l, struct tui_win_info * winInfo)
c906108c 350{
00b90ae2 351 int changed = 0;
c906108c 352 int i;
2a8854a7 353 tui_win_content content = (tui_win_content) winInfo->generic.content;
c906108c
SS
354
355 i = 0;
356 while (i < winInfo->generic.contentSize)
357 {
00b90ae2
SC
358 int newState;
359
a4b99e53 360 if (content[i]->whichElement.source.lineOrAddr.addr == l.addr)
00b90ae2 361 newState = TRUE;
c906108c 362 else
00b90ae2
SC
363 newState = FALSE;
364 if (newState != content[i]->whichElement.source.isExecPoint)
365 {
366 changed++;
367 content[i]->whichElement.source.isExecPoint = newState;
368 tui_show_source_line (winInfo, i + 1);
369 }
c906108c
SS
370 i++;
371 }
00b90ae2 372 if (changed)
ec7d9e56 373 tui_refresh_win (&winInfo->generic);
00b90ae2 374}
c906108c 375
00b2bad4
SC
376/* Update the execution windows to show the active breakpoints.
377 This is called whenever a breakpoint is inserted, removed or
378 has its state changed. */
c906108c 379void
00b2bad4 380tui_update_all_breakpoint_info ()
c906108c 381{
2a8854a7 382 struct tui_list *list = tui_source_windows ();
c906108c 383 int i;
c906108c 384
00b2bad4 385 for (i = 0; i < list->count; i++)
c906108c 386 {
2a8854a7 387 struct tui_win_info * win = (struct tui_win_info *) list->list[i];
c906108c 388
00b2bad4
SC
389 if (tui_update_breakpoint_info (win, FALSE))
390 {
f80bda8e 391 tui_update_exec_info (win);
00b2bad4 392 }
c906108c 393 }
00b2bad4 394}
c906108c
SS
395
396
00b2bad4
SC
397/* Scan the source window and the breakpoints to update the
398 hasBreak information for each line.
399 Returns 1 if something changed and the execution window
400 must be refreshed. */
401int
2a8854a7 402tui_update_breakpoint_info (struct tui_win_info * win, int current_only)
c906108c
SS
403{
404 int i;
00b2bad4 405 int need_refresh = 0;
2a8854a7 406 struct tui_source_info * src = &win->detail.sourceInfo;
c906108c 407
00b2bad4
SC
408 for (i = 0; i < win->generic.contentSize; i++)
409 {
410 struct breakpoint *bp;
411 extern struct breakpoint *breakpoint_chain;
412 int mode;
2a8854a7 413 struct tui_source_element* line;
00b2bad4 414
2a8854a7 415 line = &((struct tui_win_element *) win->generic.content[i])->whichElement.source;
00b2bad4
SC
416 if (current_only && !line->isExecPoint)
417 continue;
418
419 /* Scan each breakpoint to see if the current line has something to
420 do with it. Identify enable/disabled breakpoints as well as
421 those that we already hit. */
422 mode = 0;
423 for (bp = breakpoint_chain;
424 bp != (struct breakpoint *) NULL;
425 bp = bp->next)
426 {
427 if ((win == srcWin
428 && bp->source_file
429 && (strcmp (src->filename, bp->source_file) == 0)
430 && bp->line_number == line->lineOrAddr.lineNo)
431 || (win == disassemWin
cebe9500 432 && bp->loc->address == line->lineOrAddr.addr))
00b2bad4
SC
433 {
434 if (bp->enable_state == bp_disabled)
435 mode |= TUI_BP_DISABLED;
436 else
437 mode |= TUI_BP_ENABLED;
438 if (bp->hit_count)
439 mode |= TUI_BP_HIT;
440 if (bp->cond)
441 mode |= TUI_BP_CONDITIONAL;
442 if (bp->type == bp_hardware_breakpoint)
443 mode |= TUI_BP_HARDWARE;
444 }
445 }
446 if (line->hasBreak != mode)
447 {
448 line->hasBreak = mode;
449 need_refresh = 1;
450 }
451 }
452 return need_refresh;
453}
c906108c 454
c906108c
SS
455
456/*
c5aa993b
JM
457 ** tuiSetExecInfoContent().
458 ** Function to initialize the content of the execution info window,
459 ** based upon the input window which is either the source or
460 ** disassembly window.
461 */
22940a24 462enum tui_status
2a8854a7 463tuiSetExecInfoContent (struct tui_win_info * winInfo)
c906108c 464{
22940a24 465 enum tui_status ret = TUI_SUCCESS;
c906108c 466
2a8854a7 467 if (winInfo->detail.sourceInfo.executionInfo != (struct tui_gen_win_info *) NULL)
c906108c 468 {
2a8854a7 469 struct tui_gen_win_info * execInfoPtr = winInfo->detail.sourceInfo.executionInfo;
c906108c 470
22940a24 471 if (execInfoPtr->content == NULL)
c906108c 472 execInfoPtr->content =
22940a24 473 (void **) tui_alloc_content (winInfo->generic.height,
dd1abb8c 474 execInfoPtr->type);
22940a24 475 if (execInfoPtr->content != NULL)
c906108c
SS
476 {
477 int i;
478
00b2bad4 479 tui_update_breakpoint_info (winInfo, 1);
c906108c
SS
480 for (i = 0; i < winInfo->generic.contentSize; i++)
481 {
2a8854a7
AC
482 struct tui_win_element * element;
483 struct tui_win_element * srcElement;
00b2bad4 484 int mode;
c906108c 485
2a8854a7
AC
486 element = (struct tui_win_element *) execInfoPtr->content[i];
487 srcElement = (struct tui_win_element *) winInfo->generic.content[i];
00b2bad4
SC
488
489 memset(element->whichElement.simpleString, ' ',
490 sizeof(element->whichElement.simpleString));
491 element->whichElement.simpleString[TUI_EXECINFO_SIZE - 1] = 0;
492
493 /* Now update the exec info content based upon the state
494 of each line as indicated by the source content. */
495 mode = srcElement->whichElement.source.hasBreak;
496 if (mode & TUI_BP_HIT)
497 element->whichElement.simpleString[TUI_BP_HIT_POS] =
498 (mode & TUI_BP_HARDWARE) ? 'H' : 'B';
499 else if (mode & (TUI_BP_ENABLED | TUI_BP_DISABLED))
500 element->whichElement.simpleString[TUI_BP_HIT_POS] =
501 (mode & TUI_BP_HARDWARE) ? 'h' : 'b';
502
503 if (mode & TUI_BP_ENABLED)
504 element->whichElement.simpleString[TUI_BP_BREAK_POS] = '+';
505 else if (mode & TUI_BP_DISABLED)
506 element->whichElement.simpleString[TUI_BP_BREAK_POS] = '-';
507
508 if (srcElement->whichElement.source.isExecPoint)
509 element->whichElement.simpleString[TUI_EXEC_POS] = '>';
c906108c
SS
510 }
511 execInfoPtr->contentSize = winInfo->generic.contentSize;
512 }
513 else
514 ret = TUI_FAILURE;
515 }
516
517 return ret;
00b2bad4 518}
c906108c
SS
519
520
521/*
c5aa993b
JM
522 ** tuiShowExecInfoContent().
523 */
c906108c 524void
2a8854a7 525tuiShowExecInfoContent (struct tui_win_info * winInfo)
c906108c 526{
2a8854a7 527 struct tui_gen_win_info * execInfo = winInfo->detail.sourceInfo.executionInfo;
c906108c
SS
528 int curLine;
529
530 werase (execInfo->handle);
ec7d9e56 531 tui_refresh_win (execInfo);
c906108c
SS
532 for (curLine = 1; (curLine <= execInfo->contentSize); curLine++)
533 mvwaddstr (execInfo->handle,
534 curLine,
535 0,
2a8854a7 536 ((struct tui_win_element *)
c906108c 537 execInfo->content[curLine - 1])->whichElement.simpleString);
ec7d9e56 538 tui_refresh_win (execInfo);
c906108c
SS
539 execInfo->contentInUse = TRUE;
540
541 return;
f80bda8e 542}
c906108c
SS
543
544
c906108c 545void
2a8854a7 546tui_erase_exec_info_content (struct tui_win_info * winInfo)
c906108c 547{
2a8854a7 548 struct tui_gen_win_info * execInfo = winInfo->detail.sourceInfo.executionInfo;
c906108c
SS
549
550 werase (execInfo->handle);
ec7d9e56 551 tui_refresh_win (execInfo);
c906108c
SS
552
553 return;
f80bda8e 554}
c906108c 555
c906108c 556void
2a8854a7 557tui_clear_exec_info_content (struct tui_win_info * winInfo)
c906108c
SS
558{
559 winInfo->detail.sourceInfo.executionInfo->contentInUse = FALSE;
f80bda8e 560 tui_erase_exec_info_content (winInfo);
c906108c
SS
561
562 return;
f80bda8e 563}
c906108c 564
f80bda8e 565/* Function to update the execution info window. */
c906108c 566void
2a8854a7 567tui_update_exec_info (struct tui_win_info * winInfo)
c906108c
SS
568{
569 tuiSetExecInfoContent (winInfo);
570 tuiShowExecInfoContent (winInfo);
19eb139b 571} /* tuiUpdateExecInfo */
c906108c 572
f80bda8e
AC
573enum tui_status
574tui_alloc_source_buffer (struct tui_win_info *winInfo)
c906108c 575{
335fc5a3
SC
576 register char *srcLineBuf;
577 register int i, lineWidth, maxLines;
22940a24 578 enum tui_status ret = TUI_FAILURE;
c906108c
SS
579
580 maxLines = winInfo->generic.height; /* less the highlight box */
581 lineWidth = winInfo->generic.width - 1;
582 /*
c5aa993b
JM
583 ** Allocate the buffer for the source lines. Do this only once since they
584 ** will be re-used for all source displays. The only other time this will
585 ** be done is when a window's size changes.
586 */
22940a24 587 if (winInfo->generic.content == NULL)
c906108c
SS
588 {
589 srcLineBuf = (char *) xmalloc ((maxLines * lineWidth) * sizeof (char));
590 if (srcLineBuf == (char *) NULL)
591 fputs_unfiltered (
592 "Unable to Allocate Memory for Source or Disassembly Display.\n",
593 gdb_stderr);
594 else
595 {
596 /* allocate the content list */
597 if ((winInfo->generic.content =
22940a24 598 (void **) tui_alloc_content (maxLines, SRC_WIN)) == NULL)
c906108c 599 {
22940a24 600 xfree (srcLineBuf);
c906108c
SS
601 srcLineBuf = (char *) NULL;
602 fputs_unfiltered (
603 "Unable to Allocate Memory for Source or Disassembly Display.\n",
604 gdb_stderr);
605 }
606 }
607 for (i = 0; i < maxLines; i++)
2a8854a7 608 ((struct tui_win_element *)
c906108c
SS
609 winInfo->generic.content[i])->whichElement.source.line =
610 srcLineBuf + (lineWidth * i);
611 ret = TUI_SUCCESS;
612 }
613 else
614 ret = TUI_SUCCESS;
615
616 return ret;
617} /* tuiAllocSourceBuffer */
618
619
f80bda8e
AC
620/* Answer whether the a particular line number or address is displayed
621 in the current source window. */
c906108c 622int
2a8854a7 623tui_line_is_displayed (int line, struct tui_win_info * winInfo,
f80bda8e 624 int checkThreshold)
c906108c
SS
625{
626 int isDisplayed = FALSE;
627 int i, threshold;
628
629 if (checkThreshold)
630 threshold = SCROLL_THRESHOLD;
631 else
632 threshold = 0;
633 i = 0;
634 while (i < winInfo->generic.contentSize - threshold && !isDisplayed)
635 {
2a8854a7 636 isDisplayed = (((struct tui_win_element *)
a4b99e53
SC
637 winInfo->generic.content[i])->whichElement.source.lineOrAddr.lineNo
638 == (int) line);
c906108c
SS
639 i++;
640 }
641
642 return isDisplayed;
f80bda8e 643}
c906108c
SS
644
645
f80bda8e
AC
646/* Answer whether the a particular line number or address is displayed
647 in the current source window. */
a4b99e53 648int
2a8854a7 649tui_addr_is_displayed (CORE_ADDR addr, struct tui_win_info * winInfo,
a4b99e53
SC
650 int checkThreshold)
651{
652 int isDisplayed = FALSE;
653 int i, threshold;
654
655 if (checkThreshold)
656 threshold = SCROLL_THRESHOLD;
657 else
658 threshold = 0;
659 i = 0;
660 while (i < winInfo->generic.contentSize - threshold && !isDisplayed)
661 {
2a8854a7 662 isDisplayed = (((struct tui_win_element *)
a4b99e53
SC
663 winInfo->generic.content[i])->whichElement.source.lineOrAddr.addr
664 == addr);
665 i++;
666 }
667
668 return isDisplayed;
669}
670
671
c906108c
SS
672/*****************************************
673** STATIC LOCAL FUNCTIONS **
674******************************************/
This page took 0.434401 seconds and 4 git commands to generate.