Annotation of coherent/g/usr/lib/uucp/uuinstall/get_entry.c, revision 1.1.1.1

1.1       root        1: /* get_entry.c:        get a keystroke. Increment or decrement row/column
                      2:  *             values as indicated by the keystroke. Also test for
                      3:  *             <RETURN> or 's' being pressed. This will select the
                      4:  *             current highlighted entry for processing. If an entry
                      5:  *             is selected, the entry number within the file is returned.
                      6:  *             A -1 is returned is no selection is made (user pressed 'q').
                      7:  */
                      8: 
                      9: #include "uuinstall.h"
                     10: 
                     11: get_entry()
                     12: {
                     13:        short retflag = 0;      /* bogus, but needed for do...while loop. */
                     14:        char arrow;
                     15: 
                     16:        do{
                     17:                arrow = wgetch(selwin);         /* here's our keystroke */
                     18: 
                     19:                /* test for console arrow key. This will be represented
                     20:                 * by a 3 char escape sequence. The first char is esc,
                     21:                 * the second we don't care about. The third tells us
                     22:                 * what arrow key was pressed. We will translate this third
                     23:                 * character into a vi keystroke of h,j,k or l.
                     24:                 */
                     25: 
                     26:                if (arrow == 27){               /* escape. indicates arrow */
                     27:                        wgetch(selwin);         /* skip 2nd char of esc seq. */
                     28:                        arrow = wgetch(selwin); /* this is the value we want */
                     29: 
                     30:                        switch(arrow){
                     31:                                case 68:        arrow = 'h';
                     32:                                                break;
                     33:                                case 67:        arrow = 'l';
                     34:                                                break;
                     35:                                case 66:        arrow = 'j';
                     36:                                                break;
                     37:                                case 65:        arrow = 'k';
                     38:                                                break;
                     39:                        }
                     40:                }
                     41: 
                     42:                switch(arrow){
                     43:                        case 'h':       /* move left */
                     44:                                newcol = prevcol - 15;
                     45:                                if(newcol < 1)
                     46:                                        newcol = 61;
                     47:                        /* if the next entry position is empty, go back to
                     48:                         * first position in this row.
                     49:                         */
                     50:                                if(' ' == mvwinch(selwin,newrow,newcol))
                     51:                                        newcol = 1;
                     52:                                break;
                     53: 
                     54: 
                     55:                        case 'l':       /* move right */
                     56:                                newcol = prevcol + 15;
                     57:                                if(newcol > 61)
                     58:                                        newcol = 1;
                     59:                        /* if the next entry position is empty, go back to
                     60:                         * first position in this row.
                     61:                         */
                     62:                                if(' ' == mvwinch(selwin,newrow,newcol))
                     63:                                        newcol = 1;
                     64:                                break;
                     65: 
                     66: 
                     67:                        case 'j':       /* move down */
                     68:                                newrow = prevrow +1;
                     69:                        /* wrap to first row if we try to move down too far */
                     70:                                if (newrow == 20)
                     71:                                        newrow = 0;
                     72:                        /* if next position is empty, wrap */
                     73:                                if(' ' ==mvwinch(selwin,newrow,newcol))
                     74:                                        newrow = 0;
                     75:                                break;
                     76: 
                     77: 
                     78:                        case 'k':       /* move up */
                     79:                                newrow = prevrow -1;
                     80:                        /* wrap to last row if we try to move down too far */
                     81:                                if (newrow == -1)
                     82:                                        newrow = 19;
                     83:                        /* if next position is empty, wrap */
                     84:                                if(' ' ==mvwinch(selwin,newrow,newcol))
                     85:                                        newrow = 0;
                     86:                                break;
                     87: 
                     88:                        case 'q':
                     89:                                return(-1);
                     90:                                /* NO REACHED */
                     91:                        case 's':
                     92:                        case '\n':
                     93:                                return( ((prevrow * 5) + (prevcol/15)) );
                     94:                                /* NOT REACHED */
                     95:                }
                     96: 
                     97:        /* unhighlite previously highlighted entry (prevrow,prevcol) */
                     98:                lite(selwin,prevrow,prevcol,0);
                     99:                wrefresh(selwin);
                    100: 
                    101:        /* highlight newly indicated entry */
                    102:                lite(selwin,newrow, newcol,1);
                    103:                wrefresh(selwin);
                    104: 
                    105:        /* now set the old corrdinates to the current coordinates */
                    106:                prevrow = newrow;
                    107:                prevcol = newcol;
                    108: 
                    109:        }
                    110:        while(!retflag);
                    111: }

unix.superglobalmegacorp.com

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