Permalink
Browse files

patch 8.0.0693: no terminal emulator support

Problem:    No terminal emulator support.  Cannot properly run commands in the
            GUI.  Cannot run a job interactively with an ssh connection.
Solution:   Very early implementation of the :terminal command.  Includes
            libvterm converted to ANSI C.  Many parts still missing.
  • Loading branch information...
brammool committed Jul 7, 2017
1 parent da5116d commit e4f25e4a8db2c8a8a71a4ba2a68540b3ab341e42
Showing with 11,693 additions and 13 deletions.
  1. +72 −0 Filelist
  2. +2 −0 runtime/doc/Makefile
  3. +130 −0 runtime/doc/terminal.txt
  4. +54 −3 src/Makefile
  5. +33 −0 src/auto/configure
  6. +3 −0 src/config.h.in
  7. +2 −0 src/config.mk.in
  8. +22 −0 src/configure.ac
  9. +3 −0 src/evalfunc.c
  10. +8 −8 src/ex_cmdidxs.h
  11. +3 −0 src/ex_docmd.c
  12. +7 −0 src/feature.h
  13. +13 −0 src/libvterm/.bzrignore
  14. +18 −0 src/libvterm/.gitignore
  15. +23 −0 src/libvterm/LICENSE
  16. +145 −0 src/libvterm/Makefile
  17. +13 −0 src/libvterm/README
  18. +287 −0 src/libvterm/bin/unterm.c
  19. +362 −0 src/libvterm/bin/vterm-ctrl.c
  20. +231 −0 src/libvterm/bin/vterm-dump.c
  21. +11 −0 src/libvterm/doc/URLs
  22. +226 −0 src/libvterm/doc/seqs.txt
  23. +370 −0 src/libvterm/include/vterm.h
  24. +58 −0 src/libvterm/include/vterm_keycodes.h
  25. +232 −0 src/libvterm/src/encoding.c
  26. +31 −0 src/libvterm/src/encoding/DECdrawing.tbl
  27. +1 −0 src/libvterm/src/encoding/uk.tbl
  28. +228 −0 src/libvterm/src/keyboard.c
  29. +96 −0 src/libvterm/src/mouse.c
  30. +346 −0 src/libvterm/src/parser.c
  31. +504 −0 src/libvterm/src/pen.c
  32. +56 −0 src/libvterm/src/rect.h
  33. +937 −0 src/libvterm/src/screen.c
  34. +1,851 −0 src/libvterm/src/state.c
  35. +331 −0 src/libvterm/src/unicode.c
  36. +47 −0 src/libvterm/src/utf8.h
  37. +385 −0 src/libvterm/src/vterm.c
  38. +237 −0 src/libvterm/src/vterm_internal.h
  39. +200 −0 src/libvterm/t/02parser.test
  40. +122 −0 src/libvterm/t/03encoding_utf8.test
  41. +55 −0 src/libvterm/t/10state_putglyph.test
  42. +224 −0 src/libvterm/t/11state_movecursor.test
  43. +150 −0 src/libvterm/t/12state_scroll.test
  44. +300 −0 src/libvterm/t/13state_edit.test
  45. +105 −0 src/libvterm/t/14state_encoding.test
  46. +86 −0 src/libvterm/t/15state_mode.test
  47. +48 −0 src/libvterm/t/16state_resize.test
  48. +172 −0 src/libvterm/t/17state_mouse.test
  49. +36 −0 src/libvterm/t/18state_termprops.test
  50. +69 −0 src/libvterm/t/20state_wrapping.test
  51. +60 −0 src/libvterm/t/21state_tabstops.test
  52. +64 −0 src/libvterm/t/22state_save.test
  53. +132 −0 src/libvterm/t/25state_input.test
  54. +62 −0 src/libvterm/t/26state_query.test
  55. +32 −0 src/libvterm/t/27state_reset.test
  56. +61 −0 src/libvterm/t/28state_dbl_wh.test
  57. +19 −0 src/libvterm/t/29state_fallback.test
  58. +106 −0 src/libvterm/t/30pen.test
  59. +69 −0 src/libvterm/t/40screen_ascii.test
  60. +47 −0 src/libvterm/t/41screen_unicode.test
  61. +155 −0 src/libvterm/t/42screen_damage.test
  62. +90 −0 src/libvterm/t/43screen_resize.test
  63. +55 −0 src/libvterm/t/44screen_pen.test
  64. +16 −0 src/libvterm/t/45screen_protect.test
  65. +11 −0 src/libvterm/t/46screen_extent.test
  66. +32 −0 src/libvterm/t/47screen_dbl_wh.test
  67. +17 −0 src/libvterm/t/48screen_termprops.test
  68. +87 −0 src/libvterm/t/90vttest_01-movement-1.test
  69. +40 −0 src/libvterm/t/90vttest_01-movement-2.test
  70. +21 −0 src/libvterm/t/90vttest_01-movement-3.test
  71. +36 −0 src/libvterm/t/90vttest_01-movement-4.test
  72. +18 −0 src/libvterm/t/90vttest_02-screen-1.test
  73. +29 −0 src/libvterm/t/90vttest_02-screen-2.test
  74. +16 −0 src/libvterm/t/90vttest_02-screen-3.test
  75. +17 −0 src/libvterm/t/90vttest_02-screen-4.test
  76. +13 −0 src/libvterm/t/92lp1640917.test
  77. +929 −0 src/libvterm/t/harness.c
  78. +196 −0 src/libvterm/t/run-test.pl
  79. +51 −0 src/libvterm/tbl2inc_c.pl
  80. +9 −0 src/libvterm/vterm.pc.in
  81. +26 −2 src/option.c
  82. +3 −0 src/option.h
  83. +3 −0 src/proto.h
  84. +3 −0 src/proto/terminal.pro
  85. +10 −0 src/structs.h
  86. +211 −0 src/terminal.c
  87. +2 −0 src/version.c
View
@@ -85,6 +85,7 @@ SRC_ALL = \
src/syntax.c \
src/tag.c \
src/term.c \
src/terminal.c \
src/term.h \
src/termlib.c \
src/ui.c \
@@ -187,13 +188,84 @@ SRC_ALL = \
src/proto/syntax.pro \
src/proto/tag.pro \
src/proto/term.pro \
src/proto/terminal.pro \
src/proto/termlib.pro \
src/proto/ui.pro \
src/proto/undo.pro \
src/proto/userfunc.pro \
src/proto/version.pro \
src/proto/winclip.pro \
src/proto/window.pro \
src/libvterm/.bzrignore \
src/libvterm/.gitignore \
src/libvterm/LICENSE \
src/libvterm/Makefile \
src/libvterm/README \
src/libvterm/tbl2inc_c.pl \
src/libvterm/vterm.pc.in \
src/libvterm/bin/unterm.c \
src/libvterm/bin/vterm-ctrl.c \
src/libvterm/bin/vterm-dump.c \
src/libvterm/doc/URLs \
src/libvterm/doc/seqs.txt \
src/libvterm/include/vterm.h \
src/libvterm/include/vterm_keycodes.h \
src/libvterm/src/encoding.c \
src/libvterm/src/encoding/DECdrawing.inc \
src/libvterm/src/encoding/DECdrawing.tbl \
src/libvterm/src/encoding/uk.inc \
src/libvterm/src/encoding/uk.tbl \
src/libvterm/src/keyboard.c \
src/libvterm/src/mouse.c \
src/libvterm/src/parser.c \
src/libvterm/src/pen.c \
src/libvterm/src/rect.h \
src/libvterm/src/screen.c \
src/libvterm/src/state.c \
src/libvterm/src/unicode.c \
src/libvterm/src/utf8.h \
src/libvterm/src/vterm.c \
src/libvterm/src/vterm_internal.h \
src/libvterm/t/02parser.test \
src/libvterm/t/03encoding_utf8.test \
src/libvterm/t/10state_putglyph.test \
src/libvterm/t/11state_movecursor.test \
src/libvterm/t/12state_scroll.test \
src/libvterm/t/13state_edit.test \
src/libvterm/t/14state_encoding.test \
src/libvterm/t/15state_mode.test \
src/libvterm/t/16state_resize.test \
src/libvterm/t/17state_mouse.test \
src/libvterm/t/18state_termprops.test \
src/libvterm/t/20state_wrapping.test \
src/libvterm/t/21state_tabstops.test \
src/libvterm/t/22state_save.test \
src/libvterm/t/25state_input.test \
src/libvterm/t/26state_query.test \
src/libvterm/t/27state_reset.test \
src/libvterm/t/28state_dbl_wh.test \
src/libvterm/t/29state_fallback.test \
src/libvterm/t/30pen.test \
src/libvterm/t/40screen_ascii.test \
src/libvterm/t/41screen_unicode.test \
src/libvterm/t/42screen_damage.test \
src/libvterm/t/43screen_resize.test \
src/libvterm/t/44screen_pen.test \
src/libvterm/t/45screen_protect.test \
src/libvterm/t/46screen_extent.test \
src/libvterm/t/47screen_dbl_wh.test \
src/libvterm/t/48screen_termprops.test \
src/libvterm/t/90vttest_01-movement-1.test \
src/libvterm/t/90vttest_01-movement-2.test \
src/libvterm/t/90vttest_01-movement-3.test \
src/libvterm/t/90vttest_01-movement-4.test \
src/libvterm/t/90vttest_02-screen-1.test \
src/libvterm/t/90vttest_02-screen-2.test \
src/libvterm/t/90vttest_02-screen-3.test \
src/libvterm/t/90vttest_02-screen-4.test \
src/libvterm/t/92lp1640917.test \
src/libvterm/t/harness.c \
src/libvterm/t/run-test.pl \
# source files for Unix only
View
@@ -101,6 +101,7 @@ DOCS = \
tabpage.txt \
tagsrch.txt \
term.txt \
terminal.txt \
tips.txt \
todo.txt \
uganda.txt \
@@ -236,6 +237,7 @@ HTMLS = \
tabpage.html \
tagsrch.html \
term.html \
terminal.html \
tips.html \
todo.html \
uganda.html \
View
@@ -0,0 +1,130 @@
*terminal.txt* For Vim version 8.0. Last change: 2017 Jul 04
VIM REFERENCE MANUAL by Bram Moolenaar
Terminal window support *terminal*
WARNING: THIS IS ONLY PARTLY IMPLEMENTED, ANYTHING CAN STILL CHANGE
1. Basic use |terminal-use|
2. Remote testing |terminal-testing|
3. Debugging |terminal-debug|
{Vi does not have any of these commands}
==============================================================================
1. Basic use *terminal-use*
This feature is for running a terminal emulator in a Vim window. A job can be
started connected to the terminal emulator. For example, to run a shell: >
:term bash
Or to run a debugger: >
:term gdb vim
The job runs asynchronously from Vim, the window will be updated to show
output from the job, also while editing in any other window.
When the keyboard focus is in the terminal window, typed keys will be send to
the job. This uses a pty when possible.
Navigate between windows with CTRL-W commands (and mouse).
E.g. CTRL-W CTRL-W moves focus to the next window.
Option 'termkey'
Specify key for Vim command in terminal window. local to window.
Default is CTRL-W.
Option 'termsize'
Specify terminal size. Local to window.
When empty the terminal gets the size from the window.
When set (e.g., "24x80") the terminal size is fixed. If the window is smaller
only the top-left part is displayed. (TODO: scrolling?)
Syntax ~
*:ter* *:terminal*
:terminal[!] [command] Open a new terminal window.
If [command] is provided run it as a job and connect
the input and output to the terminal.
If [command] is not given the 'shell' option is used.
A new buffer will be created, using [command] or
'shell' as the name. If a buffer by this name already
exists a number is added in parenthesis.
E.g. if "gdb" exists the second terminal buffer will
use "gdb (1)".
The window can be closed, in which case the buffer
becomes hidden. The command will not be stopped. The
`:buffer` command can be used to turn the current
window into a terminal window, using the existing
buffer. If there are unsaved changes this fails, use
! to force, as usual.
Resizing ~
The size of the terminal can be in one of three modes:
1. The 'termsize' option is empty: The terminal size follows the window size.
The minimal size is 2 screen lines with 10 cells.
2. The 'termsize' option is "rows*cols", where "rows" is the minimal number of
screen rows and "cols" is the minial number of cells.
3. The 'termsize' option is "rowsXcols" (where the x is upper or lower case).
The terminal size is fixed to the specified number of screen lines and
cells. If the window is bigger there will be unused empty space.
If the window is smaller than the terminal size, only part of the terminal can
be seen (the lower-left part).
The |term_getsize()| function can be used to get the current size of the
terminal. |term_setsize()| can be used only when in the first or second mode,
not when 'termsize' is "rowsXcols".
==============================================================================
2. Remote testing *terminal-testing*
Most Vim tests execute a script inside Vim. For some tests this does not
work, running the test interferes with the code being tested. To avoid this
Vim is executed in a terminal window. The test sends keystrokes to it and
inspects the resulting screen state.
Functions ~
term_sendkeys() send keystrokes to a terminal
term_wait() wait for screen to be updated
term_scrape() inspect terminal screen
==============================================================================
3. Debugging *terminal-debug*
The Terminal debugging plugin can be used to debug a program with gdb and view
the source code in a Vim window. For example: >
:TermDebug vim
This opens three windows:
- A terminal window in which "gdb vim" is executed. Here you can directly
interact with gdb.
- A terminal window for the executed program. When "run" is used in gdb the
program I/O will happen in this window, so that it does not interfere with
controlling gdb.
- A normal Vim window used to show the source code. When gdb jumps to a
source file location this window will display the code, if possible. Values
of variables can be inspected, breakpoints set and cleared, etc.
This uses two terminal windows. To open the gdb window: >
:term gdb [arguments]
To open the terminal to run the tested program |term_open()| is used.
TODO
vim:tw=78:ts=8:ft=help:norl:
View
@@ -482,6 +482,11 @@ CClink = $(CC)
# Uncomment this when you do not want inter process communication.
#CONF_OPT_CHANNEL = --disable-channel
# TERMINAL - Terminal emulator support, :terminal command. Requires the
# channel feature.
# Uncomment this when you want terminal emulator support.
#CONF_OPT_TERMINAL = --enable-terminal
# MULTIBYTE - To edit multi-byte characters.
# Uncomment this when you want to edit a multibyte language.
# It's automatically enabled with normal features, GTK or IME support.
@@ -598,6 +603,9 @@ CClink = $(CC)
# Use this with GCC to check for mistakes, unused arguments, etc.
#CFLAGS = -g -Wall -Wextra -Wshadow -Wmissing-prototypes -Wunreachable-code -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
# Add -Wpedantic to find // comments and other C99 constructs.
# Better disable Perl and Python to avoid a lot of warnings.
#CFLAGS = -g -Wall -Wextra -Wshadow -Wmissing-prototypes -Wpedantic -Wunreachable-code -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
#CFLAGS = -g -O2 -Wall -Wextra -Wmissing-prototypes -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DU_DEBUG
#PYTHON_CFLAGS_EXTRA = -Wno-missing-field-initializers
#MZSCHEME_CFLAGS_EXTRA = -Wno-unreachable-code -Wno-unused-parameter
@@ -1371,6 +1379,13 @@ ALL_GUI_PRO = gui.pro gui_gtk.pro gui_motif.pro gui_xmdlg.pro gui_athena.pro gu
# }}}
TERM_DEPS = \
libvterm/include/vterm.h \
libvterm/include/vterm_keycodes.h \
libvterm/src/rect.h \
libvterm/src/utf8.h \
libvterm/src/vterm_internal.h
### Command to create dependencies based on #include "..."
### prototype headers are ignored due to -DPROTO, system
### headers #include <...> are ignored if we use the -MM option, as
@@ -1560,6 +1575,7 @@ BASIC_SRC = \
syntax.c \
tag.c \
term.c \
terminal.c \
ui.c \
undo.c \
userfunc.c \
@@ -1569,6 +1585,7 @@ BASIC_SRC = \
SRC = $(BASIC_SRC) \
$(GUI_SRC) \
$(TERM_SRC) \
$(HANGULIN_SRC) \
$(LUA_SRC) \
$(MZSCHEME_SRC) \
@@ -1610,7 +1627,7 @@ ALL_SRC = $(BASIC_SRC) $(ALL_GUI_SRC) $(UNITTEST_SRC) $(EXTRA_SRC)
LINT_SRC = $(BASIC_SRC) $(GUI_SRC) $(HANGULIN_SRC) \
$(PYTHON_SRC) $(PYTHON3_SRC) $(TCL_SRC) \
$(WORKSHOP_SRC) $(WSDEBUG_SRC) \
$(NETBEANS_SRC) $(CHANNEL_SRC)
$(NETBEANS_SRC) $(CHANNEL_SRC) $(TERM_SRC)
#LINT_SRC = $(SRC)
#LINT_SRC = $(ALL_SRC)
#LINT_SRC = $(BASIC_SRC)
@@ -1665,12 +1682,14 @@ OBJ_COMMON = \
objects/syntax.o \
objects/tag.o \
objects/term.o \
objects/terminal.o \
objects/ui.o \
objects/undo.o \
objects/userfunc.o \
objects/version.o \
objects/window.o \
$(GUI_OBJ) \
$(TERM_OBJ) \
$(LUA_OBJ) \
$(MZSCHEME_OBJ) \
$(PERL_OBJ) \
@@ -1795,6 +1814,7 @@ PRO_AUTO = \
syntax.pro \
tag.pro \
term.pro \
terminal.pro \
termlib.pro \
ui.pro \
undo.pro \
@@ -1848,7 +1868,7 @@ config auto/config.mk: auto/configure config.mk.in config.h.in
$(CONF_OPT_OUTPUT) $(CONF_OPT_GPM) $(CONF_OPT_WORKSHOP) \
$(CONF_OPT_FEAT) $(CONF_TERM_LIB) \
$(CONF_OPT_COMPBY) $(CONF_OPT_ACL) $(CONF_OPT_NETBEANS) \
$(CONF_OPT_CHANNEL) \
$(CONF_OPT_CHANNEL) $(CONF_OPT_TERMINAL) \
$(CONF_ARGS) $(CONF_OPT_MZSCHEME) $(CONF_OPT_PLTHOME) \
$(CONF_OPT_LUA) $(CONF_OPT_LUA_PREFIX) \
$(CONF_OPT_SYSMOUSE); \
@@ -3228,6 +3248,9 @@ objects/tag.o: tag.c
objects/term.o: term.c
$(CCC) -o $@ term.c
objects/terminal.o: terminal.c $(TERM_DEPS)
$(CCC) -o $@ terminal.c
objects/ui.o: ui.c
$(CCC) -o $@ ui.c
@@ -3255,6 +3278,34 @@ objects/channel.o: channel.c
Makefile:
@echo The name of the makefile MUST be "Makefile" (with capital M)!!!!
CCCTERM = $(CCC) -Ilibvterm/include -DINLINE=""
objects/term_encoding.o: libvterm/src/encoding.c $(TERM_DEPS)
$(CCCTERM) -o $@ libvterm/src/encoding.c
objects/term_keyboard.o: libvterm/src/keyboard.c $(TERM_DEPS)
$(CCCTERM) -o $@ libvterm/src/keyboard.c
objects/term_mouse.o: libvterm/src/mouse.c $(TERM_DEPS)
$(CCCTERM) -o $@ libvterm/src/mouse.c
objects/term_parser.o: libvterm/src/parser.c $(TERM_DEPS)
$(CCCTERM) -o $@ libvterm/src/parser.c
objects/term_pen.o: libvterm/src/pen.c $(TERM_DEPS)
$(CCCTERM) -o $@ libvterm/src/pen.c
objects/term_screen.o: libvterm/src/screen.c $(TERM_DEPS)
$(CCCTERM) -o $@ libvterm/src/screen.c
objects/term_state.o: libvterm/src/state.c $(TERM_DEPS)
$(CCCTERM) -o $@ libvterm/src/state.c
objects/term_unicode.o: libvterm/src/unicode.c $(TERM_DEPS)
$(CCCTERM) -o $@ libvterm/src/unicode.c
objects/term_vterm.o: libvterm/src/vterm.c $(TERM_DEPS)
$(CCCTERM) -o $@ libvterm/src/vterm.c
###############################################################################
### MacOS X installation
###
@@ -3399,7 +3450,7 @@ objects/ex_cmds2.o: ex_cmds2.c vim.h auto/config.h feature.h os_unix.h \
objects/ex_docmd.o: ex_docmd.c vim.h auto/config.h feature.h os_unix.h \
auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
regexp.h gui.h gui_beval.h proto/gui_beval.pro alloc.h ex_cmds.h spell.h \
proto.h globals.h farsi.h arabic.h
proto.h globals.h farsi.h arabic.h ex_cmdidxs.h
objects/ex_eval.o: ex_eval.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
gui_beval.h proto/gui_beval.pro alloc.h ex_cmds.h spell.h proto.h \
Oops, something went wrong.

0 comments on commit e4f25e4

Please sign in to comment.