This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: _cursesmodule.c callable update_lines_cols()
Type: enhancement Stage: resolved
Components: Extension Modules Versions: Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: nemesis, python-dev, r.david.murray, steve.dower, twouters, wiggin15
Priority: normal Keywords: patch

Created on 2008-11-03 15:02 by nemesis, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
_curses.diff nemesis, 2008-11-03 15:02 update_lines_cols public accessible
manual_test_4254.py wiggin15, 2015-04-13 22:42
issue4254.diff wiggin15, 2015-04-15 14:43
issue4254-1.diff wiggin15, 2015-04-15 16:56 review
issue4254-2.diff wiggin15, 2015-04-15 18:58 review
Messages (18)
msg75464 - (view) Author: Roland Brickl (nemesis) Date: 2008-11-03 15:02
curses.update_lines.cols() are normally usable within c programs. With
this change, it can now be used too. It only calls the preexisting
function that where only used internally. The cast in the return
statement are possibly false? But it works.
Because this aren't a big change, it would apply to some more
python-versions.
msg75468 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2008-11-03 16:18
Your function PyCurses_update_lines_cols() has no documentation. Can 
you add it?

Can you also give an use case of update_lines_cols()? The function is 
already called by curses.resizeterm() and curses.resize_term().
msg75470 - (view) Author: Roland Brickl (nemesis) Date: 2008-11-03 16:36
Hi Victor,

i use this to get updated versions of curses.COLS and curses.LINES in 
the fact of an curses.KEY_RESIZE event.
So i can use curses within python even without to have panels.
It seems that curses.panel are the prefered way to deal with terminal 
resizes.
The curses.resize[_]term() are only to change the terminal manualy.
What i also found in PyTone is more or less this functionality from 
update_lines_cols():

def getmaxyx(self):
    # taken from http://dag.wieers.com/home-made/dstat/
    try:
        h, w = int(os.environ["LINES"]), int(os.environ["COLUMNS"])
    except KeyError:
        try:
            h, w = curses.tigetnum('lines'), curses.tigetnum('cols')
        except:
            try:
                s = struct.pack('HHHH', 0, 0, 0, 0)
                x = fcntl.ioctl(sys.stdout.fileno(), termios.TIOCGWINSZ,
s)
                h, w = struct.unpack('HHHH', x)[:2]
            except:
                h, w = 25, 80

And please excuse me for the missing documentation. English aren't my 
native language so i would document it like:
Updates curses.LINES and curses.COLS :)

It's my first day here on the issue tracker.
msg75472 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2008-11-03 16:53
> i use this to get updated versions of curses.COLS and curses.LINES in
> the fact of an curses.KEY_RESIZE event.

I didn't know this event. Is a key in a special keyboard? Or an event raised 
by some curses internals?

> Updates curses.LINES and curses.COLS

Your documentation is incomplete. You may reused this comment:

/* Internal helper used for updating curses.LINES, curses.COLS, 
 * _curses.LINES and _curses.COLS */

Oh I just realized that _curses functions have no documentation, great :-/

> It's my first day here on the issue tracker.

Welcome on the tracker ;-)
msg75473 - (view) Author: Roland Brickl (nemesis) Date: 2008-11-03 17:01
>> i use this to get updated versions of curses.COLS and curses.LINES in
>> the fact of an curses.KEY_RESIZE event.

>I didn't know this event. Is a key in a special keyboard? Or an event 
>raised 
>by some curses internals?
Internal curses event.

>Oh I just realized that _curses functions have no documentation, 
>great :-/
Thats why python_curses should be more compatible to the existing 
c_curses documentations.

>> It's my first day here on the issue tracker.

Welcome on the tracker ;-)
Thanks.

Any questions? :)
msg82782 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2009-02-26 22:31
No documentation?  Doc/library/curses.rst exists; there's also
Doc/howto/curses.rst.  What functions in _curses need to be documented?
msg82783 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2009-02-26 22:35
BTW, the code portion of the patch looks OK to me.
msg110695 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-07-18 21:59
msg82783 states code portion of patch looks ok, what do we need to take this forward?
msg240793 - (view) Author: Arnon Yaari (wiggin15) * Date: 2015-04-13 22:42
Creating an automatic test for this issue proves difficult, as using curses to resize the terminal already updates the values, and using ioctls to try to bypass curses, doesn't work.
I'm adding a manual test program (mostly taken from http://www.gossamer-threads.com/lists/python/python/226137), and a newer patch with documentation.
msg241048 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-04-14 22:30
Thanks for the patch update.

The doc addition needs a .. versionadded directive, and there should be an entry in the 3.5 whatsnew document.
msg241108 - (view) Author: Arnon Yaari (wiggin15) * Date: 2015-04-15 14:43
Fixed David's comments
msg241115 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-04-15 15:26
Thanks for updating.

In the doc change you say it updates environment variables, but in the whatsnew change you say it changes constants of the curses module. I believe the whats new version is correct?  Also, doc lines should be wrapped to 80 columns.

Please omit the NEWS item from the patch...with our current system putting NEWS items in patches just makes the patches get stale really quickly.  The committer will add the NEWS item.
msg241132 - (view) Author: Arnon Yaari (wiggin15) * Date: 2015-04-15 16:56
I'm adding patch without the update to Misc/NEWS.

I'm not sure why, but the curses doc refers to LINES and COLS as "environment variables". In the doc change I referred to them as just "variables" and used the notation that works for linking to them, using :envvar:
msg241142 - (view) Author: Arnon Yaari (wiggin15) * Date: 2015-04-15 18:58
Adding a test that only calls the function.
msg241164 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2015-04-15 21:16
Arnon - we'll need you to fill out https://www.python.org/psf/contrib/contrib-form/ before we can merge this patch in. (The dev guide isn't clear on whether trivial patches are okay, but the advice I was given is that we should have a CLA for everything.)
msg241170 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-04-15 22:07
New changeset 132b5376bf34 by Steve Dower in branch 'default':
Issue #4254: Adds _curses.update_lines_cols() Patch by Arnon Yaari
https://hg.python.org/cpython/rev/132b5376bf34
msg241171 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2015-04-15 22:07
Arnon has signed the CLA at PyCon, it just hasn't been processed yet.
msg243441 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-05-18 00:51
Looks to like there is nothing left to do here, so I'm closing it.
History
Date User Action Args
2022-04-11 14:56:40adminsetgithub: 48504
2015-05-18 00:51:18r.david.murraysetstatus: open -> closed
resolution: fixed
messages: + msg243441

stage: commit review -> resolved
2015-04-15 22:07:40steve.dowersetmessages: + msg241171
stage: patch review -> commit review
2015-04-15 22:07:01python-devsetnosy: + python-dev
messages: + msg241170
2015-04-15 21:16:57steve.dowersetnosy: + steve.dower
messages: + msg241164
2015-04-15 18:58:04wiggin15setfiles: + issue4254-2.diff

messages: + msg241142
2015-04-15 16:56:45wiggin15setfiles: + issue4254-1.diff

messages: + msg241132
2015-04-15 15:26:30r.david.murraysetmessages: + msg241115
2015-04-15 14:43:31wiggin15setfiles: + issue4254.diff

messages: + msg241108
versions: + Python 3.5, - Python 3.2
2015-04-15 14:43:12wiggin15setfiles: - patch_4254.diff
2015-04-14 22:30:55r.david.murraysetnosy: + r.david.murray
messages: + msg241048
2015-04-13 23:45:04ned.deilysetnosy: + twouters
2015-04-13 22:43:41wiggin15setfiles: + patch_4254.diff
2015-04-13 22:42:42wiggin15setfiles: + manual_test_4254.py
2015-04-13 22:42:32wiggin15setnosy: + wiggin15
messages: + msg240793
2014-12-31 16:24:38akuchlingsetnosy: - akuchling
2014-02-03 19:40:29BreamoreBoysetnosy: - BreamoreBoy
2010-11-12 20:58:34akuchlingsetassignee: akuchling ->
2010-07-18 21:59:54BreamoreBoysetnosy: + BreamoreBoy
messages: + msg110695
2010-07-09 04:42:01terry.reedysetstage: patch review
versions: + Python 3.2, - Python 2.5
2010-02-22 22:29:09akuchlingsetassignee: akuchling
2009-06-08 22:50:25vstinnersetnosy: - vstinner
2009-02-26 22:35:16akuchlingsetmessages: + msg82783
2009-02-26 22:31:48akuchlingsetnosy: + akuchling
messages: + msg82782
2008-11-03 17:01:35nemesissetmessages: + msg75473
2008-11-03 16:53:15vstinnersetmessages: + msg75472
2008-11-03 16:36:05nemesissetmessages: + msg75470
2008-11-03 16:18:09vstinnersetnosy: + vstinner
messages: + msg75468
2008-11-03 15:02:08nemesiscreate