curses

How to get with Curses the window-size from a resized window?

安稳与你 提交于 2019-12-02 11:11:03
问题 I tried it this way, but it doesn't work - the returned values from getmaxyx remain always the same. #!/usr/bin/env perl use warnings; use 5.012; use Curses; my $size_changed = 0; $SIG{'WINCH'} = sub { $size_changed= 1; }; initscr(); my ( $row, $col ); getmaxyx( $row, $col ); addstr( "begin: $row - $col\n" ); refresh(); for ( 0 .. 19 ) { addstr( "-------------\n" ); if ( $size_changed ) { getmaxyx( $row, $col ); addstr( "new: $row - $col\n" ); $size_changed = 0; } refresh(); sleep 1; } sleep

How to get with Curses the window-size from a resized window?

笑着哭i 提交于 2019-12-02 05:14:12
I tried it this way, but it doesn't work - the returned values from getmaxyx remain always the same. #!/usr/bin/env perl use warnings; use 5.012; use Curses; my $size_changed = 0; $SIG{'WINCH'} = sub { $size_changed= 1; }; initscr(); my ( $row, $col ); getmaxyx( $row, $col ); addstr( "begin: $row - $col\n" ); refresh(); for ( 0 .. 19 ) { addstr( "-------------\n" ); if ( $size_changed ) { getmaxyx( $row, $col ); addstr( "new: $row - $col\n" ); $size_changed = 0; } refresh(); sleep 1; } sleep 3; endwin(); #!/usr/bin/env perl use warnings; use 5.012; use Curses; my $size_changed = 0; $SIG{'WINCH

Why won't my curses box draw?

时间秒杀一切 提交于 2019-12-02 04:21:07
I am toying with curses and I can't get a box to draw on the screen. I created a border which works but I want to draw a box in the border here is my code import curses screen = curses.initscr() try: screen.border(0) box1 = curses.newwin(20, 20, 5, 5) box1.box() screen.getch() finally: curses.endwin() any advice? furas From curses docs : When you call a method to display or erase text, the effect doesn’t immediately show up on the display. ... Accordingly, curses requires that you explicitly tell it to redraw windows, using the refresh() method of window objects. ... You need screen.refresh()

scroll page by page or line by line using python curses

删除回忆录丶 提交于 2019-12-02 04:03:19
Using python curses I am trying to write some text in to window. But when I reach end of window i get addstr() returned ERR how to scroll the output page by page or line by line.? how can I bind SPACE key or down arrow ? here is my code: try: screen = curses.initscr() screen.immedok(True) curses.start_color() curses.init_pair(1, curses.COLOR_GREEN, curses.COLOR_BLACK) curses.init_pair(2, curses.COLOR_WHITE, curses.COLOR_BLACK) screen.bkgd(curses.color_pair(2)) screen.scrollok(1) screen.border(0) p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) (output,

How do I scroll a message across the terminal?

半世苍凉 提交于 2019-12-02 02:08:57
问题 I'm trying to write a program to that acts as a marquee that uses the curses.h library to create a side-scrolling display. What should happen is that my message "Hello" should appear to scroll from the right side of the terminal to the left, character by character. "hello" should appear to scroll across the terminal like so: | H| // fist frame of animation | He| //2nd | Hel| //3rd ... | Hello | // some time in the middle of animation |Hello | // finished. Instead of appearing to scroll across

How do I scroll a message across the terminal?

会有一股神秘感。 提交于 2019-12-02 02:08:55
I'm trying to write a program to that acts as a marquee that uses the curses.h library to create a side-scrolling display. What should happen is that my message "Hello" should appear to scroll from the right side of the terminal to the left, character by character. "hello" should appear to scroll across the terminal like so: | H| // fist frame of animation | He| //2nd | Hel| //3rd ... | Hello | // some time in the middle of animation |Hello | // finished. Instead of appearing to scroll across the terminal my program simply outputs the "Hello" message on the left side of the terminal as if it

_curses.error: add_wch() returned an error

僤鯓⒐⒋嵵緔 提交于 2019-12-02 00:53:52
I have the following code rendering the display for my roguelike game. It includes rendering the map. def render_all(self): for y in range(self.height): for x in range(self.width): wall = self.map.lookup(x,y).blocked if wall: self.main.addch(y, x, "#") else: self.main.addch(y, x, ".") for thing in self.things: draw_thing(thing) It errors out every time. I think it's because it's going off the screen, but the height and width variables are coming from self.main.getmaxyx(), so it shouldn't do that, right? What am I missing? Python 3.4.3 running in Ubuntu 14.04 should that matter. That's expected

get the text in the display with ncurses

佐手、 提交于 2019-12-01 21:24:15
Is there any way to get back the characters outputted into a variable on ncurses ? let's say I do: printw("test"); then I want to be able to: somefunc(strbuffer); printf("%s",strbuffer); // test I need a function to get back all characters on the screen into a variable, scr_dump get's close but the output format is unreadable.. Craig If you put stuff on the screen using curses functions (e.g. addch, mvaddch, addstr) you can use inchstr ) and related functions to read the characters from the screen (extracting them with AND'ing the returned value with A_CHARTEXT ). However, if you use printf or

Is there a way to create a separate display and input on the same terminal using curse?

非 Y 不嫁゛ 提交于 2019-12-01 16:40:14
问题 I'd like to code a command line program that result in this UI: ------------ | | | A | |__________| |_____B____| A is a separate process that loops and displays a list of real time events. It self-refresh. B is a command prompt. It's fixed at the bottom and got a command history. I know some command line IRC programs does this so it must be possible. Bonus point if you can give me a snippet using a Python binding. I'm aware of this post but I'm kind of lost in the curse documentation. 回答1:

How can I screen-scrape output from telnet in Perl?

我只是一个虾纸丫 提交于 2019-12-01 16:23:20
I can setup a telnet connection in Perl no problems, and have just discovered Curses, and am wondering if I can use the two together to scrape the output from the telnet session. I can view on a row, column basis the contents of STDOUT using the simple script below: use Curses; my $win = new Curses; $win->addstr(10, 10, 'foo'); $win->refresh; my $thischar=$win->inch(10,10); print "Char $thischar\n"; And using the below I can open a telnet connection and send \ receive commands with no problem: use net::telnet; my $telnet = new Net::Telnet (Timeout => 9999,); $telnet->open($ipaddress) or die