diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-07-07 11:54:15 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-07-07 11:54:15 +0200 |
commit | e4f25e4a8db2c8a8a71a4ba2a68540b3ab341e42 (patch) | |
tree | 5e48e171c0581f9a8240c95d4cde445e8b354ff2 | |
parent | da5116da4586fc714434411d2cccb066caa3723e (diff) |
patch 8.0.0693: no terminal emulator supportv8.0.0693
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.
87 files changed, 11693 insertions, 13 deletions
@@ -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,6 +188,7 @@ 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 \ @@ -194,6 +196,76 @@ SRC_ALL = \ 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 diff --git a/runtime/doc/Makefile b/runtime/doc/Makefile index 1a0e841973..46b6125a9e 100644 --- a/runtime/doc/Makefile +++ b/runtime/doc/Makefile @@ -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 \ diff --git a/runtime/doc/terminal.txt b/runtime/doc/terminal.txt new file mode 100644 index 0000000000..c16a793193 --- /dev/null +++ b/runtime/doc/terminal.txt @@ -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: diff --git a/src/Makefile b/src/Makefile index 2df82ecedc..907fdb127e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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 + ############################################################################# |