summaryrefslogtreecommitdiff
path: root/payloads/libpayload/curses/PDCurses/os2/pdcgetsc.c
blob: d712dadfa84bd73c0383c1c98718f9c8a250d876 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/* Public Domain Curses */

#include "pdcos2.h"

RCSID("$Id: pdcgetsc.c,v 1.39 2008/07/14 04:24:51 wmcbrine Exp $")

/* return width of screen/viewport */

int PDC_get_columns(void)
{
#ifdef EMXVIDEO
    int rows = 0;
#else
    VIOMODEINFO modeInfo = {0};
#endif
    int cols = 0;
    const char *env_cols;

    PDC_LOG(("PDC_get_columns() - called\n"));

#ifdef EMXVIDEO
    v_dimen(&cols, &rows);
#else
    modeInfo.cb = sizeof(modeInfo);
    VioGetMode(&modeInfo, 0);
    cols = modeInfo.col;
#endif
    env_cols = getenv("COLS");

    if (env_cols)
        cols = min(atoi(env_cols), cols);

    PDC_LOG(("PDC_get_columns() - returned: cols %d\n", cols));

    return cols;
}

/* get the cursor size/shape */

int PDC_get_cursor_mode(void)
{
#ifdef EMXVIDEO
    int curstart = 0, curend = 0;
#else
    VIOCURSORINFO cursorInfo;
#endif
    PDC_LOG(("PDC_get_cursor_mode() - called\n"));

#ifdef EMXVIDEO
    v_getctype(&curstart, &curend);
    return (curstart << 8) | curend;
#else
    VioGetCurType (&cursorInfo, 0);

    return (cursorInfo.yStart << 8) | cursorInfo.cEnd;
#endif
}

/* return number of screen rows */

int PDC_get_rows(void)
{
#ifdef EMXVIDEO
    int cols = 0;
#else
    VIOMODEINFO modeInfo = {0};
#endif
    int rows = 0;
    const char *env_rows;

    PDC_LOG(("PDC_get_rows() - called\n"));

    /* use the value from LINES environment variable, if set. MH 10-Jun-92 */
    /* and use the minimum of LINES and *ROWS.                MH 18-Jun-92 */

#ifdef EMXVIDEO
    v_dimen(&cols, &rows);
#else
    modeInfo.cb = sizeof(modeInfo);
    VioGetMode(&modeInfo, 0);
    rows = modeInfo.row;
#endif
    env_rows = getenv("LINES");

    if (env_rows)
        rows = min(atoi(env_rows), rows);

    PDC_LOG(("PDC_get_rows() - returned: rows %d\n", rows));

    return rows;
}