Skip to content

Can't exit curses program and retain screen contents #5

@walles

Description

@walles

Hi!

Please try the following program:

#!/usr/bin/ruby require 'curses' include Curses init_screen crmode setpos((lines - 5) / 2, (cols - 10) / 2) addstr('Hit any key') refresh getch # Don't close_screen(); we want the screen contents to remain after # exiting

Expected result:

  • After you hit some key, the program should quit and the "Hit any key" message should still be visible on screen

Current result:

  • When the program exits, the screen contents is restored to what it was before the program was started

Note:

  • If you kill -9 the program, it exits without restoring the screen contents just like I want, but then it exits with a non-zero return code.

The use case is that I want my pager implementation to be able to exit without restoring screen contents when pressing ^C:
https://github.com/walles/moar

I currently use the kill -9 workaround, but would like to be able to do without it.

Regards /Johan

Note that this issue is cloned from https://bugs.ruby-lang.org/issues/9177 upon request from Hiroshi SHIBATA.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions