# TermAttr

`ITerm`型のターミナルオブジェクトに対して、`<<`演算子を用いてターミナル属性を指定するヘルパークラス。

```cpp
void putmsg(ITerm& trm, const char *msg) {
    trm << TermAttr(TERM_COLOR_FG_RED | TERM_BOLD);
    trm << msg;
    trm << TermAttr(TERM_ATTR_OFF);
}
```

上記の例では、出力ターミナルを`trm`に対して、文字色を赤で太字にして`msg`を出力し、属性をクリアします。

### TermAttr() - コンストラクタ

```cpp
TermAttr(GChar::tAttr attr = 0)
```

attrをパラメータとします。attrは後述の**GChar::tAttr 定数***一覧*で指定します。

指定は以下の組み合わせになります。

* TERM\_ATTR\_OFF (すべての属性のクリア)
* 以下の論理和
  * TERM\_BOLD
  * TERM\_REVERSE
  * 文字色のいずれか
  * 背景色のいずれか

## GChar::tAttr 定数

#### 色設定以外の属性

| 設定                    | 意味             |
| --------------------- | -------------- |
| TERM\_ATTR\_OFF = 0x0 | すべての属性をクリアする   |
| TERM\_BOLD            | 文字を太字にする       |
| TERM\_REVERSE         | 背景色と文字色を反転表示する |

#### 文字色

| 設定                       | 意味   |
| ------------------------ | ---- |
| TERM\_COLOR\_FG\_BLACK   | 黒    |
| TERM\_COLOR\_FG\_RED     | 赤    |
| TERM\_COLOR\_FG\_GREEN   | 緑    |
| TERM\_COLOR\_FG\_YELLOW  | 黄    |
| TERM\_COLOR\_FG\_BLUE    | 青    |
| TERM\_COLOR\_FG\_MAGENTA | マゼンタ |
| TERM\_COLOR\_FG\_CYAN    | シアン  |
| TERM\_COLOR\_FG\_WHITE   | 白    |

#### 背景色

| 設定                       | 意味   |
| ------------------------ | ---- |
| TERM\_COLOR\_BG\_BLACK   | 黒    |
| TERM\_COLOR\_BG\_RED     | 赤    |
| TERM\_COLOR\_BG\_GREEN   | 緑    |
| TERM\_COLOR\_BG\_YELLOW  | 黄    |
| TERM\_COLOR\_BG\_BLUE    | 青    |
| TERM\_COLOR\_BG\_MAGENTA | マゼンタ |
| TERM\_COLOR\_BG\_CYAN    | シアン  |
| TERM\_COLOR\_BG\_WHITE   | 白    |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mwm5.twelite.info/0.8/references/untitled/tweterm/termattr.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
