/* * * 2004/04/16 * ViViScript 用 Text Based Window System もどき * by さね * * Window Systemもどき と, その応用例. * (Window System と サンプル部が分離されていない. そのうち分離するかも) * ViVi Script で Text Base のアプリケーションを書くときに役に立つ(かもしない). * Window を手前に持ってきたり, 奥に持っていったりできる. * 再描画がとても遅い_| ̄|○ * * 使い方: * このスクリプトを実行すると, * いつくかの Window が開いた状態で * Window System(もどき)が立ち上がる. * q : 終了する * SPACE : カーソルを Window にあわせて, Window を選択/Windowを手前に移動(マウスクリックもどき) * h,j,k,l : カーソルを移動 * H.J,K.L : 選択している Window を移動 * a,x,o,d : 選択している Window のサイズを変更 * g : Window のリストを表示 * n : 選択 Window をリスト内の次の Window に変更する * O : 新しい Window を開く * * 注意: * 表示画面に半角文字を使ってはいけない. * */ var true = 1; var false = 0; var null = 0; var empty = 0; var narrow = 1; var broad = 2; var LT = 0; // left top var RT = 1; // right top var LB = 2; // left bottom var RB = 3; // right bottom var HORIZONTAL = 0; var VERTICAL = 1; var LEFT = 0; var RIGHT = 1; var UP = 2; var DOWN = 3; function raw_getExp(l, r, u, d) { if( l != empty ){ // l full if ( r != empty ){ // l,r full if( u != empty ){ // l,r,u full if( d != empty ){ // l,r,u,d full return "┼"; } else { // l,r,u full, d empty return "┴"; } } else { // l,r full, u empty if( d != empty ){ // l,r,d full, u empty return "┬"; } else { // l,r full, u,d empty return "─"; } } } else { // l full, r empty if( u != empty ){ // l,u full, r empty if( d != empty ){ // l,u,d full, r empty return "┤"; } else { // l,u full, r,d empty return "┘"; } } else { // l full, r,u empty if( d != empty ){ // l,d full, r,u empty return "┐"; } else { // l full, r,u,d empty return "?"; } } } } else { // l empty if ( r != empty ){ // r full, l empty if( u != empty ){ // r,u full, l empty if( d != empty ){ // r,u,d full, l empty return "├"; } else { // r,u full, l,d empty return "└"; } } else { // r full, l,u empty if( d != empty ){ // r,d full, l,u empty return "┌"; } else { // r full, l,u,d empty return "?"; } } } else { // l,r empty if( u != empty ){ // u full, l,r empty if( d != empty ){ // u,d full, l,r empty return "│"; } else { // u full, l,r,d empty return "?"; } } else { // l,r,u empty if( d != empty ){ // d full, l,r,u empty return "?"; } else { // l,r,u,d empty return "?"; } } } } } function raw_getEmptyExp() { return " "; } function raw_getCursorExp() { return "*"; } // txt の n 文字目を選択 function raw_charAt(txt, n){ return txt.charAt(n*2); } // txt の 文字数 function raw_stringLength(txt){ return txt.getCharCount(); } /* class Window{ private: int left; int right; int top; int bottom; String title; public: void setLeft(l); int getLeft(); void setRight(r); int getRight(); void setTop(t); int getTop(); void setBottom(b); int getBottom(); void moveRight(); void moveDown(); void resizeWidth( diff ); void resizeHeight( diff ); voie setTitle(title); String getTitle(); construct(); // construct } */ function Window_setLeft(l) { this.left = l; } function Window_getLeft() { return this.left; } function Window_setRight(r) { this.right = r; } function Window_getRight() { return this.right; } function Window_setTop(t) { this.top = t; } function Window_getTop() { return this.top; } function Window_setBottom(b) { this.bottom = b; } function Window_getBottom() { return this.bottom; } function Window_moveRight(n) { this.left += n; this.right += n; } function Window_moveDown(n) { this.top += n; this.bottom += n; } function Window_resizeWidth( diff ){ this.right += diff; if( this.right <= this.left ){ // 小さすぎ this.right = this.left + 1; } } function Window_resizeHeight( diff ){ this.bottom += diff; if( this.bottom <= this.top ){ // 小さすぎ this.bottom = this.top + 1; } } function Window_setTitle(titl) { this.title = titl; } function Window_getTitle() { return this.title; } function Window_construct( l, t, r, b, titl) { var obj; obj.left = l; obj.right = r; obj.top = t; obj.bottom = b; obj.title = titl; obj.setLeft = Window_setLeft; obj.getLeft = Window_getLeft; obj.setRight = Window_setRight; obj.getRight = Window_getRight; obj.setTop = Window_setTop; obj.getTop = Window_getTop; obj.setBottom = Window_setBottom; obj.getBottom = Window_getBottom; obj.moveRight = Window_moveRight; obj.moveDown = Window_moveDown; obj.resizeWidth = Window_resizeWidth; obj.resizeHeight = Window_resizeHeight; obj.setTitle = Window_setTitle; obj.getTitle = Window_getTitle; if( obj.right <= obj.left ){ obj.right = obj.left + 1; } if( obj.bottom <= obj.top ){ obj.bottom = obj.top + 1; } return obj; } /* class Model{ public: void setMVC( m, v, c); Window[] getWindows(); void addWindow(x0,y0,x1,y1); // window の追加 void moveWindowTop(n); // wins[n] を 一番手前に移動 int getCurX(); // cursor の x int getCurY(); // cursor の y void moveCursor( xdiff, ydiff); // cursor の移動 construct(); // construct private: int xsize; int ysize; int cursorX; int cursorY; Window wins; } */ function Model_setMVC( m, v, c) { // empty } function Model_getWindows() { return this.wins; } function Model_addWindow(x0,y0,x1,y1, title) { var size; size = this.wins.getCount(); this.wins[size] = Window_construct(x0,y0,x1,y1,title); } // wins[n] を一番手前に移動. // つまり, 配列の一番最後に移動 function Model_moveWindowTop( n ){ var len; len = this.wins.getCount(); if( n < len ){ var i; var bak = this.wins[n]; for(i=n; i"); writeln("model is ", this.model); writeln("--dump"); var x, y; for( x=0; x