1995-02-05 13:49:25 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1992, 1993, 1994 by Hellmuth Michaelis
|
|
|
|
*
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by Hellmuth Michaelis.
|
1995-05-30 03:57:47 +00:00
|
|
|
* 4. The name of the developer may not be used to endorse or promote
|
1995-02-05 13:49:25 +00:00
|
|
|
* products derived from this software without specific prior written
|
|
|
|
* permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPER ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
1995-05-30 03:57:47 +00:00
|
|
|
* select.c, 3.00, last edit-date: [Sun Jan 2 20:09:36 1994]
|
1995-02-05 13:49:25 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* select.c font editor select character
|
|
|
|
* ----------------------------------------------------
|
|
|
|
*
|
|
|
|
* written by Hellmuth Michaelis, hm@hcshh.hcs.de
|
|
|
|
*
|
|
|
|
* -hm first public release
|
|
|
|
* -hm debugging
|
|
|
|
*
|
|
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
#include "fed.h"
|
|
|
|
|
|
|
|
int sc, sr, scurchar;
|
|
|
|
|
|
|
|
int edit();
|
|
|
|
|
|
|
|
void sel_mode(void)
|
|
|
|
{
|
|
|
|
mvwprintw(cmd_win,1,1,"(E)dit ");
|
|
|
|
mvwprintw(cmd_win,2,1,"(M)ove ");
|
|
|
|
mvwprintw(cmd_win,3,1,"exchan(G)e ");
|
|
|
|
mvwprintw(cmd_win,4,1,"(Q)uit/Save ");
|
|
|
|
mvwprintw(cmd_win,5,1,"e(X)it/Undo ");
|
|
|
|
mvwprintw(cmd_win,6,1," ");
|
|
|
|
mvwprintw(cmd_win,7,1," ");
|
|
|
|
mvwprintw(cmd_win,8,1," ");
|
|
|
|
|
|
|
|
mvwprintw(cmd_win,9 ,1," ");
|
|
|
|
mvwprintw(cmd_win,10,1," ");
|
|
|
|
mvwprintw(cmd_win,11,1," ");
|
|
|
|
mvwprintw(cmd_win,12,1," ");
|
|
|
|
mvwprintw(cmd_win,13,1,"(^P)rev Line");
|
|
|
|
mvwprintw(cmd_win,14,1,"(^N)ext Line");
|
|
|
|
mvwprintw(cmd_win,15,1,"(^F)orwd Col");
|
|
|
|
mvwprintw(cmd_win,16,1,"(^B)ack Col");
|
|
|
|
wrefresh(cmd_win);
|
|
|
|
}
|
|
|
|
|
|
|
|
int selectc()
|
|
|
|
{
|
|
|
|
int c, r;
|
|
|
|
int ret;
|
|
|
|
char h, l;
|
|
|
|
unsigned int k_ch;
|
1995-05-30 03:57:47 +00:00
|
|
|
|
1995-02-05 13:49:25 +00:00
|
|
|
c = (curchar / 16);
|
|
|
|
r = (curchar % 16);
|
|
|
|
|
|
|
|
for(;;)
|
|
|
|
{
|
|
|
|
dis_cmd(" Select Character");
|
1995-05-30 03:57:47 +00:00
|
|
|
|
1995-02-05 13:49:25 +00:00
|
|
|
sel_mode();
|
|
|
|
|
|
|
|
curchar = r + (c*16);
|
|
|
|
|
|
|
|
display(curchar);
|
|
|
|
|
|
|
|
h = ((mvwinch(set_win,(r+1),((c*2)+1))) & A_CHARTEXT);
|
|
|
|
l = ((mvwinch(set_win,(r+1),((c*2)+2))) & A_CHARTEXT);
|
|
|
|
wattron(set_win,A_REVERSE);
|
|
|
|
mvwprintw(set_win,(r+1),((c*2)+1),"%c%c",h,l);
|
1995-05-30 03:57:47 +00:00
|
|
|
wattroff(set_win,A_REVERSE);
|
1995-02-05 13:49:25 +00:00
|
|
|
wmove(set_win,(r+1),((c*2)+1));
|
|
|
|
wrefresh(set_win);
|
1995-05-30 03:57:47 +00:00
|
|
|
|
1995-02-05 13:49:25 +00:00
|
|
|
k_ch = wgetch(set_win);
|
1995-05-30 03:57:47 +00:00
|
|
|
|
1995-02-05 13:49:25 +00:00
|
|
|
switch(k_ch)
|
|
|
|
{
|
|
|
|
case K_LEFT:
|
|
|
|
case KEY_LEFT:
|
|
|
|
if(c > 0)
|
|
|
|
{
|
|
|
|
normal_set(r,c);
|
|
|
|
c--;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case K_DOWN:
|
|
|
|
case KEY_DOWN:
|
|
|
|
if(r < 15)
|
|
|
|
{
|
|
|
|
normal_set(r,c);
|
|
|
|
r++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case K_UP:
|
|
|
|
case KEY_UP:
|
|
|
|
if(r > 0)
|
|
|
|
{
|
|
|
|
normal_set(r,c);
|
|
|
|
r--;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case K_RIGHT:
|
|
|
|
case KEY_RIGHT:
|
|
|
|
if(c < 15)
|
|
|
|
{
|
|
|
|
normal_set(r,c);
|
|
|
|
c++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'e':
|
1995-05-30 03:57:47 +00:00
|
|
|
case 'E':
|
1995-02-05 13:49:25 +00:00
|
|
|
edit_mode();
|
|
|
|
dis_cmd(" Edit Character");
|
|
|
|
display(curchar);
|
|
|
|
ret = edit();
|
|
|
|
if(ret == 1)
|
|
|
|
save_ch();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'g':
|
|
|
|
case 'G':
|
|
|
|
dis_cmd(" Exchange: select Destination, then press RETURN or any other Key to ABORT");
|
|
|
|
sr = r;
|
|
|
|
sc = c;
|
|
|
|
scurchar = curchar;
|
|
|
|
if((curchar = sel_dest()) == -1)
|
|
|
|
{ /* failsafe */
|
|
|
|
r = sr;
|
|
|
|
c = sc;
|
|
|
|
curchar = scurchar;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ /* valid return */
|
|
|
|
normal_set(r,c);
|
|
|
|
c = (curchar / 16);
|
|
|
|
r = (curchar % 16);
|
|
|
|
xchg_ch(scurchar,curchar);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'm':
|
|
|
|
case 'M':
|
|
|
|
dis_cmd(" Move: select Destination, then press RETURN or any other Key to ABORT");
|
|
|
|
sr = r;
|
|
|
|
sc = c;
|
|
|
|
scurchar = curchar;
|
|
|
|
if((curchar = sel_dest()) == -1)
|
|
|
|
{ /* failsafe */
|
|
|
|
r = sr;
|
|
|
|
c = sc;
|
|
|
|
curchar = scurchar;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ /* valid return */
|
|
|
|
normal_set(r,c);
|
|
|
|
c = (curchar / 16);
|
|
|
|
r = (curchar % 16);
|
|
|
|
move_ch(scurchar,curchar);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'q':
|
|
|
|
case 'Q':
|
|
|
|
normal_set(r,c);
|
1995-05-30 03:57:47 +00:00
|
|
|
wrefresh(set_win);
|
1995-02-05 13:49:25 +00:00
|
|
|
return(1);
|
|
|
|
break;
|
1995-05-30 03:57:47 +00:00
|
|
|
|
1995-02-05 13:49:25 +00:00
|
|
|
case 'x':
|
|
|
|
case 'X':
|
|
|
|
normal_set(r,c);
|
1995-05-30 03:57:47 +00:00
|
|
|
wrefresh(set_win);
|
1995-02-05 13:49:25 +00:00
|
|
|
return(0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x0c:
|
|
|
|
wrefresh(curscr);
|
|
|
|
break;
|
1995-05-30 03:57:47 +00:00
|
|
|
|
1995-02-05 13:49:25 +00:00
|
|
|
default:
|
|
|
|
beep();
|
|
|
|
break;
|
1995-05-30 03:57:47 +00:00
|
|
|
|
1995-02-05 13:49:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void normal_set(int r, int c)
|
|
|
|
{
|
|
|
|
char h, l;
|
1995-05-30 03:57:47 +00:00
|
|
|
|
1995-02-05 13:49:25 +00:00
|
|
|
h = ((mvwinch(set_win,(r+1),((c*2)+1))) & A_CHARTEXT);
|
|
|
|
l = ((mvwinch(set_win,(r+1),((c*2)+2))) & A_CHARTEXT);
|
|
|
|
wattroff(set_win,A_REVERSE);
|
|
|
|
mvwprintw(set_win,(r+1),((c*2)+1),"%c%c",h,l);
|
|
|
|
wmove(set_win,(r+1),((c*2)+1));
|
|
|
|
}
|
|
|
|
|
|
|
|
int sel_dest(void)
|
|
|
|
{
|
|
|
|
int c, r;
|
|
|
|
char h, l;
|
|
|
|
unsigned int k_ch;
|
1995-05-30 03:57:47 +00:00
|
|
|
|
1995-02-05 13:49:25 +00:00
|
|
|
c = (curchar / 16);
|
|
|
|
r = (curchar % 16);
|
|
|
|
|
|
|
|
for(;;)
|
|
|
|
{
|
|
|
|
|
|
|
|
curchar = r + (c*16);
|
1995-05-30 03:57:47 +00:00
|
|
|
|
1995-02-05 13:49:25 +00:00
|
|
|
display(curchar);
|
1995-05-30 03:57:47 +00:00
|
|
|
|
1995-02-05 13:49:25 +00:00
|
|
|
h = ((mvwinch(set_win,(r+1),((c*2)+1))) & A_CHARTEXT);
|
|
|
|
l = ((mvwinch(set_win,(r+1),((c*2)+2))) & A_CHARTEXT);
|
|
|
|
wattron(set_win,A_UNDERLINE);
|
|
|
|
mvwprintw(set_win,(r+1),((c*2)+1),"%c%c",h,l);
|
1995-05-30 03:57:47 +00:00
|
|
|
wattroff(set_win,A_UNDERLINE);
|
1995-02-05 13:49:25 +00:00
|
|
|
wmove(set_win,(r+1),((c*2)+1));
|
|
|
|
wrefresh(set_win);
|
|
|
|
|
|
|
|
k_ch = wgetch(set_win);
|
1995-05-30 03:57:47 +00:00
|
|
|
|
1995-02-05 13:49:25 +00:00
|
|
|
switch(k_ch)
|
|
|
|
{
|
|
|
|
case K_LEFT:
|
|
|
|
case KEY_LEFT:
|
|
|
|
if(c > 0)
|
|
|
|
{
|
|
|
|
normal_uset(r,c);
|
|
|
|
c--;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case K_DOWN:
|
|
|
|
case KEY_DOWN:
|
|
|
|
if(r < 15)
|
|
|
|
{
|
|
|
|
normal_uset(r,c);
|
|
|
|
r++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case K_UP:
|
|
|
|
case KEY_UP:
|
|
|
|
if(r > 0)
|
|
|
|
{
|
|
|
|
normal_uset(r,c);
|
|
|
|
r--;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case K_RIGHT:
|
|
|
|
case KEY_RIGHT:
|
|
|
|
if(c < 15)
|
|
|
|
{
|
|
|
|
normal_uset(r,c);
|
|
|
|
c++;
|
|
|
|
}
|
|
|
|
break;
|
1995-05-30 03:57:47 +00:00
|
|
|
|
1995-02-05 13:49:25 +00:00
|
|
|
case '\r':
|
|
|
|
case '\n':
|
|
|
|
normal_uset(r,c);
|
|
|
|
return(r + (c*16));
|
|
|
|
|
|
|
|
case 0x0c:
|
|
|
|
wrefresh(curscr);
|
|
|
|
break;
|
1995-05-30 03:57:47 +00:00
|
|
|
|
1995-02-05 13:49:25 +00:00
|
|
|
default:
|
1995-05-30 03:57:47 +00:00
|
|
|
normal_uset(r,c);
|
1995-02-05 13:49:25 +00:00
|
|
|
return(-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void normal_uset(int r, int c)
|
|
|
|
{
|
|
|
|
char h, l;
|
|
|
|
|
|
|
|
h = ((mvwinch(set_win,(r+1),((c*2)+1))) & A_CHARTEXT);
|
|
|
|
l = ((mvwinch(set_win,(r+1),((c*2)+2))) & A_CHARTEXT);
|
1995-05-30 03:57:47 +00:00
|
|
|
|
1995-02-05 13:49:25 +00:00
|
|
|
wattroff(set_win,A_UNDERLINE);
|
|
|
|
mvwprintw(set_win,(r+1),((c*2)+1),"%c%c",h,l);
|
|
|
|
wmove(set_win,(r+1),((c*2)+1));
|
|
|
|
|
|
|
|
if((r==sr) && (c==sc))
|
|
|
|
{
|
|
|
|
wattron(set_win,A_REVERSE);
|
|
|
|
mvwprintw(set_win,(r+1),((c*2)+1),"%c%c",h,l);
|
1995-05-30 03:57:47 +00:00
|
|
|
wattroff(set_win,A_REVERSE);
|
1995-02-05 13:49:25 +00:00
|
|
|
wmove(set_win,(r+1),((c*2)+1));
|
1995-05-30 03:57:47 +00:00
|
|
|
}
|
1995-02-05 13:49:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------- E O F ----------------------------------*/
|