home *** CD-ROM | disk | FTP | other *** search
- /*---------------------------------------------------------------------------*
- *
- * wish - windowing user friendly shell
- * ------------------------------------
- *
- * Copyright (c) 1988-1993 Hellmuth Michaelis
- *
- * Eggerstedtstr. 28
- * 22765 Hamburg
- * Germany
- *
- * Tel: +49 / 40 / 384298 (private)
- * Tel: +49 / 40 / 55903-170 (at work)
- * e-mail: hm@hcshh.hcs.de
- *
- * --------oOo--------
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- *---------------------------------------------------------------------------*
- *
- * Last Edit-Date: [Mon Aug 30 19:50:08 1993]
- *
- * -hm converting to curses and multiwindows
- * -hm separation line in attribs window
- * -hm vt220 support
- * -hm show time in header
- * -hm hpterm / zero pointers in hpux 9.0
- *
- *----------------------------------------------------------------------------*/
-
- #include "wish.h"
-
- /*---------------------------------------------------------------------------*
- * print a horizontal separation line based on delimiter-character
- *---------------------------------------------------------------------------*/
- void sepaline(WINDOW *window)
- {
- int i = COLS;
- unsigned char delim;
-
- if(window == cmnd_w)
- wmove(window, 2, 0);
- else if(window == attr_w)
- wmove(window, 0, 0);
- else
- return;
-
- if(opt_delimiter)
- {
- delim = opt_delimiter;
- }
- else if(enter_alt_charset_mode && exit_alt_charset_mode &&
- *enter_alt_charset_mode && *exit_alt_charset_mode)
- {
- wattron(window, A_ALTCHARSET);
- switch(termtype)
- {
- case TERM_HP: /* HEWLETT-PACKARD Terminals (2392,700/9x etc) */
- delim = ';';
- break;
-
- case TERM_VT2: /* DEC VT220 / 320 */
- case TERM_VT3:
- case TERM_PCVT:
- delim = 'q';
- break;
-
- case TERM_HPX: /* X11 HEWLETT-PACKARD */
- delim = '-';
- break;
-
- default: /* everything else */
- delim = DEFDELIMCH;
- break;
- }
- }
- else
- {
- delim = DEFDELIMCH;
- }
-
- while(i--)
- waddch(window, delim);
-
- if(enter_alt_charset_mode && exit_alt_charset_mode && !opt_delimiter &&
- *enter_alt_charset_mode && *exit_alt_charset_mode)
- {
- wattroff(window, A_ALTCHARSET);
- }
- }
-
- /*---------------------------------------------------------------------------*
- * print error string in header-line
- *---------------------------------------------------------------------------*/
- void error(char *str)
- {
- extern int errno;
- extern char *sys_errlist[];
- extern int sys_nerr;
-
- int i;
-
- if(str == NULL)
- {
- if(errno && (errno <= sys_nerr))
- strcpy(errorline, sys_errlist[errno]);
- else
- strcpy(errorline, "Unknown Error, call your guru ...");
- }
- strcpy(errorline, str);
-
- i = strlen(errorline);
- while(i++ < COLS)
- strcat(errorline," ");
-
- wmove(cmnd_w, C_HEAD, 0);
- wattron(cmnd_w, A_REVERSE);
- waddstr(cmnd_w, errorline);
- wattroff(cmnd_w, A_REVERSE);
- wmove(cmnd_w, C_LINE, curcol());
- suspend_time();
- errorflag = 1;
- }
-
- /*---------------------------------------------------------------------------*
- * clear error string and rewrite "normal" header
- *---------------------------------------------------------------------------*/
- void clrerror(void)
- {
- if(errorflag) /* error-string in header ? */
- {
- resume_time();
- errorflag = 0; /* reset error-flag */
- wmove(cmnd_w, C_HEAD, 0); /* headerline pos */
- wclrtoeol(cmnd_w); /* clear old */
- header(); /* rewrite header */
- wmove(cmnd_w, C_LINE, curcol());
- }
- }
-
- /*---------------------------------------------------------------------------*
- * fatal, irrecoverable error
- *---------------------------------------------------------------------------*/
- void fatal(char *str)
- {
- free_list(); /* free memory */
- fini_flabels(); /* fk-labels to normal */
- endwin(); /* exit curses */
- fprintf(stderr,"\n\n\t *** Wish Fatal Error: ***\n\t *** [%s] ***\n\n",str);
- exit(1);
- }
-
- /*---------------------------------------------------------------------------*
- * print headerline centered in display
- *---------------------------------------------------------------------------*/
- void header(void)
- {
- int p,q;
-
- wmove(cmnd_w, C_HEAD, 0);
-
- if(errorflag)
- {
- wattron(cmnd_w, A_REVERSE);
- waddstr(cmnd_w, errorline);
- wattroff(cmnd_w, A_REVERSE);
- }
- else
- {
- wattron(cmnd_w, A_REVERSE);
- if((COLS+1) > 80)
- {
- p = (COLS+1) - 80;
- p /= 2;
- q = p;
- while(q--)
- waddch(cmnd_w, SPACE);
- waddstr(cmnd_w, headerline);
- q = p;
- while(q--)
- waddch(cmnd_w, SPACE);
- }
- else
- {
- waddstr(cmnd_w, headerline);
- }
- wattroff(cmnd_w, A_REVERSE);
- }
- sepaline(cmnd_w);
- wmove(cmnd_w, C_LINE, curcol());
- }
-
- /*---------------------------------------------------------------------------*
- * display the attribute window, init if required
- *---------------------------------------------------------------------------*/
- void attribs(int flag)
- {
- if(!opt_attrib)
- return;
-
- if(flag) /* rewrite static data ?? */
- {
- sepaline(attr_w);
-
- wmove(attr_w, 1, PS_SIZE);
- wattron(attr_w, A_REVERSE);
- waddstr(attr_w, ST_SIZE);
- wattroff(attr_w, A_REVERSE);
-
- wmove(attr_w, 1, PS_USER);
- wattron(attr_w, A_REVERSE);
- waddstr(attr_w, ST_USER);
- wattroff(attr_w, A_REVERSE);
-
- wmove(attr_w, 1, PS_GRUP);
- wattron(attr_w, A_REVERSE);
- waddstr(attr_w, ST_GRUP);
- wattroff(attr_w, A_REVERSE);
-
- wmove(attr_w, 1, PS_DATE);
- wattron(attr_w, A_REVERSE);
- waddstr(attr_w, ST_DATE);
- wattroff(attr_w, A_REVERSE);
- }
- mvwaddstr(attr_w, 1, PP_PERM, cur_file->oprm); /* permissions */
- if(cur_file->oislnk) /* a link ?? */
- mvwaddch(attr_w, 1, PP_PERM, 'l'); /* yes ! */
- mvwprintw(attr_w, 1, PP_SIZE, "%-9d",cur_file->osiz); /* filesize */
- mvwaddstr(attr_w, 1, PP_USER, user_from_uid(cur_file->ousr, 8)); /* user */
- mvwaddstr(attr_w, 1, PP_GRUP, group_from_gid(cur_file->ogrp, 8)); /* group */
- mvwaddstr(attr_w, 1, PP_DATE, cur_file->odat); /* date */
- }
-
- /*---------------------------------- EOF -------------------------------------*/
-