You are not logged in.

#1 2013-05-12 07:52:02

boast
Member
Registered: 2010-09-28
Posts: 219

[SOLVED] python + ncurses, scrollable window

Say I have a huge text file and I want to put it in an ncurses pad so the user can scroll through it, how is it done?

I have something like

max_x = stdscr.getmaxyx()[1]
max_y = stdscr.getmaxyx()[0]
log_window = curses.newpad(max_y,max_x)

but I can't slam all the file lines in there because it is bigger than the newpad size.

if I do

log_window = curses.newpad(len(file_data),max_x)
log_window.refresh(window_position,0,4,0,max_y,max_x

I get

_curses.error: prefresh() returned ERR

Can't think if any way to get this done.

Last edited by boast (2013-05-12 18:00:04)


Asus M4A785TD-V ;; Phenom II X4 @ 3.9GHz ;; Ripjaws 12GB DDR3-1600 ;; 128GB Samsung 830 ;; MSI GTX460 v2 w/ blob ;; Arch Linux + KDE 4.x

Offline

#2 2013-05-12 14:28:22

firecat53
Member
From: Lake Stevens, WA, USA
Registered: 2007-05-14
Posts: 1,542
Website

Re: [SOLVED] python + ncurses, scrollable window

You can check out the code in the editor function of keepassc to see how we did it. So far we've only implemented vertical scrolling, not horizontal yet. We didn't use pads either...just fancy scrolling in the buffer.

Scott

Offline

#3 2013-05-12 14:41:25

progandy
Member
Registered: 2012-05-17
Posts: 5,280

Re: [SOLVED] python + ncurses, scrollable window

If you want to load the whole file into a pad, then you could also create a fitting pad and then use a subpad which you will display in the console.
The refresh call seems to be fine. What is the value of window_position?

Last edited by progandy (2013-05-12 14:48:04)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#4 2013-05-12 17:59:51

boast
Member
Registered: 2010-09-28
Posts: 219

Re: [SOLVED] python + ncurses, scrollable window

progandy wrote:

If you want to load the whole file into a pad, then you could also create a fitting pad and then use a subpad which you will display in the console.


ahh, I see. That worked, thanks!


Asus M4A785TD-V ;; Phenom II X4 @ 3.9GHz ;; Ripjaws 12GB DDR3-1600 ;; 128GB Samsung 830 ;; MSI GTX460 v2 w/ blob ;; Arch Linux + KDE 4.x

Offline

Board footer

Powered by FluxBB