annotate src/README.txt @ 10613:196757b230a2 v8.0.0196

patch 8.0.0196: profile test is slo and does not work on MS-Windows commit https://github.com/vim/vim/commit/c011a3d083001bcd9853b4447422f1819f3cee2f Author: Bram Moolenaar <Bram@vim.org> Date: Mon Jan 16 22:37:42 2017 +0100 patch 8.0.0196: profile test is slo and does not work on MS-Windows Problem: The test for :profile is slow and does not work on MS-Windows. Solution: Use the "-es" argument. (Dominique Pelle) Swap single and double quotes for system()
author Christian Brabandt <cb@256bit.org>
date Mon, 16 Jan 2017 22:45:04 +0100
parents 073ff46fe397
children 8412df1479a3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 README for the Vim source code
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 Here are a few hints for finding your way around the source code. This
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 doesn't make it less complex than it is, but it gets you started.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 You might also want to read ":help development".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 JUMPING AROUND
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 First of all, use ":make tags" to generate a tags file, so that you can use
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 the ":tag" command to jump around the source code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 To jump to a function or variable definition, move the cursor on the name and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 use the CTRL-] command. Use CTRL-T or CTRL-O to jump back.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 To jump to a file, move the cursor on its name and use the "gf" command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 Most code can be found in a file with an obvious name (incomplete list):
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 buffer.c manipulating buffers (loaded files)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 diff.c diff mode (vimdiff)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 eval.c expression evaluation
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 fileio.c reading and writing files
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 fold.c folding
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 getchar.c getting characters and key mapping
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 mark.c marks
2577
073ff46fe397 Fold Vim 7.2 default branch back to trunk to avoid two heads. (Tony
Bram Moolenaar <bram@vim.org>
parents: 2165
diff changeset
27 mbyte.c multi-byte character handling
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 memfile.c storing lines for buffers in a swapfile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 memline.c storing lines for buffers in memory
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 menu.c menus
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 message.c (error) messages
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 ops.c handling operators ("d", "y", "p")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 option.c options
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 quickfix.c quickfix commands (":make", ":cn")
372
a698eb686ded updated for version 7.0096
vimboss
parents: 7
diff changeset
35 regexp.c pattern matching
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 screen.c updating the windows
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 search.c pattern searching
372
a698eb686ded updated for version 7.0096
vimboss
parents: 7
diff changeset
38 spell.c spell checking
a698eb686ded updated for version 7.0096
vimboss
parents: 7
diff changeset
39 syntax.c syntax and other highlighting
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 tag.c tags
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 term.c terminal handling, termcap codes
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 undo.c undo and redo
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 window.c handling split windows
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 IMPORTANT VARIABLES
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 The current mode is stored in "State". The values it can have are NORMAL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 INSERT, CMDLINE, and a few others.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 The current window is "curwin". The current buffer is "curbuf". These point
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 to structures with the cursor position in the window, option values, the file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 name, etc. These are defined in structs.h.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 All the global variables are declared in globals.h.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 THE MAIN LOOP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 This is conveniently called main_loop(). It updates a few things and then
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 calls normal_cmd() to process a command. This returns when the command is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 finished.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 The basic idea is that Vim waits for the user to type a character and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 processes it until another character is needed. Thus there are several places
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 where Vim waits for a character to be typed. The vgetc() function is used for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 this. It also handles mapping.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 Updating the screen is mostly postponed until a command or a sequence of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 commands has finished. The work is done by update_screen(), which calls
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 win_update() for every window, which calls win_line() for every line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 See the start of screen.c for more explanations.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 COMMAND-LINE MODE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 When typing a ":", normal_cmd() will call getcmdline() to obtain a line with
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 an Ex command. getcmdline() contains a loop that will handle each typed
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 character. It returns when hitting <CR> or <Esc> or some other character that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 ends the command line mode.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 EX COMMANDS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 Ex commands are handled by the function do_cmdline(). It does the generic
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 parsing of the ":" command line and calls do_one_cmd() for each separate
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 command. It also takes care of while loops.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 do_one_cmd() parses the range and generic arguments and puts them in the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 exarg_t and passes it to the function that handles the command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 The ":" commands are listed in ex_cmds.h. The third entry of each item is the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 name of the function that handles the command. The last entry are the flags
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 that are used for the command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 NORMAL MODE COMMANDS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 The Normal mode commands are handled by the normal_cmd() function. It also
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 handles the optional count and an extra character for some commands. These
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 are passed in a cmdarg_t to the function that handles the command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 There is a table nv_cmds in normal.c which lists the first character of every
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 command. The second entry of each item is the name of the function that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 handles the command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 INSERT MODE COMMANDS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 When doing an "i" or "a" command, normal_cmd() will call the edit() function.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 It contains a loop that waits for the next character and handles it. It
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 returns when leaving Insert mode.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 OPTIONS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 There is a list with all option names in option.c, called options[].
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 THE GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 Most of the GUI code is implemented like it was a clever terminal. Typing a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 character, moving a scrollbar, clicking the mouse, etc. are all translated
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 into events which are written in the input buffer. These are read by the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 main code, just like reading from a terminal. The code for this is scattered
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 through gui.c. For example: gui_send_mouse_event() for a mouse click and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 gui_menu_cb() for a menu action. Key hits are handled by the system-specific
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 GUI code, which calls add_to_input_buf() to send the key code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 Updating the GUI window is done by writing codes in the output buffer, just
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 like writing to a terminal. When the buffer gets full or is flushed,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 gui_write() will parse the codes and draw the appropriate items. Finally the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 system-specific GUI code will be called to do the work.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 DEBUGGING THE GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 Remember to prevent that gvim forks and the debugger thinks Vim has exited,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 add the "-f" argument. In gdb: "run -f -g".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140
1197
b7ad1c609161 updated for version 7.1b
vimboss
parents: 372
diff changeset
141 When stepping through display updating code, the focus event is triggered
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 when going from the debugger to Vim and back. To avoid this, recompile with
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 some code in gui_focus_change() disabled.