From:	AITGW::"FILESERV@WKUVX1.BITNET" 16-MAR-1992 10:28:59.97
To:	ARISIA::EVERHART
CC:	
Subj:	LOOK.03_OF_04

Received: by AITGW.DECnet (utk-mail11 v1.5) ; Mon, 16 Mar 92 10:28:12 EST
Received: from ukcc.uky.edu by aitgw.ge.com (5.65/GE Gateway 1.5)
	id AA02463; Mon, 16 Mar 92 10:27:58 -0500
Message-Id: <9203161527.AA02463@aitgw.ge.com>
Received: from ukcc.uky.edu by UKCC.uky.edu (IBM VM SMTP V2R2)
   with BSMTP id 6878; Mon, 16 Mar 92 10:24:32 EST
Received: from UKCC by ukcc.uky.edu (Mailer R2.08) with BSMTP id 6633; Mon, 16
 Mar 92 10:24:30 EST
Received: from WKUVX1.BITNET by ukcc.uky.edu (Mailer R2.08) with BSMTP id 6632;
 Mon, 16 Mar 92 10:24:29 EST
Received: by WKUVX1.BITNET (MX V3.0A) id 16030; Mon, 16 Mar 1992 08:32:39 CST
Date: Mon, 16 Mar 1992 08:32:39 CST
From: FILESERV-Mgr@WKUVX1.BITNET
Reply-To: FILESERV@WKUVX1.BITNET
Subject: LOOK.03_OF_04
To: ARISIA::EVERHART
 
-+-+-+-+-+-+-+-+ START OF PART 3 -+-+-+-+-+-+-+-+
X`09`09CHECKRESULT(smg$return_cursor_pos(&vdisp.id,
X`09`09    &vdisp.cursor.row, &vdisp.cursor.col));
X`09`09for (findbeg = 1; findbeg <= vdisp.cursor.col;
X`09`09    findbeg += (vdisp.vport.len - 1))
X`09`09CHECKRESULT(smg$change_viewport(&vdisp.id,
X`09`09    &vdisp.vport.firstrow, &findbeg));
X`09`09vdisp.vport.curcol = vdisp.cursor.col -findbeg +vdisp.vport.len;
X`09`09findbeg = 0;
X`09`09no_line`5Bfound`5D = (char)any_key;
X`09`09no_line`5Bfound + linebuf`5BTOFIND`5D`5Bfbc`5BTOFIND`5D`5D.flen`5D = '
V\0';
X`09`09CHECKRESULT(smg$put_chars(&vdisp.id, outline(&no_line`5Bfound`5D),
X`09`09    &vdisp.cursor.row, &vdisp.cursor.col, &findbeg, &rend_find));
X`09`09CHECKRESULT(smg$end_display_update(&vdisp.id));
X`09`09return SS$_NORMAL;
X`09    `7D
X`09`7D
X`09cur_find = vf_inf.current + vdisp.cursor.row;
X`09if (((vf_inf.end != $_ABNORMAL) &&
X`09    ((int)(cur_find - vf_inf.end) >= vdisp.wid)) `7C`7C
X`09    ((vf_inf.end == 0) &&
X`09    (vdisp.cursor.row == vf_inf.all - 1)))
X`09`7B
X`09    vdisp.cursor.col--;
X`09    BEEP;
X`09    return SS$_NORMAL;
X`09`7D
X`09wn = 0;
X    `7D
X    else cur_find = rpt;
X
X    while (cur_find < vf_inf.all - 1)
X    `7B
X`09if ((vf_inf.end == $_ABNORMAL) && (cur_find + vdisp.wid >= vf_inf.all))
X`09`7B
X`09    rpt = cur_find;
X`09    return SS$_NORMAL;
X`09`7D
X`09FBEG(cur_find);
X`09switch(working())
X`09`7B
X`09case 0:
X`09    vdisp.cursor.col--;
X`09    return SS$_NORMAL;
X`09case $_ABNORMAL:
X`09    return $_ABNORMAL;
X`09`7D
X`09if (sh_fgets(no_line, MAXLINE, SS$_NORMAL) == -1) return $_ABNORMAL;
X        found = find_in_line();
X`09if (found != $_ABNORMAL) break;
X`09cur_find++;
X    `7D
X    rpt = 0;
X    if (found == $_ABNORMAL)
X    `7B
X        CHECKRESULT(smg$label_border(&vdisp.id,`20
X`09    outline(NOTHING_FOUND),
X`09    &vf_inf.inv.pos, &vf_inf.inv.beg, &vf_inf.inv.rend));
X`09BEEP;
X`09smg$read_keystroke(&k_id, &any_key);
X`09CHECKRESULT(smg$set_cursor_mode(&p_id, &c_on));
X`09vdisp.cursor.col--;   `20
X`09return SS$_NORMAL;
X    `7D
X    CHECKRESULT(smg$begin_display_update(&vdisp.id));
X    if (cur_find - vf_inf.current >= vdisp.wid)
X    `7B
X`09if ((vf_inf.end != $_ABNORMAL) && (cur_find > vf_inf.end))
X`09    vf_inf.current = vf_inf.end;
X`09else if (cur_find <= vdisp.wid/2)
X`09    vf_inf.current = 0;
X`09else vf_inf.current = cur_find - vdisp.wid/2;
X    `7D
X    CHECKRESULT(new_page());
X    vdisp.cursor.row = cur_find - vf_inf.current + 1;
X    vdisp.cursor.col = 1;
X    any_key = (unsigned short)no_line`5Bfound`5D;
X    no_line`5Bfound`5D = '\0';
X    CHECKRESULT(smg$set_cursor_mode(&p_id, &c_on));
X    CHECKRESULT(smg$put_chars(&vdisp.id, outline(no_line),
X`09&vdisp.cursor.row, &vdisp.cursor.col));
X    CHECKRESULT(smg$return_cursor_pos(&vdisp.id,
X`09&vdisp.cursor.row, &vdisp.cursor.col));
X    for (findbeg = 1; findbeg <= vdisp.cursor.col;
X`09findbeg += (vdisp.vport.len - 1))
X`09CHECKRESULT(smg$change_viewport(&vdisp.id,
X`09    &vdisp.vport.firstrow, &findbeg));
X    vdisp.vport.curcol = vdisp.cursor.col - findbeg + vdisp.vport.len;
X    findbeg = 0;
X    no_line`5Bfound`5D = (char)any_key;
X    no_line`5Bfound + linebuf`5BTOFIND`5D`5Bfbc`5BTOFIND`5D`5D.flen`5D = '\0
V';
X    CHECKRESULT(smg$put_chars(&vdisp.id, outline(&no_line`5Bfound`5D),
X`09&vdisp.cursor.row, &vdisp.cursor.col, &findbeg, &rend_find));
X    CHECKRESULT(smg$end_display_update(&vdisp.id));
X    return SS$_NORMAL;
X`7D
X
X`09/* Go to position by line or percentage */
X
Xint
Xgo_line()
X`7B
X    unsigned int ln = 0, p = 0;
X    char *pch = NULL;
X
X    ln = strtoul(linebuf`5BTOLINE`5D`5Bfbc`5BTOLINE`5D`5D.fline, &pch, 0);
X    vf_inf.current = 0;
X    if (pch == linebuf`5BTOLINE`5D`5Bfbc`5BTOLINE`5D`5D.fline) BEEP
X    else
X    `7B
X`09if (*pch == '%')
X`09`7B
X`09    p = (ln * sh_eof())/100;
X`09    if ((vf_inf.end == $_ABNORMAL) && (vf_inf.home`5Bvf_inf.all`5D < p))
X`09    `7B
X`09        rpt = $_ABNORMAL;
X`09        return SS$_NORMAL;
X`09    `7D
X`09    for (ln = 0; (ln < vf_inf.all) && (vf_inf.home`5Bln`5D < p); ln++);
X`09    ln++;
X`09`7D
X
X`09if (ln == 0)
X`09`7B
X`09    BEEP;
X`09    ln = 1;
X`09`7D
X
X`09if ((vf_inf.end == $_ABNORMAL) && (ln + vdisp.wid >= vf_inf.all))
X`09`7B
X`09    rpt = $_ABNORMAL;
X`09    return SS$_NORMAL;
X`09`7D
X
X`09CHECKRESULT(smg$set_cursor_mode(&p_id, &c_on));
X
X`09if (ln >= vf_inf.all)
X`09`7B
X`09    BEEP;
X`09    ln = vf_inf.all - 1;
X`09`7D
X
X`09if (ln <= vdisp.wid/2) vdisp.cursor.row = ln;
X`09else
X`09`7B
X`09    vf_inf.current = ln - vdisp.wid/2;
X`09    vdisp.cursor.row = vdisp.wid/2;
X`09    if ((vf_inf.end != $_ABNORMAL) && (vf_inf.current > vf_inf.end))
X`09    `7B
X`09        vdisp.cursor.row += (vf_inf.current - vf_inf.end);
X`09`09vf_inf.current = vf_inf.end;
X`09    `7D
X`09`7D
X`09CHECKRESULT(new_page());
X    `7D
X    rpt = 0;
X`7D
X
X`09/* Key processing */
X
Xint
Xkey_processing(unsigned short ch)
X`7B
X    unsigned int l = 0;
X
X`09switch(ch)
X`09`7B
X`09case 0:
X`09    return SS$_NORMAL;
X`09case UP:
X`09    if (vdisp.cursor.row == 1)
X`09    `7B
X`09`09if (vf_inf.current != 0)
X`09`09`7B
X`09`09    vf_inf.current--;
X`09`09    FBEG(vf_inf.current);
X`09`09    l = 1;
X`09`09    CHECKRESULT(smg$begin_display_update(&vdisp.id));
X`09`09    CHECKRESULT(smg$set_cursor_abs(&vdisp.id,`20
X`09`09`09&vdisp.cursor.row, &l));
X`09`09    outstr.dsc$w_length = MAXLINE;
X`09`09    outstr.dsc$a_pointer = no_line;
X`09`09    CHECKRESULT(smg$read_from_display(&vdisp.id, &outstr));
X`09`09    if (sh_fgets(line, MAXLINE, SS$_NORMAL) == -1)
X`09`09`09return $_ABNORMAL;
X`09`09    l = 0;
X`09`09    CHECKRESULT(smg$put_line(&vdisp.id, outline(line), &l));
X`09`09    l = 2;`09
X`09`09    CHECKRESULT(smg$insert_line(&vdisp.id, &l,`20
X`09`09`09outline(no_line), &pscroll));
X`09`09    CHECKRESULT(smg$end_display_update(&vdisp.id));
X`09`09`7D
X`09`09else BEEP;
X`09    `7D
X`09    else vdisp.cursor.row--;
X`09    return SS$_NORMAL;
X`09case DOWN:
X`09    if (vdisp.cursor.row == vdisp.wid)
X`09    `7B
X`09`09if ((vf_inf.end == $_ABNORMAL) &&
X`09`09    (vf_inf.current + vdisp.wid + 1 >= vf_inf.all))
X`09`09`7B
X`09`09    rpt = $_ABNORMAL;
X`09`09    return SS$_NORMAL;
X`09`09`7D
X`09`09if (vf_inf.current != vf_inf.end)
X`09`09`7B
X`09`09    l = 1;
X`09`09    FBEG(vf_inf.current + vdisp.wid);
X`09`09    CHECKRESULT(smg$begin_display_update(&vdisp.id));
X`09`09    CHECKRESULT(smg$set_cursor_abs(&vdisp.id,`20
X`09`09`09&vdisp.cursor.row, &l));
X`09`09    outstr.dsc$w_length = MAXLINE;
X`09`09    outstr.dsc$a_pointer = no_line;
X`09`09    CHECKRESULT(smg$read_from_display(&vdisp.id, &outstr));
X`09`09    if (sh_fgets(line, MAXLINE, SS$_NORMAL) == -1)
X`09`09`09return $_ABNORMAL;
X`09`09    l = 0;
X`09`09    CHECKRESULT(smg$put_line(&vdisp.id, outline(line), &l));
X`09`09    l = vdisp.wid - 1;
X`09`09    CHECKRESULT(smg$insert_line(&vdisp.id, &l,
X`09`09`09outline(no_line)));
X`09`09    vf_inf.current++;
X`09`09    CHECKRESULT(smg$end_display_update(&vdisp.id));
X`09`09`7D
X`09`09else BEEP;
X`09    `7D
X`09    else vdisp.cursor.row++;
X`09    rpt = 0;
X`09    return SS$_NORMAL;
X`09case LEFT:
X`09    if (vdisp.cursor.col > 1)
X`09    `7B
X`09`09if (vdisp.vport.curcol > 1) vdisp.vport.curcol--;
X`09`09else CHECKRESULT(smg$scroll_viewport(&vdisp.id, &scrright));
X`09`09vdisp.cursor.col--;
X`09    `7D
X`09    else BEEP;
X`09    return SS$_NORMAL;
X`09case RIGHT:
X`09    if (vdisp.cursor.col < vdisp.len)
X`09    `7B
X`09`09if (vdisp.vport.curcol < vdisp.vport.len) vdisp.vport.curcol++;
X`09`09else CHECKRESULT(smg$scroll_viewport(&vdisp.id, &scrleft));
X`09`09vdisp.cursor.col++;
X`09    `7D
X`09    else BEEP;
X`09    return SS$_NORMAL;
X`09case 'L':
X`09case 'l':
X`09    if (vdisp.vport.curcol > 1)
X`09    `7B
X`09`09vdisp.cursor.col -= (vdisp.vport.curcol - 1);
X`09`09vdisp.vport.curcol = 1;
X`09    `7D
X`09    else if (vdisp.cursor.col > vdisp.vport.len)
X`09    `7B
X`09`09l = vdisp.vport.len - 1;
X`09        CHECKRESULT(smg$scroll_viewport(&vdisp.id,
X`09`09    &scrright, &l));
X`09`09vdisp.cursor.col -= (vdisp.vport.len - 1);
X`09    `7D
X`09    else if (vdisp.cursor.col > 1)
X`09    `7B
X`09`09CHECKRESULT(smg$change_viewport(&vdisp.id,
X`09`09    &vdisp.vport.firstrow, &vdisp.vport.firstcol));
X`09`09vdisp.cursor.col = 1;
X`09    `7D`09
X`09    else BEEP;
X`09    return SS$_NORMAL;
X`09case 'R':
X`09case 'r':
X`09    if (vdisp.vport.curcol < vdisp.vport.len)
X`09    `7B
X`09`09vdisp.cursor.col += (vdisp.vport.len - vdisp.vport.curcol);
X`09`09vdisp.vport.curcol = vdisp.vport.len;
X`09    `7D
X`09    else if (vdisp.cursor.col < (vdisp.len - 2 * vdisp.vport.len))
X`09    `7B
X`09`09l = vdisp.vport.len - 1;
X`09        CHECKRESULT(smg$scroll_viewport(&vdisp.id,`20
X`09`09    &scrleft, &l));
X`09`09vdisp.cursor.col += (vdisp.vport.len - 1);
X`09    `7D
X`09    else if(vdisp.cursor.col < vdisp.len)
X`09    `7B
X`09`09l = vdisp.len - vdisp.vport.len + 1;
X`09`09CHECKRESULT(smg$change_viewport(&vdisp.id,
X`09`09    &vdisp.vport.firstrow, &l));
X`09`09vdisp.cursor.col = vdisp.len;
X`09    `7D`09
X`09    else BEEP;
X`09    return SS$_NORMAL;
X`09case PREV:
X`09    if (vf_inf.current == 0) BEEP
X`09    else
X`09    `7B
X`09`09if (vf_inf.current >= vdisp.wid)
X`09`09    vf_inf.current -= (vdisp.wid - 1);
X`09`09else vf_inf.current = 0;
X`09`09CHECKRESULT(new_page());
X`09    `7D
X`09    return SS$_NORMAL;
X`09case NEXT:
X`09    if ((vf_inf.end == $_ABNORMAL) &&
X`09        (vf_inf.current + 2*vdisp.wid >= vf_inf.all))
X`09`09`7B
X`09`09    wn = WORKING_STEP;
X`09`09    rpt = $_ABNORMAL;
X`09`09    return SS$_NORMAL;
X`09`09`7D
X`09    if (vf_inf.current != vf_inf.end)
X`09    `7B
X`09`09if ((vf_inf.end == $_ABNORMAL) `7C`7C
X`09`09    (vf_inf.end - vf_inf.current >= vdisp.wid))
X`09`09    vf_inf.current += (vdisp.wid - 1);
X`09`09else vf_inf.current = vf_inf.end;
X`09`09CHECKRESULT(new_page());
X`09    `7D
X`09    else BEEP;
X`09    rpt = 0;
X`09    return SS$_NORMAL;
X`09case 'H':
X`09case 'h':
X`09    if ((vf_inf.current == 0) &&
X`09`09(vdisp.vport.curcol == 1) &&
X`09`09(vdisp.cursor.row == 1) &&
X`09`09(vdisp.cursor.col == 1)) BEEP
X`09    else
X`09    `7B`09
X`09`09vdisp.vport.curcol = 1;
X`09`09vdisp.cursor.row = vdisp.cursor.col = 1;
X`09`09CHECKRESULT(smg$begin_display_update(&vdisp.id));
X`09`09if (vf_inf.current != 0)
X`09`09`7B
X`09`09    vf_inf.current = 0;
X`09`09    CHECKRESULT(new_page());
X`09`09`7D
X`09`09CHECKRESULT(smg$change_viewport(&vdisp.id,
X`09`09    &vdisp.vport.firstrow, &vdisp.vport.firstcol));
X`09`09CHECKRESULT(smg$end_display_update(&vdisp.id));
X`09    `7D
X`09    return SS$_NORMAL;
X`09case 'E':
X`09case 'e':
X`09    if (vf_inf.end == $_ABNORMAL)
X`09    `7B
X`09        rpt = $_ABNORMAL;
X`09        return SS$_NORMAL;
X`09    `7D
X`09    if ((vf_inf.current == vf_inf.end) &&
X`09`09(vdisp.vport.curcol == 1) &&
X`09`09(vdisp.cursor.col == 1) &&
X`09`09(vdisp.cursor.row == vdisp.wid)) BEEP
X`09    else
X`09    `7B`09
X`09`09vdisp.vport.curcol = 1;
X`09`09vdisp.cursor.row = vdisp.wid;
X`09`09vdisp.cursor.col = 1;
X`09`09CHECKRESULT(smg$begin_display_update(&vdisp.id));
X`09`09if (vf_inf.current != vf_inf.end)
X`09`09`7B
X`09`09    vf_inf.current = vf_inf.end;
X`09`09    CHECKRESULT(new_page());
X`09`09`7D
X`09`09CHECKRESULT(smg$change_viewport(&vdisp.id,
X`09`09    &vdisp.vport.firstrow, &vdisp.vport.firstcol));
X`09`09CHECKRESULT(smg$end_display_update(&vdisp.id));
X`09    `7D
X`09    CHECKRESULT(smg$set_cursor_mode(&p_id, &c_on));
X`09    rpt = 0;
X`09    return SS$_NORMAL;
X`09case FIND:
X`09case 'F':
X`09case 'f':
X`09    if (rpt == 0) CHECKRESULT(get_line(TOFIND));
X`09case 'N':
X`09case 'n':
X`09    if (linebuf`5BTOFIND`5D`5Bfbc`5BTOFIND`5D`5D.flen != 0)`09return next
Vfind();
X`09    else BEEP;
X`09    return SS$_NORMAL;
X`09case 'G':
X`09case 'g':
X`09    if (rpt == 0) CHECKRESULT(get_line(TOLINE));
X`09    if (linebuf`5BTOLINE`5D`5Bfbc`5BTOLINE`5D`5D.flen != 0) return go_lin
Ve();
X`09    else BEEP;
X`09    return SS$_NORMAL;
X`09case 'W':
X`09case 'w':
X`09    screensize = (screensize == SCREENMAX) ? SCREENMIN : SCREENMAX;
X`09    CHECKRESULT(smg$unpaste_virtual_display(&vdisp.id, &p_id));
X`09    CHECKRESULT(smg$change_pbd_characteristics(&p_id,
X`09        &screensize, &l));
X`09    if (screensize == l)
X`09    `7B
X`09        vdisp.vport.len = screensize - BORDERFIELD;
X`09`09l = vdisp.cursor.col - vdisp.vport.curcol + 1;
X`09`09if (l > (vdisp.len - vdisp.vport.len + 1))
X`09`09    l = vdisp.len - vdisp.vport.len + 1;
X`09`09CHECKRESULT(smg$change_viewport(&vdisp.id, 0, &l,
X`09`09    &vdisp.wid, &vdisp.vport.len));
X`09`09if (vdisp.vport.curcol > vdisp.vport.len)
X`09`09`7B
X`09`09    vdisp.cursor.col -= (vdisp.vport.curcol - vdisp.vport.len);
X`09`09    vdisp.vport.curcol = vdisp.vport.len;
X`09`09`7D
X`09`09else vdisp.vport.curcol = vdisp.cursor.col - l + 1;
X`09    `7D
X`09    else BEEP;
X`09    CHECKRESULT(smg$paste_virtual_display(&vdisp.id, &p_id,
X`09        &vdisp.firstrow, &vdisp.firstcol));
X`09    return SS$_NORMAL;
X`09case 'D':
X`09case 'd':
X`09    CHECKRESULT(smg$label_border(&vdisp.id, outline(PLEASE_WAIT),
X`09`09&vf_inf.inv.pos, &vf_inf.inv.beg, &vf_inf.inv.rend));
X`09    memset(no_line, 'A', (size_t)SCREENMAX);
X`09    no_line`5BSCREENMAX`5D = '\0';
X`09    if (lib$sys_trnlog(&elnm, &lnmlen, outline(no_line))
X`09`09!= SS$_NORMAL) strcpy(no_line, EDITCOMMAND);
X`09    sprintf(line, no_line,
X`09`09vdisp.f_spec, vf_inf.current + vdisp.cursor.row);
X`09    return (lib$spawn(outline(line)) == SS$_NORMAL)
X`09`09? EXIT_NORMAL : RELOOK;
X`09case 'P':
X`09case 'p':
X`09case hELP:
X`09    memset(line, 'A', (size_t)SCREENMAX);
X`09    line`5BSCREENMAX`5D = '\0';
X`09    if (lib$sys_trnlog(&hlnm, &lnmlen, outline(line))
X`09`09!= SS$_NORMAL) strcpy(line, HELPCOMMAND);
X`09case 'S':
X`09case 's':
X`09    CHECKRESULT(smg$label_border(&vdisp.id, outline(PLEASE_WAIT),
X`09`09&vf_inf.inv.pos, &vf_inf.inv.beg, &vf_inf.inv.rend));
X`09    CHECKRESULT(smg$set_physical_cursor(&p_id, &k_bar.firstrow,
X`09`09&k_bar.firstcol));
X`09    if ((ch == 'S') `7C`7C (ch == 's'))
X`09`09CHECKRESULT(lib$spawn(0))
X`09    else CHECKRESULT(lib$spawn(outline(line)))
X`09case REFRESH:
X`09    CHECKRESULT(smg$unpaste_virtual_display(&vdisp.id, &p_id));
X`09    CHECKRESULT(smg$unpaste_virtual_display(&k_bar.id, &p_id));
+-+-+-+-+-+-+-+-  END  OF PART 3 +-+-+-+-+-+-+-+-
