output.c (009e81b16465ea457c0e63fd49fe77f47cc27a5a) | output.c (1ea316270f1f75922ac53976d5d8808a41442f46) |
---|---|
1/* 2 * Copyright (C) 1984-2015 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 */ --- 29 unchanged lines hidden (view full) --- 38extern int so_fg_color, so_bg_color; 39extern int bl_fg_color, bl_bg_color; 40#endif 41 42/* 43 * Display the line which is in the line buffer. 44 */ 45 public void | 1/* 2 * Copyright (C) 1984-2015 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 */ --- 29 unchanged lines hidden (view full) --- 38extern int so_fg_color, so_bg_color; 39extern int bl_fg_color, bl_bg_color; 40#endif 41 42/* 43 * Display the line which is in the line buffer. 44 */ 45 public void |
46put_line() | 46put_line(void) |
47{ | 47{ |
48 register int c; 49 register int i; | 48 int c; 49 int i; |
50 int a; 51 52 if (ABORT_SIGS()) 53 { 54 /* 55 * Don't output if a signal is pending. 56 */ 57 screen_trashed = 1; --- 30 unchanged lines hidden (view full) --- 88 * is directed to a file. It also does the same if 89 * we never produce any real output; for example, if 90 * the input file(s) cannot be opened. If we do 91 * eventually produce output, code in edit() makes 92 * sure these messages can be seen before they are 93 * overwritten or scrolled away. 94 */ 95 public void | 50 int a; 51 52 if (ABORT_SIGS()) 53 { 54 /* 55 * Don't output if a signal is pending. 56 */ 57 screen_trashed = 1; --- 30 unchanged lines hidden (view full) --- 88 * is directed to a file. It also does the same if 89 * we never produce any real output; for example, if 90 * the input file(s) cannot be opened. If we do 91 * eventually produce output, code in edit() makes 92 * sure these messages can be seen before they are 93 * overwritten or scrolled away. 94 */ 95 public void |
96flush() | 96flush(void) |
97{ | 97{ |
98 register int n; 99 register int fd; | 98 int n; 99 int fd; |
100 101 n = (int) (ob - obuf); 102 if (n == 0) 103 return; 104 105#if MSDOS_COMPILER==MSOFTC 106 if (is_tty && any_display) 107 { --- 213 unchanged lines hidden (view full) --- 321 screen_trashed = 1; 322 ob = obuf; 323} 324 325/* 326 * Output a character. 327 */ 328 public int | 100 101 n = (int) (ob - obuf); 102 if (n == 0) 103 return; 104 105#if MSDOS_COMPILER==MSOFTC 106 if (is_tty && any_display) 107 { --- 213 unchanged lines hidden (view full) --- 321 screen_trashed = 1; 322 ob = obuf; 323} 324 325/* 326 * Output a character. 327 */ 328 public int |
329putchr(c) 330 int c; | 329putchr(int c) |
331{ 332#if 0 /* fake UTF-8 output for testing */ 333 extern int utf_mode; 334 if (utf_mode) 335 { 336 static char ubuf[MAX_UTF_CHAR_LEN]; 337 static int ubuf_len = 0; 338 static int ubuf_index = 0; --- 36 unchanged lines hidden (view full) --- 375 at_prompt = 0; 376 return (c); 377} 378 379/* 380 * Output a string. 381 */ 382 public void | 330{ 331#if 0 /* fake UTF-8 output for testing */ 332 extern int utf_mode; 333 if (utf_mode) 334 { 335 static char ubuf[MAX_UTF_CHAR_LEN]; 336 static int ubuf_len = 0; 337 static int ubuf_index = 0; --- 36 unchanged lines hidden (view full) --- 374 at_prompt = 0; 375 return (c); 376} 377 378/* 379 * Output a string. 380 */ 381 public void |
383putstr(s) 384 register char *s; | 382putstr(constant char *s) |
385{ 386 while (*s != '\0') 387 putchr(*s++); 388} 389 390 391/* 392 * Convert an integral type to a string. 393 */ 394#define TYPE_TO_A_FUNC(funcname, type) \ 395void funcname(num, buf) \ 396 type num; \ 397 char *buf; \ 398{ \ 399 int neg = (num < 0); \ 400 char tbuf[INT_STRLEN_BOUND(num)+2]; \ | 383{ 384 while (*s != '\0') 385 putchr(*s++); 386} 387 388 389/* 390 * Convert an integral type to a string. 391 */ 392#define TYPE_TO_A_FUNC(funcname, type) \ 393void funcname(num, buf) \ 394 type num; \ 395 char *buf; \ 396{ \ 397 int neg = (num < 0); \ 398 char tbuf[INT_STRLEN_BOUND(num)+2]; \ |
401 register char *s = tbuf + sizeof(tbuf); \ | 399 char *s = tbuf + sizeof(tbuf); \ |
402 if (neg) num = -num; \ 403 *--s = '\0'; \ 404 do { \ 405 *--s = (num % 10) + '0'; \ 406 } while ((num /= 10) != 0); \ 407 if (neg) *--s = '-'; \ 408 strcpy(buf, s); \ 409} 410 411TYPE_TO_A_FUNC(postoa, POSITION) 412TYPE_TO_A_FUNC(linenumtoa, LINENUM) 413TYPE_TO_A_FUNC(inttoa, int) 414 415/* 416 * Output an integer in a given radix. 417 */ 418 static int | 400 if (neg) num = -num; \ 401 *--s = '\0'; \ 402 do { \ 403 *--s = (num % 10) + '0'; \ 404 } while ((num /= 10) != 0); \ 405 if (neg) *--s = '-'; \ 406 strcpy(buf, s); \ 407} 408 409TYPE_TO_A_FUNC(postoa, POSITION) 410TYPE_TO_A_FUNC(linenumtoa, LINENUM) 411TYPE_TO_A_FUNC(inttoa, int) 412 413/* 414 * Output an integer in a given radix. 415 */ 416 static int |
419iprint_int(num) 420 int num; | 417iprint_int(int num) |
421{ 422 char buf[INT_STRLEN_BOUND(num)]; 423 424 inttoa(num, buf); 425 putstr(buf); 426 return ((int) strlen(buf)); 427} 428 429/* 430 * Output a line number in a given radix. 431 */ 432 static int | 418{ 419 char buf[INT_STRLEN_BOUND(num)]; 420 421 inttoa(num, buf); 422 putstr(buf); 423 return ((int) strlen(buf)); 424} 425 426/* 427 * Output a line number in a given radix. 428 */ 429 static int |
433iprint_linenum(num) 434 LINENUM num; | 430iprint_linenum(LINENUM num) |
435{ 436 char buf[INT_STRLEN_BOUND(num)]; 437 438 linenumtoa(num, buf); 439 putstr(buf); 440 return ((int) strlen(buf)); 441} 442 443/* 444 * This function implements printf-like functionality 445 * using a more portable argument list mechanism than printf's. 446 */ 447 static int | 431{ 432 char buf[INT_STRLEN_BOUND(num)]; 433 434 linenumtoa(num, buf); 435 putstr(buf); 436 return ((int) strlen(buf)); 437} 438 439/* 440 * This function implements printf-like functionality 441 * using a more portable argument list mechanism than printf's. 442 */ 443 static int |
448less_printf(fmt, parg) 449 register char *fmt; 450 PARG *parg; | 444less_printf(char *fmt, PARG *parg) |
451{ | 445{ |
452 register char *s; 453 register int col; | 446 char *s; 447 int col; |
454 455 col = 0; 456 while (*fmt != '\0') 457 { 458 if (*fmt != '%') 459 { 460 putchr(*fmt++); 461 col++; --- 26 unchanged lines hidden (view full) --- 488} 489 490/* 491 * Get a RETURN. 492 * If some other non-trivial char is pressed, unget it, so it will 493 * become the next command. 494 */ 495 public void | 448 449 col = 0; 450 while (*fmt != '\0') 451 { 452 if (*fmt != '%') 453 { 454 putchr(*fmt++); 455 col++; --- 26 unchanged lines hidden (view full) --- 482} 483 484/* 485 * Get a RETURN. 486 * If some other non-trivial char is pressed, unget it, so it will 487 * become the next command. 488 */ 489 public void |
496get_return() | 490get_return(void) |
497{ 498 int c; 499 500#if ONLY_RETURN 501 while ((c = getchr()) != '\n' && c != '\r') 502 bell(); 503#else 504 c = getchr(); 505 if (c != '\n' && c != '\r' && c != ' ' && c != READ_INTR) 506 ungetcc(c); 507#endif 508} 509 510/* 511 * Output a message in the lower left corner of the screen 512 * and wait for carriage return. 513 */ 514 public void | 491{ 492 int c; 493 494#if ONLY_RETURN 495 while ((c = getchr()) != '\n' && c != '\r') 496 bell(); 497#else 498 c = getchr(); 499 if (c != '\n' && c != '\r' && c != ' ' && c != READ_INTR) 500 ungetcc(c); 501#endif 502} 503 504/* 505 * Output a message in the lower left corner of the screen 506 * and wait for carriage return. 507 */ 508 public void |
515error(fmt, parg) 516 char *fmt; 517 PARG *parg; | 509error(char *fmt, PARG *parg) |
518{ 519 int col = 0; 520 static char return_to_continue[] = " (press RETURN)"; 521 522 errmsgs++; 523 524 if (any_display && is_tty) 525 { --- 36 unchanged lines hidden (view full) --- 562 563/* 564 * Output a message in the lower left corner of the screen 565 * and don't wait for carriage return. 566 * Usually used to warn that we are beginning a potentially 567 * time-consuming operation. 568 */ 569 public void | 510{ 511 int col = 0; 512 static char return_to_continue[] = " (press RETURN)"; 513 514 errmsgs++; 515 516 if (any_display && is_tty) 517 { --- 36 unchanged lines hidden (view full) --- 554 555/* 556 * Output a message in the lower left corner of the screen 557 * and don't wait for carriage return. 558 * Usually used to warn that we are beginning a potentially 559 * time-consuming operation. 560 */ 561 public void |
570ierror(fmt, parg) 571 char *fmt; 572 PARG *parg; | 562ierror(char *fmt, PARG *parg) |
573{ 574 at_exit(); 575 clear_bot(); 576 at_enter(AT_STANDOUT); 577 (void) less_printf(fmt, parg); 578 putstr(intr_to_abort); 579 at_exit(); 580 flush(); 581 need_clr = 1; 582} 583 584/* 585 * Output a message in the lower left corner of the screen 586 * and return a single-character response. 587 */ 588 public int | 563{ 564 at_exit(); 565 clear_bot(); 566 at_enter(AT_STANDOUT); 567 (void) less_printf(fmt, parg); 568 putstr(intr_to_abort); 569 at_exit(); 570 flush(); 571 need_clr = 1; 572} 573 574/* 575 * Output a message in the lower left corner of the screen 576 * and return a single-character response. 577 */ 578 public int |
589query(fmt, parg) 590 char *fmt; 591 PARG *parg; | 579query(char *fmt, PARG *parg) |
592{ | 580{ |
593 register int c; | 581 int c; |
594 int col = 0; 595 596 if (any_display && is_tty) 597 clear_bot(); 598 599 (void) less_printf(fmt, parg); 600 c = getchr(); 601 --- 13 unchanged lines hidden --- | 582 int col = 0; 583 584 if (any_display && is_tty) 585 clear_bot(); 586 587 (void) less_printf(fmt, parg); 588 c = getchr(); 589 --- 13 unchanged lines hidden --- |