On Thu, May 22, 2008 at 10:14 PM, Aubrey Li <aubrey at blastwave.org> wrote:
> 2008/5/22 Rafael Vanoni <Rafael.Vanoni at sun.com>:
>>
>> Cool, good points.
>> I cleaned it up and re-wrote it so it's human readable now. Let me know if
>> you think I overdid it :)
>>
> When you were drawing cstate window, I guess you were still confused with
> what is nlines and what is end_y.
>
> int cstate_lines = max(ncstates, npstates) + LINES_TITLE_SW +
> +           BEGINY_CSTAT_SW + BLANK_LINE;
> +
> +       cstate_window           = subwin(stdscr, cstate_lines, maxx,
> BEGINY_CSTAT_SW, 0);
> here, nline(cstate) = max(ncstates, npstates) + c-state-title + [BLANK_LINE];
> I failed to understand why need to add LINES_TITLE_SW and BEGINY_CSTAT_SW.
>
> And, It's good to see there is one blank line between suggestion and
> event window.
> But the blank line between cstate and wakeup window is disappear.
>
> Thanks,
> -Aubrey
>

I wrote a draft for your reference.
1) let's define the actual lines one window uses, not including blank line
2) please roll back max_cstate -> ncstates, because ncstates is still
not including C0.
max_cstate is more accurate here
3) please don't forget to move setup_window() after data collection, otherwise
max_cstate is not initialized.

Thanks,
-Aubrey

/*
 * Number of lines for the title, suggestions and status bar subwindows
 */
#define LINES_TITLE_SW  1
#define LINES_WAKEUP_SW 1
#define LINES_ACPI_SW   1
#define LINES_SUGG_SW   1
#define LINES_STAT_SW   1
#define BLANK_LINE      1

/*
 * initial y position for title and cstate subwindows
 */
#define BEGINY_TITLE_SW 0



        /*
         * draw title bar
         */

        begin_y = BEGINY_TITLE_SW;
        nlines = LINES_TITLE_SW;
        title_bar_window        = subwin(stdscr, nlines, maxx, begin_y, 0);

        /*
         * draw c/p states window
         */
        begin_y = begin_y + nlines + BLANK_LINE;        /* one blank line 
between
last subwin */
        nlines = max((max_cstate + 1), npstates) + LINES_TITLE_SW; /* cstate
title here */
        cstate_window           = subwin(stdscr, nlines, maxx, begin_y, 0);

        /*
         * draw wakeup window
         */
        begin_y = begin_y + nlines + BLANK_LINE;        /* one blank line 
between
last subwin */
        nlines = LINES_WAKEUP_SW;
        wakeup_window           = subwin(stdscr, nlines, maxx, begin_y, 0);

        /*
         * draw acpi power window
         */
        begin_y = begin_y + nlines;
        nlines = LINES_ACPI_SW;
        acpi_power_window       = subwin(stdscr, nlines, maxx, begin_y, 0);

        /*
         * draw event window
         */
        begin_y = begin_y + nlines + BLANK_LINE;        /* one blank line 
between
last subwin */
        nlines = maxy - begin_y - LINES_SUGG_SW - LINES_STAT_SW - 2 * 
BLANK_LINE;
        eventstat_window        = subwin(stdscr, nlines, maxx, begin_y, 0);
        
        /*
         * draw suggestion window
         */
        begin_y = begin_y + nlines + BLANK_LINE;
        nlines = LINES_SUGG_SW;
        suggestion_window       = subwin(stdscr, nlines, maxx, begin_y, 0);

        /*
         * draw status bar
         */
        begin_y = begin_y + nlines + BLANK_LINE;
        nlines = LINES_STAT_SW;
        status_bar_window       = subwin(stdscr, nlines, maxx, begin_y, 0);

Reply via email to