Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic xterm emulation #201

Draft
wants to merge 20 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions kermit/k95/cknwin.c
Original file line number Diff line number Diff line change
Expand Up @@ -1572,6 +1572,10 @@ gui_win_run_mode(int x)
return(1);
}

int gui_get_win_run_mode() {
return KuiGetTerminalRunMode();
}

int
gui_file_dialog(char * preface, char * prompt, int fc,
char * def, char * result, int rlength)
Expand Down
215 changes: 162 additions & 53 deletions kermit/k95/ckoco3.c

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion kermit/k95/ckocon.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,9 @@ typedef struct cell_struct { /* to be used with VioWrtNCell() */
#else /* CKOUNI_OUT */
unsigned char c ; /* character */
#endif /* CKOUNI_OUT */
unsigned char a ; /* attribute */
unsigned char a ; /* attribute (foreground & background
* color) - see comment further up by
* swapcolors and byteswapcolors */
} viocell ;

typedef struct videoline_struct {
Expand Down
6 changes: 6 additions & 0 deletions kermit/k95/ckokey.c
Original file line number Diff line number Diff line change
Expand Up @@ -7696,6 +7696,8 @@ defaultkeymap( int terminal ) {
return defvt100km(terminal);
case TT_BEOS:
return defbetermkm( terminal );
case TT_XTERM: /* TODO: What should the default xterm keymap be? */
return defvtpckm( terminal );
case TT_LINUX:
return deflinuxkm( terminal );
case TT_SCOANSI:
Expand All @@ -7708,10 +7710,14 @@ defaultkeymap( int terminal ) {
return defannarbor( terminal );
case TT_VT220:
case TT_VT320:
case TT_VT420:
case TT_VT520:
case TT_WY370:
return defvt200km( terminal );
case TT_VT220PC:
case TT_VT320PC:
case TT_VT420PC:
case TT_VT520PC:
return defvtpckm( terminal );
case TT_97801:
return defsnikm( terminal );
Expand Down
1 change: 1 addition & 0 deletions kermit/k95/ckuus3.c
Original file line number Diff line number Diff line change
Expand Up @@ -2639,6 +2639,7 @@ _PROTOTYP(int gui_mtxt_dialog,(char *,int,struct txtbox []));
_PROTOTYP(int gui_position,(int, int));
_PROTOTYP(int gui_resize_mode,(int));
_PROTOTYP(int gui_win_run_mode,(int));
_PROTOTYP(int gui_get_win_run_mode,());
_PROTOTYP(int gui_file_dialog,(char *,char *, int, char *, char *, int));
extern int gui_dialog;
#endif /* KUI */
Expand Down
11 changes: 10 additions & 1 deletion kermit/k95/ckuus5.c
Original file line number Diff line number Diff line change
Expand Up @@ -5370,6 +5370,12 @@ struct keytab shokeymtab[] = {
"vt220pc", TT_VT220PC, 0,
"vt320", TT_VT320, 0,
"vt320pc", TT_VT320PC, 0,
#ifdef CK_VT420_520_EMULATION
"vt420", TT_VT420, 0,
"vt420pc", TT_VT420PC, 0,
"vt520", TT_VT520, 0,
"vt520pc", TT_VT520PC, 0 ,
#endif /* CK_VT420_520_EMULATION */
"vt52", TT_VT52, 0,
"wp", TT_KBM_WP, 0,
"wy160", TT_WY160, 0,
Expand All @@ -5380,7 +5386,10 @@ struct keytab shokeymtab[] = {
"wyse30", TT_WY30, CM_INV,
"wyse370", TT_WY370, CM_INV,
"wyse50", TT_WY50, CM_INV,
"wyse60", TT_WY60, CM_INV
"wyse60", TT_WY60, CM_INV,
#ifdef CK_XTERM_EMULATION
"xterm", TT_XTERM, 0
#endif
};
int nshokeym = (sizeof(shokeymtab) / sizeof(struct keytab));
#endif /* OS2 */
Expand Down
22 changes: 20 additions & 2 deletions kermit/k95/ckuus7.c
Original file line number Diff line number Diff line change
Expand Up @@ -1602,6 +1602,12 @@ struct keytab ttyptab[] = {
{ "vt220pc", TT_VT220PC,0 },
{ "vt320", TT_VT320, 0 },
{ "vt320pc", TT_VT320PC,0 },
#ifdef CK_VT420_520_EMULATION
{ "vt420", TT_VT420, 0 },
{ "vt420pc", TT_VT420PC, 0 },
{ "vt520", TT_VT520, 0 },
{ "vt520pc", TT_VT520PC, 0 },
#endif /* CK_VT420_520_EMULATION */
{ "vt52", TT_VT52, 0 },
#ifdef NT
{ "vtnt", TT_VTNT, 0 },
Expand All @@ -1616,7 +1622,10 @@ struct keytab ttyptab[] = {
{ "wyse30", TT_WY30, CM_INV },
{ "wyse370", TT_WY370, CM_INV },
{ "wyse50", TT_WY50, CM_INV },
{ "wyse60", TT_WY60, CM_INV }
{ "wyse60", TT_WY60, CM_INV },
#ifdef CK_XTERM_EMULATION
{ "xterm", TT_XTERM, 0 }
#endif
};
int nttyp = (sizeof(ttyptab) / sizeof(struct keytab));

Expand Down Expand Up @@ -1673,6 +1682,12 @@ struct keytab ttkeytab[] = {
{ "vt220pc", TT_VT220PC, 0 },
{ "vt320", TT_VT320, 0 },
{ "vt320pc", TT_VT320PC, 0 },
#ifdef CK_VT420_520_EMULATION
{ "vt420", TT_VT420, 0 },
{ "vt420pc", TT_VT420PC, 0 },
{ "vt520", TT_VT520, 0 },
{ "vt520pc", TT_VT520PC, 0 },
#endif /* CK_VT420_520_EMULATION */
{ "vt52", TT_VT52, 0 },
{ "vtnt", TT_VTNT, CM_INV },
{ "wp", TT_KBM_WP, 0 }, /* Word Perfect mode */
Expand All @@ -1684,7 +1699,10 @@ struct keytab ttkeytab[] = {
{ "wyse30", TT_WY30, CM_INV },
{ "wyse370", TT_WY370, CM_INV },
{ "wyse50", TT_WY50, CM_INV },
{ "wyse60", TT_WY60, CM_INV }
{ "wyse60", TT_WY60, CM_INV },
#ifdef CK_XTERM_EMULATION
{ "xterm", TT_XTERM, 0 }
#endif
};
int nttkey = (sizeof(ttkeytab) / sizeof(struct keytab));

Expand Down
61 changes: 47 additions & 14 deletions kermit/k95/ckuusr.h
Original file line number Diff line number Diff line change
Expand Up @@ -1056,16 +1056,49 @@ struct stringint { /* String and (wide) integer */
#define TT_WY370 33 /* WYSE 370 ANSI Terminal */
#define TT_97801 34 /* Sinix 97801-5xx terminal */
#define TT_AAA 35 /* Ann Arbor Ambassador */
#define TT_TVI910 36 /* TVI 910+ */
#define TT_TVI925 37 /* TVI 925 */
#define TT_TVI950 38 /* TVI950 */
#define TT_ADM3A 39 /* LSI ADM 3A */
#define TT_ADM5 40 /* LSI ADM 5 */
#define TT_VTNT 41 /* Microsoft NT Virtual Terminal */

#define TT_VT420 36 /* DEC VT-420 */
#define TT_VT420PC 37 /* DEC VT-420 with PC keyboard */
#define TT_VT520 38 /* DEC VT-520/525 */
#define TT_VT520PC 39 /* DEC VT-520/525 with PC keyboard */

#define TT_TVI910 40 /* TVI 910+ */
#define TT_TVI925 41 /* TVI 925 */
#define TT_TVI950 42 /* TVI950 */
#define TT_ADM3A 43 /* LSI ADM 3A */
#define TT_ADM5 44 /* LSI ADM 5 */
#define TT_VTNT 45 /* Microsoft NT Virtual Terminal */

#ifdef CK_XTERM_EMULATION
#define TT_XTERM 46 /* xterm! */
#else
#define TT_XTERM 97 /* xterm! */
#endif

/* TODO: Graphics!
* -> This would be Windows/KUI only - no way of supporting it in
* the console or OS/2 versions
* -> Need to figure out how to implement graphics at all
* -> How do we represent graphics in the screen buffer?
* -> How do we render and scroll text + graphics?
* -> Sixel is the priority and probably the easiest. The rest are rarely used.
* -> The following graphics terminals require:
* VT125: ReGIS
* VT241: All of the above plus Sixel (VT240: no colour)
* VT340: All of the above plus Tektronix 4010 graphics (VT330: no colour)
* TEK40: 4010, 4014 emulation. If 4010 gets implemented for VT340 emulation
* we may as well go all the way and provide Tektronix emulation directly too.
* VT55, VT105: waveform graphics
* XTerm: Sixel, ReGIS, Tektronix 4015
*/

#ifdef CK_XTERM_EMULATION
#define TT_MAX TT_XTERM
#else
#define TT_MAX TT_VTNT
#define TT_VT420 96 /* DEC VT-420 */
#define TT_VT520 97 /* DEC VT-520/525 */
#define TT_XTERM 98 /* XTerm */
#endif /* CK_XTERM_EMULATION */

#define TT_IBM3101 98 /* IBM 3101 - not implemented */
#define TT_TEK40 99 /* Tektronix 401x */
#define TT_KBM_EMACS TT_MAX+1
#define TT_KBM_HEBREW TT_MAX+2
Expand Down Expand Up @@ -1093,10 +1126,11 @@ struct stringint { /* String and (wide) integer */
#define ISTVI910(x) (x == TT_TVI910)
#define ISTVI925(x) (x == TT_TVI925)
#define ISTVI950(x) (x == TT_TVI950)
#define ISXTERM(x) (x == TT_XTERM)
#define ISVT52(x) (x == TT_VT52 || x == TT_H19)
#ifdef COMMENT
#define ISVT520(x) (x == TT_VT520)
#define ISVT420(x) (x >= TT_VT420 && x <= TT_VT520)
#ifdef CK_VT420_520_EMULATION
#define ISVT520(x) (x == TT_VT520 || x == TT_VT520PC)
#define ISVT420(x) (x >= TT_VT420 && x <= TT_VT520PC)
#else /* COMMENT */
/* Since we do not yet support 420/520 extend 320 */
#define ISVT520(x) (ISVT320(x))
Expand All @@ -1105,7 +1139,7 @@ struct stringint { /* String and (wide) integer */
#define ISVT320(x) (x >= TT_VT320 && x <= TT_AAA)
#define ISVT220(x) (x >= TT_VT220 && x <= TT_AAA || \
ISBEOS(x) || ISQANSI(x) || \
ISLINUX(x) || ISSUN(x))
ISLINUX(x) || ISSUN(x) || ISXTERM(x))
#define ISVT102(x) (x >= TT_VIP7809 && x <= TT_BA80 || \
x == TT_VT102 || ISVT220(x))
#define ISVT100(x) (x == TT_VT100 || ISVT102(x))
Expand All @@ -1126,7 +1160,6 @@ struct stringint { /* String and (wide) integer */
#define ISVTNT(x) (x == TT_VTNT)
#define ISADM3A(x) (x == TT_ADM3A)
#define ISADM5(x) (x == TT_ADM5)
#define ISXTERM(x) (x == TT_XTERM)
#endif /* OS2 */

#define XYTCS 2 /* Terminal Character Set */
Expand Down
12 changes: 12 additions & 0 deletions kermit/k95/feature_flags.mak
Original file line number Diff line number Diff line change
Expand Up @@ -544,3 +544,15 @@ DISABLED_FEATURE_DEFS = $(DISABLED_FEATURE_DEFS) -DNOSCROLLWHEEL
ENABLED_FEATURES = $(ENABLED_FEATURES) Windows-Unicode
ENABLED_FEATURE_DEFS = $(ENABLED_FEATURE_DEFS) -DCK_NT_UNICODE -DUNICODE -D_UNICODE
!endif

# Enable xterm emulation option
!if "$(CKF_XTERM_EMULATION)" == "yes"
ENABLED_FEATURES = $(ENABLED_FEATURES) Xterm-emulation
ENABLED_FEATURE_DEFS = $(ENABLED_FEATURE_DEFS) -DCK_XTERM_EMULATION
!endif

# Enable VT420 and VT520 emulation options
!if "$(CKF_VT420_520_EMULATION)" == "yes"
ENABLED_FEATURES = $(ENABLED_FEATURES) vt420-vt520-emulation
ENABLED_FEATURE_DEFS = $(ENABLED_FEATURE_DEFS) -DCK_VT420_520_EMULATION
!endif
29 changes: 29 additions & 0 deletions kermit/k95/kui/ikui.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,35 @@ KuiSetTerminalRunMode(int x)
}
}

int KuiGetTerminalRunMode() {
long ret = GetWindowLong(kui->getTerminal()->hwnd(), GWL_STYLE);

if (ret & WS_MINIMIZE) return 2;
return 1;
}

int widthToChars(int width) {
return width / kui->getTerminal()->getKFont()->getFontW();
}

int heightToChars(int height) {
return height / kui->getTerminal()->getKFont()->getFontSpacedH();
}

void KuiGetTerminalMaximisedSize(BOOL inChars, int* width, int* height) {
RECT rec;
BOOL r = SystemParametersInfo(
SPI_GETWORKAREA,0, &rec, 0);

*width = rec.right - rec.left;
*height = rec.bottom - rec.top;

if (inChars) {
*width = widthToChars(*width);
*height = heightToChars(*height);
}
}

int
KuiFileDialog(char * title, char * def, char * result, int rlen,
BOOL downloadButton, BOOL openFile)
Expand Down
2 changes: 2 additions & 0 deletions kermit/k95/kui/ikui.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ void KuiSetTerminalSize(int, int);
void KuiSetTerminalResizeMode(int);
int KuiGetTerminalResizeMode(void);
void KuiSetTerminalRunMode(int);
int KuiGetTerminalRunMode();
void KuiGetTerminalMaximisedSize(BOOL inChars, int* width, int* height);
#define STATUS_CMD_TERM 0
#define STATUS_LOCUS 1
#define STATUS_PROTO 2
Expand Down
Loading