Annotation of nono/lib/textscreen.h, revision 1.1.1.1

1.1       root        1: //
                      2: // nono
                      3: // Copyright (C) 2018 [email protected]
                      4: //
                      5: 
                      6: #pragma once
                      7: 
                      8: // 属性
                      9: enum TA {
                     10:        Normal  = 0x00 << 8,
                     11:        // On, Off, Disable は3ビットを使った状態値。
                     12:        // これらが実際どう表現されるかはデバイスによる。
                     13:        On              = 0x01 << 8,    // ビットとかがオンであることを示す
                     14:        Off             = 0x02 << 8,    // ビットとかがオフであることを示す
                     15:        Disable = 0x03 << 8,    // 機能などが無効であることを示す
                     16:        Em              = 0x04 << 8,    // 値の変化など強調することを示す
                     17: };
                     18: 
                     19: //
                     20: // テキストスクリーン
                     21: //
                     22: // col × row で指定されるテキスト画面。
                     23: // 表示可能なのは 0x20..0x7e の printable 文字。
                     24: // 0x20 未満と 0x7f の動作は未定。
                     25: // 漢字は 2桁占有する。文字列として指定する時は UTF-8 だが、内部コードは
                     26: // Shift_JIS なので、第一水準、第二水準の文字だけを指定すること。
                     27: //
                     28: // TextScreen() コンストラクタで作成して Init(col, row) するか、
                     29: // TextScreen(col, row) コンストラクタを呼ぶかどちらか選択。
                     30: // チェックとかはしていないので併用しないこと。
                     31: //
                     32: class TextScreen
                     33: {
                     34:  public:
                     35:        TextScreen();
                     36:        TextScreen(int col, int row);
                     37:        virtual ~TextScreen();
                     38: 
                     39:        // 初期化
                     40:        void Init(int col, int row);
                     41: 
                     42:        // クリア
                     43:        void Clear();
                     44: 
                     45:        // 現在位置に1文字出力 (上位バイトは属性)
                     46:        void Putc(uint16 ch);
                     47: 
                     48:        // 現在位置に字列を出力
                     49:        void Puts(const char *str);
                     50: 
                     51:        // 現在位置に指定の属性で文字列を出力
                     52:        void Puts(uint attr, const char *str);
                     53: 
                     54:        // 座標を指定して属性なしで書式付き文字列を出力
                     55:        void Print(int x, int y, const char *fmt, ...) __printflike(4, 5);
                     56: 
                     57:        // 座標と属性を指定して、書式付き文字列を出力
                     58:        void Print(int x, int y, uint attr, const char *fmt, ...)
                     59:                __printflike(5, 6);
                     60: 
                     61:        // バッファアドレスを取得。(描画デバイス向け)
                     62:        const uint16 *GetBuf() const { return textbuf; }
                     63: 
                     64:        // XXX 生バッファを取得
                     65:        // バッファの内部構造を変えた場合はこれを呼んでる人については
                     66:        // 見直しをすること。そのうちなんとかするかも
                     67:        uint16 *GetRawBuf() { return textbuf; }
                     68: 
                     69:        // 桁数を取得
                     70:        int GetCol() const { return col; }
                     71: 
                     72:        // 行数を取得
                     73:        int GetRow() const { return row; }
                     74: 
                     75:  private:
                     76:        // バッファ (幅x高さちょうどの長さ、ゼロ終端文字列ではない)
                     77:        // 上位8ビットは属性、下位8ビットが文字コード。
                     78:        uint16 *textbuf = NULL;
                     79: 
                     80:        // 幅
                     81:        int col = 0;
                     82: 
                     83:        // 高さ
                     84:        int row = 0;
                     85: 
                     86:        // カーソル X 座標
                     87:        int X = 0;
                     88: 
                     89:        // カーソル Y 座標
                     90:        int Y = 0;
                     91: };

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.