downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

ncurses_init> <ncurses_init_color
[edit] Last updated: Fri, 17 May 2013

view this page in

ncurses_init_pair

(PHP 4 >= 4.0.7, PHP 5 < 5.3.0, PECL ncurses >= 1.0.0)

ncurses_init_pair色ペアを定義する

説明

int ncurses_init_pair ( int $pair , int $fg , int $bg )

前景色と背景色の色ペアを定義/再定義します。 色ペアが事前に初期化されている場合は、 画面が再描画されて即時に新しい定義が反映されます。

この関数をコールする前に、 ncurses_start_color() で色機能を初期化しておく必要があります。 最初の色ペア (色ペア 0) はデフォルトで黒地に白となっていますが、 ncurses_assume_default_colors() で変更することも可能です。

パラメータ

pair

定義したい色ペアの番号。

fg

色ペアの前景色。 定義済みの色 のいずれか、あるいは端末に色変更機能がある場合に ncurses_init_color() で定義したものとなります。

bg

色ペアの背景色。 定義済みの色 のいずれか、あるいは端末に色変更機能がある場合に ncurses_init_color() で定義したものとなります。

返り値

関数が成功した場合は -1、 ncurses や端末の色機能の初期化ができていない場合は 0 を返します。

注意

既存の色で色ペアを定義する際には、色の変更機能は不要であることに注意しましょう。 この機能が必要となるのは、色自体の定義 (赤、緑、青コンポーネント) を ncurses_init_color() で変更したい場合です。

例1 指定した色で文字列を画面に書き込む

<?php
ncurses_init
();

// 端末が色をサポートしている場合に、初期化してアクティブな色を設定します
if (ncurses_has_colors()) {
    
ncurses_start_color();
    
ncurses_init_pair(1NCURSES_COLOR_YELLOWNCURSES_COLOR_BLUE);
    
ncurses_color_set(1);
}

// 指定した位置に文字列を書き込みます
ncurses_mvaddstr(1010"Hello world! Yellow on blue text!");

// 出力をフラッシュします
ncurses_refresh();

ncurses_end();
?>

参考



add a note add a note User Contributed Notes ncurses_init_pair - [0 notes]
There are no user contributed notes for this page.

 
show source | credits | sitemap | contact | advertising | mirror sites