Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_cursesmodule.c callable update_lines_cols() #48504

Closed
nemesis mannequin opened this issue Nov 3, 2008 · 18 comments
Closed

_cursesmodule.c callable update_lines_cols() #48504

nemesis mannequin opened this issue Nov 3, 2008 · 18 comments
Labels
extension-modules C modules in the Modules dir type-feature A feature request or enhancement

Comments

@nemesis
Copy link
Mannequin

nemesis mannequin commented Nov 3, 2008

BPO 4254
Nosy @Yhg1s, @bitdancer, @wiggin15, @zooba
Files
  • _curses.diff: update_lines_cols public accessible
  • manual_test_4254.py
  • issue4254.diff
  • issue4254-1.diff
  • issue4254-2.diff
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2015-05-18.00:51:18.747>
    created_at = <Date 2008-11-03.15:02:07.897>
    labels = ['extension-modules', 'type-feature']
    title = '_cursesmodule.c callable update_lines_cols()'
    updated_at = <Date 2015-05-18.00:51:18.745>
    user = 'https://bugs.python.org/nemesis'

    bugs.python.org fields:

    activity = <Date 2015-05-18.00:51:18.745>
    actor = 'r.david.murray'
    assignee = 'none'
    closed = True
    closed_date = <Date 2015-05-18.00:51:18.747>
    closer = 'r.david.murray'
    components = ['Extension Modules']
    creation = <Date 2008-11-03.15:02:07.897>
    creator = 'nemesis'
    dependencies = []
    files = ['11932', '38971', '39037', '39044', '39048']
    hgrepos = []
    issue_num = 4254
    keywords = ['patch']
    message_count = 18.0
    messages = ['75464', '75468', '75470', '75472', '75473', '82782', '82783', '110695', '240793', '241048', '241108', '241115', '241132', '241142', '241164', '241170', '241171', '243441']
    nosy_count = 6.0
    nosy_names = ['twouters', 'nemesis', 'r.david.murray', 'wiggin15', 'python-dev', 'steve.dower']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue4254'
    versions = ['Python 3.5']

    @nemesis
    Copy link
    Mannequin Author

    nemesis mannequin commented Nov 3, 2008

    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.

    @nemesis nemesis mannequin added extension-modules C modules in the Modules dir type-feature A feature request or enhancement labels Nov 3, 2008
    @vstinner
    Copy link
    Member

    vstinner commented Nov 3, 2008

    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().

    @nemesis
    Copy link
    Mannequin Author

    nemesis mannequin commented Nov 3, 2008

    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.

    @vstinner
    Copy link
    Member

    vstinner commented Nov 3, 2008

    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 ;-)

    @nemesis
    Copy link
    Mannequin Author

    nemesis mannequin commented Nov 3, 2008

    > 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? :)

    @akuchling
    Copy link
    Member

    No documentation? Doc/library/curses.rst exists; there's also
    Doc/howto/curses.rst. What functions in _curses need to be documented?

    @akuchling
    Copy link
    Member

    BTW, the code portion of the patch looks OK to me.

    @akuchling akuchling self-assigned this Feb 22, 2010
    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Jul 18, 2010

    msg82783 states code portion of patch looks ok, what do we need to take this forward?

    @akuchling akuchling removed their assignment Nov 12, 2010
    @wiggin15
    Copy link
    Mannequin

    wiggin15 mannequin commented Apr 13, 2015

    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.

    @bitdancer
    Copy link
    Member

    Thanks for the patch update.

    The doc addition needs a .. versionadded directive, and there should be an entry in the 3.5 whatsnew document.

    @wiggin15
    Copy link
    Mannequin

    wiggin15 mannequin commented Apr 15, 2015

    Fixed David's comments

    @bitdancer
    Copy link
    Member

    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.

    @wiggin15
    Copy link
    Mannequin

    wiggin15 mannequin commented Apr 15, 2015

    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:

    @wiggin15
    Copy link
    Mannequin

    wiggin15 mannequin commented Apr 15, 2015

    Adding a test that only calls the function.

    @zooba
    Copy link
    Member

    zooba commented Apr 15, 2015

    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.)

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Apr 15, 2015

    New changeset 132b5376bf34 by Steve Dower in branch 'default':
    Issue bpo-4254: Adds _curses.update_lines_cols() Patch by Arnon Yaari
    https://hg.python.org/cpython/rev/132b5376bf34

    @zooba
    Copy link
    Member

    zooba commented Apr 15, 2015

    Arnon has signed the CLA at PyCon, it just hasn't been processed yet.

    @bitdancer
    Copy link
    Member

    Looks to like there is nothing left to do here, so I'm closing it.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    extension-modules C modules in the Modules dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants