Deleted Added
full compact
screen.c (210386) screen.c (300395)
1/*
2 * Top users/processes display for Unix
3 * Version 3
4 *
5 * This program may be freely redistributed,
6 * but this entire comment MUST remain intact.
7 *
8 * Copyright (c) 1984, 1989, William LeFebvre, Rice University
9 * Copyright (c) 1989, 1990, 1992, William LeFebvre, Northwestern University
10 *
1/*
2 * Top users/processes display for Unix
3 * Version 3
4 *
5 * This program may be freely redistributed,
6 * but this entire comment MUST remain intact.
7 *
8 * Copyright (c) 1984, 1989, William LeFebvre, Rice University
9 * Copyright (c) 1989, 1990, 1992, William LeFebvre, Northwestern University
10 *
11 * $FreeBSD: head/contrib/top/screen.c 210386 2010-07-22 18:52:29Z rpaulo $
11 * $FreeBSD: head/contrib/top/screen.c 300395 2016-05-22 04:17:00Z ngie $
12 */
13
14/* This file contains the routines that interface to termcap and stty/gtty.
15 *
16 * Paul Vixie, February 1987: converted to use ioctl() instead of stty/gtty.
17 *
18 * I put in code to turn on the TOSTOP bit while top was running, but I
19 * didn't really like the results. If you desire it, turn on the

--- 25 unchanged lines hidden (view full) ---

45# endif
46# endif
47#endif
48#include "screen.h"
49#include "boolean.h"
50
51extern char *myname;
52
12 */
13
14/* This file contains the routines that interface to termcap and stty/gtty.
15 *
16 * Paul Vixie, February 1987: converted to use ioctl() instead of stty/gtty.
17 *
18 * I put in code to turn on the TOSTOP bit while top was running, but I
19 * didn't really like the results. If you desire it, turn on the

--- 25 unchanged lines hidden (view full) ---

45# endif
46# endif
47#endif
48#include "screen.h"
49#include "boolean.h"
50
51extern char *myname;
52
53int putstdout();
54
55int overstrike;
56int screen_length;
57int screen_width;
58char ch_erase;
59char ch_kill;
60char smart_terminal;
61char PC;

--- 169 unchanged lines hidden (view full) ---

231#ifdef TERMIOS
232 if (tcgetattr(STDOUT, &old_settings) == -1)
233 {
234 smart_terminal = No;
235 }
236#endif
237}
238
53
54int overstrike;
55int screen_length;
56int screen_width;
57char ch_erase;
58char ch_kill;
59char smart_terminal;
60char PC;

--- 169 unchanged lines hidden (view full) ---

230#ifdef TERMIOS
231 if (tcgetattr(STDOUT, &old_settings) == -1)
232 {
233 smart_terminal = No;
234 }
235#endif
236}
237
238void
239init_screen()
240
241{
242 /* get the old settings for safe keeping */
243#ifdef SGTTY
244 if (ioctl(STDOUT, TIOCGETP, &old_settings) != -1)
245 {
246 /* copy the settings so we can modify them */

--- 74 unchanged lines hidden (view full) ---

321
322 if (!is_a_terminal)
323 {
324 /* not a terminal at all---consider it dumb */
325 smart_terminal = No;
326 }
327}
328
239init_screen()
240
241{
242 /* get the old settings for safe keeping */
243#ifdef SGTTY
244 if (ioctl(STDOUT, TIOCGETP, &old_settings) != -1)
245 {
246 /* copy the settings so we can modify them */

--- 74 unchanged lines hidden (view full) ---

321
322 if (!is_a_terminal)
323 {
324 /* not a terminal at all---consider it dumb */
325 smart_terminal = No;
326 }
327}
328
329void
329end_screen()
330
331{
332 /* move to the lower left, clear the line and send "te" */
333 if (smart_terminal)
334 {
335 putcap(lower_left);
336 putcap(clear_line);

--- 14 unchanged lines hidden (view full) ---

351 (void) ioctl(STDOUT, TCSETA, &old_settings);
352#endif
353#ifdef TERMIOS
354 (void) tcsetattr(STDOUT, TCSADRAIN, &old_settings);
355#endif
356 }
357}
358
330end_screen()
331
332{
333 /* move to the lower left, clear the line and send "te" */
334 if (smart_terminal)
335 {
336 putcap(lower_left);
337 putcap(clear_line);

--- 14 unchanged lines hidden (view full) ---

352 (void) ioctl(STDOUT, TCSETA, &old_settings);
353#endif
354#ifdef TERMIOS
355 (void) tcsetattr(STDOUT, TCSADRAIN, &old_settings);
356#endif
357 }
358}
359
360void
359reinit_screen()
360
361{
362 /* install our settings if it is a terminal */
363 if (is_a_terminal)
364 {
365#ifdef SGTTY
366 (void) ioctl(STDOUT, TIOCSETP, &new_settings);

--- 11 unchanged lines hidden (view full) ---

378
379 /* send init string */
380 if (smart_terminal)
381 {
382 putcap(terminal_init);
383 }
384}
385
361reinit_screen()
362
363{
364 /* install our settings if it is a terminal */
365 if (is_a_terminal)
366 {
367#ifdef SGTTY
368 (void) ioctl(STDOUT, TIOCSETP, &new_settings);

--- 11 unchanged lines hidden (view full) ---

380
381 /* send init string */
382 if (smart_terminal)
383 {
384 putcap(terminal_init);
385 }
386}
387
388void
386get_screensize()
387
388{
389
390#ifdef TIOCGWINSZ
391
392 struct winsize ws;
393

--- 29 unchanged lines hidden (view full) ---

423#endif /* TIOCGSIZE */
424#endif /* TIOCGWINSZ */
425
426 (void) strncpy(lower_left, tgoto(cursor_motion, 0, screen_length - 1),
427 sizeof(lower_left) - 1);
428 lower_left[sizeof(lower_left) - 1] = '\0';
429}
430
389get_screensize()
390
391{
392
393#ifdef TIOCGWINSZ
394
395 struct winsize ws;
396

--- 29 unchanged lines hidden (view full) ---

426#endif /* TIOCGSIZE */
427#endif /* TIOCGWINSZ */
428
429 (void) strncpy(lower_left, tgoto(cursor_motion, 0, screen_length - 1),
430 sizeof(lower_left) - 1);
431 lower_left[sizeof(lower_left) - 1] = '\0';
432}
433
434void
431standout(msg)
432
433char *msg;
434
435{
436 if (smart_terminal)
437 {
438 putcap(start_standout);
439 fputs(msg, stdout);
440 putcap(end_standout);
441 }
442 else
443 {
444 fputs(msg, stdout);
445 }
446}
447
435standout(msg)
436
437char *msg;
438
439{
440 if (smart_terminal)
441 {
442 putcap(start_standout);
443 fputs(msg, stdout);
444 putcap(end_standout);
445 }
446 else
447 {
448 fputs(msg, stdout);
449 }
450}
451
452void
448clear()
449
450{
451 if (smart_terminal)
452 {
453 putcap(clear_screen);
454 }
455}
456
453clear()
454
455{
456 if (smart_terminal)
457 {
458 putcap(clear_screen);
459 }
460}
461
462int
457clear_eol(len)
458
459int len;
460
461{
462 if (smart_terminal && !overstrike && len > 0)
463 {
464 if (clear_line)

--- 8 unchanged lines hidden (view full) ---

473 putchar(' ');
474 }
475 return(1);
476 }
477 }
478 return(-1);
479}
480
463clear_eol(len)
464
465int len;
466
467{
468 if (smart_terminal && !overstrike && len > 0)
469 {
470 if (clear_line)

--- 8 unchanged lines hidden (view full) ---

479 putchar(' ');
480 }
481 return(1);
482 }
483 }
484 return(-1);
485}
486
487void
481go_home()
482
483{
484 if (smart_terminal)
485 {
486 putcap(home);
487 }
488}
489
490/* This has to be defined as a subroutine for tputs (instead of a macro) */
491
488go_home()
489
490{
491 if (smart_terminal)
492 {
493 putcap(home);
494 }
495}
496
497/* This has to be defined as a subroutine for tputs (instead of a macro) */
498
499void
492putstdout(ch)
493
494char ch;
495
496{
497 putchar(ch);
498}
499
500putstdout(ch)
501
502char ch;
503
504{
505 putchar(ch);
506}
507