output.c (7e1b7636c894be9d1130c284089ce1ea0786ecec) | output.c (b2ea244070ff84eab79e04befb7aa30c982fc84d) |
---|---|
1/* 2 * Copyright (C) 1984-2017 Mark Nudelman 3 * 4 * You may distribute under the terms of either the GNU General Public 5 * License or the Less License, as specified in the README file. 6 * 7 * For more information, see the README file. 8 */ 9 10 11/* 12 * High level routines dealing with the output to the screen. 13 */ 14 15#include "less.h" 16#if MSDOS_COMPILER==WIN32C 17#include "windows.h" | 1/* 2 * Copyright (C) 1984-2017 Mark Nudelman 3 * 4 * You may distribute under the terms of either the GNU General Public 5 * License or the Less License, as specified in the README file. 6 * 7 * For more information, see the README file. 8 */ 9 10 11/* 12 * High level routines dealing with the output to the screen. 13 */ 14 15#include "less.h" 16#if MSDOS_COMPILER==WIN32C 17#include "windows.h" |
18#ifndef COMMON_LVB_UNDERSCORE 19#define COMMON_LVB_UNDERSCORE 0x8000 |
|
18#endif | 20#endif |
21#endif |
|
19 20public int errmsgs; /* Count of messages displayed by error() */ 21public int need_clr; 22public int final_attr; 23public int at_prompt; 24 25extern int sigs; 26extern int sc_width; --- 6 unchanged lines hidden (view full) --- 33#if MSDOS_COMPILER==WIN32C || MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC 34extern int ctldisp; 35extern int nm_fg_color, nm_bg_color; 36extern int bo_fg_color, bo_bg_color; 37extern int ul_fg_color, ul_bg_color; 38extern int so_fg_color, so_bg_color; 39extern int bl_fg_color, bl_bg_color; 40extern int sgr_mode; | 22 23public int errmsgs; /* Count of messages displayed by error() */ 24public int need_clr; 25public int final_attr; 26public int at_prompt; 27 28extern int sigs; 29extern int sc_width; --- 6 unchanged lines hidden (view full) --- 36#if MSDOS_COMPILER==WIN32C || MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC 37extern int ctldisp; 38extern int nm_fg_color, nm_bg_color; 39extern int bo_fg_color, bo_bg_color; 40extern int ul_fg_color, ul_bg_color; 41extern int so_fg_color, so_bg_color; 42extern int bl_fg_color, bl_bg_color; 43extern int sgr_mode; |
44#if MSDOS_COMPILER==WIN32C 45extern int have_ul; |
|
41#endif | 46#endif |
47#endif |
|
42 43/* 44 * Display the line which is in the line buffer. 45 */ 46 public void 47put_line() 48{ 49 int c; --- 72 unchanged lines hidden (view full) --- 122 { 123 /* 124 * Look for SGR escape sequences, and convert them 125 * to color commands. Replace bold, underline, 126 * and italic escapes into colors specified via 127 * the -D command-line option. 128 */ 129 char *anchor, *p, *p_next; | 48 49/* 50 * Display the line which is in the line buffer. 51 */ 52 public void 53put_line() 54{ 55 int c; --- 72 unchanged lines hidden (view full) --- 128 { 129 /* 130 * Look for SGR escape sequences, and convert them 131 * to color commands. Replace bold, underline, 132 * and italic escapes into colors specified via 133 * the -D command-line option. 134 */ 135 char *anchor, *p, *p_next; |
130 static unsigned char fg, fgi, bg, bgi; 131 static unsigned char at; 132 unsigned char f, b; | 136 static int fg, fgi, bg, bgi; 137 static int at; 138 int f, b; |
133#if MSDOS_COMPILER==WIN32C 134 /* Screen colors used by 3x and 4x SGR commands. */ 135 static unsigned char screen_color[] = { 136 0, /* BLACK */ 137 FOREGROUND_RED, 138 FOREGROUND_GREEN, 139 FOREGROUND_RED|FOREGROUND_GREEN, 140 FOREGROUND_BLUE, --- 113 unchanged lines hidden (view full) --- 254 case 1: /* bold on */ 255 fgi = 8; 256 at |= 1; 257 break; 258 case 3: /* italic on */ 259 case 7: /* inverse on */ 260 at |= 2; 261 break; | 139#if MSDOS_COMPILER==WIN32C 140 /* Screen colors used by 3x and 4x SGR commands. */ 141 static unsigned char screen_color[] = { 142 0, /* BLACK */ 143 FOREGROUND_RED, 144 FOREGROUND_GREEN, 145 FOREGROUND_RED|FOREGROUND_GREEN, 146 FOREGROUND_BLUE, --- 113 unchanged lines hidden (view full) --- 260 case 1: /* bold on */ 261 fgi = 8; 262 at |= 1; 263 break; 264 case 3: /* italic on */ 265 case 7: /* inverse on */ 266 at |= 2; 267 break; |
262 case 4: /* underline on */ 263 bgi = 8; | 268 case 4: /* underline on */ 269#if MSDOS_COMPILER==WIN32C 270 if (have_ul) 271 bgi = COMMON_LVB_UNDERSCORE >> 4; 272 else 273#endif 274 bgi = 8; |
264 at |= 4; 265 break; 266 case 5: /* slow blink on */ 267 case 6: /* fast blink on */ 268 bgi = 8; 269 at |= 8; 270 break; 271 case 8: /* concealed on */ --- 79 unchanged lines hidden (view full) --- 351 { 352 f = nm_fg_color; 353 b = nm_bg_color; 354 } 355 } 356 if (at & 16) 357 f = b ^ 8; 358 f &= 0xf; | 275 at |= 4; 276 break; 277 case 5: /* slow blink on */ 278 case 6: /* fast blink on */ 279 bgi = 8; 280 at |= 8; 281 break; 282 case 8: /* concealed on */ --- 79 unchanged lines hidden (view full) --- 362 { 363 f = nm_fg_color; 364 b = nm_bg_color; 365 } 366 } 367 if (at & 16) 368 f = b ^ 8; 369 f &= 0xf; |
359 b &= 0xf; | 370#if MSDOS_COMPILER==WIN32C 371 b &= 0xf | (COMMON_LVB_UNDERSCORE >> 4); 372#else 373 b &= 0xf; 374#endif |
360 WIN32setcolors(f, b); 361 p_next = anchor = p + 1; 362 } else 363 p_next++; 364 } 365 366 /* Output what's left in the buffer. */ 367 WIN32textout(anchor, ob - anchor); --- 163 unchanged lines hidden (view full) --- 531 case 'd': 532 col += iprint_int(parg->p_int); 533 parg++; 534 break; 535 case 'n': 536 col += iprint_linenum(parg->p_linenum); 537 parg++; 538 break; | 375 WIN32setcolors(f, b); 376 p_next = anchor = p + 1; 377 } else 378 p_next++; 379 } 380 381 /* Output what's left in the buffer. */ 382 WIN32textout(anchor, ob - anchor); --- 163 unchanged lines hidden (view full) --- 546 case 'd': 547 col += iprint_int(parg->p_int); 548 parg++; 549 break; 550 case 'n': 551 col += iprint_linenum(parg->p_linenum); 552 parg++; 553 break; |
554 case '%': 555 putchr('%'); 556 break; |
|
539 } 540 } 541 } 542 return (col); 543} 544 545/* 546 * Get a RETURN. --- 48 unchanged lines hidden (view full) --- 595 } 596 597 putstr(return_to_continue); 598 at_exit(); 599 col += sizeof(return_to_continue) + so_e_width; 600 601 get_return(); 602 lower_left(); | 557 } 558 } 559 } 560 return (col); 561} 562 563/* 564 * Get a RETURN. --- 48 unchanged lines hidden (view full) --- 613 } 614 615 putstr(return_to_continue); 616 at_exit(); 617 col += sizeof(return_to_continue) + so_e_width; 618 619 get_return(); 620 lower_left(); |
603 clear_eol(); | 621 clear_eol(); |
604 605 if (col >= sc_width) 606 /* 607 * Printing the message has probably scrolled the screen. 608 * {{ Unless the terminal doesn't have auto margins, 609 * in which case we just hammered on the right margin. }} 610 */ 611 screen_trashed = 1; --- 58 unchanged lines hidden --- | 622 623 if (col >= sc_width) 624 /* 625 * Printing the message has probably scrolled the screen. 626 * {{ Unless the terminal doesn't have auto margins, 627 * in which case we just hammered on the right margin. }} 628 */ 629 screen_trashed = 1; --- 58 unchanged lines hidden --- |