/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/* Copyright (c) 1988 AT&T */
/* All Rights Reserved */
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
* Copyright 2015 Gary Mills
*/
/*
* cscope - interactive C symbol cross-reference
*
* display functions
*/
#include "global.h"
#include "version.h" /* FILEVERSION and FIXVERSION */
#include <curses.h> /* COLS and LINES */
#include <setjmp.h> /* jmp_buf */
#include <string.h>
#include <errno.h>
/* see if the function column should be displayed */
/* field length */
static struct {
char *text1;
char *text2;
enum {
} patterntype;
/* last search is not part of the cscope display */
{ "Find this", "C symbol",
{ "Find this", "definition",
{ "Find", "functions called by this function",
{ "Find", "functions calling this function",
{ "Find", "assignments to",
{ "Change this", "grep pattern",
findgreppat, EGREP},
{ "Find this", "egrep pattern",
{ "Find this", "file",
{ "Find", "files #including this file",
};
/* initialize display parameters */
void
dispinit(void)
{
/* calculate the maximum displayed reference lines */
if (mdisprefs <= 0) {
(void) printw("cscope: window must be at least %d lines high",
FIELDS + 6);
myexit(1);
}
(void) printw("cscope: window must be at least %d columns wide",
MINCOLS);
myexit(1);
}
if (!mouse) {
}
/* calculate the maximum selection number width */
}
/* allocate the displayed line array */
}
/* display a page of the references */
void
display(void)
{
int i;
char *s;
(void) erase();
/* if there are no references */
if (totallines == 0) {
if (*lastmsg != '\0') {
} else {
(void) addstr(helpstring);
}
} else { /* display the pattern */
(void) printw("Change \"%s\" to \"%s\"",
} else {
(void) printw("%c%s: %s",
}
/* display the cscope invocation nesting depth */
if (cscopedepth > 1) {
(void) addstr(depthstring);
}
/* display the column headings */
}
if (dispcomponents > 0) {
}
if (displayfcn()) {
}
(void) addstr("Line");
}
(void) addch('\n');
/* if at end of file go back to beginning */
if (nextline > totallines) {
seekline(1);
}
/* calculate the source text column */
}
if (dispcomponents > 0) {
}
if (displayfcn()) {
}
/*
* until the max references have been displayed or
* there is no more room
*/
++disprefs, ++screenline) {
/* read the reference line */
break;
}
++nextline;
/* if no mouse, display the selection number */
if (!mouse) {
}
/* display any change mark */
(void) addch('>');
} else {
(void) addch(' ');
}
/* display the file name */
continue;
}
/* if OGS, display the subsystem and book names */
book);
}
/* display the requested path components */
if (dispcomponents > 0) {
}
/* display the function name */
if (displayfcn()) {
function);
}
/* display the line number */
/* there may be tabs in egrep output */
*s = ' ';
}
/* display the source line */
s = yytext;
for (;;) {
/* see if the source line will fit */
/* find the nearest blank */
for (i = width; s[i] != ' ' && i > 0;
--i) {
}
if (i == 0) {
i = width; /* no blank */
}
}
/* print up to this point */
(void) printw("%.*s", i, s);
s += i;
/* if line didn't wrap around */
if (i < width) {
/* go to next line */
(void) addch('\n');
}
/* skip blanks */
while (*s == ' ') {
++s;
}
/* see if there is more text */
if (*s == '\0') {
break;
}
/* if the source line is too long */
if (++screenline > lastdispline) {
/*
* if this is the first displayed line,
* display what will fit on the screen
*/
goto endrefs;
}
/* erase the reference */
while (--screenline >=
(void) move(screenline, 0);
(void) clrtoeol();
}
++screenline;
/*
* go back to the beginning of this
* reference
*/
--nextline;
goto endrefs;
}
/* indent the continued source line */
}
}
/* check for more references */
(void) standout();
} else {
bottomline - 1);
}
(void) printw(" of %d, press the space bar to "
"display next lines", totallines);
(void) standend();
}
}
/* display the input fields */
for (i = 0; i < FIELDS; ++i) {
}
}
/* set the cursor position for the field */
void
setfield(void)
{
}
/* move to the current input field */
void
atfield(void)
{
}
/* search for the symbol or text pattern */
/*ARGSUSED*/
{
}
search(void)
{
FP f; /* searching function */
char *s;
int c;
/* note: the pattern may have been a cscope argument */
for (s = pattern; *s != '\0'; ++s) {
*s = tolower(*s);
}
}
/* open the references found file for writing */
if (writerefsfound() == NO) {
return (NO);
}
/* find the pattern - stop on an interrupt */
putmsg("Searching");
}
initprogress();
egreperror = (*f)(pattern);
} else {
return (NO);
}
(void) dbseek(0L); /* goto the first block */
(*f)();
findcleanup();
/* append the non-global references */
}
}
(void) fclose(nonglobalrefs);
}
}
/* reopen the references found file for reading */
nextline = 1;
totallines = 0;
/* see if it is empty */
if (egreperror != NULL) {
pattern);
} else if (rc == REGCMPERROR) {
"Error in this regcmp(3X) regular expression: %s",
pattern);
} else {
}
return (NO);
}
/* put back the character read */
countrefs();
return (YES);
}
/* open the references found file for writing */
writerefsfound(void)
{
return (NO);
}
putmsg("Cannot reopen temporary file");
return (NO);
}
return (YES);
}
/* count the references found */
void
countrefs(void)
{
int i;
/*
* count the references found and find the length of the file,
* function, and line number display fields
*/
numlen = 0;
putmsg("File does not have expected format");
totallines = 0;
return;
}
dispcomponents))) > filelen) {
filelen = i;
}
subsystemlen = i;
}
booklen = i;
}
}
fcnlen = i;
}
numlen = i;
}
++totallines;
}
/* restrict the width of displayed columns */
}
if (filelen > i && i > 4) {
filelen = i;
}
if (subsystemlen > i && i > 9) {
subsystemlen = i;
}
if (booklen > i && i > 4) {
booklen = i;
}
if (fcnlen > i && i > 8) {
fcnlen = i;
}
}
/* print error message on system call failure */
void
{
}
/* putmsg clears the message line and prints the message */
void
{
} else {
(void) clrtoeol();
(void) refresh();
}
}
/* clearmsg2 clears the second message line */
void
clearmsg2(void)
{
(void) clrtoeol();
}
}
/* putmsg2 clears the second message line and prints the message */
void
{
} else {
clearmsg2();
(void) refresh();
}
}
/* position the references found file at the specified line */
void
{
int c;
/* verify that there is a references found file */
return;
}
/* go to the beginning of the file */
/* find the requested line */
nextline = 1;
if (c == '\n') {
nextline++;
}
}
}
/* get the OGS subsystem and book names */
void
{
char *s, *slash;
s = buf;
if (*s == '/') {
++s;
}
*slash = '\0';
*subsystem = s;
s = slash + 1;
*book = s;
*slash = '\0';
}
break;
}
s = slash + 1;
}
}
/* get the requested path components */
char *
{
int i;
char *s;
for (i = 0; i < components; ++i) {
while (s > path && *--s != '/') {
;
}
}
if (s > path && *s == '/') {
++s;
}
return (s);
}