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

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: 
1.1.1.2 ! root       42:        // 折り返しモードかどうか
        !            43:        bool foldmode {};
        !            44: 
1.1       root       45:        // クリア
                     46:        void Clear();
                     47: 
1.1.1.2 ! root       48:        // 現在位置を移動
        !            49:        void Locate(int x, int y);
        !            50: 
1.1       root       51:        // 現在位置に1文字出力 (上位バイトは属性)
                     52:        void Putc(uint16 ch);
                     53: 
                     54:        // 現在位置に字列を出力
                     55:        void Puts(const char *str);
                     56: 
                     57:        // 現在位置に指定の属性で文字列を出力
                     58:        void Puts(uint attr, const char *str);
                     59: 
1.1.1.2 ! root       60:        // 現在位置に属性なしで書式付き文字列を出力
        !            61:        void Print(const char *fmt, ...) __printflike(2, 3);
        !            62: 
1.1       root       63:        // 座標を指定して属性なしで書式付き文字列を出力
                     64:        void Print(int x, int y, const char *fmt, ...) __printflike(4, 5);
                     65: 
                     66:        // 座標と属性を指定して、書式付き文字列を出力
                     67:        void Print(int x, int y, uint attr, const char *fmt, ...)
                     68:                __printflike(5, 6);
                     69: 
                     70:        // バッファアドレスを取得。(描画デバイス向け)
1.1.1.2 ! root       71:        const uint16 *GetBuf() const { return textbuf.get(); }
1.1       root       72: 
                     73:        // XXX 生バッファを取得
                     74:        // バッファの内部構造を変えた場合はこれを呼んでる人については
                     75:        // 見直しをすること。そのうちなんとかするかも
1.1.1.2 ! root       76:        uint16 *GetRawBuf() { return textbuf.get(); }
        !            77: 
        !            78:        // 現在の X 座標を取得
        !            79:        int GetX() const { return X; }
        !            80:        // 現在の Y 座標を取得
        !            81:        int GetY() const { return Y; }
1.1       root       82: 
                     83:        // 桁数を取得
                     84:        int GetCol() const { return col; }
                     85: 
                     86:        // 行数を取得
                     87:        int GetRow() const { return row; }
                     88: 
                     89:  private:
1.1.1.2 ! root       90:        // 改行(次の行の左端に移動)
        !            91:        void CRLF();
        !            92: 
1.1       root       93:        // バッファ (幅x高さちょうどの長さ、ゼロ終端文字列ではない)
                     94:        // 上位8ビットは属性、下位8ビットが文字コード。
1.1.1.2 ! root       95:        std::unique_ptr<uint16[]> textbuf {};
1.1       root       96: 
                     97:        // 幅
                     98:        int col = 0;
                     99: 
                    100:        // 高さ
                    101:        int row = 0;
                    102: 
                    103:        // カーソル X 座標
                    104:        int X = 0;
                    105: 
                    106:        // カーソル Y 座標
                    107:        int Y = 0;
                    108: };

unix.superglobalmegacorp.com

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