Back to index

citadel  8.12
Defines | Functions | Variables
screen.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define SCR_NOBLOCK   0
#define SCR_BLOCK   -1

Functions

void screen_new (void)
int scr_printf (char *fmt,...)
int scr_getc (int delay)
int scr_putc (int c)
void scr_flush (void)
int scr_blockread (void)
RETSIGTYPE scr_winch (int signum)
void wait_indicator (int state)
void ctdl_beep (void)
void scr_wait_indicator (int)
void check_screen_dims (void)

Variables

char status_line []
int screenwidth
int screenheight

Define Documentation

#define SCR_BLOCK   -1

Definition at line 18 of file screen.h.

#define SCR_NOBLOCK   0

Definition at line 17 of file screen.h.


Function Documentation

void check_screen_dims ( void  )

Definition at line 55 of file screen.c.

{
#ifdef TIOCGWINSZ
       struct {
              unsigned short height;      /* rows */
              unsigned short width;       /* columns */
              unsigned short xpixels;
              unsigned short ypixels;     /* pixels */
       } xwinsz;

       if (ioctl(0, TIOCGWINSZ, &xwinsz) == 0) {
              if (xwinsz.height)
                     screenheight = (int) xwinsz.height;
              if (xwinsz.width)
                     screenwidth = (int) xwinsz.width;
       }
#endif
}

Here is the caller graph for this function:

void ctdl_beep ( void  )

Definition at line 91 of file screen.c.

                     {
       putc(7, stdout);
}

Here is the caller graph for this function:

int scr_blockread ( void  )
void scr_flush ( void  )

Definition at line 216 of file screen.c.

{
       if ((enable_color) && (screenwidth > 0) && (enable_status_line)) {
              if (strlen(status_line) < screenwidth) {
                     memset(&status_line[strlen(status_line)], 32, screenwidth - strlen(status_line));
              }
              printf("\033[s\033[1;1H\033[K\033[7m");
              fwrite(status_line, screenwidth, 1, stdout);
              printf("\033[27m\033[u");
       }
       fflush(stdout);
}

Here is the caller graph for this function:

int scr_getc ( int  delay)

Definition at line 123 of file screen.c.

{
       unsigned char buf;

       scr_flush();

       buf = '\0';
       if (!read (0, &buf, 1))
              logoff(NULL, 3);

       lines_printed = 0;
       return buf;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int scr_printf ( char *  fmt,
  ... 
)

Definition at line 101 of file screen.c.

{
       static char outbuf[4096];   /* static for performance -- not re-entrant -- change if needed */
       va_list ap;
       register int retval;
       int i, len;

       va_start(ap, fmt);
       retval = vsnprintf(outbuf, sizeof outbuf, fmt, ap);
       va_end(ap);

       len = strlen(outbuf);
       for (i=0; i<len; ++i) {
              scr_putc(outbuf[i]);
       }
       return retval;
}

Here is the call graph for this function:

int scr_putc ( int  c)

Definition at line 170 of file screen.c.

{
       /* handle tabs normally */
       if (c == '\t') {
              do {
                     scr_putc(' ');
              } while ((cols_printed % 8) != 0);
              return(c);
       }

       /* Output the character... */
       if (putc(c, stdout) == EOF) {
              logoff(NULL, 3);
       }

       if (c == '\n') {
              ++lines_printed;
              cols_printed = 0;
       }
       else if (c == '\r') {
              cols_printed = 0;
       }
       else if (isprint(c)) {
              ++cols_printed;
              if ((screenwidth > 0) && (cols_printed > screenwidth)) {
                     ++lines_printed;
                     cols_printed = 0;
              }
       }

       /* How many lines output before stopping for the paginator?
        * Depends on whether we are displaying a status line.
        */
       int height_offset = ( ((enable_color) && (screenwidth > 0) && (enable_status_line)) ? (3) : (2) ) ;

       /* Ok, go check it.  Stop and display the paginator prompt if necessary. */
       if ((screenheight > 0) && (lines_printed > (screenheight-height_offset))) {
              lines_printed = 0;
              hit_any_key();
              lines_printed = 0;
              cols_printed = 0;
       }

       return c;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void scr_wait_indicator ( int  )

Definition at line 252 of file screen.c.

                                   {
       int sp = (screenwidth - 2);

       if (!enable_status_line) return;

       if (screenwidth > 0) {
              switch (state) {
                     default:
                     case 0:        /* Idle */
                            status_line[sp] = ' ';
                            break;
                     case 1:        /* Waiting */
                            status_line[sp] = 'X';
                            break;
                     case 2:        /* Receiving */
                            status_line[sp] = '<';
                            break;
                     case 3:        /* Sending */
                            status_line[sp] = '>';
                            break;
              }
              scr_flush();
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

RETSIGTYPE scr_winch ( int  signum)

Definition at line 237 of file screen.c.

{
       /* if we receive this signal, we must be running
        * in a terminal that supports resizing.
        */
       caught_sigwinch = 1;
       check_screen_dims();
       signal(SIGWINCH, scr_winch);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void screen_new ( void  )

Definition at line 78 of file screen.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void wait_indicator ( int  state)

Variable Documentation

Definition at line 42 of file screen.c.

Definition at line 43 of file screen.c.

char status_line[]

Definition at line 37 of file screen.c.