⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tcxldemo.c

📁 就一个字强.很不错,希望大家能喜欢.这是我朋友发给我的
💻 C
📖 第 1 页 / 共 2 页
字号:
        wtextattr(LCYAN|_BLACK);
        wputs("\n  The ssave() and srestore()"
              "\n  functions allow screen"
              "\n  swapping to/from memory.");
        wprints(5,8,LRED|BLINK|_BLACK,pressakey);
        if(waitkeyt(273)==ESC) exit_prog();
        wprints(5,8,_BLACK,spaces);
        sbuf2=ssave();
        if(!sbuf2) error_exit();
        gotoxy_(24,79);
        clrscrn();
        prints(10,27,LMAGENTA,"Press a key to return");
        if(waitkeyt(273)==ESC) exit_prog();
        srestore(sbuf2);


        /*  open demo window 6 and demonstrate activating of windows  */

        whandle[6]=wopen(11,48,21,77,1,LCYAN|_CYAN);
        wtextattr(WHITE|_CYAN);
        wputs("\n TCXL's wactiv() is used to"
              "\n activate a window, making"
              "\n it available for windowing"
              "\n operations.");
        wprints(4,14,YELLOW|BLINK|_CYAN,pressakey);
        if(waitkeyt(273)==ESC) exit_prog();
        wprints(4,14,_CYAN,spaces);
        for(i=0;i<=6;i++) {
            if(kbhit()) {                            /*  check for keypress  */
                if(getch()==ESC) exit_prog();
            }
            if(wactiv(whandle[i])) error_exit();
            delay_(15);
        }


        /*  open demo window 7 and demonstrate moving of active window  */

        whandle[7]=wopen(4,2,16,35,2,LGREEN|_BROWN);
        if(!whandle[7]) error_exit();
        wtextattr(WHITE|_BROWN);
        wputs("\n To move the active window,"
              "\n the wmove() function is"
              "\n used.");
        wprints(3,8,YELLOW|BLINK|_BROWN,pressakey);
        if(waitkeyt(273)==ESC) exit_prog();
        wprints(3,8,_BROWN,spaces);
        if(wmove(0,0)) error_exit();
        delay_(12);
        if(wmove(10,4)) error_exit();
        delay_(12);
        if(wmove(6,19)) error_exit();
        delay_(12);
        if(kbhit()) {                               /*  check for keypress  */
            if(getch()==ESC) exit_prog();
        }
        if(wmove(1,13)) error_exit();
        delay_(12);
        if(wmove(2,35)) error_exit();
        delay_(12);
        if(wmove(11,35)) error_exit();
        delay_(12);


        /*  demonstrate making copies of the same window  */

        wtextattr(LRED|_BROWN);
        wputs("\n\n The wcopy() function will"
                "\n create a duplicate of the"
                "\n active window.");
        wprints(7,17,YELLOW|BLINK|_BROWN,pressakey);
        if(waitkeyt(273)==ESC) exit_prog();
        wprints(7,17,_BROWN,spaces);
        whandle[8]=wcopy(0,0);
        if(!whandle[8]) error_exit();
        delay_(12);
        whandle[9]=wcopy(1,37);
        if(!whandle[9]) error_exit();
        if(kbhit()) {                               /*  check for keypress  */
            if(getch()==ESC) exit_prog();
        }
        delay_(18);
        wclose();                                      /*  close copies  */
        delay_(12);
        wclose();
        delay_(12);


        /*  close all windows except window 0  */

        while(wnopen()>1) {
            if(kbhit()) {
                if(getch()==ESC) exit_prog();
            }
            wclose();
            delay_(6);
        }


        /*  list other features of TCXL  */

        wclear();
        wputs("  Other features of TCXL include:\n");
        wtextattr(LGREEN|_RED);
        wputs("\n  - EGA 43 & VGA 50 line modes"
              "\n  - expanded memory usage"
              "\n  - screen/window swapping to disk"
              "\n  - advanced string manipulation"
              "\n  - equipment detection"
              "\n  - mouse functions"
              "\n  - printer functions");
        wprints(8,26,YELLOW|BLINK|_RED,pressakey);
        if(waitkeyt(273)==ESC) exit_prog();
        wprints(8,26,_RED,spaces);


        /*  get response from the keyboard, controlling input  */

        wclear();
        if(wmove(7,19)) error_exit();
        wgotoxy(3,11);
        wtextattr(WHITE|_RED);
        wputs("View demo again?  ");
        setcursz(7,1);                           /*  turn cursor on  */
        clearkeys();                             /*  clear keyboard buffer  */
        ch=wgetchf("YyNn");                      /*  get keyboard response  */
        setcursz(32,0);                          /*  turn cursor back off  */
        if(ch==ESC) exit_prog();                 /*  see if Esc was pressed  */
        wclose();
        if(ch=='Y'||ch=='y') {
        }
        else {
            exit_prog();
        }
    }
}

/*  This function is the demonstration of pull-down windows   */

void pulldown_demo(void)
{
    char m1,m2;

    if(!wopen(0,0,24,79,2,CYAN)) error_exit();
    wprints(0,0,_BLUE,"                                        "
                      "                                      ");
    wprints(1,0,CYAN,"哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪"
                      "哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪");
    wgotoxy(2,0);
    wtextattr(YELLOW);
    wputs("This is a sample editor interface to demonstrate how TCXL's "
          "wmbardef()\n"
          "and wmbarget() functions can be used for pull-down menus.  "
          "Use arrow keys\n"
          "to move selection bar around and use the Esc key to exit the "
          "menu you are\n"
          "currently in.  Any selection from a pull-down menu will return "
          "you to demo.");
    m1='F';                         /* initialize selection bar position  */
    m2=PDMAIN;
    top:
    wmbardef(0,2,YELLOW|_BLUE,"File",'F');      /* define main menu */
    wmbardef(0,15,YELLOW|_BLUE,"Editing",'E');
    wmbardef(0,31,YELLOW|_BLUE,"Defaults",'D');
    wmbardef(0,47,YELLOW|_BLUE,"Help",'H');
    wmbardef(0,59,YELLOW|_BLUE,"Options",'O');
    if(wmbardef(0,73,YELLOW|_BLUE,"Quit",'Q')) error_exit();
    m1=wmbarget(YELLOW|_MAGENTA,m1,m2);
    switch(m1) {          /*  test return value from main (horizontal) menu  */
        case 'F':                    /* define pull-down menu for option 'F' */
            if(!wopen(2,1,11,14,0,LGREY)) error_exit();
            wmbardef(0,0,YELLOW|_BLUE," Load       ",'L');
            wmbardef(1,0,YELLOW|_BLUE," Save       ",'S');
            wmbardef(2,0,YELLOW|_BLUE," Rename     ",'R');
            wmbardef(3,0,YELLOW|_BLUE," New        ",'N');
            wmbardef(4,0,YELLOW|_BLUE," Directory  ",'D');
            wmbardef(5,0,YELLOW|_BLUE," Change dir ",'C');
            wmbardef(6,0,YELLOW|_BLUE," OS Shell   ",'O');
            if(wmbardef(7,0,YELLOW|_BLUE," Quit       ",'Q')) error_exit();
            m2=wmbarget(YELLOW|_MAGENTA,'L',PDMENU);
            wclose();
            if(m2<=PDMENU) goto top;        /* test for Esc or Lt/Rt Arrow   */

/*          This is where you would test the
            return value from the pull-down menu        */

            break;
        case 'E':                    /* define pull-down menu for option 'E' */
            if(!wopen(2,14,10,28,0,LGREY)) error_exit();
            wmbardef(0,0,YELLOW|_BLUE," Cut         ",'C');
            wmbardef(1,0,YELLOW|_BLUE," Paste       ",'P');
            wmbardef(2,0,YELLOW|_BLUE," cOpy        ",'O');
            wmbardef(3,0,YELLOW|_BLUE," block Begin ",'B');
            wmbardef(4,0,YELLOW|_BLUE," block End   ",'E');
            wmbardef(5,0,YELLOW|_BLUE," Insert line ",'I');
            if(wmbardef(6,0,YELLOW|_BLUE," Delete line ",'D')) error_exit();
            m2=wmbarget(YELLOW|_MAGENTA,'C',PDMENU);
            wclose();
            if(m2<=PDMENU) goto top;        /* test for Esc or Lt/Rt Arrow   */

/*          This is where you would test the
            return value from the pull-down menu        */

            break;
        case 'D':                    /* define pull-down menu for option 'D' */
            if(!wopen(2,30,11,52,0,LGREY)) error_exit();
            wmbardef(0,0,YELLOW|_BLUE," Left margin       0 ",'L');
            wmbardef(1,0,YELLOW|_BLUE," Right margin     72 ",'R');
            wmbardef(2,0,YELLOW|_BLUE," Tab width         4 ",'T');
            wmbardef(3,0,YELLOW|_BLUE," tab eXpansion   yes ",'X');
            wmbardef(4,0,YELLOW|_BLUE," Insert mode     yes ",'I');
            wmbardef(5,0,YELLOW|_BLUE," iNdent mode     yes ",'N');
            wmbardef(6,0,YELLOW|_BLUE," Word wrap mode   no ",'W');
            if(wmbardef(7,0,YELLOW|_BLUE," Save defaults       ",'S')) {
                error_exit();
            }
            m2=wmbarget(YELLOW|_MAGENTA,'L',PDMENU);
            wclose();
            if(m2<=PDMENU) goto top;        /* test for Esc or Lt/Rt Arrow   */

/*          This is where you would test the
            return value from the pull-down menu        */

            break;
        case 'H':                    /* define pull-down menu for option 'H' */
            if(!wopen(2,46,7,65,0,LGREY)) error_exit();
            wmbardef(0,0,YELLOW|_BLUE," help on Help     ",'H');
            wmbardef(1,0,YELLOW|_BLUE," help on Editing  ",'E');
            wmbardef(2,0,YELLOW|_BLUE," help on Defaults ",'D');
            if(wmbardef(3,0,YELLOW|_BLUE," help on Options  ",'O')) {
                error_exit();
            }
            m2=wmbarget(YELLOW|_MAGENTA,'H',PDMENU);
            wclose();
            if(m2<=PDMENU) goto top;        /* test for Esc or Lt/Rt Arrow   */

/*          This is where you would test the
            return value from the pull-down menu        */

            break;
        case 'O':                    /* define pull-down menu for option 'O' */
            if(!wopen(2,56,8,77,0,LGREY)) error_exit();
            wmbardef(0,0,YELLOW|_BLUE," screen siZe     43 ",'Z');
            wmbardef(1,0,YELLOW|_BLUE," Backup files   yes ",'B');
            wmbardef(2,0,YELLOW|_BLUE," bOxed display   no ",'O');
            wmbardef(3,0,YELLOW|_BLUE," Load options       ",'L');
            if(wmbardef(4,0,YELLOW|_BLUE," Save options       ",'S')) {
                error_exit();
            }
            m2=wmbarget(YELLOW|_MAGENTA,'Z',PDMENU);
            wclose();
            if(m2<=PDMENU) goto top;        /* test for Esc or Lt/Rt Arrow   */

/*          This is where you would test the
            return value from the pull-down menu        */

            break;
        case 'Q':                    /* define pull-down menu for option 'Q' */
            if(!wopen(2,60,7,78,0,LGREY)) error_exit();
            wcclear(BLUE|_BLUE);
            wprints(0,2,WHITE|_BLUE,"Are you sure?");
            wmbardef(2,0,YELLOW|_BLUE,"       No        ",'N');
            if(wmbardef(3,0,YELLOW|_BLUE,"       Yes       ",'Y')) {
                error_exit();
            }
            m2=wmbarget(YELLOW|_MAGENTA,'N',PDMENU);
            wclose();
            if(m2<=PDMENU) goto top;        /* test for Esc or Lt/Rt Arrow   */

/*          This is where you would test the
            return value from the pull-down menu        */

            break;
        default:
    }
    wclose();
}


/*  if the Esc key or Ctrl-Break is pressed, this function will be called  */ 

void interrupt exit_prog(void)
{
    clearkeys();                       /*  clear keyboard buffer  */
    setcursz(6,7);                     /*  set cursor size back to normal  */
    srestore(sbuf1);                   /*  restore original screen  */
    gotoxy_(row,col);                  /*  restore original cursor position  */
    exit(0);
}

/*  if an error occurs, this function will be called  */

void error_exit(void)
{
    setcursz(6,7);                       /*  set cursor size back to normal  */
    if(_werrno) {
        printf("\nError:  %s      ",werrmsg());    /*  display error message */
    }
    else {
        abort();
    }
    exit(1);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -