Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/nvi Add imctrl and imkey options, inspired by c...



details:   https://anonhg.NetBSD.org/src/rev/72f86acab0cb
branches:  trunk
changeset: 365221:72f86acab0cb
user:      rin <rin%NetBSD.org@localhost>
date:      Tue Aug 07 08:05:47 2018 +0000

description:
Add imctrl and imkey options, inspired by cannactrl and fepkey options in
nvi-m17n by itojun.

If imctrl option is set, input method is controlled by using escape
sequences compatible to Tera Term and RLogin. The state of input method in
commands specified by imkey option is saved and restored automatically.
Input method is then deactivated on returning to command mode.

diffstat:

 external/bsd/nvi/dist/cl/cl_funcs.c      |  39 +++++++++++++++++++++++++++++-
 external/bsd/nvi/dist/cl/cl_main.c       |   7 ++++-
 external/bsd/nvi/dist/common/gs.h        |  11 ++++++++-
 external/bsd/nvi/dist/common/options.c   |  19 +++++++++++++-
 external/bsd/nvi/dist/common/options_f.c |  20 ++++++++++++++-
 external/bsd/nvi/dist/docs/vi.man/vi.1   |  17 ++++++++++++-
 external/bsd/nvi/dist/ip/ip_funcs.c      |  21 +++++++++++++++-
 external/bsd/nvi/dist/ip/ip_main.c       |   7 ++++-
 external/bsd/nvi/dist/vi/v_replace.c     |   7 ++++-
 external/bsd/nvi/dist/vi/v_txt.c         |   7 ++++-
 external/bsd/nvi/dist/vi/vi.c            |  40 ++++++++++++++++++++++++++++++-
 external/bsd/nvi/usr.bin/nvi/Makefile    |   5 ++-
 12 files changed, 177 insertions(+), 23 deletions(-)

diffs (truncated from 482 to 300 lines):

diff -r f32958044723 -r 72f86acab0cb external/bsd/nvi/dist/cl/cl_funcs.c
--- a/external/bsd/nvi/dist/cl/cl_funcs.c       Tue Aug 07 07:19:28 2018 +0000
+++ b/external/bsd/nvi/dist/cl/cl_funcs.c       Tue Aug 07 08:05:47 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cl_funcs.c,v 1.8 2018/02/04 09:15:45 mrg Exp $ */
+/*     $NetBSD: cl_funcs.c,v 1.9 2018/08/07 08:05:47 rin Exp $ */
 /*-
  * Copyright (c) 1993, 1994
  *     The Regents of the University of California.  All rights reserved.
@@ -16,7 +16,7 @@
 static const char sccsid[] = "Id: cl_funcs.c,v 10.72 2002/03/02 23:18:33 skimo Exp  (Berkeley) Date: 2002/03/02 23:18:33 ";
 #endif /* not lint */
 #else
-__RCSID("$NetBSD: cl_funcs.c,v 1.8 2018/02/04 09:15:45 mrg Exp $");
+__RCSID("$NetBSD: cl_funcs.c,v 1.9 2018/08/07 08:05:47 rin Exp $");
 #endif
 
 #include <sys/types.h>
@@ -465,6 +465,41 @@
        return (0);
 }
 
+#ifdef IMCTRL
+/*
+ * cl_imctrl --
+ *     Control the state of input method by using escape sequences compatible
+ *     to Tera Term and RLogin.
+ *
+ * PUBLIC: void cl_imctrl __P((SCR *, imctrl_t));
+ */
+void
+cl_imctrl(SCR *sp, imctrl_t action)
+{
+#define        TT_IM_OFF       "\033[<t"       /* TTIMEST */
+#define        TT_IM_RESTORE   "\033[<r"       /* TTIMERS */
+#define        TT_IM_SAVE      "\033[<s"       /* TTIMESV */
+
+       if (!O_ISSET(sp, O_IMCTRL) && action != IMCTRL_INIT)
+               return;
+
+       switch (action) {
+       case IMCTRL_INIT:
+               (void)printf(TT_IM_OFF TT_IM_SAVE);
+               break;
+       case IMCTRL_OFF:
+               (void)printf(TT_IM_SAVE TT_IM_OFF);
+               break;
+       case IMCTRL_ON:
+               (void)printf(TT_IM_RESTORE);
+               break;
+       default:
+               abort();
+       }
+       (void)fflush(stdout);
+}
+#endif
+
 /*
  * cl_insertln --
  *     Push down the current line, discarding the bottom line.
diff -r f32958044723 -r 72f86acab0cb external/bsd/nvi/dist/cl/cl_main.c
--- a/external/bsd/nvi/dist/cl/cl_main.c        Tue Aug 07 07:19:28 2018 +0000
+++ b/external/bsd/nvi/dist/cl/cl_main.c        Tue Aug 07 08:05:47 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cl_main.c,v 1.9 2017/12/06 17:16:14 jmcneill Exp $ */
+/*     $NetBSD: cl_main.c,v 1.10 2018/08/07 08:05:47 rin Exp $ */
 /*-
  * Copyright (c) 1993, 1994
  *     The Regents of the University of California.  All rights reserved.
@@ -16,7 +16,7 @@
 static const char sccsid[] = "Id: cl_main.c,v 10.54 2001/07/29 19:07:27 skimo Exp  (Berkeley) Date: 2001/07/29 19:07:27 ";
 #endif /* not lint */
 #else
-__RCSID("$NetBSD: cl_main.c,v 1.9 2017/12/06 17:16:14 jmcneill Exp $");
+__RCSID("$NetBSD: cl_main.c,v 1.10 2018/08/07 08:05:47 rin Exp $");
 #endif
 
 #include <sys/types.h>
@@ -442,6 +442,9 @@
        gp->scr_event = cl_event;
        gp->scr_ex_adjust = cl_ex_adjust;
        gp->scr_fmap = cl_fmap;
+#ifdef IMCTRL
+       gp->scr_imctrl = cl_imctrl;
+#endif
        gp->scr_insertln = cl_insertln;
        gp->scr_keyval = cl_keyval;
        gp->scr_move = cl_move;
diff -r f32958044723 -r 72f86acab0cb external/bsd/nvi/dist/common/gs.h
--- a/external/bsd/nvi/dist/common/gs.h Tue Aug 07 07:19:28 2018 +0000
+++ b/external/bsd/nvi/dist/common/gs.h Tue Aug 07 08:05:47 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gs.h,v 1.3 2013/11/25 22:43:46 christos Exp $ */
+/*     $NetBSD: gs.h,v 1.4 2018/08/07 08:05:47 rin Exp $ */
 /*-
  * Copyright (c) 1993, 1994
  *     The Regents of the University of California.  All rights reserved.
@@ -45,6 +45,11 @@
 /* Screen attribute arguments to scr_attr(). */
 typedef enum { SA_ALTERNATE, SA_INVERSE } scr_attr_t;
 
+#ifdef IMCTRL
+/* Input method control arguments to scr_imctrl(). */
+typedef enum { IMCTRL_INIT, IMCTRL_OFF, IMCTRL_ON } imctrl_t;
+#endif
+
 /* Key type arguments to scr_keyval(). */
 typedef enum { KEY_VEOF, KEY_VERASE, KEY_VKILL, KEY_VWERASE } scr_keyval_t;
 
@@ -152,6 +157,10 @@
            __P((SCR *, seq_t, CHAR_T *, size_t, CHAR_T *, size_t));
                                        /* Get terminal key value. */
        int     (*scr_keyval) __P((SCR *, scr_keyval_t, CHAR_T *, int *));
+#ifdef IMCTRL
+                                       /* Control the state of input method. */
+       void    (*scr_imctrl) __P((SCR *, imctrl_t));
+#endif
                                        /* Insert a line. */
        int     (*scr_insertln) __P((SCR *));
                                        /* Handle an option change. */
diff -r f32958044723 -r 72f86acab0cb external/bsd/nvi/dist/common/options.c
--- a/external/bsd/nvi/dist/common/options.c    Tue Aug 07 07:19:28 2018 +0000
+++ b/external/bsd/nvi/dist/common/options.c    Tue Aug 07 08:05:47 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: options.c,v 1.5 2017/11/06 03:21:13 rin Exp $ */
+/*     $NetBSD: options.c,v 1.6 2018/08/07 08:05:47 rin Exp $ */
 /*-
  * Copyright (c) 1991, 1993, 1994
  *     The Regents of the University of California.  All rights reserved.
@@ -16,7 +16,7 @@
 static const char sccsid[] = "Id: options.c,v 10.65 2002/01/18 22:34:43 skimo Exp  (Berkeley) Date: 2002/01/18 22:34:43 ";
 #endif /* not lint */
 #else
-__RCSID("$NetBSD: options.c,v 1.5 2017/11/06 03:21:13 rin Exp $");
+__RCSID("$NetBSD: options.c,v 1.6 2018/08/07 08:05:47 rin Exp $");
 #endif
 
 #include <sys/types.h>
@@ -112,6 +112,18 @@
        {L("iclower"),  f_recompile,    OPT_0BOOL,      0},
 /* O_IGNORECASE            4BSD */
        {L("ignorecase"),       f_recompile,    OPT_0BOOL,      0},
+/* O_IMCTRL    nvi-m17n/NetBSD */
+#ifdef IMCTRL
+       {L("imctrl"),   f_imctrl,       OPT_0BOOL,      0},
+#else
+       {L("imctrl"),   NULL,           OPT_0BOOL,      OPT_NDISP|OPT_NOSAVE|OPT_NOSET},
+#endif
+/* O_IMKEY     nvi-m17n/NetBSD */
+#ifdef IMCTRL
+       {L("imkey"),    NULL,           OPT_STR,        0},
+#else
+       {L("imkey"),    NULL,           OPT_STR,        OPT_NDISP|OPT_NOSAVE},
+#endif
 /* O_INPUTENCODING */
        {L("inputencoding"),f_encoding, OPT_STR,        OPT_WC},
 /* O_KEYTIME     4.4BSD */
@@ -405,6 +417,9 @@
        OI(O_TABSTOP, L("tabstop=8"));
        (void)SPRINTF(b2, SIZE(b2), L("tags=%s"), _PATH_TAGS);
        OI(O_TAGS, b2);
+#ifdef IMCTRL
+       OI(O_IMKEY, L("imkey=/?aioAIO"));
+#endif
 
        /*
         * XXX
diff -r f32958044723 -r 72f86acab0cb external/bsd/nvi/dist/common/options_f.c
--- a/external/bsd/nvi/dist/common/options_f.c  Tue Aug 07 07:19:28 2018 +0000
+++ b/external/bsd/nvi/dist/common/options_f.c  Tue Aug 07 08:05:47 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: options_f.c,v 1.3 2014/01/26 21:43:45 christos Exp $ */
+/*     $NetBSD: options_f.c,v 1.4 2018/08/07 08:05:47 rin Exp $ */
 /*-
  * Copyright (c) 1993, 1994
  *     The Regents of the University of California.  All rights reserved.
@@ -16,7 +16,7 @@
 static const char sccsid[] = "Id: options_f.c,v 10.33 2001/06/25 15:19:11 skimo Exp  (Berkeley) Date: 2001/06/25 15:19:11 ";
 #endif /* not lint */
 #else
-__RCSID("$NetBSD: options_f.c,v 1.3 2014/01/26 21:43:45 christos Exp $");
+__RCSID("$NetBSD: options_f.c,v 1.4 2018/08/07 08:05:47 rin Exp $");
 #endif
 
 #include <sys/types.h>
@@ -301,3 +301,19 @@
 
        return conv_enc(sp, offset, str);
 }
+
+#ifdef IMCTRL
+/*
+ * PUBLIC: #ifdef IMCTRL
+ * PUBLIC: int f_imctrl __P((SCR *, OPTION *, const char *, u_long *));
+ * PUBLIC: #endif
+ */
+int
+f_imctrl(SCR *sp, OPTION *op, const char *str, u_long *valp)
+{
+
+       if (*valp)
+               sp->gp->scr_imctrl(sp, IMCTRL_INIT);
+       return (0);
+}
+#endif
diff -r f32958044723 -r 72f86acab0cb external/bsd/nvi/dist/docs/vi.man/vi.1
--- a/external/bsd/nvi/dist/docs/vi.man/vi.1    Tue Aug 07 07:19:28 2018 +0000
+++ b/external/bsd/nvi/dist/docs/vi.man/vi.1    Tue Aug 07 08:05:47 2018 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: vi.1,v 1.5 2016/12/27 06:50:03 abhinav Exp $
+.\"    $NetBSD: vi.1,v 1.6 2018/08/07 08:05:47 rin Exp $
 .\"
 .\" Copyright (c) 1994
 .\"     The Regents of the University of California.  All rights reserved.
@@ -12,7 +12,7 @@
 .\"
 .\"     Id: vi.1,v 8.53 2001/01/28 13:20:06 skimo Exp  (Berkeley) Date: 2001/01/28 13:20:06 
 .\"
-.TH VI 1 "November 22, 2013"
+.TH VI 1 "August 7, 2018"
 .UC
 .SH NAME
 ex, vi, view \- text editors
@@ -1147,6 +1147,19 @@
 .B "ignorecase, ic [off]"
 Ignore case differences in regular expressions.
 .TP
+.B "imctrl [off]"
+Control input method by using escape sequences compatible to
+Tera Term and RLogin.
+The state of input method in commands specified by imkey option is
+saved and restored automatically.
+Input method is then deactivated on returning to command mode.
+If terminal does not accept these escape sequences,
+screen should be corrupted.
+.TP
+.B "imkey [/?aioAIO]"
+Set commands which the state of input method is restored and saved on
+entering and leaving, respectively.
+.TP
 .B "keytime [6]"
 The 10th's of a second
 .I ex/vi
diff -r f32958044723 -r 72f86acab0cb external/bsd/nvi/dist/ip/ip_funcs.c
--- a/external/bsd/nvi/dist/ip/ip_funcs.c       Tue Aug 07 07:19:28 2018 +0000
+++ b/external/bsd/nvi/dist/ip/ip_funcs.c       Tue Aug 07 08:05:47 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_funcs.c,v 1.4 2014/01/26 21:43:45 christos Exp $    */
+/*     $NetBSD: ip_funcs.c,v 1.5 2018/08/07 08:05:47 rin Exp $ */
 /*-
  * Copyright (c) 1996
  *     Keith Bostic.  All rights reserved.
@@ -14,7 +14,7 @@
 static const char sccsid[] = "Id: ip_funcs.c,v 8.23 2001/06/25 15:19:23 skimo Exp  (Berkeley) Date: 2001/06/25 15:19:23 ";
 #endif /* not lint */
 #else
-__RCSID("$NetBSD: ip_funcs.c,v 1.4 2014/01/26 21:43:45 christos Exp $");
+__RCSID("$NetBSD: ip_funcs.c,v 1.5 2018/08/07 08:05:47 rin Exp $");
 #endif
 
 #include <sys/types.h>
@@ -316,6 +316,23 @@
        /* NOTREACHED */
 }
 
+#ifdef IMCTRL
+/*
+ * ip_imctrl --
+ *     XXX not implemented yet.
+ *
+ * PUBLIC: #ifdef IMCTRL
+ * PUBLIC: void ip_imctrl __P((SCR *, imctrl_t));
+ * PUBLIC: #endif
+ */
+void
+ip_imctrl(SCR *sp, imctrl_t action)
+{
+
+       return;
+}
+#endif
+
 /*
  * ip_insertln --
  *     Push down the current line, discarding the bottom line.
diff -r f32958044723 -r 72f86acab0cb external/bsd/nvi/dist/ip/ip_main.c
--- a/external/bsd/nvi/dist/ip/ip_main.c        Tue Aug 07 07:19:28 2018 +0000
+++ b/external/bsd/nvi/dist/ip/ip_main.c        Tue Aug 07 08:05:47 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_main.c,v 1.3 2014/01/26 21:43:45 christos Exp $ */
+/*     $NetBSD: ip_main.c,v 1.4 2018/08/07 08:05:47 rin Exp $ */
 /*-
  * Copyright (c) 1996
  *     Keith Bostic.  All rights reserved.
@@ -14,7 +14,7 @@
 static const char sccsid[] = "Id: ip_main.c,v 8.24 2001/07/29 19:07:30 skimo Exp  (Berkeley) Date: 2001/07/29 19:07:30 ";
 #endif /* not lint */
 #else
-__RCSID("$NetBSD: ip_main.c,v 1.3 2014/01/26 21:43:45 christos Exp $");
+__RCSID("$NetBSD: ip_main.c,v 1.4 2018/08/07 08:05:47 rin Exp $");



Home | Main Index | Thread Index | Old Index