Commit Graph

67 Commits

Author SHA1 Message Date
blymn a7d2c21606 * Don't redraw the background if the new background character is the
same as the old one.  This prevents excessive redraws in some
   applications.

 * Fix bug introduced when wbkgrndset was fixed, we cannot blindly
   replace any instance of the old background character with the new one
   because some of those characters were put there by the application
   leading to display corruption.  So flag characters as background when
   they are erased and only update the flagged characters when setting
   the background.
2022-05-03 07:25:34 +00:00
blymn 301bf8cc44 Make the default colour pair be pair 0 which appears to match other
curses implementations.
2022-04-12 07:03:04 +00:00
uwe f560b4a780 __makenew: use calloc to get zeroed memory for window contents.
PR lib/56767.
2022-03-26 16:03:02 +00:00
blymn f1942931a2 Correct (hopefully) the handling of wide characters.
* Remove the WCOL family of macros, these were "stealing" the upper bits
  of a character attribute to store the column width of a character.  No
  warning was given about this in curses.h which meant it was easy to
  accidentally reuse the bits in use by the WCOL macros (we already did).
  Add couple of 16bit ints to the character structure iff HAVE_WCHAR is
  true to hold the display width and wide char related flags (just
  continuation at the moment)
* Convert all instances of WCOL macros to just reference the column width
  in the char structure so it is not obfuscated.
* Fix cursor positioning so placing a cursor in the middle of a wide char
  actually does just that.
* Fix plod so it understands that if the cursor is going to be positioned
  in the middle of a wide char it cannot just reprint the char to get there.
* Fix plodput so it correctly counts the number of output characters for
  wide characters.
* Fix slk routines to properly size the wctomb() buffer.
2022-01-25 03:05:06 +00:00
blymn 63621d5a6b Add a bit more debug. 2021-10-19 06:41:03 +00:00
rin 43ea4784d7 PR lib/56388
For __newwin() and __resizewin(), the line hash was calculated as if
HAVE_WCHAR is disabled.

Fix this bug by refactoring __hash_line() function, which calculates
the line hash by an appropriate method.
2021-09-07 01:23:09 +00:00
rin 0bd3a62045 Expand __CTRACE() to __nothing #ifndef DEBUG.
Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
2021-09-06 07:03:49 +00:00
mcf bd85fcf225 Fix initial line hash calculation for subwindows
lp->hash is not initialized at this point. Since the hash is
calculated in chunks using __hash_more(), it needs to be initialized
to 0 first (just as in doupdate()).

Detected with valgrind while running python's test suite when
debugging an unrelated issue.

ok uwe@
2021-06-01 00:59:01 +00:00
uwe 21d563f5dc __newwin - fix BGWCOL initialization.
From Michael Forney in PR lib/56174
2021-05-15 11:06:07 +00:00
uwe ccb2ee4b73 newwin - fix crash with negative ncols.
When support for negative nrows/ncols was added, one s/ncols/maxx/ was
missed so we ended up passing negative (i.e. huge unsigned) length
when hashing the line contents.

Reported by Naman Jain in PR lib/55484
2020-07-14 04:39:39 +00:00
blymn 2a780e62ed Rework previous fix for getch cursor position when cursor is moved
without refresh.  If the window is not dirty but the window cursor
position does not match curscr then move the cursor.  This fixes
the issues seen in PR lib/54263.
2019-06-09 07:40:14 +00:00
blymn e2cfd49c61 Back out incorrect fix for PR 53617 and fix it in a different way.
Keep track of the cursor location, if getch is called without a refresh
and without pending updates (dirty windows) then move the cursor to the
correct location directly.  Doing this prevents unnecessary refreshes.
2019-05-20 22:17:41 +00:00
roy 69f3641e49 printw: rework vw_printw so it uses open_memstream rather than funopen2
This makes it more portable as open_memstream is POSIX and fixes a
potential issue with wide characters not fully being printed
due to any buffer overflow.
2019-04-01 11:39:15 +00:00
roy 65c1447580 curses: test terminal capabilities for drawing in the bottom right corner
If auto margins are present, we need to turn them off or enter
an insert mode to "push" the character we want into the corner.
If pushing a wide character of greater than one cell, we need something
more than ich1, othewise the bottom right corner will remain blank.

Follow on fix for PR# 30978.

OK jdc@
2018-10-10 09:40:11 +00:00
roy 4ab8a24fa9 curses: allow drawing the lowest right hand cell of the terminal
This is a historical behaviour that needs fixing
If any terminal does scroll when drawing in the lowest right hand cell
of the terminal then an entry should be made in the terminfo database
(currently there is no standard code) to state that and define
__SCROLLWIN as before.

Fixes PR# 30978.
2018-10-05 11:59:05 +00:00
roy d34c5681a4 curses: fix ripoffline
When creating stdscr, ensure it's placed and sized in accordance with
lines ripped off.
LINES is no longer adjusted for lines ripped off.
POSIX makes no mention that it should be adjusted.
Bottom lines are now placed correctly.
Lines ripped off are now displayed after calling initscr.

ok kamil@

Fixes PR #53635
2018-10-02 17:35:44 +00:00
roy ab1cdcdbe2 Allow a subwindow to contain another subwindow.
This reverts r1.37 and allows wip/rtv to work better.
2017-09-18 10:18:13 +00:00
roy 50a63ac8d2 KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
2017-01-06 13:53:18 +00:00
roy 506f84ec9a Implement ncurses is_pad(3).
Correct documentation about is_keypad(3).
2017-01-05 23:15:43 +00:00
christos 59538e7ea4 It is expensive to open and close files for every printf, keep it around. 2016-10-23 21:20:56 +00:00
roy 43d5eb454b Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
2009-07-22 16:57:14 +00:00
jdc dfc45432ab Make __subwin() static. 2008-04-14 20:33:15 +00:00
blymn e124de36d8 Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
2007-05-28 15:01:53 +00:00
jdc 1f221324cf Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable.  Postive vales include
debug areas, negative values exclude them.
2007-01-21 13:25:36 +00:00
jdc 978ab4ad4e Background characters and attributes don't need to be kept per character
cell, as they are merged when characters are added.  Remove the per cell
storage and clarify the manual page.  Pointed out by ruibiao@.
2006-01-15 11:43:54 +00:00
jdc a6a9a97d12 Changes to support *echochar().
Should fix PR lib/24927.
2004-03-28 08:58:37 +00:00
agc eb7c1594f1 Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22280, verified by myself.
2003-08-07 16:42:00 +00:00
dsl a2a4308b26 Remove unused extern for __winlistp. 2003-08-01 13:29:06 +00:00
dsl 87e998f336 Remove __winlistp, add *screen to WINDOW and initialise in newwin().
Make delwin() remove window from list of windows on its screen.
Free win->lspace and win->lines for subwins (they only share text space).
Free things in the correct (and same) order if malloc() fails in __makenew().
Adjust delscreen() for delwin() removing itself from winlist.
Fixes potential massive corruptions if delwin() called on a main window.
NB: not responsible for the sysinst core dumps :-(
2003-07-30 11:19:00 +00:00
jdc 24b8aeb15a New sub-windows should not be marked as pads.
(Also noticed by David Laight.)
2003-07-05 19:03:32 +00:00
dsl b70727e760 Error attempts at nested subwindows, the data structures don't support them.
I can't quite decide whether the X/Open Curses Issue 4, version 2 needs them.
2003-06-26 17:13:55 +00:00
jdc 44d2f865a0 Mark all lines on new pads as dirty. This ensures that we draw blank
(untouched) lines when the pad is refreshed.
2003-06-09 06:58:11 +00:00
jdc 38b99f1400 Make sure that windows are not off the left or top edges of the screen.
Noticed while looking at PR 21041.
2003-04-08 05:56:01 +00:00
dsl d75ec8181e Fix resize of windows with subwins.
Let window size be given as a -ver number => lines from bottom.
Fix trace calls of pointers
(approved by Brett Lumn)
2003-02-17 11:07:19 +00:00
jdc c1d36848fe Add newpad() and subpad().
Modify __makenew(), __newwin() and __subwin() to handle pads.
2002-12-23 12:17:03 +00:00
jdc c5f3aee499 Mark lines on new windows unchanged.
Add window to __set_subwin() debug.
2002-12-05 17:14:34 +00:00
jdc 4da2d0814d Set default colour on windows created after a call to start_color().
(Also noticed by Pooka).
2002-11-25 09:11:26 +00:00
blymn d5dc62cbd8 Fix lint nits mainly with the len parameter type in hash_more. 2002-10-22 11:37:34 +00:00
blymn 8d2591041a * Added new function idcok - this closes PR 10802
* Added sentinels to the line structures when in debug mode to try
  to pick up data overwrite problems, if they occur.
2002-07-19 13:22:41 +00:00
blymn ef5927835e Remove extraneous tabs from blank lines. 2002-01-02 10:38:27 +00:00
blymn 51344953b1 * Remove termcap globals from public interface
* Clean up commented out code
2001-12-11 11:18:17 +00:00
blymn c84d91aad5 * Major change to add support for the newterm/set_term functions.
* Added fix to getch.c suggested by Gabriel Rosenkoetter (thanks :-)
2001-12-02 09:14:20 +00:00
jdc 048f92e86e Set scrolling region top correctly.
Fixes scrolling bug in sub-windows.
2001-05-17 19:04:01 +00:00
jdc 3f9388e3e3 Implement scrolling regions :
has_ic()
  has_il()
  setscrreg()
  wsetscrreg()
2001-04-20 12:56:08 +00:00
christos 9791d7cf26 remove redundant declarations. 2001-01-05 22:51:21 +00:00
blymn fd2c9043b8 * Added new function dupwin.
* Fixed bug in copywin overwrite code.
2000-04-20 13:12:14 +00:00
jdc 92a8633938 Set background character and attributes for added characters. 2000-04-18 22:45:23 +00:00
blymn e79669d636 More multiple changes:
* Added function derwin.
* Added function copywin.
* Modified both overlay and overwrite to use copywin.
* Updated man page with new functions and fixed minor format glitch.
2000-04-18 12:23:01 +00:00
blymn ec6e2540fe Multiple fixes:
* Added Bill's fixes for errors when compiling with WARNS=1
* Incorporated fixes to make usage of unctrl consistent in debug and
  made improvements to ctrace - it now timestamps it's output better.
* Reduced the number of mallocs done by __init_getch by allocating key
  structs in bunches instead of singly.
* Removed the shadowing of global declarations in newwin and subwin
  functions
2000-04-17 12:25:45 +00:00
mycroft 3dda981dc7 Make subwindows scroll correctly. 2000-04-16 05:48:25 +00:00