2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License, Version 1.0 only 2N/A * (the "License"). You may not use this file except in compliance 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 1995, by Sun Microsystems, Inc. 2N/A * All rights reserved. 2N/A#
pragma ident "%Z%%M% %I% %E% SMI" 2N/A * Copyright 1990, 1995 by Mortice Kern Systems Inc. All rights reserved. 2N/A * Disable typeahead trapping because it slow down updated dramatically 2N/A * This value is the ideal length for the cursor addressing sequence 2N/A * being four bytes long, ie. "<escape><cursor addressing code><row><col>". 2N/A * eg. VT52 - "\EYrc" or ADM3A - "\E=rc" 2N/A * This value is the ideal length for the clear-to-eol sequence 2N/A * being two bytes long, ie "<escape><clear eol code>". 2N/Astatic unsigned long *
nhash = (
unsigned long *) 0;
2N/A * Wrapper that streams Curses output. 2N/A * All escape sequences going to the screen come through here. 2N/A * All ordinary characters go to the screen via the putc in doupdate.c 2N/A * Allocate or grow doupdate() structures. 2N/A * Clear from the start of the current row to bottom of screen. 2N/A /* Restore default color pair before doing area clears. */ 2N/A * Replace a line of text. 2N/A * The principal scheme is to overwrite the region of a line between 2N/A * the first and last differing characters. A clear-eol is used to 2N/A * optimise an update region that consist largely of blanks. This can 2N/A * happen fairly often in the case of scrolled lines or full redraws. 2N/A * Miller's line redraw algorithm, used in the 'S' editor [Mil87], 2N/A * should be re-investigated to see if it is simple and fast enough for 2N/A * our needs, and if it can be adapted to handle the ceol_standout_glitch 2N/A * (HP 2392A terminals) and multibyte character sequences. 2N/A * Very early versions of this code applied a Gosling algorithm column 2N/A * wise in addition to the row-wise used in complex(). It was removed 2N/A * in favour of both computation and transmission speed. The assumption 2N/A * being that overwrites of a line region occured far more frequently 2N/A * [Mil87] W. Miller, A Software Tools Sampler, Prentice-Hall, 1987 2N/A /* Before replacing a line of text, check for type-ahead. */ 2N/A#
endif /* M_CURSES_TYPEAHEAD */ 2N/A /* Find start of blank tail region. */ 2N/A /* Only consider clear-to-end-of-line optimization if the 2N/A * blank tail falls within the end of the dirty region by 2N/A * more than ideal length of clear-to-end-of-line sequence. 2N/A * Else disable the check by forcing tail to be at the 2N/A /* Skip common regions. */ 2N/A /* Advance before possible goto. */ 2N/A /* Move the cursor by redrawing characters or using 2N/A * cursor motion commands. The first time that we 2N/A * address this row, jump equals -1, so that the cursor 2N/A * will be forced to the correct screen line. Once 2N/A * there, we should be able to track the cursor motion 2N/A * along the line and jump only when the cost of redrawing 2N/A * to column N is more expensive than a jump to column N. 2N/A /* First time addressing this row or cost of 2N/A * jumping cheaper than redrawing. 2N/A /* If attributes at start of field are different 2N/A * force an attribute cookie to be dropped. 2N/A /* Redraw to move short distance. */ 2N/A /* Write difference region. */ 2N/A /* Check for clear-to-end-of-line optimization. */ 2N/A /* For HP terminals, only clear-to-end-of-line 2N/A * once the attributes have been turned off. 2N/A * Other terminals, we can proceed normally. 2N/A /* Make sure we don't scroll the screen by writing 2N/A * to the bottom right corner. 2N/A *** hacks for writting into the last 2N/A *** column of the last line so as not 2N/A /* Remember any existing attribute cookie. */ 2N/A /* Change attribute state. On HP terminals we also 2N/A * have to check for attribute cookies that may need 2N/A /* Remember new or existing cookie. */ 2N/A /* Don't display internal characters. */ 2N/A /* Update copy of screen image. */ 2N/A /* Check the attributes at the end of the field with 2N/A * those of start of the next common region. If they 2N/A * differ, force another iteration of the write-loop 2N/A * that will change the attribute state. 2N/A /* Before leaving this line, check if we have to turn off 2N/A * attributes and record a cookie. 2N/A /* ceol_standout_glitch, which affects HP terminals, 2N/A * drops hidden cookies on the screen where ever the 2N/A * cursor is, so disabling attributes before a cursor 2N/A * motion operation could disturb existing highlights. 2N/A /* Attributes on an HP terminal do not cross lines. */ 2N/A /* Re-check for clear to end-of-line optimization. */ 2N/A /* Is the tail of the current screen image non-blank? */ 2N/A /* If tail didn't reach the right margin of 2N/A * the current screen image, then we will 2N/A * make it look like the new image with a 2N/A * clear to end-of-line. 2N/A /* Restore default color pair before area clear. */ 2N/A /* Line wrapping checks. */ 2N/A * Replace a block of lines. 2N/A * Only ever used for complex(). 2N/A * Delete a block of lines. 2N/A * Only ever used for complex(). 2N/A /* Assume that the sequence to delete more than one 2N/A * line is faster than repeated single delete_lines. 2N/A 0, 0, 0, 0, 0, 0, 0, 0
2N/A /* Error -- what to do. */ 2N/A * Insert a block of lines. 2N/A * Only ever used for complex(). 2N/A * We must assume that insert_line and parm_insert_line reset the 2N/A * cursor column to zero. Therefore it is text_replace() responsiblity 2N/A * to move the cursor to the correct column to begin the update. 2N/A /* Position the cursor and insert a block of lines into the screen 2N/A * image now, insert lines into the physical screen, then draw the 2N/A /* Assume that the sequence to insert more than one line is 2N/A * faster than repeated single insert_lines. 2N/A 0, 0, 0, 0, 0, 0, 0, 0
2N/A /* For the single line insert we use to iterate moving 2N/A * the cursor, inserting, and then drawing a line. That 2N/A * would appear to be slow but visually appealing. However, 2N/A * people on slow terminals want speed and those on fast 2N/A * terminal won't see it. 2N/A /* Error -- what to do. */ 2N/A 0, 0, 0, 0, 0, 0, 0, 0
2N/A /* Scroll recorded image. */ 2N/A 0, 0, 0, 0, 0, 0, 0, 0
2N/A /* Scroll recorded image. */ 2N/A * Dynamic programming algorithm for the string edit problem. 2N/A * This is a modified Gosling cost algorithm that takes into account 2N/A * Costs for move, delete, replace, and insert are 0, 1, 2, and 3 2N/A /* Prepare initial row and column of cost matrix. 2N/A /* Top row is 3, 6, 9, ... */ 2N/A /* Left column is 1, 2, 3, ... */ 2N/A /* Assume move op. */ 2N/A/* Should no longer require this code. Using the POSIX 32-bit CRC to 2N/A * generate a hash value should be sufficient now, since text_replace() 2N/A * will compare the contents of a line and output only the dirty regions. 2N/A /* Lines are different, assume replace op. */ 2N/A /* Compare insert op. */ 2N/A /* Compare delete op. */ 2N/A * Build edit script. 2N/A * Normally this would be a recursve routine doing the deletes, inserts, 2N/A * and replaces on individual lines. Instead we build the script so that 2N/A * we can later do the operations on a block basis. For terminals with 2N/A * parm_delete or parm_insert strings this will be better in terms of the 2N/A * number of characters sent to delete and insert a block of lines. 2N/A * Also we can optimize the script so that tail inserts become replaces. 2N/A * This saves unnecessary inserts operations when the tail can just be 2N/A /* We don't have to bounds check i or j becuase row fr and 2N/A * column fr of lc have been preset in order to guarantee the 2N/A /* Optimize Tail Inserts */ 2N/A /* Make each character in the screen line image invalid. */ 2N/A * [MyM86] E.W. Myers & W. Miller, Row Replacement Algorithms for 2N/A * Screen Editors, TR 86-19, Dept. Computer Science, U. of Arizona 2N/A * [MyM87] E.W. Myers & W. Miller, A Simple Row Replacement Method, 2N/A * TR 86-28, Dept. Computer Science, U. of Arizona 2N/A * [Mil87] W. Miller, A Software Tools Sampler, Prentice-Hall, 1987 2N/A * [Gos81] James Gosling, A redisplay algorithm, Proceedings of the 2N/A * ACM Symposium on Text Manipulation, SIGPLAN Notices, 2N/A * 16(6) June 1981, pg 123-129 2N/A * All the above were reviewed and experimented with. Due to the nature of 2N/A * Curses' having to handling overlapping WINDOWs, the only suitable 2N/A * algorithum is [Gos81]. The others are better suited to editor type 2N/A * applications that have one window being the entire terminal screen. 2N/A /* Find block of lines to change */ 2N/A /* Compute new hash. */ 2N/A /* Line not dirty so hash same as before. */ 2N/A /* Do deletes first in reverse order. */ 2N/A for (i = j-
1;
fr <= i; --i)
2N/A /* Find size of block */ 2N/A /* _line[], which contains pointers to screen lines, 2N/A /* Save new hash for next update. */ 2N/A /* Mark line as untouched. */ 2N/A * Simple screen update algorithm 2N/A * We perform a simple incremental update of the terminal screen. 2N/A * Only the segment of a line that was touched is replaced on the 2N/A /* Mark line as untouched. */ 2N/A * Send all changes made to _newscr to the physical terminal. 2N/A * If idlok() is set TRUE then doupdate will try and use hardware insert 2N/A * and delete line sequences in an effort to optimize output. idlok() 2N/A * should really only be used in applications that want a proper scrolling 2N/A * Added scroll heuristic to handle special case where a full size window 2N/A * with full size scroll region, will scroll the window and replace dirty 2N/A /* Set up non-blocking input for typeahead trapping. */ 2N/A#
endif /* M_CURSES_TYPEAHEAD */ 2N/A "doupdate(void) using %s algorithm.",
2N/A /* Return from temporary escape done with endwin(). */ 2N/A /* Force redraw of screen. */ 2N/A#
endif /* M_CURSES_TYPEAHEAD */ 2N/A /* When redrawwing a window, we not only assume that line 2N/A * noise may have lost characters, but line noise may have 2N/A * generated bogus characters on the screen outside the 2N/A * the window in question, in which case redraw the entire 2N/A * screen to be sure. 2N/A#
if 0
/* This first expression, of undefined section, is useless 2N/A * since newscr->_scroll is unsigned and never LT zero. 2N/A /* Restore previous input mode. */ 2N/A#
endif /* M_CURSES_TYPEAHEAD */ 2N/A * If true, the implementation may use hardware insert and delete, 2N/A * character features of the terminal. The window parameter 2N/A * If true, the implementation may use hardware insert, delete, 2N/A * and scroll line features of the terminal. The window parameter 2N/A * Use the POSIX 32-bit CRC function to compute a hash value 2N/A * for the window line.