Mirror of the Vim source from https://github.com/vim/vim
Revision | 4ac1dce8dd5e8d8e97e3e7b921f3ada9db2fe2de (tree) |
---|---|
Time | 2004-07-26 21:53:41 |
Author | vimboss |
Commiter | vimboss |
updated for version 7.0012
@@ -148,8 +148,8 @@ | ||
148 | 148 | src/gui_gtk_f.h \ |
149 | 149 | src/gui_gtk_x11.c \ |
150 | 150 | src/gui_kde.cc \ |
151 | - src/gui_kde_widget.cc \ | |
152 | - src/gui_kde_widget.h \ | |
151 | + src/gui_kde_wid.cc \ | |
152 | + src/gui_kde_wid.h \ | |
153 | 153 | src/gui_kde_x11.cc \ |
154 | 154 | src/kvim_iface.h \ |
155 | 155 | src/gui_motif.c \ |
@@ -365,7 +365,7 @@ | ||
365 | 365 | src/os_mac.sit.hqx \ |
366 | 366 | src/os_mac_conv.c \ |
367 | 367 | src/os_macosx.c \ |
368 | - src/os_mac.pbproj/project.pbxproj | |
368 | + src/os_mac.pbproj/project.pbxproj \ | |
369 | 369 | src/proto/gui_mac.pro \ |
370 | 370 | src/proto/os_mac.pro \ |
371 | 371 |
@@ -1,4 +1,4 @@ | ||
1 | -*diff.txt* For Vim version 7.0aa. Last change: 2004 Jul 11 | |
1 | +*diff.txt* For Vim version 7.0aa. Last change: 2004 Jul 20 | |
2 | 2 | |
3 | 3 | |
4 | 4 | VIM REFERENCE MANUAL by Bram Moolenaar |
@@ -344,6 +344,10 @@ | ||
344 | 344 | If it's not clear what the problem is set the 'verbose' option to see more |
345 | 345 | messages. |
346 | 346 | |
347 | +The self-installing Vim includes a diff program. If you don't have it you | |
348 | +might want to download a diff.exe. For example from | |
349 | +http://jlb.twu.net/code/unixkit.php. | |
350 | + | |
347 | 351 | |
348 | 352 | USING PATCHES *diff-patchexpr* |
349 | 353 |
@@ -1,4 +1,4 @@ | ||
1 | -*eval.txt* For Vim version 7.0aa. Last change: 2004 Jul 19 | |
1 | +*eval.txt* For Vim version 7.0aa. Last change: 2004 Jul 25 | |
2 | 2 | |
3 | 3 | |
4 | 4 | VIM REFERENCE MANUAL by Bram Moolenaar |
@@ -846,8 +846,10 @@ | ||
846 | 846 | getcmdline() String return the current command-line |
847 | 847 | getcmdpos() Number return cursor position in command-line |
848 | 848 | getcwd() String the current working directory |
849 | -getfsize( {fname}) Number size in bytes of file | |
849 | +getfperm( {fname}) String file permissions of file {fname} | |
850 | +getfsize( {fname}) Number size in bytes of file {fname} | |
850 | 851 | getftime( {fname}) Number last modification time of file |
852 | +getftype( {fname}) String description of type of file {fname} | |
851 | 853 | getline( {lnum}) String line {lnum} from current buffer |
852 | 854 | getreg( [{regname}]) String contents of register |
853 | 855 | getregtype( [{regname}]) String type of register |
@@ -1580,6 +1582,20 @@ | ||
1580 | 1582 | If {fname} is a directory, 0 is returned. |
1581 | 1583 | If the file {fname} can't be found, -1 is returned. |
1582 | 1584 | |
1585 | +getfperm({fname}) *getfperm()* | |
1586 | + The result is a String, which is the read, write, and execute | |
1587 | + permissions of the given file {fname}. | |
1588 | + If {fname} does not exist or its directory cannot be read, an | |
1589 | + empty string is returned. | |
1590 | + The result is of the form "rwxrwxrwx", where each group of | |
1591 | + "rwx" flags represent, in turn, the permissions of the owner | |
1592 | + of the file, the group the file belongs to, and other users. | |
1593 | + If a user does not have a given permission the flag for this | |
1594 | + is replaced with the string "-". Example: > | |
1595 | + :echo getfperm("/etc/passwd") | |
1596 | +< This will hopefully (from a security point of view) display | |
1597 | + the string "rw-r--r--" or even "rw-------". | |
1598 | + | |
1583 | 1599 | getftime({fname}) *getftime()* |
1584 | 1600 | The result is a Number, which is the last modification time of |
1585 | 1601 | the given file {fname}. The value is measured as seconds |
@@ -1587,6 +1603,26 @@ | ||
1587 | 1603 | |localtime()| and |strftime()|. |
1588 | 1604 | If the file {fname} can't be found -1 is returned. |
1589 | 1605 | |
1606 | +getftype({fname}) *getftype()* | |
1607 | + The result is a String, which is a description of the kind of | |
1608 | + file of the given file {fname}. | |
1609 | + If {fname} does not exist an empty string is returned. | |
1610 | + Here is a table over different kinds of files and their | |
1611 | + results: | |
1612 | + Normal file "file" | |
1613 | + Directory "dir" | |
1614 | + Symbolic link "link" | |
1615 | + Block device "bdev" | |
1616 | + Character device "cdev" | |
1617 | + Socket "socket" | |
1618 | + FIFO "fifo" | |
1619 | + All other "other" | |
1620 | + Example: > | |
1621 | + getftype("/home") | |
1622 | +< Note that a type such as "link" will only be returned on | |
1623 | + systems that support it. On some systems only "dir" and | |
1624 | + "file" are returned. | |
1625 | + | |
1590 | 1626 | *getline()* |
1591 | 1627 | getline({lnum}) The result is a String, which is line {lnum} from the current |
1592 | 1628 | buffer. Example: > |
@@ -2246,14 +2282,16 @@ | ||
2246 | 2282 | cursor position. |
2247 | 2283 | {flags} is a String, which can contain these character flags: |
2248 | 2284 | 'b' search backward instead of forward |
2285 | + 'n' do Not move the cursor | |
2249 | 2286 | 'w' wrap around the end of the file |
2250 | 2287 | 'W' don't wrap around the end of the file |
2251 | 2288 | If neither 'w' or 'W' is given, the 'wrapscan' option applies. |
2252 | 2289 | |
2253 | - When a match has been found its line number is returned, and | |
2254 | - the cursor will be positioned at the match. If there is no | |
2255 | - match a 0 is returned and the cursor doesn't move. No error | |
2256 | - message is given. | |
2290 | + When a match has been found its line number is returned. | |
2291 | + The cursor will be positioned at the match, unless the 'n' | |
2292 | + flag is used). | |
2293 | + If there is no match a 0 is returned and the cursor doesn't | |
2294 | + move. No error message is given. | |
2257 | 2295 | |
2258 | 2296 | Example (goes over all files in the argument list): > |
2259 | 2297 | :let n = 1 |
@@ -2747,9 +2785,15 @@ | ||
2747 | 2785 | the window. The first line is one. |
2748 | 2786 | |
2749 | 2787 | *winnr()* |
2750 | -winnr() The result is a Number, which is the number of the current | |
2751 | - window. The top window has number 1. The number can be used | |
2752 | - with |CTRL-W_w| and ":wincmd w" |:wincmd|. | |
2788 | +winnr([{arg}]) The result is a Number, which is the number of the current | |
2789 | + window. The top window has number 1. | |
2790 | + When the optional argument is "$", the number of the | |
2791 | + last window is returnd (the window count). | |
2792 | + When the optional argument is "#", the number of the last | |
2793 | + accessed window is returned (where |CTRL-W_p| goes to). | |
2794 | + If there is no previous window 0 is returned. | |
2795 | + The number can be used with |CTRL-W_w| and ":wincmd w" | |
2796 | + |:wincmd|. | |
2753 | 2797 | |
2754 | 2798 | *winrestcmd()* |
2755 | 2799 | winrestcmd() Returns a sequence of |:resize| commands that should restore |
@@ -1,4 +1,4 @@ | ||
1 | -*if_cscop.txt* For Vim version 7.0aa. Last change: 2004 Jan 17 | |
1 | +*if_cscop.txt* For Vim version 7.0aa. Last change: 2004 Jul 23 | |
2 | 2 | |
3 | 3 | |
4 | 4 | VIM REFERENCE MANUAL by Andy Kahn |
@@ -335,6 +335,9 @@ | ||
335 | 335 | |
336 | 336 | http://iamphet.nm.ru/cscope/index.html |
337 | 337 | |
338 | +The DJGPP-built version from http://cscope.sourceforge.net is known to not | |
339 | +work with Vim. | |
340 | + | |
338 | 341 | There are a couple of hard-coded limitations: |
339 | 342 | |
340 | 343 | 1. The maximum number of cscope connections allowed is 8. Do you |
@@ -1,4 +1,4 @@ | ||
1 | -*if_pyth.txt* For Vim version 7.0aa. Last change: 2004 Feb 28 | |
1 | +*if_pyth.txt* For Vim version 7.0aa. Last change: 2004 Jul 25 | |
2 | 2 | |
3 | 3 | |
4 | 4 | VIM REFERENCE MANUAL by Paul Moore |
@@ -91,23 +91,23 @@ | ||
91 | 91 | :python import vim |
92 | 92 | |
93 | 93 | Overview > |
94 | - print "Hello" # displays a message | |
95 | - vim.command(cmd) # execute an ex command | |
96 | - w = vim.windows[n] # gets window "n" | |
97 | - cw = vim.current.window # gets the current window | |
98 | - b = vim.buffers[n] # gets buffer "n" | |
99 | - cb = vim.current.buffer # gets the current buffer | |
100 | - w.height = lines # sets the window height | |
101 | - w.cursor = (row, col) # sets the window cursor position | |
102 | - pos = w.cursor # gets a tuple (row, col) | |
103 | - name = b.name # gets the buffer file name | |
104 | - line = b[n] # gets a line from the buffer | |
105 | - lines = b[n:m] # gets a list of lines | |
106 | - num = len(b) # gets the number of lines | |
107 | - b[n] = str # sets a line in the buffer | |
108 | - b[n:m] = [str1, str2, str3] # sets a number of lines at once | |
109 | - del b[n] # deletes a line | |
110 | - del b[n:m] # deletes a number of lines | |
94 | + :py print "Hello" # displays a message | |
95 | + :py vim.command(cmd) # execute an ex command | |
96 | + :py w = vim.windows[n] # gets window "n" | |
97 | + :py cw = vim.current.window # gets the current window | |
98 | + :py b = vim.buffers[n] # gets buffer "n" | |
99 | + :py cb = vim.current.buffer # gets the current buffer | |
100 | + :py w.height = lines # sets the window height | |
101 | + :py w.cursor = (row, col) # sets the window cursor position | |
102 | + :py pos = w.cursor # gets a tuple (row, col) | |
103 | + :py name = b.name # gets the buffer file name | |
104 | + :py line = b[n] # gets a line from the buffer | |
105 | + :py lines = b[n:m] # gets a list of lines | |
106 | + :py num = len(b) # gets the number of lines | |
107 | + :py b[n] = str # sets a line in the buffer | |
108 | + :py b[n:m] = [str1, str2, str3] # sets a number of lines at once | |
109 | + :py del b[n] # deletes a line | |
110 | + :py del b[n:m] # deletes a number of lines | |
111 | 111 | |
112 | 112 | |
113 | 113 | Methods of the "vim" module |
@@ -115,8 +115,8 @@ | ||
115 | 115 | vim.command(str) *python-command* |
116 | 116 | Executes the vim (ex-mode) command str. Returns None. |
117 | 117 | Examples: > |
118 | - vim.command("set tw=72") | |
119 | - vim.command("%s/aaa/bbb/g") | |
118 | + :py vim.command("set tw=72") | |
119 | + :py vim.command("%s/aaa/bbb/g") | |
120 | 120 | < The following definition executes Normal mode commands: > |
121 | 121 | def normal(str): |
122 | 122 | vim.command("normal "+str) |
@@ -126,15 +126,15 @@ | ||
126 | 126 | < *E659* |
127 | 127 | The ":python" command cannot be used recursively with Python 2.2 and |
128 | 128 | older. This only works with Python 2.3 and later: > |
129 | - :python vim.command("python print 'Hello again Python'") | |
129 | + :py vim.command("python print 'Hello again Python'") | |
130 | 130 | |
131 | 131 | vim.eval(str) *python-eval* |
132 | 132 | Evaluates the expression str using the vim internal expression |
133 | 133 | evaluator (see |expression|). Returns the expression result as a |
134 | 134 | string. |
135 | 135 | Examples: > |
136 | - text_width = vim.eval("&tw") | |
137 | - str = vim.eval("12+12") # NB result is a string! Use | |
136 | + :py text_width = vim.eval("&tw") | |
137 | + :py str = vim.eval("12+12") # NB result is a string! Use | |
138 | 138 | # string.atoi() to convert to |
139 | 139 | # a number. |
140 | 140 |
@@ -158,18 +158,18 @@ | ||
158 | 158 | vim.buffers *python-buffers* |
159 | 159 | A sequence object providing access to the list of vim buffers. The |
160 | 160 | object supports the following operations: > |
161 | - b = vim.buffers[i] # Indexing (read-only) | |
162 | - b in vim.buffers # Membership test | |
163 | - n = len(vim.buffers) # Number of elements | |
164 | - for b in vim.buffers: # Sequential access | |
161 | + :py b = vim.buffers[i] # Indexing (read-only) | |
162 | + :py b in vim.buffers # Membership test | |
163 | + :py n = len(vim.buffers) # Number of elements | |
164 | + :py for b in vim.buffers: # Sequential access | |
165 | 165 | < |
166 | 166 | vim.windows *python-windows* |
167 | 167 | A sequence object providing access to the list of vim windows. The |
168 | 168 | object supports the following operations: > |
169 | - w = vim.windows[i] # Indexing (read-only) | |
170 | - w in vim.windows # Membership test | |
171 | - n = len(vim.windows) # Number of elements | |
172 | - for w in vim.windows: # Sequential access | |
169 | + :py w = vim.windows[i] # Indexing (read-only) | |
170 | + :py w in vim.windows # Membership test | |
171 | + :py n = len(vim.windows) # Number of elements | |
172 | + :py for w in vim.windows: # Sequential access | |
173 | 173 | < |
174 | 174 | vim.current *python-current* |
175 | 175 | An object providing access (via specific attributes) to various |
@@ -236,17 +236,21 @@ | ||
236 | 236 | represents the part of the given buffer between line |
237 | 237 | numbers s and e |inclusive|. |
238 | 238 | |
239 | +Note that when adding a line it must not contain a line break character '\n'. | |
240 | +A trailing '\n' is allowed and ignored, so that you can do: > | |
241 | + :py b.append(f.readlines()) | |
242 | + | |
239 | 243 | Examples (assume b is the current buffer) > |
240 | - print b.name # write the buffer file name | |
241 | - b[0] = "hello!!!" # replace the top line | |
242 | - b[:] = None # delete the whole buffer | |
243 | - del b[:] # delete the whole buffer (same as above) | |
244 | - b[0:0] = [ "a line" ] # add a line at the top | |
245 | - del b[2] # delete a line (the third) | |
246 | - b.append("bottom") # add a line at the bottom | |
247 | - n = len(b) # number of lines | |
248 | - (row,col) = b.mark('a') # named mark | |
249 | - r = b.range(1,5) # a sub-range of the buffer | |
244 | + :py print b.name # write the buffer file name | |
245 | + :py b[0] = "hello!!!" # replace the top line | |
246 | + :py b[:] = None # delete the whole buffer | |
247 | + :py del b[:] # delete the whole buffer | |
248 | + :py b[0:0] = [ "a line" ] # add a line at the top | |
249 | + :py del b[2] # delete a line (the third) | |
250 | + :py b.append("bottom") # add a line at the bottom | |
251 | + :py n = len(b) # number of lines | |
252 | + :py (row,col) = b.mark('a') # named mark | |
253 | + :py r = b.range(1,5) # a sub-range of the buffer | |
250 | 254 | |
251 | 255 | ============================================================================== |
252 | 256 | 4. Range objects *python-range* |
@@ -1,4 +1,4 @@ | ||
1 | -*message.txt* For Vim version 7.0aa. Last change: 2004 Jan 17 | |
1 | +*message.txt* For Vim version 7.0aa. Last change: 2004 Jul 23 | |
2 | 2 | |
3 | 3 | |
4 | 4 | VIM REFERENCE MANUAL by Bram Moolenaar |
@@ -643,6 +643,7 @@ | ||
643 | 643 | A command line started with a backslash or the range of a command contained a |
644 | 644 | backslash in a wrong place. This is often caused by command-line continuation |
645 | 645 | being disabled. Remove the 'C' flag from the 'cpoptions' option to enable it. |
646 | +Or use ":set nocp". | |
646 | 647 | |
647 | 648 | *E471* > |
648 | 649 | Argument required |
@@ -1,4 +1,4 @@ | ||
1 | -*motion.txt* For Vim version 7.0aa. Last change: 2004 Jul 02 | |
1 | +*motion.txt* For Vim version 7.0aa. Last change: 2004 Jul 25 | |
2 | 2 | |
3 | 3 | |
4 | 4 | VIM REFERENCE MANUAL by Bram Moolenaar |
@@ -83,6 +83,7 @@ | ||
83 | 83 | end of the motion is moved to the end of the previous line and the motion |
84 | 84 | becomes inclusive. Example: "}" moves to the first line after a paragraph, |
85 | 85 | but "d}" will not include that line. |
86 | + *exclusive-linewise* | |
86 | 87 | 2. If the motion is exclusive, the end of the motion is in column 1 and the |
87 | 88 | start of the motion was at or before the first non-blank in the line, the |
88 | 89 | motion becomes linewise. Example: If a paragraph begins with some blanks |
@@ -424,20 +425,24 @@ | ||
424 | 425 | |
425 | 426 | *]]* |
426 | 427 | ]] [count] sections forward or to the next '{' in the |
427 | - first column. When used after an operator, then the | |
428 | - '}' in the first column. |linewise| | |
428 | + first column. When used after an operator, then also | |
429 | + stops below a '}' in the first column. |exclusive| | |
430 | + Note that |exclusive-linewise| often applies. | |
429 | 431 | |
430 | 432 | *][* |
431 | 433 | ][ [count] sections forward or to the next '}' in the |
432 | - first column. |linewise| | |
434 | + first column. |exclusive| | |
435 | + Note that |exclusive-linewise| often applies. | |
433 | 436 | |
434 | 437 | *[[* |
435 | 438 | [[ [count] sections backward or to the previous '{' in |
436 | - the first column. |linewise| | |
439 | + the first column. |exclusive| | |
440 | + Note that |exclusive-linewise| often applies. | |
437 | 441 | |
438 | 442 | *[]* |
439 | 443 | [] [count] sections backward or to the previous '}' in |
440 | - the first column. |linewise| | |
444 | + the first column. |exclusive| | |
445 | + Note that |exclusive-linewise| often applies. | |
441 | 446 | |
442 | 447 | These commands move over three kinds of text objects. |
443 | 448 |
@@ -1,4 +1,4 @@ | ||
1 | -*options.txt* For Vim version 7.0aa. Last change: 2004 Jul 15 | |
1 | +*options.txt* For Vim version 7.0aa. Last change: 2004 Jul 24 | |
2 | 2 | |
3 | 3 | |
4 | 4 | VIM REFERENCE MANUAL by Bram Moolenaar |
@@ -3924,7 +3924,7 @@ | ||
3924 | 3924 | NOTE: To avoid portability problems with using patterns, always keep |
3925 | 3925 | this option at the default "on". Only switch it off when working with |
3926 | 3926 | old Vi scripts. In any other situation write patterns that work when |
3927 | - 'magic' is on. | |
3927 | + 'magic' is on. Include "\M" when you want to |/\M|. | |
3928 | 3928 | |
3929 | 3929 | *'makeef'* *'mef'* |
3930 | 3930 | 'makeef' 'mef' string (default: "") |
@@ -1,4 +1,4 @@ | ||
1 | -*pattern.txt* For Vim version 7.0aa. Last change: 2004 May 09 | |
1 | +*pattern.txt* For Vim version 7.0aa. Last change: 2004 Jul 24 | |
2 | 2 | |
3 | 3 | |
4 | 4 | VIM REFERENCE MANUAL by Bram Moolenaar |
@@ -382,7 +382,7 @@ | ||
382 | 382 | |/\%c| \%23c \%23c in column 23 |/zero-width| |
383 | 383 | |/\%v| \%23v \%23v in virtual column 23 |/zero-width| |
384 | 384 | |
385 | -Character classes {not in Vi}: | |
385 | +Character classes {not in Vi}: */character-classes* | |
386 | 386 | |/\i| \i \i identifier character (see 'isident' option) |
387 | 387 | |/\I| \I \I like "\i", but excluding digits |
388 | 388 | |/\k| \k \k keyword character (see 'iskeyword' option) |
@@ -1337,6 +1337,7 @@ | ||
1337 | 1337 | /atom pattern.txt /*\/atom* |
1338 | 1338 | /bar pattern.txt /*\/bar* |
1339 | 1339 | /branch pattern.txt /*\/branch* |
1340 | +/character-classes pattern.txt /*\/character-classes* | |
1340 | 1341 | /collection pattern.txt /*\/collection* |
1341 | 1342 | /concat pattern.txt /*\/concat* |
1342 | 1343 | /dyn various.txt /*\/dyn* |
@@ -3570,6 +3571,7 @@ | ||
3570 | 3571 | Eterm syntax.txt /*Eterm* |
3571 | 3572 | Ex intro.txt /*Ex* |
3572 | 3573 | Ex-mode intro.txt /*Ex-mode* |
3574 | +Exuberant_ctags tagsrch.txt /*Exuberant_ctags* | |
3573 | 3575 | F motion.txt /*F* |
3574 | 3576 | FAQ intro.txt /*FAQ* |
3575 | 3577 | Farsi farsi.txt /*Farsi* |
@@ -4518,6 +4520,7 @@ | ||
4518 | 4520 | exception-handling eval.txt /*exception-handling* |
4519 | 4521 | exception-variable eval.txt /*exception-variable* |
4520 | 4522 | exclusive motion.txt /*exclusive* |
4523 | +exclusive-linewise motion.txt /*exclusive-linewise* | |
4521 | 4524 | executable() eval.txt /*executable()* |
4522 | 4525 | execute-menus gui.txt /*execute-menus* |
4523 | 4526 | exim starting.txt /*exim* |
@@ -4625,6 +4628,7 @@ | ||
4625 | 4628 | filter change.txt /*filter* |
4626 | 4629 | find-manpage usr_12.txt /*find-manpage* |
4627 | 4630 | find-replace usr_10.txt /*find-replace* |
4631 | +finddir() eval.txt /*finddir()* | |
4628 | 4632 | findfile() eval.txt /*findfile()* |
4629 | 4633 | fixed-5.1 version5.txt /*fixed-5.1* |
4630 | 4634 | fixed-5.2 version5.txt /*fixed-5.2* |
@@ -4773,8 +4777,10 @@ | ||
4773 | 4777 | getcmdline() eval.txt /*getcmdline()* |
4774 | 4778 | getcmdpos() eval.txt /*getcmdpos()* |
4775 | 4779 | getcwd() eval.txt /*getcwd()* |
4780 | +getfperm() eval.txt /*getfperm()* | |
4776 | 4781 | getfsize() eval.txt /*getfsize()* |
4777 | 4782 | getftime() eval.txt /*getftime()* |
4783 | +getftype() eval.txt /*getftype()* | |
4778 | 4784 | getline() eval.txt /*getline()* |
4779 | 4785 | getreg() eval.txt /*getreg()* |
4780 | 4786 | getregtype() eval.txt /*getregtype()* |
@@ -1,4 +1,4 @@ | ||
1 | -*tagsrch.txt* For Vim version 7.0aa. Last change: 2004 Apr 29 | |
1 | +*tagsrch.txt* For Vim version 7.0aa. Last change: 2004 Jul 23 | |
2 | 2 | |
3 | 3 | |
4 | 4 | VIM REFERENCE MANUAL by Bram Moolenaar |
@@ -468,6 +468,7 @@ | ||
468 | 468 | Some programs that generate tags files: |
469 | 469 | ctags As found on most Unix systems. Only supports C. Only |
470 | 470 | does the basic work. |
471 | + *Exuberant_ctags* | |
471 | 472 | exuberant ctags This a very good one. It works for C, C++, Java, |
472 | 473 | Fortran, Eiffel and others. It can generate tags for |
473 | 474 | many items. See http://ctags.sourceforge.net. |
@@ -1,4 +1,4 @@ | ||
1 | -*todo.txt* For Vim version 7.0aa. Last change: 2004 Jul 19 | |
1 | +*todo.txt* For Vim version 7.0aa. Last change: 2004 Jul 26 | |
2 | 2 | |
3 | 3 | |
4 | 4 | VIM REFERENCE MANUAL by Bram Moolenaar |
@@ -30,27 +30,18 @@ | ||
30 | 30 | *known-bugs* |
31 | 31 | -------------------- Known bugs and current work ----------------------- |
32 | 32 | |
33 | -Add fix for zh_cn to Vim 6.3? (Liang) | |
33 | +Aborting at the ATTENTION prompt causes trouble: | |
34 | + buffer remains active, nwindows isn't closed (fixed in buffer.c) | |
35 | + alternate buffer gets "read error" flag. | |
36 | + ":sbuf" and ":ball" leave an empty window behind. | |
37 | +Change in handle_swap_exists() also in 6.3? | |
34 | 38 | |
35 | 39 | |
36 | 40 | For version 7.0: |
37 | 41 | - Include many PATCHES: |
38 | 42 | 8 Add functions: |
39 | - realname() Get user name (first, last, full) | |
40 | - user_fullname() patch by Nikolai Weibull, Nov | |
41 | - 3 2002) | |
42 | - getfperm() file permissions, in form "rwxrwxrwx" | |
43 | - (patch from Nikolai Weibull 2003 Jan 13) | |
44 | - getftype() "file", "dir", "link", "other"? | |
45 | - (patch from Nikolai Weibull 2003 Jan 13) | |
46 | 43 | setbufline() set line in any buffer (patch from Yegappan |
47 | 44 | Lakshmanan, 2003 Jan 21) |
48 | - winnr("$") Get number of windows. (patch from Nikolai | |
49 | - Weibull 2003 Jan 13) (another patch from | |
50 | - Yegappan Lakshmanan, 2004 Jul 11) | |
51 | - search() Add optional offset argument. | |
52 | - Add 'n' flag. (patch from Nikolai Weibull | |
53 | - 2003 Jan 13) | |
54 | 45 | filter() Patch from Yegappan Lakshmanan, 2004 Jul 11 |
55 | 46 | 8 Make it possible to delete marks. Charles Campbell has a patch that |
56 | 47 | does this with the markclear() function (2004 Jan 9). |
@@ -63,6 +54,7 @@ | ||
63 | 54 | When "filename" has no wildcards and there is no matching buffer, add |
64 | 55 | the buffer (unlisted). |
65 | 56 | Patch for \xnn (Ciaran McCreesh) 2004 Jul 10 |
57 | + http://dev.gentoo.org/~ciaranm/patches/vim/vim-7.00a-regexp-numbered-characters-r5.patch | |
66 | 58 | 7 Add 'taglistfiles' option, show file name and type when listing matching |
67 | 59 | tags name with CTRL-D completion. Patch from Yegappan Lakshmanan. |
68 | 60 | 2004 Jul 11 |
@@ -72,6 +64,15 @@ | ||
72 | 64 | 8 Make 'statusline' local, so that each window can have a different |
73 | 65 | value. But should it also be local to a buffer? (Yegappan Lakshmanan |
74 | 66 | has a patch, 2004 Jul 11) |
67 | + 8 Add buffer-local autocommands? Reduces overhead for autocommands that | |
68 | + trigger often (inserting a character, switching mode). | |
69 | + :au Event <buffer> do-something | |
70 | + E.g.: | |
71 | + :au BufEnter <buffer> menu enable ... | |
72 | + :au BufLeave <buffer> menu disable ... | |
73 | + Patch from Yakov Lerner, including test (2004 Jan 7). | |
74 | + VimResized - When the Vim window has been resized (SIGWINCH) | |
75 | + patch from Yakov Lerner, 2003 July 24. | |
75 | 76 | --- awaiting updated patch --- |
76 | 77 | 7 Add patch from Wall for this one ( ~/Mail/oldmail/wall/in.00019 ): |
77 | 78 | 'flipcase' variable: upper/lowercase pairs. |
@@ -84,18 +85,7 @@ | ||
84 | 85 | 8 Add ":n" to fnamemodify(): normalize path, remove "../" when possible. |
85 | 86 | Aric Blumer has a patch for this. |
86 | 87 | He will update the patch for 6.3. |
87 | - 8 Add buffer-local autocommands? Reduces overhead for autocommands that | |
88 | - trigger often (inserting a character, switching mode). | |
89 | - :au Event <buffer> do-something | |
90 | - E.g.: | |
91 | - :au BufEnter <buffer> menu enable ... | |
92 | - :au BufLeave <buffer> menu disable ... | |
93 | - Patch from Yakov Lerner, including test (2004 Jan 7). | |
94 | - He'll send updated patch. | |
95 | 88 | Autocommands: |
96 | - VimResized - When the Vim window has been resized (SIGWINCH) | |
97 | - patch from Yakov Lerner, 2003 July 24. | |
98 | - He'll write documentation and send updated patch. | |
99 | 89 | 7 Completion of network shares, patch by Yasuhiro Matsumoto. |
100 | 90 | Update 2004 Jun 17. |
101 | 91 | How does this work? Missing comments. |
@@ -1458,6 +1448,14 @@ | ||
1458 | 1448 | 7 Add argument to winwidth() to subtract the space taken by 'foldcolumn', |
1459 | 1449 | signs and/or 'number'. |
1460 | 1450 | 8 Add functions: |
1451 | + search() Add optional offset argument. | |
1452 | + realname() Get user name (first, last, full) | |
1453 | + user_fullname() patch by Nikolai Weibull, Nov | |
1454 | + 3 2002 | |
1455 | + Only add this when also implemented for | |
1456 | + non-Unix systems, otherwise a shell cmd could | |
1457 | + be used. | |
1458 | + get_user_name() gets login name. | |
1461 | 1459 | menuprop({name}, {idx}, {what}) |
1462 | 1460 | Get menu property of menu {name} item {idx}. |
1463 | 1461 | menuprop("", 1, "name") returns "File". |
@@ -3196,6 +3194,7 @@ | ||
3196 | 3194 | column number. Can use the code of ":helpgrep". |
3197 | 3195 | Also support using "**" in filename, so that a directory tree can be |
3198 | 3196 | searched. |
3197 | + Also see the "minigrep.vim" script on www.vim.org. | |
3199 | 3198 | - Change ":fixdel" into option 'fixdel', t_del will be adjusted each time |
3200 | 3199 | t_bs is set? (Webb) |
3201 | 3200 | - "gc": goto character, move absolute character positions forward, also |
@@ -1,4 +1,4 @@ | ||
1 | -*version7.txt* For Vim version 7.0aa. Last change: 2004 Jul 19 | |
1 | +*version7.txt* For Vim version 7.0aa. Last change: 2004 Jul 25 | |
2 | 2 | |
3 | 3 | |
4 | 4 | VIM REFERENCE MANUAL by Bram Moolenaar |
@@ -127,6 +127,9 @@ | ||
127 | 127 | finddir(name) |finddir()| Find a directory in 'path'. |
128 | 128 | findfile(name) |findfile()| Find a file in 'path'. (Johannes |
129 | 129 | Zellner) |
130 | +getfperm(fname) |getfperm()| Get file permission string. (Nikolai | |
131 | + Weibull) | |
132 | +getftype(fname) |getftype()| Get type of file. (Nikolai Weibull) | |
130 | 133 | repeat(expr, count) |repeat()| Repeat "expr" "count" times. |
131 | 134 | (Christophe Poucet) |
132 | 135 | tr(expr, from, to) |tr()| Translate characters. (Ron Aaron) |
@@ -187,6 +190,11 @@ | ||
187 | 190 | |
188 | 191 | Added the "count" argument to match(), matchend() and matchstr(). (Ilya Sher) |
189 | 192 | |
193 | +winnr() takes an optional "$" and "#" arguments. (Nikolai Weibull, Yegappan | |
194 | +Lakshmanan) | |
195 | + | |
196 | +Added 'n' flag to search(): don't move the cursor. (Nikolai Weibull) | |
197 | + | |
190 | 198 | ============================================================================== |
191 | 199 | COMPILE TIME CHANGES *compile-changes-7* |
192 | 200 |
@@ -272,4 +280,13 @@ | ||
272 | 280 | The default for 'helplang' was "zh" for both "zh_cn" and "zh_tw". Now use |
273 | 281 | "cn" or "tw" as intended. |
274 | 282 | |
283 | +When 'bin' is set and 'eol' is not set then line2byte() added the line break | |
284 | +after the last line while it's not there. | |
285 | + | |
286 | +Using foldlevel() in a WinEnter autocommand may not work. Noticed when | |
287 | +resizing the GUI shell upon startup. | |
288 | + | |
289 | +Python: Using buffer.append(f.readlines()) didn't work. Allow appending a | |
290 | +string with a trailing newline. The newline is ignored. | |
291 | + | |
275 | 292 | vim:tw=78:ts=8:ft=help:norl: |
@@ -1,10 +1,10 @@ | ||
1 | 1 | " Vim settings file |
2 | 2 | " Language: LambdaProlog (Teyjus) |
3 | 3 | " Maintainer: Markus Mottl <markus@oefai.at> |
4 | -" URL: http://www.ai.univie.ac.at/~markus/vim/ftplugin/lprolog.vim | |
5 | -" Last Change: 2003 May 11 | |
6 | -" 2001 Sep 16 - fixed 'no_mail_maps'-bug (MM) | |
7 | -" 2001 Sep 02 - initial release (MM) | |
4 | +" URL: http://www.oefai.at/~markus/vim/ftplugin/lprolog.vim | |
5 | +" Last Change: 2001 Oct 02 - fixed uncommenting bug (MM) | |
6 | +" 2001 Sep 16 - fixed 'no_mail_maps'-bug (MM) | |
7 | +" 2001 Sep 02 - initial release (MM) | |
8 | 8 | |
9 | 9 | " Only do these settings when not done yet for this buffer |
10 | 10 | if exists("b:did_ftplugin") |
@@ -1,12 +1,14 @@ | ||
1 | 1 | " Vim settings file |
2 | 2 | " Language: OCaml |
3 | -" Maintainers: Mike Leary <leary@nwlink.com> | |
4 | -" Markus Mottl <markus@oefai.at> | |
5 | -" URL: http://www.ai.univie.ac.at/~markus/vim/ftplugin/ocaml.vim | |
6 | -" Last Change: 2003 May 11 | |
7 | -" 2001 Nov 01 - added local bindings for inserting | |
8 | -" type holes using 'assert false' (MM) | |
9 | -" 2001 Oct 02 - insert spaces in line comments (MM) | |
3 | +" Maintainers: Mike Leary <leary@nwlink.com> | |
4 | +" Markus Mottl <markus@oefai.at> | |
5 | +" Stefano Zacchiroli <zack@bononia.it> | |
6 | +" URL: http://www.oefai.at/~markus/vim/ftplugin/ocaml.vim | |
7 | +" Last Change: 2004 Apr 12 - better .ml/.mli-switching without Python (SZ) | |
8 | +" 2003 Nov 21 - match_words-patterns and .ml/.mli-switching (MM) | |
9 | +" 2003 Oct 16 - re-entered variable 'did_ocaml_dtypes' (MM) | |
10 | +" 2003 Oct 15 - added Stefano Zacchirolis (SZ) Python-code for | |
11 | +" displaying type annotations (MM) | |
10 | 12 | |
11 | 13 | " Only do these settings when not done yet for this buffer |
12 | 14 | if exists("b:did_ftplugin") |
@@ -47,3 +49,253 @@ | ||
47 | 49 | iabbrev <buffer> ASS (assert false) |
48 | 50 | endif |
49 | 51 | endif |
52 | + | |
53 | +" Let % jump between structure elements (due to Issac Trotts) | |
54 | +let b:mw='\<let\>:\<and\>:\(\<in\>\|;;\),' | |
55 | +let b:mw=b:mw . '\<if\>:\<then\>:\<else\>,\<do\>:\<done\>,' | |
56 | +let b:mw=b:mw . '\<\(object\|sig\|struct\|begin\)\>:\<end\>' | |
57 | +let b:match_words=b:mw | |
58 | + | |
59 | +" switching between interfaces (.mli) and implementations (.ml) | |
60 | +if !exists("g:did_ocaml_switch") | |
61 | + let g:did_ocaml_switch = 1 | |
62 | + map ,s :call OCaml_switch(0)<CR> | |
63 | + map ,S :call OCaml_switch(1)<CR> | |
64 | + fun OCaml_switch(newwin) | |
65 | + if (match(bufname(""), "\\.mli$") >= 0) | |
66 | + let fname = substitute(bufname(""), "\\.mli$", ".ml", "") | |
67 | + if (a:newwin == 1) | |
68 | + exec "new " . fname | |
69 | + else | |
70 | + exec "arge " . fname | |
71 | + endif | |
72 | + elseif (match(bufname(""), "\\.ml$") >= 0) | |
73 | + let fname = bufname("") . "i" | |
74 | + if (a:newwin == 1) | |
75 | + exec "new " . fname | |
76 | + else | |
77 | + exec "arge " . fname | |
78 | + endif | |
79 | + endif | |
80 | + endfun | |
81 | +endif | |
82 | + | |
83 | +" Vim support for OCaml 3.07 .annot files (requires Vim with python support) | |
84 | +" | |
85 | +" Executing OCamlPrintType(<mode>) function will display in the Vim bottom | |
86 | +" line(s) the type of an ocaml value getting it from the corresponding .annot | |
87 | +" file (if any). If Vim is in visual mode, <mode> should be "visual" and the | |
88 | +" selected ocaml value correspond to the highlighted text, otherwise (<mode> | |
89 | +" can be anything else) it corresponds to the literal found at the current | |
90 | +" cursor position. | |
91 | +" | |
92 | +" .annot files are parsed lazily the first time OCamlPrintType is invoked; is | |
93 | +" also possible to force the parsing using the OCamlParseAnnot() function. | |
94 | +" | |
95 | +" Hitting the <F3> key will cause OCamlPrintType function to be invoked with | |
96 | +" the right argument depending on the current mode (visual or not). | |
97 | +" | |
98 | +" Copyright (C) <2003> Stefano Zacchiroli <zack@bononia.it> | |
99 | +" | |
100 | +" Created: Wed, 01 Oct 2003 18:16:22 +0200 zack | |
101 | +" LastModified: Mon, 06 Oct 2003 11:05:39 +0200 zack | |
102 | +" | |
103 | +" This program is free software; you can redistribute it and/or modify | |
104 | +" it under the terms of the GNU General Public License as published by | |
105 | +" the Free Software Foundation; either version 2 of the License, or | |
106 | +" (at your option) any later version. | |
107 | +" | |
108 | +" This program is distributed in the hope that it will be useful, | |
109 | +" but WITHOUT ANY WARRANTY; without even the implied warranty of | |
110 | +" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
111 | +" GNU General Public License for more details. | |
112 | +" | |
113 | +" You should have received a copy of the GNU General Public License | |
114 | +" along with this program; if not, write to the Free Software | |
115 | +" Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
116 | +" | |
117 | + | |
118 | +if !has("python") | |
119 | + echo "Python support not found: OCaml .annot support disabled" | |
120 | + finish | |
121 | +endif | |
122 | + | |
123 | +if !exists("g:did_ocaml_dtypes") | |
124 | + let g:did_ocaml_dtypes = 1 | |
125 | +else | |
126 | + finish | |
127 | +endif | |
128 | + | |
129 | +python << EOF | |
130 | + | |
131 | +import re | |
132 | +import os | |
133 | +import string | |
134 | +import time | |
135 | +import vim | |
136 | + | |
137 | +debug = False | |
138 | + | |
139 | +class AnnExc(Exception): | |
140 | + def __init__(self, reason): | |
141 | + self.reason = reason | |
142 | + | |
143 | +no_annotations = AnnExc("No type annotations (.annot) file found") | |
144 | +annotation_not_found = AnnExc("No type annotation found for the given text") | |
145 | +def malformed_annotations(lineno): | |
146 | + return AnnExc("Malformed .annot file (line = %d)" % lineno) | |
147 | + | |
148 | +class Annotations: | |
149 | + """ | |
150 | + .annot ocaml file representation | |
151 | + | |
152 | + File format (copied verbatim from caml-types.el) | |
153 | + | |
154 | + file ::= block * | |
155 | + block ::= position <SP> position <LF> annotation * | |
156 | + position ::= filename <SP> num <SP> num <SP> num | |
157 | + annotation ::= keyword open-paren <LF> <SP> <SP> data <LF> close-paren | |
158 | + | |
159 | + <SP> is a space character (ASCII 0x20) | |
160 | + <LF> is a line-feed character (ASCII 0x0A) | |
161 | + num is a sequence of decimal digits | |
162 | + filename is a string with the lexical conventions of O'Caml | |
163 | + open-paren is an open parenthesis (ASCII 0x28) | |
164 | + close-paren is a closed parenthesis (ASCII 0x29) | |
165 | + data is any sequence of characters where <LF> is always followed by | |
166 | + at least two space characters. | |
167 | + | |
168 | + - in each block, the two positions are respectively the start and the | |
169 | + - end of the range described by the block. | |
170 | + - in a position, the filename is the name of the file, the first num | |
171 | + is the line number, the second num is the offset of the beginning | |
172 | + of the line, the third num is the offset of the position itself. | |
173 | + - the char number within the line is the difference between the third | |
174 | + and second nums. | |
175 | + | |
176 | + For the moment, the only possible keyword is \"type\"." | |
177 | + """ | |
178 | + | |
179 | + def __init__(self): | |
180 | + self.__filename = None # last .annot parsed file | |
181 | + self.__ml_filename = None # as above but s/.annot/.ml/ | |
182 | + self.__timestamp = None # last parse action timestamp | |
183 | + self.__annot = {} | |
184 | + self.__re = re.compile( | |
185 | + '^"[^"]+"\s+(\d+)\s+(\d+)\s+(\d+)\s+"[^"]+"\s+(\d+)\s+(\d+)\s+(\d+)$') | |
186 | + | |
187 | + def __parse(self, fname): | |
188 | + try: | |
189 | + f = open(fname) | |
190 | + line = f.readline() # position line | |
191 | + lineno = 1 | |
192 | + while (line != ""): | |
193 | + m = self.__re.search(line) | |
194 | + if (not m): | |
195 | + raise malformed_annotations(lineno) | |
196 | + line1 = int(m.group(1)) | |
197 | + col1 = int(m.group(3)) - int(m.group(2)) | |
198 | + line2 = int(m.group(4)) | |
199 | + col2 = int(m.group(6)) - int(m.group(5)) | |
200 | + line = f.readline() # "type(" string | |
201 | + lineno += 1 | |
202 | + if (line == ""): raise malformed_annotations(lineno) | |
203 | + type = [] | |
204 | + line = f.readline() # type description | |
205 | + lineno += 1 | |
206 | + if (line == ""): raise malformed_annotations(lineno) | |
207 | + while line != ")\n": | |
208 | + type.append(string.strip(line)) | |
209 | + line = f.readline() | |
210 | + lineno += 1 | |
211 | + if (line == ""): raise malformed_annotations(lineno) | |
212 | + type = string.join(type, "\n") | |
213 | + self.__annot[(line1, col1), (line2, col2)] = type | |
214 | + line = f.readline() # position line | |
215 | + f.close() | |
216 | + self.__filename = fname | |
217 | + self.__ml_filename = re.sub("\.annot$", ".ml", fname) | |
218 | + self.__timestamp = int(time.time()) | |
219 | + except IOError: | |
220 | + raise no_annotations | |
221 | + | |
222 | + def parse(self): | |
223 | + annot_file = re.sub("\.ml$", ".annot", vim.current.buffer.name) | |
224 | + self.__parse(annot_file) | |
225 | + | |
226 | + def get_type(self, (line1, col1), (line2, col2)): | |
227 | + if debug: | |
228 | + print line1, col1, line2, col2 | |
229 | + if vim.current.buffer.name == None: | |
230 | + raise no_annotations | |
231 | + if vim.current.buffer.name != self.__ml_filename or \ | |
232 | + os.stat(self.__filename).st_mtime > self.__timestamp: | |
233 | + self.parse() | |
234 | + try: | |
235 | + return self.__annot[(line1, col1), (line2, col2)] | |
236 | + except KeyError: | |
237 | + raise annotation_not_found | |
238 | + | |
239 | +word_char_RE = re.compile("^[\w.]$") | |
240 | + | |
241 | + # TODO this function should recognize ocaml literals, actually it's just an | |
242 | + # hack that recognize continuous sequences of word_char_RE above | |
243 | +def findBoundaries(line, col): | |
244 | + """ given a cursor position (as returned by vim.current.window.cursor) | |
245 | + return two integers identify the beggining and end column of the word at | |
246 | + cursor position, if any. If no word is at the cursor position return the | |
247 | + column cursor position twice """ | |
248 | + left, right = col, col | |
249 | + line = line - 1 # mismatch vim/python line indexes | |
250 | + (begin_col, end_col) = (0, len(vim.current.buffer[line]) - 1) | |
251 | + try: | |
252 | + while word_char_RE.search(vim.current.buffer[line][left - 1]): | |
253 | + left = left - 1 | |
254 | + except IndexError: | |
255 | + pass | |
256 | + try: | |
257 | + while word_char_RE.search(vim.current.buffer[line][right + 1]): | |
258 | + right = right + 1 | |
259 | + except IndexError: | |
260 | + pass | |
261 | + return (left, right) | |
262 | + | |
263 | +annot = Annotations() # global annotation object | |
264 | + | |
265 | +def printOCamlType(mode): | |
266 | + try: | |
267 | + if mode == "visual": # visual mode: lookup highlighted text | |
268 | + (line1, col1) = vim.current.buffer.mark("<") | |
269 | + (line2, col2) = vim.current.buffer.mark(">") | |
270 | + else: # any other mode: lookup word at cursor position | |
271 | + (line, col) = vim.current.window.cursor | |
272 | + (col1, col2) = findBoundaries(line, col) | |
273 | + (line1, line2) = (line, line) | |
274 | + begin_mark = (line1, col1) | |
275 | + end_mark = (line2, col2 + 1) | |
276 | + print annot.get_type(begin_mark, end_mark) | |
277 | + except AnnExc, exc: | |
278 | + print exc.reason | |
279 | + | |
280 | +def parseOCamlAnnot(): | |
281 | + try: | |
282 | + annot.parse() | |
283 | + except AnnExc, exc: | |
284 | + print exc.reason | |
285 | + | |
286 | +EOF | |
287 | + | |
288 | +fun OCamlPrintType(current_mode) | |
289 | + if (a:current_mode == "visual") | |
290 | + python printOCamlType("visual") | |
291 | + else | |
292 | + python printOCamlType("normal") | |
293 | + endif | |
294 | +endfun | |
295 | + | |
296 | +fun OCamlParseAnnot() | |
297 | + python parseOCamlAnnot() | |
298 | +endfun | |
299 | + | |
300 | +map <F3> :call OCamlPrintType("normal")<RETURN> | |
301 | +vmap <F3> :call OCamlPrintType("visual")<RETURN> |
@@ -1,12 +1,12 @@ | ||
1 | 1 | " Vim indent file |
2 | -" Language: OCaml | |
3 | -" Maintainers: Jean-Francois Yuen <jfyuen@ifrance.com> | |
4 | -" Mike Leary <leary@nwlink.com> | |
5 | -" Markus Mottl <markus@oefai.at> | |
6 | -" URL: http://www.oefai.at/~markus/vim/indent/ocaml.vim | |
7 | -" Last Change: 2003 Apr 14 | |
8 | -" 2003 Mar 05 - Added '{<' and some fixes (JY) | |
9 | -" 2002 Nov 06 - Some fixes (JY) | |
2 | +" Language: OCaml | |
3 | +" Maintainers: Jean-Francois Yuen <jfyuen@happycoders.org> | |
4 | +" Mike Leary <leary@nwlink.com> | |
5 | +" Markus Mottl <markus@oefai.at> | |
6 | +" URL: http://www.oefai.at/~markus/vim/indent/ocaml.vim | |
7 | +" Last Change: 2004 Apr 11 - Added indent for 'class' (JY) | |
8 | +" 2003 Sep 16 - Added 'private' as keyword (JY) | |
9 | +" 2003 Mar 29 - Fixed bug with 'if' and 'else' (JY) | |
10 | 10 | |
11 | 11 | " Only load this indent file when no other was loaded. |
12 | 12 | if exists("b:did_indent") |
@@ -16,7 +16,7 @@ | ||
16 | 16 | |
17 | 17 | setlocal expandtab |
18 | 18 | setlocal indentexpr=GetOCamlIndent() |
19 | -setlocal indentkeys+=0=and,0=constraint,0=done,0=else,0=end,0=exception,0=external,0=if,0=in,0=include,0=inherit,0=initializer,0=let,0=method,0=open,0=then,0=type,0=val,0=with,0=;;,0=>\],0=\|\],0=\|,0=*),0=>},0},0\],0) | |
19 | +setlocal indentkeys+=0=and,0=class,0=constraint,0=done,0=else,0=end,0=exception,0=external,0=if,0=in,0=include,0=inherit,0=initializer,0=let,0=method,0=open,0=then,0=type,0=val,0=with,0;;,0>\],0\|\],0>},0\|,0},0\],0) | |
20 | 20 | setlocal nolisp |
21 | 21 | setlocal nosmartindent |
22 | 22 | setlocal textwidth=80 |
@@ -33,14 +33,13 @@ | ||
33 | 33 | endif |
34 | 34 | |
35 | 35 | " Define some patterns: |
36 | -let s:beflet = '^\s*\(initializer\|method\|try\)\|\(\<\(begin\|do\|else\|in\|then\|try\)\|->\|;\|(\)\s*$' | |
36 | +let s:beflet = '^\s*\(initializer\|method\|try\)\|\(\<\(begin\|do\|else\|in\|then\|try\)\|->\|<-\|=\|;\|(\)\s*$' | |
37 | 37 | let s:letpat = '^\s*\(let\|type\|module\|class\|open\|exception\|val\|include\|external\)\>' |
38 | 38 | let s:letlim = '\(\<\(sig\|struct\)\|;;\)\s*$' |
39 | 39 | let s:lim = '^\s*\(exception\|external\|include\|let\|module\|open\|type\|val\)\>' |
40 | 40 | let s:module = '\<\%(begin\|sig\|struct\|object\)\>' |
41 | 41 | let s:obj = '^\s*\(constraint\|inherit\|initializer\|method\|val\)\>\|\<\(object\|object\s*(.*)\)\s*$' |
42 | -let s:type = '^\s*\%(let\|type\)\>.*=' | |
43 | -let s:val = '^\s*\(val\|external\)\>.*:' | |
42 | +let s:type = '^\s*\%(class\|let\|type\)\>.*=' | |
44 | 43 | |
45 | 44 | " Skipping pattern, for comments |
46 | 45 | function s:SkipPattern(lnum, pat) |
@@ -75,7 +74,7 @@ | ||
75 | 74 | " Indent 'let' |
76 | 75 | function s:FindLet(pstart, pmid, pend) |
77 | 76 | call search(a:pend, 'bW') |
78 | - return indent(searchpair(a:pstart, a:pmid, a:pend, 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment" || getline(".") =~ "^\\s*let\\>.*=.*\\<in\\s*$" || getline(prevnonblank(".") - 1) =~ "^\\s*let\\>.*=\\s*$\\|" . s:beflet')) | |
77 | + return indent(searchpair(a:pstart, a:pmid, a:pend, 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment" || getline(".") =~ "^\\s*let\\>.*=.*\\<in\\s*$" || getline(prevnonblank(".") - 1) =~ s:beflet')) | |
79 | 78 | endfunction |
80 | 79 | |
81 | 80 | function GetOCamlIndent() |
@@ -97,8 +96,7 @@ | ||
97 | 96 | |
98 | 97 | let line = getline(v:lnum) |
99 | 98 | |
100 | - " Indent if current line begins with 'end' | |
101 | - " for 'sig', 'struct', 'object' and 'begin': | |
99 | + " Indent if current line begins with 'end': | |
102 | 100 | if line =~ '^\s*end\>' |
103 | 101 | return s:FindPair(s:module, '','\<end\>') |
104 | 102 |
@@ -118,27 +116,25 @@ | ||
118 | 116 | elseif line =~ '^\s*)' |
119 | 117 | return s:FindPair('(', '',')') |
120 | 118 | |
121 | - " Indent if current line begins with 'let' | |
122 | - " and last line does not begin with 'let' or end with 'in' or ';;': | |
119 | + " Indent if current line begins with 'let': | |
123 | 120 | elseif line =~ '^\s*let\>' |
124 | 121 | if lline !~ s:lim . '\|' . s:letlim . '\|' . s:beflet |
125 | 122 | return s:FindLet(s:type, '','\<let\s*$') |
126 | 123 | else return ind |
127 | 124 | endif |
128 | 125 | |
129 | - " Indent if current line begins with 'type' | |
130 | - " and last line does not end with 'and' or ';;': | |
131 | - elseif line =~ '^\s*type\>' | |
126 | + " Indent if current line begins with 'class' or 'type': | |
127 | + elseif line =~ '^\s*\(class\|type\)\>' | |
132 | 128 | if lline !~ s:lim . '\|\<and\s*$\|' . s:letlim |
133 | - return s:FindLet(s:type, '','\<type\s*$') | |
129 | + return s:FindLet(s:type, '','\<\(class\|type\)\s*$') | |
134 | 130 | else return ind |
135 | 131 | endif |
136 | 132 | |
137 | 133 | " Indent for pattern matching: |
138 | 134 | elseif line =~ '^\s*|' |
139 | - if lline !~ '^\s*\(|\|\(match\|with\|type\)\>\)\|\<\(function\|parser\|with\)\s*$' | |
135 | + if lline !~ '^\s*\(|[^\]]\|\(match\|type\|with\)\>\)\|\<\(function\|parser\|private\|with\)\s*$' | |
140 | 136 | call search('|', 'bW') |
141 | - return indent(searchpair('^\s*\(type\|match\)\>\|\<\(with\|function\|parser\)\s*$', '', '|', 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment" || getline(".") =~ "\\[|\\||\\]" && getline(".") !~ "^\\s*|.*->"')) | |
137 | + return indent(searchpair('^\s*\(match\|type\)\>\|\<\(function\|parser\|private\|with\)\s*$', '', '^\s*|', 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment" || getline(".") !~ "^\\s*|.*->"')) | |
142 | 138 | else return ind |
143 | 139 | endif |
144 | 140 |
@@ -149,41 +145,35 @@ | ||
149 | 145 | else return ind |
150 | 146 | endif |
151 | 147 | |
152 | - " Indent if current line begins with 'in' and previous | |
153 | - " line does not start with 'let' or 'and': | |
148 | + " Indent if current line begins with 'in': | |
154 | 149 | elseif line =~ '^\s*in\>' |
155 | 150 | if lline !~ '^\s*\(let\|and\)\>' |
156 | 151 | return s:FindPair('\<let\>', '', '\<in\>') |
157 | 152 | else return ind |
158 | 153 | endif |
159 | 154 | |
160 | - " Indent if current line begins with 'else' | |
161 | - " and previous line does not start with 'if', 'then' or 'else': | |
155 | + " Indent if current line begins with 'else': | |
162 | 156 | elseif line =~ '^\s*else\>' |
163 | - if lline !~ '^\s*\(if\|else\|then\)\>' | |
157 | + if lline !~ '^\s*\(if\|then\)\>' | |
164 | 158 | return s:FindPair('\<if\>', '', '\<else\>') |
165 | 159 | else return ind |
166 | 160 | endif |
167 | 161 | |
168 | - " Indent if current line begins with 'then' | |
169 | - " and previous line does not start with 'if', 'then' or 'else': | |
162 | + " Indent if current line begins with 'then': | |
170 | 163 | elseif line =~ '^\s*then\>' |
171 | - if lline !~ '^\s*\(if\|else\|then\)\>' | |
164 | + if lline !~ '^\s*\(if\|else\)\>' | |
172 | 165 | return s:FindPair('\<if\>', '', '\<then\>') |
173 | 166 | else return ind |
174 | 167 | endif |
175 | 168 | |
176 | - " Subtract a 'shiftwidth' if current line begins with 'and' and previous | |
177 | - " line does not start with 'let', 'and' or 'type' or end with 'end' | |
178 | - " (for classes): | |
169 | + " Indent if current line begins with 'and': | |
179 | 170 | elseif line =~ '^\s*and\>' |
180 | 171 | if lline !~ '^\s*\(and\|let\|type\)\>\|\<end\s*$' |
181 | 172 | return ind - &sw |
182 | 173 | else return ind |
183 | 174 | endif |
184 | 175 | |
185 | - " Indent if current line begins with 'with' | |
186 | - " and previous line does not start with 'match' or 'try': | |
176 | + " Indent if current line begins with 'with': | |
187 | 177 | elseif line =~ '^\s*with\>' |
188 | 178 | if lline !~ '^\s*\(match\|try\)\>' |
189 | 179 | return s:FindPair('\<\%(match\|try\)\>', '','\<with\>') |
@@ -193,35 +183,35 @@ | ||
193 | 183 | " Indent if current line begins with 'exception': |
194 | 184 | elseif line =~ '^\s*exception\>' |
195 | 185 | if lline !~ s:lim . '\|' . s:letlim |
196 | - return indent(search(s:val . '\|^\s*\(external\|include\|open\|type\)\>', 'bW')) | |
186 | + return indent(search('^\s*\(\(external\|include\|open\|type\)\>\|val\>.*:\)', 'bW')) | |
197 | 187 | else return ind |
198 | 188 | endif |
199 | 189 | |
200 | 190 | " Indent if current line begins with 'external': |
201 | 191 | elseif line =~ '^\s*external\>' |
202 | 192 | if lline !~ s:lim . '\|' . s:letlim |
203 | - return indent(search(s:val . '\|^\s*\(exception\|include\|open\|type\)\>', 'bW')) | |
193 | + return indent(search('^\s*\(\(exception\|external\|include\|open\|type\)\>\|val\>.*:\)', 'bW')) | |
204 | 194 | else return ind |
205 | 195 | endif |
206 | 196 | |
207 | 197 | " Indent if current line begins with 'include': |
208 | 198 | elseif line =~ '^\s*include\>' |
209 | 199 | if lline !~ s:lim . '\|' . s:letlim |
210 | - return indent(search(s:val . '\|^\s*\(exception\|external\|open\|type\)\>', 'bW')) | |
200 | + return indent(search('^\s*\(\(exception\|external\|open\|type\)\>\|val\>.*:\)', 'bW')) | |
211 | 201 | else return ind |
212 | 202 | endif |
213 | 203 | |
214 | 204 | " Indent if current line begins with 'open': |
215 | 205 | elseif line =~ '^\s*open\>' |
216 | 206 | if lline !~ s:lim . '\|' . s:letlim |
217 | - return indent(search(s:val . '\|^\s*\(exception\|external\|include\|type\)\>', 'bW')) | |
207 | + return indent(search('^\s*\(\(exception\|external\|include\|type\)\>\|val\>.*:\)', 'bW')) | |
218 | 208 | else return ind |
219 | 209 | endif |
220 | 210 | |
221 | 211 | " Indent if current line begins with 'val': |
222 | 212 | elseif line =~ '^\s*val\>' |
223 | 213 | if lline !~ '^\s*\(exception\|external\|include\|open\)\>\|' . s:obj . '\|' . s:letlim |
224 | - return indent(search(s:val . '\|^\s*\(exception\|include\|initializer\|method\|open\|type\)\>', 'bW')) | |
214 | + return indent(search('^\s*\(\(exception\|include\|initializer\|method\|open\|type\|val\)\>\|external\>.*:\)', 'bW')) | |
225 | 215 | else return ind |
226 | 216 | endif |
227 | 217 |
@@ -253,15 +243,10 @@ | ||
253 | 243 | else return ind |
254 | 244 | endif |
255 | 245 | |
256 | - " Indent back to normal after comments: | |
257 | - elseif line =~ '^\s*\*)' | |
258 | - call search('\*)', 'bW') | |
259 | - return indent(searchpair('(\*', '', '\*)', 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string"')) | |
260 | - | |
261 | 246 | endif |
262 | 247 | |
263 | 248 | " Add a 'shiftwidth' after lines ending with: |
264 | - if lline =~ '\(:\|=\|->\|<-\|(\|\[\|{\|{<\|\[|\|\[<\|\<\(begin\|struct\|sig\|functor\|initializer\|object\|try\|do\|if\|then\|else\|fun\|function\|parser\)\|\<object\s*(.*)\)\s*$' | |
249 | + if lline =~ '\(:\|=\|->\|<-\|(\|\[\|{\|{<\|\[|\|\[<\|\<\(begin\|do\|else\|fun\|function\|functor\|if\|initializer\|object\|parser\|private\|sig\|struct\|then\|try\)\|\<object\s*(.*)\)\s*$' | |
265 | 250 | let ind = ind + &sw |
266 | 251 | |
267 | 252 | " Back to normal indent after lines ending with ';;': |
@@ -2,7 +2,7 @@ | ||
2 | 2 | " Language: Python |
3 | 3 | " Maintainer: Bram Moolenaar <Bram@vim.org> |
4 | 4 | " Original Author: David Bustos <bustos@caltech.edu> |
5 | -" Last Change: 2004 Jun 15 | |
5 | +" Last Change: 2004 Jul 25 | |
6 | 6 | |
7 | 7 | " Only load this indent file when no other was loaded. |
8 | 8 | if exists("b:did_indent") |
@@ -99,15 +99,36 @@ | ||
99 | 99 | " Use syntax highlighting attributes when possible. |
100 | 100 | let pline = getline(plnum) |
101 | 101 | let pline_len = strlen(pline) |
102 | - let col = 0 | |
103 | - while col < pline_len | |
104 | - if pline[col] == '#' && (!has('syntax_items') | |
105 | - \ || synIDattr(synID(plnum, col + 1, 1), "name") =~ "Comment$") | |
106 | - let pline = strpart(pline, 0, col) | |
107 | - break | |
102 | + if has('syntax_items') | |
103 | + " If the last character in the line is a comment, do a binary search for | |
104 | + " the start of the comment. synID() is slow, a linear search would take | |
105 | + " too long on a long line. | |
106 | + if synIDattr(synID(plnum, pline_len, 1), "name") =~ "Comment$" | |
107 | + let min = 1 | |
108 | + let max = pline_len | |
109 | + while min < max | |
110 | + let col = (min + max) / 2 | |
111 | + if synIDattr(synID(plnum, col, 1), "name") =~ "Comment$" | |
112 | + let max = col | |
113 | + else | |
114 | + let min = col + 1 | |
115 | + endif | |
116 | + endwhile | |
117 | + echomsg min | |
118 | + let pline = strpart(pline, 0, min - 1) | |
119 | + echomsg pline | |
120 | + sleep 1 | |
108 | 121 | endif |
109 | - let col = col + 1 | |
110 | - endwhile | |
122 | + else | |
123 | + let col = 0 | |
124 | + while col < pline_len | |
125 | + if pline[col] == '#' | |
126 | + let pline = strpart(pline, 0, col) | |
127 | + break | |
128 | + endif | |
129 | + let col = col + 1 | |
130 | + endwhile | |
131 | + endif | |
111 | 132 | |
112 | 133 | " If the previous line ended with a colon, indent this line |
113 | 134 | if pline =~ ':\s*$' |
@@ -2,9 +2,9 @@ | ||
2 | 2 | " Language: Dot |
3 | 3 | " Filenames: *.dot |
4 | 4 | " Maintainer: Markus Mottl <markus@oefai.at> |
5 | -" URL: http://www.ai.univie.ac.at/~markus/vim/syntax/dot.vim | |
6 | -" Last Change: 2003 May 11 | |
7 | -" 2001 May 04 - initial version | |
5 | +" URL: http://www.oefai.at/~markus/vim/syntax/dot.vim | |
6 | +" Last Change: 2004 Jul 26 | |
7 | +" 2001 May 04 - initial version | |
8 | 8 | |
9 | 9 | " For version 5.x: Clear all syntax items |
10 | 10 | " For version 6.x: Quit when a syntax file was already loaded |
@@ -1,203 +1,314 @@ | ||
1 | 1 | " Vim syntax file |
2 | -" Language: IDL (Interface Description Language) | |
3 | -" Maintainer: Jody Goldberg <jgoldberg@home.com> or <jody@gnome.org> | |
4 | -" Last Change: 2004 Jul 12 | |
2 | +" Language: IDL (Interface Description Language) | |
3 | +" Created By: Jody Goldberg <jody@gnome.org> | |
4 | +" Maintainer: Michael Geddes <michaelrgeddes@optushome.com.au> | |
5 | +" Last Change: 2004 Jul 20 | |
5 | 6 | |
6 | 7 | " This is an experiment. IDL's structure is simple enough to permit a full |
7 | 8 | " grammar based approach to rather than using a few heuristics. The result |
8 | 9 | " is large and somewhat repetative but seems to work. |
9 | 10 | |
10 | -" For version 5.x: Clear all syntax items | |
11 | -" For version 6.x: Quit when a syntax file was already loaded | |
12 | -if version < 600 | |
13 | - syntax clear | |
14 | -elseif exists("b:current_syntax") | |
11 | +" There are some Microsoft extensions to idl files that are here. Some of | |
12 | +" them are disabled by defining idl_no_ms_extensions. | |
13 | +" | |
14 | +" The more complex of the extensions are disabled by defining idl_no_extensions. | |
15 | +" | |
16 | + | |
17 | +if exists("b:current_syntax") | |
15 | 18 | finish |
16 | 19 | endif |
17 | 20 | |
21 | +if exists("idlsyntax_showerror") | |
22 | + syn match idlError +\S+ skipwhite skipempty nextgroup=idlError | |
23 | +endif | |
24 | + | |
25 | +syn region idlCppQuote start='\<cpp_quote\s*(' end=')' contains=idlString | |
26 | + | |
18 | 27 | " Misc basic |
19 | -syn match idlId contained "[a-zA-Z][a-zA-Z0-9_]*" | |
20 | -syn match idlSemiColon contained ";" | |
21 | -syn match idlCommaArg contained "," skipempty skipwhite nextgroup=idlSimpDecl | |
22 | -syn region idlArraySize1 contained start=:\[: end=:\]: skipempty skipwhite nextgroup=idlArraySize1,idlSemiColon,idlCommaArg contains=idlArraySize1,idlLiteral | |
23 | -syn match idlSimpDecl contained "[a-zA-Z][a-zA-Z0-9_]*" skipempty skipwhite nextgroup=idlSemiColon,idlCommaArg,idlArraySize1 | |
24 | -syn region idlSting contained start=+"+ skip=+\\\(\\\\\)*"+ end=+"+ | |
25 | -syn match idlLiteral contained "[1-9]\d*\(\.\d*\)\=" | |
26 | -syn match idlLiteral contained "\.\d\+" | |
27 | -syn keyword idlLiteral contained TRUE FALSE | |
28 | +syn match idlId contained "[a-zA-Z][a-zA-Z0-9_]*" skipwhite skipempty nextgroup=idlEnumComma,idlEnumNumber | |
29 | +syn match idlEnumComma contained "," | |
30 | +syn match idlEnumNumber contained "=" skipwhite skipempty nextgroup=idlString,idlLiteral | |
31 | +syn match idlSemiColon contained ";" | |
32 | +syn match idlCommaArg contained "," skipempty skipwhite nextgroup=idlSimpDecl | |
33 | +syn region idlArraySize1 contained start=:\[: end=:\]: skipempty skipwhite nextgroup=idlArraySize1,idlError,idlSemiColon,idlCommaArg contains=idlArraySize1,idlLiteral | |
34 | +syn match idlSimpDecl contained "[a-zA-Z][a-zA-Z0-9_]*" skipempty skipwhite nextgroup=idlError,idlSemiColon,idlCommaArg,idlArraySize1 | |
35 | +syn region idlString contained start=+"+ skip=+\\\(\\\\\)*"+ end=+"+ | |
36 | +syn match idlLiteral contained "[1-9]\d*\(\.\d*\)\=" | |
37 | +syn match idlLiteral contained "0" | |
38 | +syn match idlLiteral contained "\.\d\+" | |
39 | +syn match idlLiteral contained "0x[0-9A-Fa-f]\+" | |
40 | +syn match idlLiteral contained "0[0-7]\+" | |
41 | +syn keyword idlLiteral contained TRUE FALSE | |
28 | 42 | |
29 | 43 | " Comments |
30 | -syn keyword idlTodo contained TODO FIXME XXX | |
31 | -syn region idlComment start="/\*" end="\*/" contains=idlTodo | |
32 | -syn match idlComment "//.*" contains=idlTodo | |
33 | -syn match idlCommentError "\*/" | |
44 | +syn keyword idlTodo contained TODO FIXME XXX | |
45 | +syn region idlComment start="/\*" end="\*/" contains=idlTodo | |
46 | +syn match idlComment "//.*" contains=idlTodo | |
47 | +syn match idlCommentError "\*/" | |
34 | 48 | |
35 | 49 | " C style Preprocessor |
36 | -syn region idlIncluded contained start=+"+ skip=+\\\(\\\\\)*"+ end=+"+ | |
37 | -syn match idlIncluded contained "<[^>]*>" | |
38 | -syn match idlInclude "^[ \t]*#[ \t]*include\>[ \t]*["<]" contains=idlIncluded,idlString | |
39 | -syn region idlPreCondit start="^[ \t]*#[ \t]*\(if\>\|ifdef\>\|ifndef\>\|elif\>\|else\>\|endif\>\)" skip="\\$" end="$" contains=idlComment,idlCommentError | |
40 | -syn region idlDefine start="^[ \t]*#[ \t]*\(define\>\|undef\>\)" skip="\\$" end="$" contains=idlLiteral, idlString | |
50 | +syn region idlIncluded contained start=+"+ skip=+\\\(\\\\\)*"+ end=+"+ | |
51 | +syn match idlIncluded contained "<[^>]*>" | |
52 | +syn match idlInclude "^[ \t]*#[ \t]*include\>[ \t]*["<]" contains=idlIncluded,idlString | |
53 | +syn region idlPreCondit start="^[ \t]*#[ \t]*\(if\>\|ifdef\>\|ifndef\>\|elif\>\|else\>\|endif\>\)" skip="\\$" end="$" contains=idlComment,idlCommentError | |
54 | +syn region idlDefine start="^[ \t]*#[ \t]*\(define\>\|undef\>\)" skip="\\$" end="$" contains=idlLiteral,idlString | |
41 | 55 | |
42 | 56 | " Constants |
43 | -syn keyword idlConst const skipempty skipwhite nextgroup=idlBaseType,idlBaseTypeInt | |
57 | +syn keyword idlConst const skipempty skipwhite nextgroup=idlBaseType,idlBaseTypeInt | |
44 | 58 | |
45 | 59 | " Attribute |
46 | -syn keyword idlROAttr readonly skipempty skipwhite nextgroup=idlAttr | |
47 | -syn keyword idlAttr attribute skipempty skipwhite nextgroup=idlBaseTypeInt,idlBaseType | |
60 | +syn keyword idlROAttr readonly skipempty skipwhite nextgroup=idlAttr | |
61 | +syn keyword idlAttr attribute skipempty skipwhite nextgroup=idlBaseTypeInt,idlBaseType | |
48 | 62 | |
49 | 63 | " Types |
50 | -syn region idlD4 contained start="<" end=">" skipempty skipwhite nextgroup=idlSimpDecl contains=idlSeqType,idlBaseTypeInt,idlBaseType,idlLiteral | |
51 | -syn keyword idlSeqType contained sequence skipempty skipwhite nextgroup=idlD4 | |
52 | -syn keyword idlBaseType contained float double char boolean octet any skipempty skipwhite nextgroup=idlSimpDecl | |
53 | -syn keyword idlBaseTypeInt contained short long skipempty skipwhite nextgroup=idlSimpDecl | |
54 | -syn keyword idlBaseType contained unsigned skipempty skipwhite nextgroup=idlBaseTypeInt | |
55 | -syn region idlD1 contained start="<" end=">" skipempty skipwhite nextgroup=idlSimpDecl contains=idlString,idlLiteral | |
56 | -syn keyword idlBaseType contained string skipempty skipwhite nextgroup=idlD1,idlSimpDecl | |
57 | -syn match idlBaseType contained "[a-zA-Z0-9_]\+[ \t]*\(::[ \t]*[a-zA-Z0-9_]\+\)*" skipempty skipwhite nextgroup=idlSimpDecl | |
64 | +syn region idlD4 contained start="<" end=">" skipempty skipwhite nextgroup=idlSimpDecl contains=idlSeqType,idlBaseTypeInt,idlBaseType,idlLiteral | |
65 | +syn keyword idlSeqType contained sequence skipempty skipwhite nextgroup=idlD4 | |
66 | +syn keyword idlBaseType contained float double char boolean octet any skipempty skipwhite nextgroup=idlSimpDecl | |
67 | +syn keyword idlBaseTypeInt contained short long skipempty skipwhite nextgroup=idlSimpDecl | |
68 | +syn keyword idlBaseType contained unsigned skipempty skipwhite nextgroup=idlBaseTypeInt | |
69 | +syn region idlD1 contained start="<" end=">" skipempty skipwhite nextgroup=idlSimpDecl contains=idlString,idlLiteral | |
70 | +syn keyword idlBaseType contained string skipempty skipwhite nextgroup=idlD1,idlSimpDecl | |
71 | +syn match idlBaseType contained "[a-zA-Z0-9_]\+[ \t]*\(::[ \t]*[a-zA-Z0-9_]\+\)*" skipempty skipwhite nextgroup=idlSimpDecl | |
58 | 72 | |
59 | 73 | " Modules |
60 | -syn region idlModuleContent contained start="{" end="}" skipempty skipwhite nextgroup=idlSemiColon contains=idlUnion,idlStruct,idlEnum,idlInterface,idlComment,idlTypedef,idlConst,idlException,idlModule | |
61 | -syn match idlModuleName contained "[a-zA-Z0-9_]\+" skipempty skipwhite nextgroup=idlModuleContent,idlSemiColon | |
62 | -syn keyword idlModule module skipempty skipwhite nextgroup=idlModuleName | |
74 | +syn region idlModuleContent contained start="{" end="}" skipempty skipwhite nextgroup=idlError,idlSemiColon contains=idlUnion,idlStruct,idlEnum,idlInterface,idlComment,idlTypedef,idlConst,idlException,idlModule | |
75 | +syn match idlModuleName contained "[a-zA-Z0-9_]\+" skipempty skipwhite nextgroup=idlModuleContent,idlError,idlSemiColon | |
76 | +syn keyword idlModule module skipempty skipwhite nextgroup=idlModuleName | |
63 | 77 | |
64 | 78 | " Interfaces |
65 | -syn region idlInterfaceContent contained start="{" end="}" skipempty skipwhite nextgroup=idlSemiColon contains=idlUnion,idlStruct,idlEnum,idlComment,idlROAttr,idlAttr,idlOp,idlOneWayOp,idlException,idlConst,idlTypedef | |
66 | -syn match idlInheritFrom2 contained "," skipempty skipwhite nextgroup=idlInheritFrom | |
67 | -syn match idlInheritFrom contained "[a-zA-Z0-9_]\+[ \t]*\(::[ \t]*[a-zA-Z0-9_]\+\)*" skipempty skipwhite nextgroup=idlInheritFrom2,idlInterfaceContent | |
68 | -syn match idlInherit contained ":" skipempty skipwhite nextgroup=idlInheritFrom | |
69 | -syn match idlInterfaceName contained "[a-zA-Z0-9_]\+" skipempty skipwhite nextgroup=idlInterfaceContent,idlInherit,idlSemiColon | |
70 | -syn keyword idlInterface interface skipempty skipwhite nextgroup=idlInterfaceName | |
79 | +syn cluster idlCommentable contains=idlComment | |
80 | +syn cluster idlContentCluster contains=idlUnion,idlStruct,idlEnum,idlROAttr,idlAttr,idlOp,idlOneWayOp,idlException,idlConst,idlTypedef,idlAttributes,idlErrorSquareBracket,idlErrorBracket,idlInterfaceSections | |
81 | + | |
82 | +syn region idlInterfaceContent contained start="{" end="}" skipempty skipwhite nextgroup=idlError,idlSemiColon contains=@idlContentCluster,@idlCommentable | |
83 | +syn match idlInheritFrom2 contained "," skipempty skipwhite nextgroup=idlInheritFrom | |
84 | +syn match idlInheritFrom contained "[a-zA-Z0-9_]\+[ \t]*\(::[ \t]*[a-zA-Z0-9_]\+\)*" skipempty skipwhite nextgroup=idlInheritFrom2,idlInterfaceContent | |
85 | +syn match idlInherit contained ":" skipempty skipwhite nextgroup=idlInheritFrom | |
86 | +syn match idlInterfaceName contained "[a-zA-Z0-9_]\+" skipempty skipwhite nextgroup=idlInterfaceContent,idlInherit,idlError,idlSemiColon | |
87 | +syn keyword idlInterface interface dispinterface skipempty skipwhite nextgroup=idlInterfaceName | |
88 | +syn keyword idlInterfaceSections contained properties methods skipempty skipwhite nextgroup=idlSectionColon,idlError | |
89 | +syn match idlSectionColon contained ":" | |
71 | 90 | |
72 | 91 | |
92 | +syn match idlLibraryName contained "[a-zA-Z0-9_]\+" skipempty skipwhite nextgroup=idlLibraryContent,idlError,idlSemiColon | |
93 | +syn keyword idlLibrary library skipempty skipwhite nextgroup=idlLibraryName | |
94 | +syn region idlLibraryContent contained start="{" end="}" skipempty skipwhite nextgroup=idlError,idlSemiColon contains=@idlCommentable,idlAttributes,idlErrorSquareBracket,idlErrorBracket,idlImportlib,idlCoclass,idlTypedef,idlInterface | |
95 | + | |
96 | +syn keyword idlImportlib contained importlib skipempty skipwhite nextgroup=idlStringArg | |
97 | +syn region idlStringArg contained start="(" end=")" contains=idlString nextgroup=idlError,idlSemiColon,idlErrorBrace,idlErrorSquareBracket | |
98 | + | |
99 | +syn keyword idlCoclass coclass contained skipempty skipwhite nextgroup=idlCoclassName | |
100 | +syn match idlCoclassName "[a-zA-Z0-9_]\+" contained skipempty skipwhite nextgroup=idlCoclassDefinition,idlError,idlSemiColon | |
101 | + | |
102 | +syn region idlCoclassDefinition contained start="{" end="}" contains=idlCoclassAttributes,idlInterface,idlErrorBracket,idlErrorSquareBracket skipempty skipwhite nextgroup=idlError,idlSemiColon | |
103 | +syn region idlCoclassAttributes contained start=+\[+ end=+]+ skipempty skipwhite nextgroup=idlInterface contains=idlErrorBracket,idlErrorBrace,idlCoclassAttribute | |
104 | +syn keyword idlCoclassAttribute contained default source | |
105 | +"syn keyword idlInterface interface skipempty skipwhite nextgroup=idlInterfaceStubName | |
106 | + | |
107 | +syn match idlImportString +"\f\+"+ skipempty skipwhite nextgroup=idlError,idlSemiColon | |
108 | +syn keyword idlImport import skipempty skipwhite nextgroup=idlImportString | |
109 | + | |
110 | +syn region idlAttributes start="\[" end="\]" contains=idlAttribute,idlAttributeParam,idlErrorBracket,idlErrorBrace,idlComment | |
111 | +syn keyword idlAttribute contained propput propget propputref id helpstring object uuid pointer_default | |
112 | +if !exists('idl_no_ms_extensions') | |
113 | +syn keyword idlAttribute contained nonextensible dual version aggregatable restricted hidden noncreatable oleautomation | |
114 | +endif | |
115 | +syn region idlAttributeParam contained start="(" end=")" contains=idlString,idlUuid,idlLiteral,idlErrorBrace,idlErrorSquareBracket | |
116 | +" skipwhite nextgroup=idlArraySize,idlParmList contains=idlArraySize,idlLiteral | |
117 | +syn match idlErrorBrace contained "}" | |
118 | +syn match idlErrorBracket contained ")" | |
119 | +syn match idlErrorSquareBracket contained "\]" | |
120 | + | |
121 | +syn match idlUuid contained +[0-9a-zA-Z]\{8}-\([0-9a-zA-Z]\{4}-\)\{3}[0-9a-zA-Z]\{12}+ | |
122 | + | |
73 | 123 | " Raises |
74 | -syn keyword idlRaises contained raises skipempty skipwhite nextgroup=idlRaises,idlContext,idlSemiColon | |
124 | +syn keyword idlRaises contained raises skipempty skipwhite nextgroup=idlRaises,idlContext,idlError,idlSemiColon | |
75 | 125 | |
76 | 126 | " Context |
77 | -syn keyword idlContext contained context skipempty skipwhite nextgroup=idlRaises,idlContext,idlSemiColon | |
127 | +syn keyword idlContext contained context skipempty skipwhite nextgroup=idlRaises,idlContext,idlError,idlSemiColon | |
78 | 128 | |
79 | 129 | " Operation |
80 | -syn match idlParmList contained "," skipempty skipwhite nextgroup=idlOpParms | |
81 | -syn region idlArraySize contained start="\[" end="\]" skipempty skipwhite nextgroup=idlArraySize,idlParmList contains=idlArraySize,idlLiteral | |
82 | -syn match idlParmName contained "[a-zA-Z0-9_]\+" skipempty skipwhite nextgroup=idlParmList,idlArraySize | |
83 | -syn keyword idlParmInt contained short long skipempty skipwhite nextgroup=idlParmName | |
84 | -syn keyword idlParmType contained unsigned skipempty skipwhite nextgroup=idlParmInt | |
85 | -syn region idlD3 contained start="<" end=">" skipempty skipwhite nextgroup=idlParmName contains=idlString,idlLiteral | |
86 | -syn keyword idlParmType contained string skipempty skipwhite nextgroup=idlD3,idlParmName | |
87 | -syn keyword idlParmType contained void float double char boolean octet any skipempty skipwhite nextgroup=idlParmName | |
88 | -syn match idlParmType contained "[a-zA-Z0-9_]\+[ \t]*\(::[ \t]*[a-zA-Z0-9_]\+\)*" skipempty skipwhite nextgroup=idlParmName | |
89 | -syn keyword idlOpParms contained in out inout skipempty skipwhite nextgroup=idlParmType | |
130 | +syn match idlParmList contained "," skipempty skipwhite nextgroup=idlOpParms | |
131 | +syn region idlArraySize contained start="\[" end="\]" skipempty skipwhite nextgroup=idlArraySize,idlParmList contains=idlArraySize,idlLiteral | |
132 | +syn match idlParmName contained "[a-zA-Z0-9_]\+" skipempty skipwhite nextgroup=idlParmList,idlArraySize | |
133 | +syn keyword idlParmInt contained short long skipempty skipwhite nextgroup=idlParmName | |
134 | +syn keyword idlParmType contained unsigned skipempty skipwhite nextgroup=idlParmInt | |
135 | +syn region idlD3 contained start="<" end=">" skipempty skipwhite nextgroup=idlParmName contains=idlString,idlLiteral | |
136 | +syn keyword idlParmType contained string skipempty skipwhite nextgroup=idlD3,idlParmName | |
137 | +syn keyword idlParmType contained void float double char boolean octet any skipempty skipwhite nextgroup=idlParmName | |
138 | +syn match idlParmType contained "[a-zA-Z0-9_]\+[ \t]*\(::[ \t]*[a-zA-Z0-9_]\+\)*" skipempty skipwhite nextgroup=idlParmName | |
139 | +syn keyword idlOpParms contained in out inout skipempty skipwhite nextgroup=idlParmType | |
90 | 140 | |
91 | -syn region idlOpContents contained start="(" end=")" skipempty skipwhite nextgroup=idlRaises,idlContext,idlSemiColon contains=idlOpParms | |
92 | -syn match idlOpName contained "[a-zA-Z0-9_]\+" skipempty skipwhite nextgroup=idlOpContents | |
93 | -syn keyword idlOpInt contained short long skipempty skipwhite nextgroup=idlOpName | |
94 | -syn region idlD2 contained start="<" end=">" skipempty skipwhite nextgroup=idlOpName contains=idlString,idlLiteral | |
95 | -syn keyword idlOp contained unsigned skipempty skipwhite nextgroup=idlOpInt | |
96 | -syn keyword idlOp contained string skipempty skipwhite nextgroup=idlD2,idlOpName | |
97 | -syn keyword idlOp contained void float double char boolean octet any skipempty skipwhite nextgroup=idlOpName | |
98 | -syn match idlOp contained "[a-zA-Z0-9_]\+[ \t]*\(::[ \t]*[a-zA-Z0-9_]\+\)*" skipempty skipwhite nextgroup=idlOpName | |
99 | -syn keyword idlOp contained void skipempty skipwhite nextgroup=idlOpName | |
100 | -syn keyword idlOneWayOp contained oneway skipempty skipwhite nextgroup=idOp | |
141 | +if !exists('idl_no_ms_extensions') | |
142 | +syn keyword idlOpParms contained retval optional skipempty skipwhite nextgroup=idlParmType | |
143 | + syn match idlOpParms contained +\<\(iid_is\|defaultvalue\)\s*([^)]*)+ skipempty skipwhite nextgroup=idlParamType | |
144 | + | |
145 | + syn keyword idlVariantType contained BSTR VARIANT VARIANT_BOOL long short unsigned double CURRENCY DATE | |
146 | + syn region idlSafeArray contained matchgroup=idlVariantType start=+SAFEARRAY(\s*+ end=+)+ contains=idlVariantType | |
147 | +endif | |
148 | + | |
149 | +syn region idlOpContents contained start="(" end=")" skipempty skipwhite nextgroup=idlRaises,idlContext,idlError,idlSemiColon contains=idlOpParms,idlSafeArray,idlVariantType,@idlCommentable | |
150 | +syn match idlOpName contained "[a-zA-Z0-9_]\+" skipempty skipwhite nextgroup=idlOpContents | |
151 | +syn keyword idlOpInt contained short long skipempty skipwhite nextgroup=idlOpName | |
152 | +syn region idlD2 contained start="<" end=">" skipempty skipwhite nextgroup=idlOpName contains=idlString,idlLiteral | |
153 | +syn keyword idlOp contained unsigned skipempty skipwhite nextgroup=idlOpInt | |
154 | +syn keyword idlOp contained string skipempty skipwhite nextgroup=idlD2,idlOpName | |
155 | +syn keyword idlOp contained void float double char boolean octet any skipempty skipwhite nextgroup=idlOpName | |
156 | +syn match idlOp contained "[a-zA-Z0-9_]\+[ \t]*\(::[ \t]*[a-zA-Z0-9_]\+\)*" skipempty skipwhite nextgroup=idlOpName | |
157 | +syn keyword idlOp contained void skipempty skipwhite nextgroup=idlOpName | |
158 | +syn keyword idlOneWayOp contained oneway skipempty skipwhite nextgroup=idOp | |
101 | 159 | |
102 | 160 | " Enum |
103 | -syn region idlEnumContents contained start="{" end="}" skipempty skipwhite nextgroup=idlSemiColon, idlSimpDecl contains=idlId,idlComment | |
104 | -syn match idlEnumName contained "[a-zA-Z0-9_]\+" skipempty skipwhite nextgroup=idlEnumContents | |
105 | -syn keyword idlEnum enum skipempty skipwhite nextgroup=idlEnumName | |
161 | +syn region idlEnumContents contained start="{" end="}" skipempty skipwhite nextgroup=idlError,idlSemiColon,idlSimpDecl contains=idlId,idlAttributes,@idlCommentable | |
162 | +syn match idlEnumName contained "[a-zA-Z0-9_]\+" skipempty skipwhite nextgroup=idlEnumContents | |
163 | +syn keyword idlEnum enum skipempty skipwhite nextgroup=idlEnumName,idlEnumContents | |
106 | 164 | |
107 | 165 | " Typedef |
108 | -syn keyword idlTypedef typedef skipempty skipwhite nextgroup=idlBaseType, idlBaseTypeInt, idlSeqType | |
166 | +syn keyword idlTypedef typedef skipempty skipwhite nextgroup=idlTypedefOtherTypeQualifier,idlDefBaseType,idlDefBaseTypeInt,idlDefSeqType,idlDefv1Enum,idlDefEnum,idlDefOtherType,idlDefAttributes,idlError | |
167 | + | |
168 | +if !exists('idl_no_extensions') | |
169 | + syn keyword idlTypedefOtherTypeQualifier contained struct enum interface nextgroup=idlDefBaseType,idlDefBaseTypeInt,idlDefSeqType,idlDefv1Enum,idlDefEnum,idlDefOtherType,idlDefAttributes,idlError skipwhite | |
170 | + | |
171 | + syn region idlDefAttributes contained start="\[" end="\]" contains=idlAttribute,idlAttributeParam,idlErrorBracket,idlErrorBrace skipempty skipwhite nextgroup=idlDefBaseType,idlDefBaseTypeInt,idlDefSeqType,idlDefv1Enum,idlDefEnum,idlDefOtherType,idlError | |
172 | + | |
173 | + syn keyword idlDefBaseType contained float double char boolean octet any skipempty skipwhite nextgroup=idlTypedefDecl,idlError | |
174 | + syn keyword idlDefBaseTypeInt contained short long skipempty skipwhite nextgroup=idlTypedefDecl,idlError | |
175 | + syn match idlDefOtherType contained +\<\k\+\>+ skipempty nextgroup=idlTypedefDecl,idlError | |
176 | + " syn keyword idlDefSeqType contained sequence skipempty skipwhite nextgroup=idlD4 | |
177 | + | |
178 | + " Enum typedef | |
179 | + syn keyword idlDefEnum contained enum skipempty skipwhite nextgroup=idlDefEnumName,idlDefEnumContents | |
180 | + syn match idlDefEnumName contained "[a-zA-Z0-9_]\+" skipempty skipwhite nextgroup=idlDefEnumContents,idlTypedefDecl | |
181 | + syn region idlDefEnumContents contained start="{" end="}" skipempty skipwhite nextgroup=idlError,idlTypedefDecl contains=idlId,idlAttributes | |
182 | + | |
183 | + syn match idlTypedefDecl contained "[a-zA-Z0-9_]\+" skipempty skipwhite nextgroup=idlError,idlSemiColon | |
184 | +endif | |
109 | 185 | |
110 | 186 | " Struct |
111 | -syn region idlStructContent contained start="{" end="}" skipempty skipwhite nextgroup=idlSemiColon, idlSimpDecl contains=idlBaseType, idlBaseTypeInt, idlSeqType,idlComment, idlEnum, idlUnion | |
112 | -syn match idlStructName contained "[a-zA-Z0-9_]\+" skipempty skipwhite nextgroup=idlStructContent | |
113 | -syn keyword idlStruct struct skipempty skipwhite nextgroup=idlStructName | |
187 | +syn region idlStructContent contained start="{" end="}" skipempty skipwhite nextgroup=idlError,idlSemiColon,idlSimpDecl contains=idlBaseType,idlBaseTypeInt,idlSeqType,@idlCommentable,idlEnum,idlUnion | |
188 | +syn match idlStructName contained "[a-zA-Z0-9_]\+" skipempty skipwhite nextgroup=idlStructContent | |
189 | +syn keyword idlStruct struct skipempty skipwhite nextgroup=idlStructName | |
114 | 190 | |
115 | 191 | " Exception |
116 | -syn keyword idlException exception skipempty skipwhite nextgroup=idlStructName | |
192 | +syn keyword idlException exception skipempty skipwhite nextgroup=idlStructName | |
117 | 193 | |
118 | 194 | " Union |
119 | -syn match idlColon contained ":" skipempty skipwhite nextgroup=idlCase,idlSeqType,idlBaseType,idlBaseTypeInt | |
120 | -syn region idlCaseLabel contained start="" skip="::" end=":"me=e-1 skipempty skipwhite nextgroup=idlColon contains=idlLiteral,idlString | |
121 | -syn keyword idlCase contained case skipempty skipwhite nextgroup=idlCaseLabel | |
122 | -syn keyword idlCase contained default skipempty skipwhite nextgroup=idlColon | |
123 | -syn region idlUnionContent contained start="{" end="}" skipempty skipwhite nextgroup=idlSemiColon,idlSimpDecl contains=idlCase | |
124 | -syn region idlSwitchType contained start="(" end=")" skipempty skipwhite nextgroup=idlUnionContent | |
125 | -syn keyword idlUnionSwitch contained switch skipempty skipwhite nextgroup=idlSwitchType | |
126 | -syn match idlUnionName contained "[a-zA-Z0-9_]\+" skipempty skipwhite nextgroup=idlUnionSwitch | |
127 | -syn keyword idlUnion union skipempty skipwhite nextgroup=idlUnionName | |
128 | - | |
129 | -syn sync lines=200 | |
130 | - | |
131 | -" Define the default highlighting. | |
132 | -" For version 5.7 and earlier: only when not done already | |
133 | -" For version 5.8 and later: only when an item doesn't have highlighting yet | |
134 | -if version >= 508 || !exists("did_idl_syntax_inits") | |
135 | - if version < 508 | |
136 | - let did_idl_syntax_inits = 1 | |
137 | - command -nargs=+ HiLink hi link <args> | |
138 | - else | |
139 | - command -nargs=+ HiLink hi def link <args> | |
140 | - endif | |
141 | - | |
142 | - HiLink idlInclude Include | |
143 | - HiLink idlPreProc PreProc | |
144 | - HiLink idlPreCondit PreCondit | |
145 | - HiLink idlDefine Macro | |
146 | - HiLink idlIncluded String | |
147 | - HiLink idlString String | |
148 | - HiLink idlComment Comment | |
149 | - HiLink idlTodo Todo | |
150 | - HiLink idlLiteral Number | |
195 | +syn match idlColon contained ":" skipempty skipwhite nextgroup=idlCase,idlSeqType,idlBaseType,idlBaseTypeInt | |
196 | +syn region idlCaseLabel contained start="" skip="::" end=":"me=e-1 skipempty skipwhite nextgroup=idlColon contains=idlLiteral,idlString | |
197 | +syn keyword idlCase contained case skipempty skipwhite nextgroup=idlCaseLabel | |
198 | +syn keyword idlCase contained default skipempty skipwhite nextgroup=idlColon | |
199 | +syn region idlUnionContent contained start="{" end="}" skipempty skipwhite nextgroup=idlError,idlSemiColon,idlSimpDecl contains=idlCase | |
200 | +syn region idlSwitchType contained start="(" end=")" skipempty skipwhite nextgroup=idlUnionContent | |
201 | +syn keyword idlUnionSwitch contained switch skipempty skipwhite nextgroup=idlSwitchType | |
202 | +syn match idlUnionName contained "[a-zA-Z0-9_]\+" skipempty skipwhite nextgroup=idlUnionSwitch | |
203 | +syn keyword idlUnion union skipempty skipwhite nextgroup=idlUnionName | |
151 | 204 | |
152 | - HiLink idlModule Keyword | |
153 | - HiLink idlInterface Keyword | |
154 | - HiLink idlEnum Keyword | |
155 | - HiLink idlStruct Keyword | |
156 | - HiLink idlUnion Keyword | |
157 | - HiLink idlTypedef Keyword | |
158 | - HiLink idlException Keyword | |
159 | - | |
160 | - HiLink idlModuleName Typedef | |
161 | - HiLink idlInterfaceName Typedef | |
162 | - HiLink idlEnumName Typedef | |
163 | - HiLink idlStructName Typedef | |
164 | - HiLink idlUnionName Typedef | |
205 | +if !exists('idl_no_extensions') | |
206 | + syn sync match idlInterfaceSync grouphere idlInterfaceContent "\<\(disp\)\=interface\>\s\+\k\+\s*:\s*\k\+\_s*{" skipempty skipwhite nextgroup=idlError,idlSemiColon contains=@idlContentCluster,@idlCommentable | |
207 | + syn sync maxlines=1000 minlines=100 | |
208 | +else | |
209 | + syn sync lines=200 | |
210 | +endif | |
211 | +" syn sync fromstart | |
165 | 212 | |
166 | - HiLink idlBaseTypeInt idlType | |
167 | - HiLink idlBaseType idlType | |
168 | - HiLink idlSeqType idlType | |
169 | - HiLink idlD1 Paren | |
170 | - HiLink idlD2 Paren | |
171 | - HiLink idlD3 Paren | |
172 | - HiLink idlD4 Paren | |
173 | - "HiLink idlArraySize Paren | |
174 | - "HiLink idlArraySize1 Paren | |
175 | - HiLink idlModuleContent Paren | |
176 | - HiLink idlUnionContent Paren | |
177 | - HiLink idlStructContent Paren | |
178 | - HiLink idlEnumContents Paren | |
179 | - HiLink idlInterfaceContent Paren | |
213 | +if !exists("did_idl_syntax_inits") | |
214 | + let did_idl_syntax_inits = 1 | |
215 | + " The default methods for highlighting. Can be overridden later | |
216 | + command -nargs=+ HiLink hi def link <args> | |
180 | 217 | |
181 | - HiLink idlSimpDecl Identifier | |
182 | - HiLink idlROAttr StorageClass | |
183 | - HiLink idlAttr Keyword | |
184 | - HiLink idlConst StorageClass | |
218 | + HiLink idlInclude Include | |
219 | + HiLink idlPreProc PreProc | |
220 | + HiLink idlPreCondit PreCondit | |
221 | + HiLink idlDefine Macro | |
222 | + HiLink idlIncluded String | |
223 | + HiLink idlString String | |
224 | + HiLink idlComment Comment | |
225 | + HiLink idlTodo Todo | |
226 | + HiLink idlLiteral Number | |
227 | + HiLink idlUuid Number | |
228 | + HiLink idlType Type | |
229 | + HiLink idlVariantType idlType | |
185 | 230 | |
186 | - HiLink idlOneWayOp StorageClass | |
187 | - HiLink idlOp idlType | |
188 | - HiLink idlParmType idlType | |
189 | - HiLink idlOpName Function | |
190 | - HiLink idlOpParms StorageClass | |
191 | - HiLink idlParmName Identifier | |
192 | - HiLink idlInheritFrom Identifier | |
231 | + HiLink idlModule Keyword | |
232 | + HiLink idlInterface Keyword | |
233 | + HiLink idlEnum Keyword | |
234 | + HiLink idlStruct Keyword | |
235 | + HiLink idlUnion Keyword | |
236 | + HiLink idlTypedef Keyword | |
237 | + HiLink idlException Keyword | |
238 | + HiLink idlTypedefOtherTypeQualifier keyword | |
193 | 239 | |
194 | - HiLink idlId Constant | |
195 | - "HiLink idlCase Keyword | |
196 | - HiLink idlCaseLabel Constant | |
240 | + HiLink idlModuleName Typedef | |
241 | + HiLink idlInterfaceName Typedef | |
242 | + HiLink idlEnumName Typedef | |
243 | + HiLink idlStructName Typedef | |
244 | + HiLink idlUnionName Typedef | |
197 | 245 | |
246 | + HiLink idlBaseTypeInt idlType | |
247 | + HiLink idlBaseType idlType | |
248 | + HiLink idlSeqType idlType | |
249 | + HiLink idlD1 Paren | |
250 | + HiLink idlD2 Paren | |
251 | + HiLink idlD3 Paren | |
252 | + HiLink idlD4 Paren | |
253 | + "HiLink idlArraySize Paren | |
254 | + "HiLink idlArraySize1 Paren | |
255 | + HiLink idlModuleContent Paren | |
256 | + HiLink idlUnionContent Paren | |
257 | + HiLink idlStructContent Paren | |
258 | + HiLink idlEnumContents Paren | |
259 | + HiLink idlInterfaceContent Paren | |
260 | + | |
261 | + HiLink idlSimpDecl Identifier | |
262 | + HiLink idlROAttr StorageClass | |
263 | + HiLink idlAttr Keyword | |
264 | + HiLink idlConst StorageClass | |
265 | + | |
266 | + HiLink idlOneWayOp StorageClass | |
267 | + HiLink idlOp idlType | |
268 | + HiLink idlParmType idlType | |
269 | + HiLink idlOpName Function | |
270 | + HiLink idlOpParms SpecialComment | |
271 | + HiLink idlParmName Identifier | |
272 | + HiLink idlInheritFrom Identifier | |
273 | + HiLink idlAttribute SpecialComment | |
274 | + | |
275 | + HiLink idlId Constant | |
276 | + "HiLink idlCase Keyword | |
277 | + HiLink idlCaseLabel Constant | |
278 | + | |
279 | + HiLink idlErrorBracket Error | |
280 | + HiLink idlErrorBrace Error | |
281 | + HiLink idlErrorSquareBracket Error | |
282 | + | |
283 | + HiLink idlImport Keyword | |
284 | + HiLink idlImportString idlString | |
285 | + HiLink idlCoclassAttribute StorageClass | |
286 | + HiLink idlLibrary Keyword | |
287 | + HiLink idlImportlib Keyword | |
288 | + HiLink idlCoclass Keyword | |
289 | + HiLink idlLibraryName Typedef | |
290 | + HiLink idlCoclassName Typedef | |
291 | + " hi idlLibraryContent guifg=red | |
292 | + HiLink idlTypedefDecl Typedef | |
293 | + HiLink idlDefEnum Keyword | |
294 | + HiLink idlDefv1Enum Keyword | |
295 | + HiLink idlDefEnumName Typedef | |
296 | + HiLink idlDefEnumContents Paren | |
297 | + HiLink idlDefBaseTypeInt idlType | |
298 | + HiLink idlDefBaseType idlType | |
299 | + HiLink idlDefSeqType idlType | |
300 | + HiLink idlInterfaceSections Label | |
301 | + | |
302 | + if exists("idlsyntax_showerror") | |
303 | + if exists("idlsyntax_showerror_soft") | |
304 | + hi default idlError guibg=#d0ffd0 | |
305 | + else | |
306 | + HiLink idlError Error | |
307 | + endif | |
308 | + endif | |
198 | 309 | delcommand HiLink |
199 | 310 | endif |
200 | 311 | |
201 | 312 | let b:current_syntax = "idl" |
202 | 313 | |
203 | -" vim: ts=8 | |
314 | +" vim: sw=2 et |
@@ -2,22 +2,23 @@ | ||
2 | 2 | " This is a GENERATED FILE. Please always refer to source file at the URI below. |
3 | 3 | " Language: lilo configuration (lilo.conf) |
4 | 4 | " Maintainer: David Ne\v{c}as (Yeti) <yeti@physics.muni.cz> |
5 | -" Last Change: 2003 May 04 | |
5 | +" Last Change: 2004-07-20 | |
6 | 6 | " URL: http://trific.ath.cx/Ftp/vim/syntax/lilo.vim |
7 | 7 | |
8 | + | |
8 | 9 | " Setup |
9 | 10 | if version >= 600 |
10 | - if exists("b:current_syntax") | |
11 | - finish | |
12 | - endif | |
11 | + if exists("b:current_syntax") | |
12 | + finish | |
13 | + endif | |
13 | 14 | else |
14 | - syntax clear | |
15 | + syntax clear | |
15 | 16 | endif |
16 | 17 | |
17 | 18 | if version >= 600 |
18 | - command -nargs=1 SetIsk setlocal iskeyword=<args> | |
19 | + command -nargs=1 SetIsk setlocal iskeyword=<args> | |
19 | 20 | else |
20 | - command -nargs=1 SetIsk set iskeyword=<args> | |
21 | + command -nargs=1 SetIsk set iskeyword=<args> | |
21 | 22 | endif |
22 | 23 | SetIsk @,48-57,.,-,_ |
23 | 24 | delcommand SetIsk |
@@ -34,23 +35,23 @@ | ||
34 | 35 | syn match liloDecNumberP "\d\+p\=" contained |
35 | 36 | syn match liloSpecial contained "\\\(\"\|\\\|$\)" |
36 | 37 | syn region liloString start=+"+ skip=+\\\\\|\\"+ end=+"+ contained contains=liloSpecial,liloEnviron |
37 | -syn match liloLabel "\S\+" contained contains=liloSpecial,liloEnviron | |
38 | +syn match liloLabel :[^ "]\+: contained contains=liloSpecial,liloEnviron | |
38 | 39 | syn region liloPath start=+[$/]+ skip=+\\\\\|\\ \|\\$"+ end=+ \|$+ contained contains=liloSpecial,liloEnviron |
39 | 40 | syn match liloDecNumberList "\(\d\|,\)\+" contained contains=liloDecNumber |
40 | 41 | syn match liloDecNumberPList "\(\d\|[,p]\)\+" contained contains=liloDecNumberP,liloDecNumber |
41 | 42 | syn region liloAnything start=+[^[:space:]#]+ skip=+\\\\\|\\ \|\\$+ end=+ \|$+ contained contains=liloSpecial,liloEnviron,liloString |
42 | 43 | |
43 | 44 | " Path |
44 | -syn keyword liloOption backup bitmap boot disktab force-backup install keytable map message nextgroup=liloEqPath,liloEqPathComment,liloError skipwhite skipempty | |
45 | +syn keyword liloOption backup bitmap boot disktab force-backup keytable map message nextgroup=liloEqPath,liloEqPathComment,liloError skipwhite skipempty | |
45 | 46 | syn keyword liloKernelOpt initrd root nextgroup=liloEqPath,liloEqPathComment,liloError skipwhite skipempty |
46 | 47 | syn keyword liloImageOpt path loader table nextgroup=liloEqPath,liloEqPathComment,liloError skipwhite skipempty |
47 | 48 | syn keyword liloDiskOpt partition nextgroup=liloEqPath,liloEqPathComment,liloError skipwhite skipempty |
48 | 49 | |
49 | 50 | " Other |
50 | -syn keyword liloOption menu-scheme raid-extra-boot serial nextgroup=liloEqAnything,liloEqAnythingComment,liloError skipwhite skipempty | |
51 | -syn keyword liloOption default nextgroup=liloEqLabel,liloEqLabelComment,liloError skipwhite skipempty | |
51 | +syn keyword liloOption menu-scheme raid-extra-boot serial install nextgroup=liloEqAnything,liloEqAnythingComment,liloError skipwhite skipempty | |
52 | +syn keyword liloOption bios-passes-dl nextgroup=liloEqAnything,liloEqAnythingComment,liloError skipwhite skipempty | |
53 | +syn keyword liloOption default label alias wmdefault nextgroup=liloEqLabelString,liloEqLabelStringComment,liloError skipwhite skipempty | |
52 | 54 | syn keyword liloKernelOpt ramdisk nextgroup=liloEqAnything,liloEqAnythingComment,liloError skipwhite skipempty |
53 | -syn keyword liloImageOpt alias label nextgroup=liloEqLabel,liloEqLabelComment,liloError skipwhite skipempty | |
54 | 55 | syn keyword liloImageOpt password range nextgroup=liloEqAnything,liloEqAnythingComment,liloError skipwhite skipempty |
55 | 56 | syn keyword liloDiskOpt set type nextgroup=liloEqAnything,liloEqAnythingComment,liloError skipwhite skipempty |
56 | 57 |
@@ -67,19 +68,21 @@ | ||
67 | 68 | syn keyword liloImageOpt fallback literal nextgroup=liloEqString,liloEqStringComment,liloError skipwhite skipempty |
68 | 69 | |
69 | 70 | " Hex number |
70 | -syn keyword liloImageOpt map-drive to nextgroup=liloEqHexNumber,liloEqHexNumberComment,liloError skipwhite skipempty | |
71 | +syn keyword liloImageOpt map-drive to boot-as nextgroup=liloEqHexNumber,liloEqHexNumberComment,liloError skipwhite skipempty | |
71 | 72 | syn keyword liloDiskOpt bios normal hidden nextgroup=liloEqNumber,liloEqNumberComment,liloError skipwhite skipempty |
72 | 73 | |
73 | 74 | " Number list |
74 | -syn keyword liloOption bmp-colors bmp-timer nextgroup=liloEqNumberList,liloEqNumberListComment,liloError skipwhite skipempty | |
75 | +syn keyword liloOption bmp-colors nextgroup=liloEqNumberList,liloEqNumberListComment,liloError skipwhite skipempty | |
75 | 76 | |
76 | 77 | " Number list, some of the numbers followed by p |
77 | -syn keyword liloOption bmp-table nextgroup=liloEqDecNumberPList,liloEqDecNumberPListComment,liloError skipwhite skipempty | |
78 | +syn keyword liloOption bmp-table bmp-timer nextgroup=liloEqDecNumberPList,liloEqDecNumberPListComment,liloError skipwhite skipempty | |
78 | 79 | |
79 | 80 | " Flag |
80 | 81 | syn keyword liloOption compact fix-table geometric ignore-table lba32 linear mandatory nowarn prompt |
82 | +syn keyword liloOption bmp-retain el-torito-bootable-CD large-memory suppress-boot-time-BIOS-data | |
81 | 83 | syn keyword liloKernelOpt read-only read-write |
82 | 84 | syn keyword liloImageOpt bypass lock mandatory optional restricted single-key unsafe |
85 | +syn keyword liloImageOpt master-boot wmwarn wmdisable | |
83 | 86 | syn keyword liloDiskOpt change activate deactivate inaccessible reset |
84 | 87 | |
85 | 88 | " Image |
@@ -97,7 +100,7 @@ | ||
97 | 100 | syn match liloEqDecNumberComment "#.*$" contained nextgroup=liloEqDecNumber,liloEqDecNumberComment,liloError skipwhite skipempty |
98 | 101 | syn match liloEqHexNumberComment "#.*$" contained nextgroup=liloEqHexNumber,liloEqHexNumberComment,liloError skipwhite skipempty |
99 | 102 | syn match liloEqStringComment "#.*$" contained nextgroup=liloEqString,liloEqStringComment,liloError skipwhite skipempty |
100 | -syn match liloEqLabelComment "#.*$" contained nextgroup=liloEqLabel,liloEqLabelComment,liloError skipwhite skipempty | |
103 | +syn match liloEqLabelStringComment "#.*$" contained nextgroup=liloEqLabelString,liloEqLabelStringComment,liloError skipwhite skipempty | |
101 | 104 | syn match liloEqNumberListComment "#.*$" contained nextgroup=liloEqNumberList,liloEqNumberListComment,liloError skipwhite skipempty |
102 | 105 | syn match liloEqDecNumberPListComment "#.*$" contained nextgroup=liloEqDecNumberPList,liloEqDecNumberPListComment,liloError skipwhite skipempty |
103 | 106 | syn match liloEqAnythingComment "#.*$" contained nextgroup=liloEqAnything,liloEqAnythingComment,liloError skipwhite skipempty |
@@ -109,7 +112,7 @@ | ||
109 | 112 | syn match liloEqDecNumber "=" contained nextgroup=liloDecNumber,liloDecNumberComment,liloError skipwhite skipempty |
110 | 113 | syn match liloEqHexNumber "=" contained nextgroup=liloHexNumber,liloHexNumberComment,liloError skipwhite skipempty |
111 | 114 | syn match liloEqString "=" contained nextgroup=liloString,liloStringComment,liloError skipwhite skipempty |
112 | -syn match liloEqLabel "=" contained nextgroup=liloLabel,liloLabelComment,liloError skipwhite skipempty | |
115 | +syn match liloEqLabelString "=" contained nextgroup=liloString,liloLabel,liloLabelStringComment,liloError skipwhite skipempty | |
113 | 116 | syn match liloEqNumberList "=" contained nextgroup=liloDecNumberList,liloDecNumberListComment,liloError skipwhite skipempty |
114 | 117 | syn match liloEqDecNumberPList "=" contained nextgroup=liloDecNumberPList,liloDecNumberPListComment,liloError skipwhite skipempty |
115 | 118 | syn match liloEqAnything "=" contained nextgroup=liloAnything,liloAnythingComment,liloError skipwhite skipempty |
@@ -121,74 +124,71 @@ | ||
121 | 124 | syn match liloDecNumberComment "#.*$" contained nextgroup=liloDecNumber,liloDecNumberComment,liloError skipwhite skipempty |
122 | 125 | syn match liloHexNumberComment "#.*$" contained nextgroup=liloHexNumber,liloHexNumberComment,liloError skipwhite skipempty |
123 | 126 | syn match liloStringComment "#.*$" contained nextgroup=liloString,liloStringComment,liloError skipwhite skipempty |
124 | -syn match liloLabelComment "#.*$" contained nextgroup=liloLabel,liloLabelComment,liloError skipwhite skipempty | |
127 | +syn match liloLabelStringComment "#.*$" contained nextgroup=liloString,liloLabel,liloLabelStringComment,liloError skipwhite skipempty | |
125 | 128 | syn match liloDecNumberListComment "#.*$" contained nextgroup=liloDecNumberList,liloDecNumberListComment,liloError skipwhite skipempty |
126 | 129 | syn match liloDecNumberPListComment "#.*$" contained nextgroup=liloDecNumberPList,liloDecNumberPListComment,liloError skipwhite skipempty |
127 | 130 | syn match liloAnythingComment "#.*$" contained nextgroup=liloAnything,liloAnythingComment,liloError skipwhite skipempty |
128 | 131 | |
129 | 132 | " Define the default highlighting |
130 | 133 | if version >= 508 || !exists("did_lilo_syntax_inits") |
131 | - if version < 508 | |
132 | - let did_lilo_syntax_inits = 1 | |
133 | - command -nargs=+ HiLink hi link <args> | |
134 | - else | |
135 | - command -nargs=+ HiLink hi def link <args> | |
136 | - endif | |
137 | - | |
138 | - HiLink liloEqPath liloEquals | |
139 | - HiLink liloEqWord liloEquals | |
140 | - HiLink liloEqVga liloEquals | |
141 | - HiLink liloEqDecNumber liloEquals | |
142 | - HiLink liloEqHexNumber liloEquals | |
143 | - HiLink liloEqNumber liloEquals | |
144 | - HiLink liloEqString liloEquals | |
145 | - HiLink liloEqLabel liloEquals | |
146 | - HiLink liloEqAnything liloEquals | |
147 | - HiLink liloEquals Special | |
148 | - | |
149 | - HiLink liloError Error | |
134 | + if version < 508 | |
135 | + let did_lilo_syntax_inits = 1 | |
136 | + command -nargs=+ HiLink hi link <args> | |
137 | + else | |
138 | + command -nargs=+ HiLink hi def link <args> | |
139 | + endif | |
150 | 140 | |
151 | - HiLink liloEqPathComment liloComment | |
152 | - HiLink liloEqVgaComment liloComment | |
153 | - HiLink liloEqDecNumberComment liloComment | |
154 | - HiLink liloEqHexNumberComment liloComment | |
155 | - HiLink liloEqStringComment liloComment | |
156 | - HiLink liloEqLabelComment liloComment | |
157 | - HiLink liloEqAnythingComment liloComment | |
158 | - HiLink liloPathComment liloComment | |
159 | - HiLink liloVgaComment liloComment | |
160 | - HiLink liloDecNumberComment liloComment | |
161 | - HiLink liloHexNumberComment liloComment | |
162 | - HiLink liloNumberComment liloComment | |
163 | - HiLink liloStringComment liloComment | |
164 | - HiLink liloLabelComment liloComment | |
165 | - HiLink liloAnythingComment liloComment | |
166 | - HiLink liloComment Comment | |
141 | + HiLink liloEqPath liloEquals | |
142 | + HiLink liloEqWord liloEquals | |
143 | + HiLink liloEqVga liloEquals | |
144 | + HiLink liloEqDecNumber liloEquals | |
145 | + HiLink liloEqHexNumber liloEquals | |
146 | + HiLink liloEqNumber liloEquals | |
147 | + HiLink liloEqString liloEquals | |
148 | + HiLink liloEqAnything liloEquals | |
149 | + HiLink liloEquals Special | |
167 | 150 | |
168 | - HiLink liloDiskOpt liloOption | |
169 | - HiLink liloKernelOpt liloOption | |
170 | - HiLink liloImageOpt liloOption | |
171 | - HiLink liloOption Keyword | |
172 | - | |
173 | - HiLink liloDecNumber liloNumber | |
174 | - HiLink liloHexNumber liloNumber | |
175 | - HiLink liloDecNumberP liloNumber | |
176 | - HiLink liloNumber Number | |
177 | - HiLink liloString String | |
178 | - HiLink liloPath Constant | |
151 | + HiLink liloError Error | |
179 | 152 | |
180 | - HiLink liloSpecial Special | |
181 | - HiLink liloLabel Title | |
182 | - HiLink liloDecNumberList Special | |
183 | - HiLink liloDecNumberPList Special | |
184 | - HiLink liloAnything Normal | |
185 | - HiLink liloEnviron Identifier | |
186 | - HiLink liloVgaKeyword Identifier | |
187 | - HiLink liloImage Type | |
188 | - HiLink liloChRules Preproc | |
189 | - HiLink liloDisk Preproc | |
153 | + HiLink liloEqPathComment liloComment | |
154 | + HiLink liloEqVgaComment liloComment | |
155 | + HiLink liloEqDecNumberComment liloComment | |
156 | + HiLink liloEqHexNumberComment liloComment | |
157 | + HiLink liloEqStringComment liloComment | |
158 | + HiLink liloEqAnythingComment liloComment | |
159 | + HiLink liloPathComment liloComment | |
160 | + HiLink liloVgaComment liloComment | |
161 | + HiLink liloDecNumberComment liloComment | |
162 | + HiLink liloHexNumberComment liloComment | |
163 | + HiLink liloNumberComment liloComment | |
164 | + HiLink liloStringComment liloComment | |
165 | + HiLink liloAnythingComment liloComment | |
166 | + HiLink liloComment Comment | |
190 | 167 | |
191 | - delcommand HiLink | |
168 | + HiLink liloDiskOpt liloOption | |
169 | + HiLink liloKernelOpt liloOption | |
170 | + HiLink liloImageOpt liloOption | |
171 | + HiLink liloOption Keyword | |
172 | + | |
173 | + HiLink liloDecNumber liloNumber | |
174 | + HiLink liloHexNumber liloNumber | |
175 | + HiLink liloDecNumberP liloNumber | |
176 | + HiLink liloNumber Number | |
177 | + HiLink liloString String | |
178 | + HiLink liloPath Constant | |
179 | + | |
180 | + HiLink liloSpecial Special | |
181 | + HiLink liloLabel Title | |
182 | + HiLink liloDecNumberList Special | |
183 | + HiLink liloDecNumberPList Special | |
184 | + HiLink liloAnything Normal | |
185 | + HiLink liloEnviron Identifier | |
186 | + HiLink liloVgaKeyword Identifier | |
187 | + HiLink liloImage Type | |
188 | + HiLink liloChRules Preproc | |
189 | + HiLink liloDisk Preproc | |
190 | + | |
191 | + delcommand HiLink | |
192 | 192 | endif |
193 | 193 | |
194 | 194 | let b:current_syntax = "lilo" |
@@ -2,10 +2,10 @@ | ||
2 | 2 | " Language: LambdaProlog (Teyjus) |
3 | 3 | " Filenames: *.mod *.sig |
4 | 4 | " Maintainer: Markus Mottl <markus@oefai.at> |
5 | -" URL: http://www.ai.univie.ac.at/~markus/vim/syntax/lprolog.vim | |
6 | -" Last Change: 2003 May 11 | |
7 | -" 2001 Apr 26 - Upgraded for new Vim version | |
8 | -" 2000 Jun 5 - Initial release | |
5 | +" URL: http://www.oefai.at/~markus/vim/syntax/lprolog.vim | |
6 | +" Last Change: 2004 Jul 26 | |
7 | +" 2001 Apr 26 - Upgraded for new Vim version | |
8 | +" 2000 Jun 5 - Initial release | |
9 | 9 | |
10 | 10 | " For version 5.x: Clear all syntax items |
11 | 11 | " For version 6.x: Quit when a syntax file was already loaded |
@@ -2,12 +2,12 @@ | ||
2 | 2 | " Language: OCaml |
3 | 3 | " Filenames: *.ml *.mli *.mll *.mly |
4 | 4 | " Maintainers: Markus Mottl <markus@oefai.at> |
5 | -" Karl-Heinz Sylla <Karl-Heinz.Sylla@gmd.de> | |
6 | -" Issac Trotts <<ijtrotts@ucdavis.edu> | |
7 | -" URL: http://www.oefai.at/~markus/vim/syntax/ocaml.vim | |
8 | -" Last Change: 2003 May 04 | |
9 | -" 2002 Oct 24 - Small fix for "module type" (MM) | |
10 | -" 2002 Jun 16 - Added "&&", "<" and ">" as operators (MM) | |
5 | +" Karl-Heinz Sylla <Karl-Heinz.Sylla@gmd.de> | |
6 | +" Issac Trotts <ijtrotts@ucdavis.edu> | |
7 | +" URL: http://www.oefai.at/~markus/vim/syntax/ocaml.vim | |
8 | +" Last Change: 2004 Jul 26 | |
9 | +" 2003 Jan 19 - Added keyword "require" for scripting (MM) | |
10 | +" 2002 Oct 30 - New variable "ocaml_revised" (MM) | |
11 | 11 | |
12 | 12 | " For version 5.x: Clear all syntax items |
13 | 13 | " For version 6.x: Quit when a syntax file was already loaded |
@@ -24,7 +24,7 @@ | ||
24 | 24 | syn match ocamlComment "^#!.*" |
25 | 25 | |
26 | 26 | " Scripting directives |
27 | -syn match ocamlScript "^#\<\(quit\|labels\|warnings\|directory\|cd\|load\|use\|install_printer\|remove_printer\|trace\|untrace\|untrace_all\|print_depth\|print_length\)\>" | |
27 | +syn match ocamlScript "^#\<\(quit\|labels\|warnings\|directory\|cd\|load\|use\|install_printer\|remove_printer\|require\|trace\|untrace\|untrace_all\|print_depth\|print_length\)\>" | |
28 | 28 | |
29 | 29 | " lowercase identifier - the standard way to match |
30 | 30 | syn match ocamlLCIdentifier /\<\(\l\|_\)\(\w\|'\)*\>/ |
@@ -163,7 +163,7 @@ | ||
163 | 163 | syn match ocamlKeyChar "!" |
164 | 164 | endif |
165 | 165 | |
166 | -syn keyword ocamlType array bool char exn float format int | |
166 | +syn keyword ocamlType array bool char exn float format format4 int | |
167 | 167 | syn keyword ocamlType list option string unit |
168 | 168 | |
169 | 169 | syn keyword ocamlOperator asr lor lsl lsr lxor mod not |
@@ -1,12 +1,12 @@ | ||
1 | 1 | " Vim syntax file |
2 | 2 | " Language: SML |
3 | 3 | " Filenames: *.sml *.sig |
4 | -" Maintainers: Markus Mottl <markus@oefai.at> | |
5 | -" Fabrizio Zeno Cornelli <zeno@filibusta.crema.unimi.it> | |
6 | -" URL: http://www.ai.univie.ac.at/~markus/vim/syntax/sml.vim | |
7 | -" Last Change: 2003 May 11 | |
8 | -" 2001 Nov 20 - Fixed small highlighting bug with modules (MM) | |
9 | -" 2001 Aug 29 - Fixed small highlighting bug (MM) | |
4 | +" Maintainers: Markus Mottl <markus@oefai.at> | |
5 | +" Fabrizio Zeno Cornelli <zeno@filibusta.crema.unimi.it> | |
6 | +" URL: http://www.oefai.at/~markus/vim/syntax/sml.vim | |
7 | +" Last Change: 2004 Jul 26 | |
8 | +" 2001 Nov 20 - Fixed small highlighting bug with modules (MM) | |
9 | +" 2001 Aug 29 - Fixed small highlighting bug (MM) | |
10 | 10 | |
11 | 11 | " For version 5.x: Clear all syntax items |
12 | 12 | " For version 6.x: Quit when a syntax file was already loaded |
@@ -1055,9 +1055,9 @@ | ||
1055 | 1055 | NONE_INSTALL = install_normal |
1056 | 1056 | |
1057 | 1057 | ### KDE GUI interface. |
1058 | -KDE_SRC = gui.c pty.c gui_kde.cc gui_kde_x11.cc gui_kde_widget.cc gui_kde_widget_moc.cc kvim_iface_skel.cc | |
1058 | +KDE_SRC = gui.c pty.c gui_kde.cc gui_kde_x11.cc gui_kde_wid.cc gui_kde_wid_moc.cc kvim_iface_skel.cc | |
1059 | 1059 | KDE_OBJ = objects/gui.o objects/pty.o objects/gui_kde.o objects/gui_kde_x11.o \ |
1060 | - objects/gui_kde_widget.o objects/gui_kde_widget_moc.o \ | |
1060 | + objects/gui_kde_wid.o objects/gui_kde_wid_moc.o \ | |
1061 | 1061 | objects/kvim_iface_skel.o |
1062 | 1062 | KDE_DEFS = -DFEAT_GUI_KDE $(NARROW_PROTO) |
1063 | 1063 | KDE_IPATH = $(GUI_INC_LOC) |
@@ -1201,7 +1201,7 @@ | ||
1201 | 1201 | CARBONGUI_TESTARG = VIMPROG=../$(CARBONGUI_BUNDLE)/Contents/MacOS/$(VIMTARGET) |
1202 | 1202 | |
1203 | 1203 | # All GUI files |
1204 | -ALL_GUI_SRC = gui.c gui_gtk.c gui_gtk_f.c gui_motif.c gui_athena.c gui_gtk_x11.c gui_x11.c gui_at_sb.c gui_at_fs.c pty.c gui_kde.cc gui_kde_widget.cc gui_kde_x11.cc gui_kde_widget_moc.cc | |
1204 | +ALL_GUI_SRC = gui.c gui_gtk.c gui_gtk_f.c gui_motif.c gui_athena.c gui_gtk_x11.c gui_x11.c gui_at_sb.c gui_at_fs.c pty.c gui_kde.cc gui_kde_wid.cc gui_kde_x11.cc gui_kde_wid_moc.cc | |
1205 | 1205 | ALL_GUI_PRO = gui.pro gui_gtk.pro gui_motif.pro gui_athena.pro gui_gtk_x11.pro gui_x11.pro gui_w16.pro gui_w32.pro gui_amiga.pro gui_photon.pro gui_kde.pro gui_kde_x11.pro |
1206 | 1206 | |
1207 | 1207 | # }}} |
@@ -2038,7 +2038,7 @@ | ||
2038 | 2038 | -rm -f $(TOOLS) auto/osdef.h auto/pathdef.c auto/if_perl.c |
2039 | 2039 | -rm -f conftest* *~ auto/link.sed |
2040 | 2040 | -rm -rf $(GUI_BUNDLE) |
2041 | - -rm -f gui_kde_widget_moc.cc kvim_iface_skel.cc *.kidl | |
2041 | + -rm -f gui_kde_wid_moc.cc kvim_iface_skel.cc *.kidl | |
2042 | 2042 | if test -d $(PODIR); then \ |
2043 | 2043 | cd $(PODIR); $(MAKE) prefix=$(DESTDIR)$(prefix) clean; \ |
2044 | 2044 | fi |
@@ -2393,17 +2393,17 @@ | ||
2393 | 2393 | objects/gui_kde_x11.o: gui_kde_x11.cc |
2394 | 2394 | $(CCC) -o $@ gui_kde_x11.cc |
2395 | 2395 | |
2396 | -objects/gui_kde_widget.o: gui_kde_widget.cc | |
2397 | - $(MOC) -o gui_kde_widget_moc.cc gui_kde_widget.h | |
2396 | +objects/gui_kde_wid.o: gui_kde_wid.cc | |
2397 | + $(MOC) -o gui_kde_wid_moc.cc gui_kde_wid.h | |
2398 | 2398 | $(KDE_DIR)/bin/dcopidl kvim_iface.h > kvim_iface.kidl || ( rm -f kvim_iface.kidl ; /bin/false ) |
2399 | 2399 | $(KDE_DIR)/bin/dcopidl2cpp --c++-suffix cc --no-stub kvim_iface.kidl |
2400 | - $(CCC) -o $@ gui_kde_widget.cc | |
2401 | - | |
2402 | -gui_kde_widget_moc.cc: objects/gui_kde_widget.o | |
2403 | -objects/gui_kde_widget_moc.o: gui_kde_widget_moc.cc | |
2404 | - $(CCC) -o $@ gui_kde_widget_moc.cc | |
2405 | - | |
2406 | -kvim_iface_skel.cc: objects/gui_kde_widget.o | |
2400 | + $(CCC) -o $@ gui_kde_wid.cc | |
2401 | + | |
2402 | +gui_kde_wid_moc.cc: objects/gui_kde_wid.o | |
2403 | +objects/gui_kde_wid_moc.o: gui_kde_wid_moc.cc | |
2404 | + $(CCC) -o $@ gui_kde_wid_moc.cc | |
2405 | + | |
2406 | +kvim_iface_skel.cc: objects/gui_kde_wid.o | |
2407 | 2407 | objects/kvim_iface_skel.o: kvim_iface_skel.cc |
2408 | 2408 | $(CCC) -o $@ kvim_iface_skel.cc |
2409 | 2409 |
@@ -2716,21 +2716,21 @@ | ||
2716 | 2716 | ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h gui_beval.h \ |
2717 | 2717 | proto/gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \ |
2718 | 2718 | arabic.h |
2719 | -objects/gui_kde.o: gui_kde.cc gui_kde_widget.h kvim_iface.h vim.h \ | |
2719 | +objects/gui_kde.o: gui_kde.cc gui_kde_wid.h kvim_iface.h vim.h \ | |
2720 | 2720 | auto/config.h feature.h os_unix.h auto/osdef.h ascii.h keymap.h \ |
2721 | 2721 | term.h macros.h structs.h regexp.h gui.h option.h ex_cmds.h proto.h \ |
2722 | 2722 | globals.h farsi.h |
2723 | -objects/gui_kde_widget.o: gui_kde_widget.cc gui_kde_widget.h kvim_iface.h \ | |
2723 | +objects/gui_kde_wid.o: gui_kde_wid.cc gui_kde_wid.h kvim_iface.h \ | |
2724 | 2724 | vim.h auto/config.h feature.h os_unix.h auto/osdef.h ascii.h keymap.h \ |
2725 | 2725 | term.h macros.h structs.h regexp.h gui.h option.h ex_cmds.h proto.h \ |
2726 | 2726 | globals.h farsi.h proto/../../pixmaps/alert.xpm proto/../../pixmaps/error.xpm \ |
2727 | 2727 | proto/../../pixmaps/generic.xpm proto/../../pixmaps/info.xpm \ |
2728 | 2728 | proto/../../pixmaps/quest.xpm |
2729 | -objects/gui_kde_x11.o: gui_kde_x11.cc gui_kde_widget.h kvim_iface.h vim.h \ | |
2729 | +objects/gui_kde_x11.o: gui_kde_x11.cc gui_kde_wid.h kvim_iface.h vim.h \ | |
2730 | 2730 | auto/config.h feature.h os_unix.h auto/osdef.h ascii.h keymap.h \ |
2731 | 2731 | term.h macros.h structs.h regexp.h gui.h option.h ex_cmds.h proto.h \ |
2732 | 2732 | globals.h farsi.h version.h ../runtime/vim32x32.xpm |
2733 | -objects/gui_kde_widget_moc.o: gui_kde_widget_moc.cc gui_kde_widget.h \ | |
2733 | +objects/gui_kde_wid_moc.o: gui_kde_wid_moc.cc gui_kde_wid.h \ | |
2734 | 2734 | kvim_iface.h vim.h auto/config.h feature.h os_unix.h auto/osdef.h \ |
2735 | 2735 | ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h option.h \ |
2736 | 2736 | ex_cmds.h proto.h globals.h |
@@ -216,6 +216,12 @@ | ||
216 | 216 | #endif |
217 | 217 | curbuf->b_flags |= BF_READERR; |
218 | 218 | |
219 | +#ifdef FEAT_FOLDING | |
220 | + /* Need to update automatic folding. Do this before the autocommands, | |
221 | + * they may use the fold info. */ | |
222 | + foldUpdateAll(curwin); | |
223 | +#endif | |
224 | + | |
219 | 225 | #ifdef FEAT_AUTOCMD |
220 | 226 | /* need to set w_topline, unless some autocommand already did that. */ |
221 | 227 | if (!(curwin->w_valid & VALID_TOPLINE)) |
@@ -263,11 +269,6 @@ | ||
263 | 269 | #endif |
264 | 270 | } |
265 | 271 | |
266 | -#ifdef FEAT_FOLDING | |
267 | - /* Need to update automatic folding. */ | |
268 | - foldUpdateAll(curwin); | |
269 | -#endif | |
270 | - | |
271 | 272 | return retval; |
272 | 273 | } |
273 | 274 |
@@ -408,8 +409,7 @@ | ||
408 | 409 | if (!buf_valid(buf)) |
409 | 410 | return; |
410 | 411 | # ifdef FEAT_EVAL |
411 | - /* Autocommands may abort script processing. */ | |
412 | - if (aborting()) | |
412 | + if (aborting()) /* autocmds may abort script processing */ | |
413 | 413 | return; |
414 | 414 | # endif |
415 | 415 |
@@ -538,7 +538,8 @@ | ||
538 | 538 | return; |
539 | 539 | } |
540 | 540 | # ifdef FEAT_EVAL |
541 | - if (aborting()) /* autocmds may abort script processing */ | |
541 | + /* autocmds may abort script processing */ | |
542 | + if (aborting()) | |
542 | 543 | return; |
543 | 544 | # endif |
544 | 545 |
@@ -669,8 +670,16 @@ | ||
669 | 670 | && (defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)) |
670 | 671 | if (swap_exists_action == SEA_QUIT && *eap->cmd == 's') |
671 | 672 | { |
672 | - /* Quitting means closing the split window, nothing else. */ | |
673 | + int old_got_int = got_int; | |
674 | + | |
675 | + /* Quitting means closing the split window, nothing else. | |
676 | + * Reset got_int here, because it causes aborting() to return TRUE | |
677 | + * which breaks closing a window. */ | |
678 | + got_int = FALSE; | |
679 | + | |
673 | 680 | win_close(curwin, TRUE); |
681 | + | |
682 | + got_int |= old_got_int; | |
674 | 683 | swap_exists_action = SEA_NONE; |
675 | 684 | } |
676 | 685 | else |
@@ -688,6 +697,12 @@ | ||
688 | 697 | handle_swap_exists(old_curbuf) |
689 | 698 | buf_T *old_curbuf; |
690 | 699 | { |
700 | + int old_got_int = got_int; | |
701 | + | |
702 | + /* Reset got_int here, because it causes aborting() to return TRUE which | |
703 | + * breaks closing a buffer. */ | |
704 | + got_int = FALSE; | |
705 | + | |
691 | 706 | if (swap_exists_action == SEA_QUIT) |
692 | 707 | { |
693 | 708 | /* User selected Quit at ATTENTION prompt. Go back to previous |
@@ -712,6 +727,7 @@ | ||
712 | 727 | do_modelines(); |
713 | 728 | } |
714 | 729 | swap_exists_action = SEA_NONE; |
730 | + got_int |= old_got_int; | |
715 | 731 | } |
716 | 732 | #endif |
717 | 733 |
@@ -4226,26 +4242,28 @@ | ||
4226 | 4242 | #endif |
4227 | 4243 | set_curbuf(buf, DOBUF_GOTO); |
4228 | 4244 | #ifdef FEAT_AUTOCMD |
4229 | -# ifdef FEAT_EVAL | |
4230 | - /* Autocommands deleted the buffer or aborted script | |
4231 | - * processing!!! */ | |
4232 | - if (!buf_valid(buf) || aborting()) | |
4233 | -# else | |
4234 | 4245 | if (!buf_valid(buf)) /* autocommands deleted the buffer!!! */ |
4235 | -# endif | |
4236 | 4246 | { |
4237 | -#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) | |
4247 | +# if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) | |
4238 | 4248 | swap_exists_action = SEA_NONE; |
4239 | -#endif | |
4249 | +# endif | |
4240 | 4250 | break; |
4241 | 4251 | } |
4242 | 4252 | #endif |
4243 | 4253 | #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) |
4244 | 4254 | if (swap_exists_action == SEA_QUIT) |
4245 | 4255 | { |
4246 | - /* User selected Quit at ATTENTION prompt; close this window. */ | |
4256 | + int old_got_int = got_int; | |
4257 | + | |
4258 | + /* User selected Quit at ATTENTION prompt; close this window. | |
4259 | + * Reset got_int here, because it causes aborting() to return | |
4260 | + * TRUE which breaks closing a window. */ | |
4261 | + got_int = FALSE; | |
4262 | + | |
4247 | 4263 | win_close(curwin, TRUE); |
4248 | 4264 | --open_wins; |
4265 | + | |
4266 | + got_int |= old_got_int; | |
4249 | 4267 | swap_exists_action = SEA_NONE; |
4250 | 4268 | } |
4251 | 4269 | else |
@@ -4259,6 +4277,11 @@ | ||
4259 | 4277 | (void)vgetc(); /* only break the file loading, not the rest */ |
4260 | 4278 | break; |
4261 | 4279 | } |
4280 | +#ifdef FEAT_EVAL | |
4281 | + /* Autocommands deleted the buffer or aborted script processing!!! */ | |
4282 | + if (aborting()) | |
4283 | + break; | |
4284 | +#endif | |
4262 | 4285 | } |
4263 | 4286 | #ifdef FEAT_AUTOCMD |
4264 | 4287 | --autocmd_no_enter; |
@@ -2641,7 +2641,7 @@ | ||
2641 | 2641 | |
2642 | 2642 | #ifdef FEAT_COMPL_FUNC |
2643 | 2643 | static char_u *call_completefunc __ARGS((char_u *line, char_u *base, int col, int preproc)); |
2644 | -static int expand_by_function __ARGS((int lnum, int col, char_u *base, char_u ***matches)); | |
2644 | +static int expand_by_function __ARGS((linenr_T lnum, int col, char_u *base, char_u ***matches)); | |
2645 | 2645 | |
2646 | 2646 | /* |
2647 | 2647 | * Execute user defined complete function 'completefunc'. |
@@ -2665,7 +2665,7 @@ | ||
2665 | 2665 | args[0] = line; |
2666 | 2666 | args[1] = base; |
2667 | 2667 | args[2] = colbuf; |
2668 | - args[3] = preproc ? "1" : "0"; | |
2668 | + args[3] = (char_u *)(preproc ? "1" : "0"); | |
2669 | 2669 | return call_vim_function(curbuf->b_p_cfu, 4, args, FALSE); |
2670 | 2670 | } |
2671 | 2671 |
@@ -2676,7 +2676,7 @@ | ||
2676 | 2676 | */ |
2677 | 2677 | static int |
2678 | 2678 | expand_by_function(lnum, col, base, matches) |
2679 | - int lnum; | |
2679 | + linenr_T lnum; | |
2680 | 2680 | int col; |
2681 | 2681 | char_u *base; |
2682 | 2682 | char_u ***matches; |
@@ -3528,7 +3528,7 @@ | ||
3528 | 3528 | lenstr = call_completefunc(line, NULL, complete_col, 1); |
3529 | 3529 | if (lenstr == NULL) |
3530 | 3530 | return FAIL; |
3531 | - keeplen = atoi(lenstr); | |
3531 | + keeplen = atoi((char *)lenstr); | |
3532 | 3532 | vim_free(lenstr); |
3533 | 3533 | if (keeplen < 0) |
3534 | 3534 | return FAIL; |
@@ -295,8 +295,10 @@ | ||
295 | 295 | static void f_getcmdline __ARGS((VAR argvars, VAR retvar)); |
296 | 296 | static void f_getcmdpos __ARGS((VAR argvars, VAR retvar)); |
297 | 297 | static void f_getcwd __ARGS((VAR argvars, VAR retvar)); |
298 | +static void f_getfperm __ARGS((VAR argvars, VAR retvar)); | |
298 | 299 | static void f_getfsize __ARGS((VAR argvars, VAR retvar)); |
299 | 300 | static void f_getftime __ARGS((VAR argvars, VAR retvar)); |
301 | +static void f_getftype __ARGS((VAR argvars, VAR retvar)); | |
300 | 302 | static void f_getline __ARGS((VAR argvars, VAR retvar)); |
301 | 303 | static void f_getreg __ARGS((VAR argvars, VAR retvar)); |
302 | 304 | static void f_getregtype __ARGS((VAR argvars, VAR retvar)); |
@@ -751,7 +753,7 @@ | ||
751 | 753 | if (argv[i] == NULL || *argv[i] == NUL) |
752 | 754 | { |
753 | 755 | argvars[i].var_type = VAR_STRING; |
754 | - argvars[i].var_val.var_string = ""; | |
756 | + argvars[i].var_val.var_string = (char_u *)""; | |
755 | 757 | continue; |
756 | 758 | } |
757 | 759 |
@@ -2853,8 +2855,10 @@ | ||
2853 | 2855 | {"getcmdline", 0, 0, f_getcmdline}, |
2854 | 2856 | {"getcmdpos", 0, 0, f_getcmdpos}, |
2855 | 2857 | {"getcwd", 0, 0, f_getcwd}, |
2858 | + {"getfperm", 1, 1, f_getfperm}, | |
2856 | 2859 | {"getfsize", 1, 1, f_getfsize}, |
2857 | 2860 | {"getftime", 1, 1, f_getftime}, |
2861 | + {"getftype", 1, 1, f_getftype}, | |
2858 | 2862 | {"getline", 1, 1, f_getline}, |
2859 | 2863 | {"getreg", 0, 1, f_getreg}, |
2860 | 2864 | {"getregtype", 0, 1, f_getregtype}, |
@@ -2941,7 +2945,7 @@ | ||
2941 | 2945 | {"wincol", 0, 0, f_wincol}, |
2942 | 2946 | {"winheight", 1, 1, f_winheight}, |
2943 | 2947 | {"winline", 0, 0, f_winline}, |
2944 | - {"winnr", 0, 0, f_winnr}, | |
2948 | + {"winnr", 0, 1, f_winnr}, | |
2945 | 2949 | {"winrestcmd", 0, 0, f_winrestcmd}, |
2946 | 2950 | {"winwidth", 1, 1, f_winwidth}, |
2947 | 2951 | }; |
@@ -4578,6 +4582,38 @@ | ||
4578 | 4582 | } |
4579 | 4583 | |
4580 | 4584 | /* |
4585 | + * "getfperm({fname})" function | |
4586 | + */ | |
4587 | + static void | |
4588 | +f_getfperm(argvars, retvar) | |
4589 | + VAR argvars; | |
4590 | + VAR retvar; | |
4591 | +{ | |
4592 | + char_u *fname; | |
4593 | + struct stat st; | |
4594 | + char_u *perm = NULL; | |
4595 | + char_u flags[] = "rwx"; | |
4596 | + int i; | |
4597 | + | |
4598 | + fname = get_var_string(&argvars[0]); | |
4599 | + | |
4600 | + retvar->var_type = VAR_STRING; | |
4601 | + if (mch_stat((char *)fname, &st) >= 0) | |
4602 | + { | |
4603 | + perm = vim_strsave((char_u *)"---------"); | |
4604 | + if (perm != NULL) | |
4605 | + { | |
4606 | + for (i = 0; i < 9; i++) | |
4607 | + { | |
4608 | + if (st.st_mode & (1 << (8 - i))) | |
4609 | + perm[i] = flags[i % 3]; | |
4610 | + } | |
4611 | + } | |
4612 | + } | |
4613 | + retvar->var_val.var_string = perm; | |
4614 | +} | |
4615 | + | |
4616 | +/* | |
4581 | 4617 | * "getfsize({fname})" function |
4582 | 4618 | */ |
4583 | 4619 | static void |
@@ -4623,6 +4659,86 @@ | ||
4623 | 4659 | } |
4624 | 4660 | |
4625 | 4661 | /* |
4662 | + * "getftype({fname})" function | |
4663 | + */ | |
4664 | + static void | |
4665 | +f_getftype(argvars, retvar) | |
4666 | + VAR argvars; | |
4667 | + VAR retvar; | |
4668 | +{ | |
4669 | + char_u *fname; | |
4670 | + struct stat st; | |
4671 | + char_u *type = NULL; | |
4672 | + char *t; | |
4673 | + | |
4674 | + fname = get_var_string(&argvars[0]); | |
4675 | + | |
4676 | + retvar->var_type = VAR_STRING; | |
4677 | + if (mch_lstat((char *)fname, &st) >= 0) | |
4678 | + { | |
4679 | +#ifdef S_ISREG | |
4680 | + if (S_ISREG(st.st_mode)) | |
4681 | + t = "file"; | |
4682 | + else if (S_ISDIR(st.st_mode)) | |
4683 | + t = "dir"; | |
4684 | +# ifdef S_ISLNK | |
4685 | + else if (S_ISLNK(st.st_mode)) | |
4686 | + t = "link"; | |
4687 | +# endif | |
4688 | +# ifdef S_ISBLK | |
4689 | + else if (S_ISBLK(st.st_mode)) | |
4690 | + t = "bdev"; | |
4691 | +# endif | |
4692 | +# ifdef S_ISCHR | |
4693 | + else if (S_ISCHR(st.st_mode)) | |
4694 | + t = "cdev"; | |
4695 | +# endif | |
4696 | +# ifdef S_ISFIFO | |
4697 | + else if (S_ISFIFO(st.st_mode)) | |
4698 | + t = "fifo"; | |
4699 | +# endif | |
4700 | +# ifdef S_ISSOCK | |
4701 | + else if (S_ISSOCK(st.st_mode)) | |
4702 | + t = "fifo"; | |
4703 | +# endif | |
4704 | + else | |
4705 | + t = "other"; | |
4706 | +#else | |
4707 | +# ifdef S_IFMT | |
4708 | + switch (st.st_mode & S_IFMT) | |
4709 | + { | |
4710 | + case S_IFREG: t = "file"; break; | |
4711 | + case S_IFDIR: t = "dir"; break; | |
4712 | +# ifdef S_IFLNK | |
4713 | + case S_IFLNK: t = "link"; break; | |
4714 | +# endif | |
4715 | +# ifdef S_IFBLK | |
4716 | + case S_IFBLK: t = "bdev"; break; | |
4717 | +# endif | |
4718 | +# ifdef S_IFCHR | |
4719 | + case S_IFCHR: t = "cdev"; break; | |
4720 | +# endif | |
4721 | +# ifdef S_IFIFO | |
4722 | + case S_IFIFO: t = "fifo"; break; | |
4723 | +# endif | |
4724 | +# ifdef S_IFSOCK | |
4725 | + case S_IFSOCK: t = "socket"; break; | |
4726 | +# endif | |
4727 | + default: t = "other"; | |
4728 | + } | |
4729 | +# else | |
4730 | + if (mch_isdir(fname)) | |
4731 | + t = "dir"; | |
4732 | + else | |
4733 | + t = "file"; | |
4734 | +# endif | |
4735 | +#endif | |
4736 | + type = vim_strsave((char_u *)t); | |
4737 | + } | |
4738 | + retvar->var_val.var_string = type; | |
4739 | +} | |
4740 | + | |
4741 | +/* | |
4626 | 4742 | * "getreg()" function |
4627 | 4743 | */ |
4628 | 4744 | static void |
@@ -6305,6 +6421,10 @@ | ||
6305 | 6421 | retvar->var_type = VAR_STRING; |
6306 | 6422 | } |
6307 | 6423 | |
6424 | +#define SP_NOMOVE 1 /* don't move cursor */ | |
6425 | +#define SP_REPEAT 2 /* repeat to find outer pair */ | |
6426 | +#define SP_RETCOUNT 4 /* return matchcount */ | |
6427 | + | |
6308 | 6428 | /* |
6309 | 6429 | * "search()" function |
6310 | 6430 | */ |
@@ -6315,13 +6435,24 @@ | ||
6315 | 6435 | { |
6316 | 6436 | char_u *pat; |
6317 | 6437 | pos_T pos; |
6438 | + pos_T save_cursor; | |
6318 | 6439 | int save_p_ws = p_ws; |
6319 | 6440 | int dir; |
6441 | + int flags = 0; | |
6442 | + | |
6443 | + retvar->var_val.var_number = 0; /* default: FAIL */ | |
6320 | 6444 | |
6321 | 6445 | pat = get_var_string(&argvars[0]); |
6322 | - dir = get_search_arg(&argvars[1], NULL); /* may set p_ws */ | |
6323 | - | |
6324 | - pos = curwin->w_cursor; | |
6446 | + dir = get_search_arg(&argvars[1], &flags); /* may set p_ws */ | |
6447 | + if (dir == 0) | |
6448 | + goto theend; | |
6449 | + if ((flags & ~SP_NOMOVE) != 0) | |
6450 | + { | |
6451 | + EMSG2(_(e_invarg2), get_var_string(&argvars[1])); | |
6452 | + goto theend; | |
6453 | + } | |
6454 | + | |
6455 | + pos = save_cursor = curwin->w_cursor; | |
6325 | 6456 | if (searchit(curwin, curbuf, &pos, dir, pat, 1L, |
6326 | 6457 | SEARCH_KEEP, RE_SEARCH) != FAIL) |
6327 | 6458 | { |
@@ -6331,15 +6462,14 @@ | ||
6331 | 6462 | * correct that here */ |
6332 | 6463 | check_cursor(); |
6333 | 6464 | } |
6334 | - else | |
6335 | - retvar->var_val.var_number = 0; | |
6465 | + | |
6466 | + /* If 'n' flag is used: restore cursor position. */ | |
6467 | + if (flags & SP_NOMOVE) | |
6468 | + curwin->w_cursor = save_cursor; | |
6469 | +theend: | |
6336 | 6470 | p_ws = save_p_ws; |
6337 | 6471 | } |
6338 | 6472 | |
6339 | -#define SP_NOMOVE 1 /* don't move cursor */ | |
6340 | -#define SP_REPEAT 2 /* repeat to find outer pair */ | |
6341 | -#define SP_RETCOUNT 4 /* return matchcount */ | |
6342 | - | |
6343 | 6473 | /* |
6344 | 6474 | * "searchpair()" function |
6345 | 6475 | */ |
@@ -6393,6 +6523,8 @@ | ||
6393 | 6523 | |
6394 | 6524 | /* Handle the optional fourth argument: flags */ |
6395 | 6525 | dir = get_search_arg(&argvars[3], &flags); /* may set p_ws */ |
6526 | + if (dir == 0) | |
6527 | + goto theend; | |
6396 | 6528 | |
6397 | 6529 | /* Optional fifth argument: skip expresion */ |
6398 | 6530 | if (argvars[3].var_type == VAR_UNKNOWN |
@@ -6474,6 +6606,11 @@ | ||
6474 | 6606 | p_cpo = save_cpo; |
6475 | 6607 | } |
6476 | 6608 | |
6609 | +/* | |
6610 | + * Get flags for a search function. | |
6611 | + * Possibly sets "p_ws". | |
6612 | + * Returns BACKWARD, FORWARD or zero (for an error). | |
6613 | + */ | |
6477 | 6614 | static int |
6478 | 6615 | get_search_arg(varp, flagsp) |
6479 | 6616 | VAR varp; |
@@ -6482,24 +6619,37 @@ | ||
6482 | 6619 | int dir = FORWARD; |
6483 | 6620 | char_u *flags; |
6484 | 6621 | char_u nbuf[NUMBUFLEN]; |
6622 | + int mask; | |
6485 | 6623 | |
6486 | 6624 | if (varp->var_type != VAR_UNKNOWN) |
6487 | 6625 | { |
6488 | 6626 | flags = get_var_string_buf(varp, nbuf); |
6489 | - if (vim_strchr(flags, 'b') != NULL) | |
6490 | - dir = BACKWARD; | |
6491 | - if (vim_strchr(flags, 'w') != NULL) | |
6492 | - p_ws = TRUE; | |
6493 | - if (vim_strchr(flags, 'W') != NULL) | |
6494 | - p_ws = FALSE; | |
6495 | - if (flagsp != NULL) | |
6496 | - { | |
6497 | - if (vim_strchr(flags, 'n') != NULL) | |
6498 | - *flagsp |= SP_NOMOVE; | |
6499 | - if (vim_strchr(flags, 'r') != NULL) | |
6500 | - *flagsp |= SP_REPEAT; | |
6501 | - if (vim_strchr(flags, 'm') != NULL) | |
6502 | - *flagsp |= SP_RETCOUNT; | |
6627 | + while (*flags != NUL) | |
6628 | + { | |
6629 | + switch (*flags) | |
6630 | + { | |
6631 | + case 'b': dir = BACKWARD; break; | |
6632 | + case 'w': p_ws = TRUE; break; | |
6633 | + case 'W': p_ws = FALSE; break; | |
6634 | + default: mask = 0; | |
6635 | + if (flagsp != NULL) | |
6636 | + switch (*flags) | |
6637 | + { | |
6638 | + case 'n': mask = SP_NOMOVE; break; | |
6639 | + case 'r': mask = SP_REPEAT; break; | |
6640 | + case 'm': mask = SP_RETCOUNT; break; | |
6641 | + } | |
6642 | + if (mask == 0) | |
6643 | + { | |
6644 | + EMSG2(_(e_invarg2), flags); | |
6645 | + dir = 0; | |
6646 | + } | |
6647 | + else | |
6648 | + *flagsp |= mask; | |
6649 | + } | |
6650 | + if (dir == 0) | |
6651 | + break; | |
6652 | + ++flags; | |
6503 | 6653 | } |
6504 | 6654 | } |
6505 | 6655 | return dir; |
@@ -7648,7 +7798,9 @@ | ||
7648 | 7798 | /* not multi-byte: fromstr and tostr must be the same length */ |
7649 | 7799 | if (STRLEN(fromstr) != STRLEN(tostr)) |
7650 | 7800 | { |
7801 | +#ifdef FEAT_MBYTE | |
7651 | 7802 | error: |
7803 | +#endif | |
7652 | 7804 | EMSG2(_(e_invarg2), fromstr); |
7653 | 7805 | ga_clear(&ga); |
7654 | 7806 | return; |
@@ -7859,9 +8011,30 @@ | ||
7859 | 8011 | int nr = 1; |
7860 | 8012 | #ifdef FEAT_WINDOWS |
7861 | 8013 | win_T *wp; |
7862 | - | |
7863 | - for (wp = firstwin; wp != curwin; wp = wp->w_next) | |
7864 | - ++nr; | |
8014 | + win_T *twin = curwin; | |
8015 | + char_u *arg; | |
8016 | + | |
8017 | + if (argvars[0].var_type != VAR_UNKNOWN) | |
8018 | + { | |
8019 | + arg = get_var_string(&argvars[0]); | |
8020 | + if (STRCMP(arg, "$") == 0) | |
8021 | + twin = lastwin; | |
8022 | + else if (STRCMP(arg, "#") == 0) | |
8023 | + { | |
8024 | + twin = prevwin; | |
8025 | + if (prevwin == NULL) | |
8026 | + nr = 0; | |
8027 | + } | |
8028 | + else | |
8029 | + { | |
8030 | + EMSG2(_(e_invexpr2), arg); | |
8031 | + nr = 0; | |
8032 | + } | |
8033 | + } | |
8034 | + | |
8035 | + if (nr > 0) | |
8036 | + for (wp = firstwin; wp != twin; wp = wp->w_next) | |
8037 | + ++nr; | |
7865 | 8038 | #endif |
7866 | 8039 | retvar->var_val.var_number = nr; |
7867 | 8040 | } |
@@ -3806,6 +3806,7 @@ | ||
3806 | 3806 | {"Courier", "Courier-Bold", "Courier-Oblique", "Courier-BoldOblique"} |
3807 | 3807 | }; |
3808 | 3808 | |
3809 | +#ifdef FEAT_MBYTE | |
3809 | 3810 | /* Generic font metrics for multi-byte fonts */ |
3810 | 3811 | static struct prt_ps_font_S prt_ps_mb_font = |
3811 | 3812 | { |
@@ -3814,6 +3815,7 @@ | ||
3814 | 3815 | -250, 805, |
3815 | 3816 | {NULL, NULL, NULL, NULL} |
3816 | 3817 | }; |
3818 | +#endif | |
3817 | 3819 | |
3818 | 3820 | /* Pointer to current font set being used */ |
3819 | 3821 | static struct prt_ps_font_S* prt_ps_font; |
@@ -3822,8 +3824,8 @@ | ||
3822 | 3824 | * building CID font name */ |
3823 | 3825 | struct prt_ps_encoding_S |
3824 | 3826 | { |
3825 | - char_u *encoding; | |
3826 | - char_u *cmap_encoding; | |
3827 | + char *encoding; | |
3828 | + char *cmap_encoding; | |
3827 | 3829 | int needs_charset; |
3828 | 3830 | }; |
3829 | 3831 |
@@ -3834,6 +3836,8 @@ | ||
3834 | 3836 | int has_charset; |
3835 | 3837 | }; |
3836 | 3838 | |
3839 | +#ifdef FEAT_MBYTE | |
3840 | + | |
3837 | 3841 | #define CS_JIS_C_1978 (0x01) |
3838 | 3842 | #define CS_JIS_X_1983 (0x02) |
3839 | 3843 | #define CS_JIS_X_1990 (0x04) |
@@ -4017,6 +4021,7 @@ | ||
4017 | 4021 | "KS_X_1992" |
4018 | 4022 | } |
4019 | 4023 | }; |
4024 | +#endif /* FEAT_MBYTE */ | |
4020 | 4025 | |
4021 | 4026 | struct prt_ps_resource_S |
4022 | 4027 | { |
@@ -4076,7 +4081,7 @@ | ||
4076 | 4081 | |
4077 | 4082 | struct prt_dsc_comment_S |
4078 | 4083 | { |
4079 | - char_u *string; | |
4084 | + char *string; | |
4080 | 4085 | int len; |
4081 | 4086 | int type; |
4082 | 4087 | }; |
@@ -4092,11 +4097,11 @@ | ||
4092 | 4097 | #define SIZEOF_CSTR(s) (sizeof(s) - 1) |
4093 | 4098 | struct prt_dsc_comment_S prt_dsc_table[] = |
4094 | 4099 | { |
4095 | - {PRT_DSC_TITLE, SIZEOF_CSTR(PRT_DSC_TITLE), PRT_DSC_TITLE_TYPE}, | |
4100 | + {PRT_DSC_TITLE, SIZEOF_CSTR(PRT_DSC_TITLE), PRT_DSC_TITLE_TYPE}, | |
4096 | 4101 | {PRT_DSC_VERSION, SIZEOF_CSTR(PRT_DSC_VERSION), |
4097 | - PRT_DSC_VERSION_TYPE}, | |
4102 | + PRT_DSC_VERSION_TYPE}, | |
4098 | 4103 | {PRT_DSC_ENDCOMMENTS, SIZEOF_CSTR(PRT_DSC_ENDCOMMENTS), |
4099 | - PRT_DSC_ENDCOMMENTS_TYPE} | |
4104 | + PRT_DSC_ENDCOMMENTS_TYPE} | |
4100 | 4105 | }; |
4101 | 4106 | |
4102 | 4107 | static void prt_write_file_raw_len __ARGS((char_u *buffer, int bytes)); |
@@ -4135,6 +4140,7 @@ | ||
4135 | 4140 | static int prt_resfile_skip_ws __ARGS((int offset)); |
4136 | 4141 | static int prt_next_dsc __ARGS((struct prt_dsc_line_S *p_dsc_line)); |
4137 | 4142 | #ifdef FEAT_MBYTE |
4143 | +static int prt_build_cid_fontname __ARGS((int font, char_u *name, int name_len)); | |
4138 | 4144 | static void prt_def_cidfont __ARGS((char *new_name, int height, char *cidfont)); |
4139 | 4145 | static int prt_match_encoding __ARGS((char *p_encoding, struct prt_ps_mbfont_S *p_cmap, struct prt_ps_encoding_S **pp_mbenc)); |
4140 | 4146 | static int prt_match_charset __ARGS((char *p_charset, struct prt_ps_mbfont_S *p_cmap, struct prt_ps_charset_S **pp_mbchar)); |
@@ -5097,15 +5103,16 @@ | ||
5097 | 5103 | return (int)((prt_right_margin - prt_left_margin) / prt_char_width); |
5098 | 5104 | } |
5099 | 5105 | |
5106 | +#ifdef FEAT_MBYTE | |
5100 | 5107 | static int |
5101 | 5108 | prt_build_cid_fontname(font, name, name_len) |
5102 | 5109 | int font; |
5103 | - char *name; | |
5110 | + char_u *name; | |
5104 | 5111 | int name_len; |
5105 | 5112 | { |
5106 | 5113 | char *fontname; |
5107 | 5114 | |
5108 | - fontname = alloc(name_len + 1); | |
5115 | + fontname = (char *)alloc(name_len + 1); | |
5109 | 5116 | if (fontname == NULL) |
5110 | 5117 | return FALSE; |
5111 | 5118 | STRNCPY(fontname, name, name_len); |
@@ -5114,6 +5121,7 @@ | ||
5114 | 5121 | |
5115 | 5122 | return TRUE; |
5116 | 5123 | } |
5124 | +#endif | |
5117 | 5125 | |
5118 | 5126 | /* |
5119 | 5127 | * Get number of lines of text that fit on a page (excluding the header). |
@@ -5152,13 +5160,13 @@ | ||
5152 | 5160 | #ifdef FEAT_MBYTE |
5153 | 5161 | static int |
5154 | 5162 | prt_match_encoding(p_encoding, p_cmap, pp_mbenc) |
5155 | - char *p_encoding; | |
5156 | - struct prt_ps_mbfont_S *p_cmap; | |
5157 | - struct prt_ps_encoding_S **pp_mbenc; | |
5158 | -{ | |
5159 | - int mbenc; | |
5160 | - int enc_len; | |
5161 | - struct prt_ps_encoding_S *p_mbenc; | |
5163 | + char *p_encoding; | |
5164 | + struct prt_ps_mbfont_S *p_cmap; | |
5165 | + struct prt_ps_encoding_S **pp_mbenc; | |
5166 | +{ | |
5167 | + int mbenc; | |
5168 | + int enc_len; | |
5169 | + struct prt_ps_encoding_S *p_mbenc; | |
5162 | 5170 | |
5163 | 5171 | *pp_mbenc = NULL; |
5164 | 5172 | /* Look for recognised encoding */ |
@@ -5178,12 +5186,12 @@ | ||
5178 | 5186 | |
5179 | 5187 | static int |
5180 | 5188 | prt_match_charset(p_charset, p_cmap, pp_mbchar) |
5181 | - char *p_charset; | |
5182 | - struct prt_ps_mbfont_S *p_cmap; | |
5189 | + char *p_charset; | |
5190 | + struct prt_ps_mbfont_S *p_cmap; | |
5183 | 5191 | struct prt_ps_charset_S **pp_mbchar; |
5184 | 5192 | { |
5185 | - int mbchar; | |
5186 | - int char_len; | |
5193 | + int mbchar; | |
5194 | + int char_len; | |
5187 | 5195 | struct prt_ps_charset_S *p_mbchar; |
5188 | 5196 | |
5189 | 5197 | /* Look for recognised character set, using default if one is not given */ |
@@ -5226,7 +5234,7 @@ | ||
5226 | 5234 | char_u *p_encoding; |
5227 | 5235 | struct prt_ps_encoding_S *p_mbenc; |
5228 | 5236 | struct prt_ps_encoding_S *p_mbenc_first; |
5229 | - struct prt_ps_charset_S *p_mbchar; | |
5237 | + struct prt_ps_charset_S *p_mbchar; | |
5230 | 5238 | #endif |
5231 | 5239 | |
5232 | 5240 | #if 0 |
@@ -5262,11 +5270,13 @@ | ||
5262 | 5270 | p_mbenc_first = NULL; |
5263 | 5271 | p_mbchar = NULL; |
5264 | 5272 | for (cmap = 0; cmap < NUM_ELEMENTS(prt_ps_mbfonts); cmap++) |
5265 | - if (prt_match_encoding(p_encoding, &prt_ps_mbfonts[cmap], &p_mbenc)) | |
5273 | + if (prt_match_encoding((char *)p_encoding, &prt_ps_mbfonts[cmap], | |
5274 | + &p_mbenc)) | |
5266 | 5275 | { |
5267 | 5276 | if (p_mbenc_first == NULL) |
5268 | 5277 | p_mbenc_first = p_mbenc; |
5269 | - if (prt_match_charset(p_pmcs, &prt_ps_mbfonts[cmap], &p_mbchar)) | |
5278 | + if (prt_match_charset((char *)p_pmcs, &prt_ps_mbfonts[cmap], | |
5279 | + &p_mbchar)) | |
5270 | 5280 | break; |
5271 | 5281 | } |
5272 | 5282 |
@@ -5343,8 +5353,8 @@ | ||
5343 | 5353 | return FALSE; |
5344 | 5354 | if (mbfont_opts[OPT_MBFONT_BOLDOBLIQUE].present) |
5345 | 5355 | if (!prt_build_cid_fontname(PRT_PS_FONT_BOLDOBLIQUE, |
5346 | - mbfont_opts[OPT_MBFONT_BOLDOBLIQUE].string, | |
5347 | - mbfont_opts[OPT_MBFONT_BOLDOBLIQUE].strlen)) | |
5356 | + mbfont_opts[OPT_MBFONT_BOLDOBLIQUE].string, | |
5357 | + mbfont_opts[OPT_MBFONT_BOLDOBLIQUE].strlen)) | |
5348 | 5358 | return FALSE; |
5349 | 5359 | |
5350 | 5360 | /* Check if need to use Courier for ASCII code range, and if so pick up |
@@ -5555,8 +5565,8 @@ | ||
5555 | 5565 | EMSG2(_("E456: Can't open file \"%s\""), resource->filename); |
5556 | 5566 | return FALSE; |
5557 | 5567 | } |
5558 | - prt_dsc_resources("BeginResource", | |
5559 | - prt_resource_types[resource->type], resource->title); | |
5568 | + prt_dsc_resources("BeginResource", prt_resource_types[resource->type], | |
5569 | + (char *)resource->title); | |
5560 | 5570 | |
5561 | 5571 | prt_dsc_textline("BeginDocument", (char *)resource->filename); |
5562 | 5572 |
@@ -5602,7 +5612,7 @@ | ||
5602 | 5612 | double bottom; |
5603 | 5613 | struct prt_ps_resource_S res_prolog; |
5604 | 5614 | struct prt_ps_resource_S res_encoding; |
5605 | - char_u buffer[256]; | |
5615 | + char buffer[256]; | |
5606 | 5616 | char_u *p_encoding; |
5607 | 5617 | #ifdef FEAT_MBYTE |
5608 | 5618 | struct prt_ps_resource_S res_cidfont; |
@@ -5614,7 +5624,7 @@ | ||
5614 | 5624 | */ |
5615 | 5625 | prt_dsc_start(); |
5616 | 5626 | prt_dsc_textline("Title", (char *)psettings->jobname); |
5617 | - if (!get_user_name(buffer, 256)) | |
5627 | + if (!get_user_name((char_u *)buffer, 256)) | |
5618 | 5628 | STRCPY(buffer, "Unknown"); |
5619 | 5629 | prt_dsc_textline("For", buffer); |
5620 | 5630 | prt_dsc_textline("Creator", VIM_VERSION_LONG); |
@@ -5757,7 +5767,7 @@ | ||
5757 | 5767 | if (!prt_find_resource(prt_ascii_encoding, &res_encoding)) |
5758 | 5768 | { |
5759 | 5769 | EMSG2(_("E456: Can't find PostScript resource file \"%s.ps\""), |
5760 | - prt_ascii_encoding); | |
5770 | + prt_ascii_encoding); | |
5761 | 5771 | return FALSE; |
5762 | 5772 | } |
5763 | 5773 | if (!prt_open_resource(&res_encoding)) |
@@ -5786,7 +5796,7 @@ | ||
5786 | 5796 | if (!prt_find_resource(prt_cmap, &res_cmap)) |
5787 | 5797 | { |
5788 | 5798 | EMSG2(_("E456: Can't find PostScript resource file \"%s.ps\""), |
5789 | - prt_cmap); | |
5799 | + prt_cmap); | |
5790 | 5800 | return FALSE; |
5791 | 5801 | } |
5792 | 5802 | if (!prt_open_resource(&res_cmap)) |
@@ -5911,7 +5921,7 @@ | ||
5911 | 5921 | /* When using Courier for ASCII range when printing multi-byte, need to |
5912 | 5922 | * pick up ASCII encoding to use with it. */ |
5913 | 5923 | if (prt_use_courier) |
5914 | - p_encoding = prt_ascii_encoding; | |
5924 | + p_encoding = (char_u *)prt_ascii_encoding; | |
5915 | 5925 | #endif |
5916 | 5926 | prt_dsc_resources("IncludeResource", "font", |
5917 | 5927 | prt_ps_courier_font.ps_fontname[PRT_PS_FONT_ROMAN]); |
@@ -6015,7 +6025,7 @@ | ||
6015 | 6025 | |
6016 | 6026 | /* Write CTRL-D to close serial communication link if used. |
6017 | 6027 | * NOTHING MUST BE WRITTEN AFTER THIS! */ |
6018 | - prt_write_file(IF_EB("\004", "\067")); | |
6028 | + prt_write_file((char_u *)IF_EB("\004", "\067")); | |
6019 | 6029 | |
6020 | 6030 | if (!prt_file_error && psettings->outfile == NULL |
6021 | 6031 | && !got_int && !psettings->user_abort) |
@@ -6274,7 +6284,7 @@ | ||
6274 | 6284 | */ |
6275 | 6285 | do |
6276 | 6286 | { |
6277 | - ch = prt_hexchar[(*p) >> 4]; | |
6287 | + ch = prt_hexchar[(unsigned)(*p) >> 4]; | |
6278 | 6288 | ga_append(&prt_ps_buffer, ch); |
6279 | 6289 | ch = prt_hexchar[(*p) & 0xf]; |
6280 | 6290 | ga_append(&prt_ps_buffer, ch); |
@@ -29,7 +29,7 @@ | ||
29 | 29 | #include <qmessagebox.h> |
30 | 30 | #include <qiconset.h> |
31 | 31 | #include <qtextcodec.h> |
32 | -#include "gui_kde_widget.h" | |
32 | +#include "gui_kde_wid.h" | |
33 | 33 | |
34 | 34 | extern "C" { |
35 | 35 | #include "vim.h" |
@@ -0,0 +1,1449 @@ | ||
1 | +/* vi:set ts=8 sts=4 sw=4: | |
2 | + * | |
3 | + * VIM - Vi IMproved by Bram Moolenaar | |
4 | + * | |
5 | + * Do ":help uganda" in Vim to read copying and usage conditions. | |
6 | + * Do ":help credits" in Vim to see a list of people who contributed. | |
7 | + */ | |
8 | + | |
9 | +/* | |
10 | + * Porting to KDE(2) was done by | |
11 | + * | |
12 | + * (C) 2000 by Thomas Capricelli <orzel@freehackers.org> | |
13 | + * | |
14 | + * Please visit http://freehackers.org/kvim for other vim- or | |
15 | + * kde-related coding. | |
16 | + * | |
17 | + * $Id$ | |
18 | + * | |
19 | + */ | |
20 | + | |
21 | +#include <assert.h> | |
22 | +#include <qpainter.h> | |
23 | +#include <qevent.h> | |
24 | +#include <qpushbutton.h> | |
25 | +#include <qscrollbar.h> | |
26 | +#include <qlayout.h> | |
27 | +#include <qclipboard.h> | |
28 | +#include <qdragobject.h> | |
29 | +#include <qstrlist.h> | |
30 | +#include <qmenubar.h> | |
31 | +#include <qtextcodec.h> | |
32 | +#if QT_VERSION>=300 | |
33 | +#include <qptrlist.h> | |
34 | +#include <ktip.h> | |
35 | +#endif | |
36 | +#include <kglobal.h> | |
37 | +#include <kconfig.h> | |
38 | +#include <kaboutapplication.h> | |
39 | +#include <dcopclient.h> | |
40 | +#include <kaboutkde.h> | |
41 | +#include <kbugreport.h> | |
42 | +#include <kurldrag.h> | |
43 | +#include <kmenubar.h> | |
44 | +#include <ktoolbar.h> | |
45 | +#include <kstandarddirs.h> | |
46 | +#include "gui_kde_wid.h" | |
47 | +#include <qxembed.h> | |
48 | + | |
49 | +extern "C" | |
50 | +{ | |
51 | +#include "version.h" | |
52 | +} | |
53 | + | |
54 | +// Pixmap for dialog | |
55 | +#ifdef FEAT_GUI_DIALOG | |
56 | +# include "../../pixmaps/alert.xpm" | |
57 | +# include "../../pixmaps/error.xpm" | |
58 | +# include "../../pixmaps/generic.xpm" | |
59 | +# include "../../pixmaps/info.xpm" | |
60 | +# include "../../pixmaps/quest.xpm" | |
61 | +#endif | |
62 | + | |
63 | +/** | |
64 | + * Keycodes recognized by vim. | |
65 | + */ | |
66 | +struct special_key {//{{{ | |
67 | + int qtkey; | |
68 | + char_u code0; | |
69 | + char_u code1; | |
70 | +} special_keys[] = | |
71 | +{ | |
72 | + { Qt::Key_Up, 'k', 'u' }, | |
73 | + { Qt::Key_Down, 'k', 'd' }, | |
74 | + { Qt::Key_Left, 'k', 'l' }, | |
75 | + { Qt::Key_Right, 'k', 'r' }, | |
76 | + { Qt::Key_F1, 'k', '1' }, | |
77 | + { Qt::Key_F2, 'k', '2' }, | |
78 | + { Qt::Key_F3, 'k', '3' }, | |
79 | + { Qt::Key_F4, 'k', '4' }, | |
80 | + { Qt::Key_F5, 'k', '5' }, | |
81 | + { Qt::Key_F6, 'k', '6' }, | |
82 | + { Qt::Key_F7, 'k', '7' }, | |
83 | + { Qt::Key_F8, 'k', '8' }, | |
84 | + { Qt::Key_F9, 'k', '9' }, | |
85 | + { Qt::Key_F10, 'k', ';' }, | |
86 | + { Qt::Key_F11, 'F', '1' }, | |
87 | + { Qt::Key_F12, 'F', '2' }, | |
88 | + { Qt::Key_F13, 'F', '3' }, | |
89 | + { Qt::Key_F14, 'F', '4' }, | |
90 | + { Qt::Key_F15, 'F', '5' }, | |
91 | + { Qt::Key_F16, 'F', '6' }, | |
92 | + { Qt::Key_F17, 'F', '7' }, | |
93 | + { Qt::Key_F18, 'F', '8' }, | |
94 | + { Qt::Key_F19, 'F', '9' }, | |
95 | + { Qt::Key_F20, 'F', 'A' }, | |
96 | + { Qt::Key_F21, 'F', 'B' }, | |
97 | + { Qt::Key_F22, 'F', 'C' }, | |
98 | + { Qt::Key_F23, 'F', 'D' }, | |
99 | + { Qt::Key_F24, 'F', 'E' }, | |
100 | + { Qt::Key_F25, 'F', 'F' }, | |
101 | + { Qt::Key_F26, 'F', 'G' }, | |
102 | + { Qt::Key_F27, 'F', 'H' }, | |
103 | + { Qt::Key_F28, 'F', 'I' }, | |
104 | + { Qt::Key_F29, 'F', 'J' }, | |
105 | + { Qt::Key_F30, 'F', 'K' }, | |
106 | + { Qt::Key_F31, 'F', 'L' }, | |
107 | + { Qt::Key_F32, 'F', 'M' }, | |
108 | + { Qt::Key_F33, 'F', 'N' }, | |
109 | + { Qt::Key_F34, 'F', 'O' }, | |
110 | + { Qt::Key_F35, 'F', 'P' }, | |
111 | + { Qt::Key_Help, '%', '1' }, | |
112 | + // { Qt::Key_Undo, '&', '8' }, <= hmmm ? | |
113 | + { Qt::Key_BackSpace, 'k', 'b' }, | |
114 | + { Qt::Key_Insert, KS_EXTRA, KE_KINS }, | |
115 | + { Qt::Key_Delete, KS_EXTRA, KE_KDEL }, | |
116 | + { Qt::Key_Home, 'K', '1' }, | |
117 | + { Qt::Key_End, 'K', '4' }, | |
118 | + { Qt::Key_Prior, 'K', '3' }, | |
119 | + { Qt::Key_Next, 'K', '5' }, | |
120 | + { Qt::Key_Print, '%', '9' }, | |
121 | + | |
122 | + { Qt::Key_Plus, 'K', '6'}, | |
123 | + { Qt::Key_Minus, 'K', '7'}, | |
124 | + { Qt::Key_Slash, 'K', '8'}, | |
125 | + { Qt::Key_multiply, 'K', '9'}, | |
126 | + { Qt::Key_Enter, 'K', 'A'}, | |
127 | + { Qt::Key_Period, 'K', 'B'}, | |
128 | + | |
129 | + { Qt::Key_0, 'K', 'C'}, | |
130 | + { Qt::Key_1, 'K', 'D'}, | |
131 | + { Qt::Key_2, 'K', 'E'}, | |
132 | + { Qt::Key_3, 'K', 'F'}, | |
133 | + { Qt::Key_4, 'K', 'G'}, | |
134 | + { Qt::Key_5, 'K', 'H'}, | |
135 | + { Qt::Key_6, 'K', 'I'}, | |
136 | + { Qt::Key_7, 'K', 'J'}, | |
137 | + { Qt::Key_8, 'K', 'K'}, | |
138 | + { Qt::Key_9, 'K', 'L'}, | |
139 | + /* End of list marker: */ | |
140 | + { 0, 0, 0 } | |
141 | +};//}}} | |
142 | + | |
143 | +#ifdef FEAT_CLIENTSERVER | |
144 | +typedef int (*QX11EventFilter) (XEvent*); | |
145 | +extern QX11EventFilter qt_set_x11_event_filter (QX11EventFilter filter); | |
146 | +static QX11EventFilter oldFilter = 0; | |
147 | +static int kvim_x11_event_filter( XEvent* e); | |
148 | +#endif | |
149 | +void gui_keypress(QKeyEvent *e); | |
150 | + | |
151 | +/* | |
152 | + * Return OK if the key with the termcap name "name" is supported. | |
153 | + */ | |
154 | + int | |
155 | +gui_mch_haskey(char_u * name)//{{{ | |
156 | +{ | |
157 | + for (int i=0; special_keys[i].qtkey != 0; i++) | |
158 | + if (name[0] == special_keys[i].code0 && | |
159 | + name[1] == special_keys[i].code1) | |
160 | + return OK; | |
161 | + return FAIL; | |
162 | +}//}}} | |
163 | + | |
164 | +/* | |
165 | + * custom Frame for drawing ... | |
166 | + */ | |
167 | +void VimWidget::paintEvent( QPaintEvent *e)//{{{ | |
168 | +{ | |
169 | + QRect r = e->rect(); | |
170 | + gui_redraw(r.x(), r.y(), r.width(), r.height() ); | |
171 | +}//}}} | |
172 | + | |
173 | +void VimWidget::draw_string(int x, int y, QString s, int len, int flags)//{{{ | |
174 | +{ | |
175 | + gui.current_font->setBold( flags & DRAW_BOLD ); | |
176 | + gui.current_font->setUnderline( flags & DRAW_UNDERL ); | |
177 | + gui.current_font->setItalic(flags & DRAW_ITALIC); | |
178 | + painter->setBackgroundMode( flags & DRAW_TRANSP ? Qt::TransparentMode : Qt::OpaqueMode); | |
179 | + painter->setFont( *(gui.current_font) ); | |
180 | + painter->drawText( x, y, s, len); | |
181 | +}//}}} | |
182 | + | |
183 | +void VimWidget::mousePressEvent(QMouseEvent *event)//{{{ | |
184 | +{ | |
185 | + int button=0; | |
186 | + int modifiers=0; | |
187 | + ButtonState state = event->state(); | |
188 | + ButtonState buttons = event->button(); | |
189 | + | |
190 | + //Look at button states | |
191 | + if (buttons & QMouseEvent::LeftButton) | |
192 | + button |= MOUSE_LEFT; | |
193 | + if (buttons & QMouseEvent::RightButton) | |
194 | + button |= MOUSE_RIGHT; | |
195 | + if (buttons & QMouseEvent::MidButton) | |
196 | + button |= MOUSE_MIDDLE; | |
197 | + //Look for keyboard modifiers | |
198 | + if (state & QMouseEvent::ShiftButton) | |
199 | + modifiers |= MOUSE_SHIFT; | |
200 | + if (state & QMouseEvent::ControlButton) | |
201 | + modifiers |= MOUSE_CTRL; | |
202 | + if (state & QMouseEvent::AltButton) | |
203 | + modifiers |= MOUSE_ALT; | |
204 | + gui_send_mouse_event(button,event->x(),event->y(),FALSE,modifiers); | |
205 | +#if QT_VERSION>=300 | |
206 | + QByteArray params; | |
207 | + QDataStream stream(params, IO_WriteOnly); | |
208 | + stream << kapp->dcopClient()->appId() << button << modifiers << gui.row << gui.col; | |
209 | + kapp->dcopClient()->emitDCOPSignal("mousePEvent(QCString,int,int,int,int)", params); | |
210 | +#endif | |
211 | + event->accept(); | |
212 | +}//}}} | |
213 | + | |
214 | +#if defined(FEAT_SESSION) | |
215 | +void VimMainWindow::saveGlobalProperties (KConfig *conf) | |
216 | +{ | |
217 | + //we write a mksession file to a file written in the user's ~/.kde/share/config/ | |
218 | + //the name of the file in saved in 'conf' | |
219 | + //when restoring app, we source this file | |
220 | +#if 0 //disabled for release | |
221 | + QString filename = KGlobal::dirs()->localkdedir() + KGlobal::dirs()->kde_default("config") + kapp->randomString(10); | |
222 | + QString cmd("mksession "); | |
223 | + cmd+=filename; | |
224 | + do_cmdline_cmd((char_u*)cmd.latin1()); | |
225 | + conf->writePathEntry("sessionfile", filename); | |
226 | + conf->sync(); | |
227 | +#endif | |
228 | +} | |
229 | + | |
230 | +void VimMainWindow::readGlobalProperties (KConfig *conf) | |
231 | +{ | |
232 | +#if 0 | |
233 | + QString filename = conf->readPathEntry("sessionfile"); | |
234 | + if (filename.isNull()) return; | |
235 | + QString cmd("source "); | |
236 | + cmd+=filename; | |
237 | + do_cmdline_cmd((char_u*)cmd.latin1()); | |
238 | +#endif | |
239 | +} | |
240 | +#endif | |
241 | + | |
242 | +void VimMainWindow::wheelEvent (QWheelEvent *event)//{{{ | |
243 | +{ | |
244 | + ButtonState state = event->state(); | |
245 | + int button=0; | |
246 | + int modifiers=0; | |
247 | + | |
248 | + if (event->delta()>0) | |
249 | + button|=MOUSE_4; | |
250 | + else button|=MOUSE_5; | |
251 | + | |
252 | + if (state & ShiftButton) | |
253 | + modifiers|=MOUSE_SHIFT; | |
254 | + if (state & ControlButton) | |
255 | + modifiers|=MOUSE_CTRL; | |
256 | + if (state & AltButton) | |
257 | + modifiers|=MOUSE_ALT; | |
258 | + | |
259 | + gui_send_mouse_event(button,event->x(),event->y(),FALSE,modifiers); | |
260 | +#if QT_VERSION>=300 | |
261 | + QByteArray params; | |
262 | + QDataStream stream(params, IO_WriteOnly); | |
263 | + stream << kapp->dcopClient()->appId() << button << modifiers << gui.row << gui.col; | |
264 | + kapp->dcopClient()->emitDCOPSignal("mouseWhlEvent(QCString, int, int,int,int)", params); | |
265 | +#endif | |
266 | + event->accept(); | |
267 | +}//}}} | |
268 | + | |
269 | +void VimWidget::mouseDoubleClickEvent(QMouseEvent *event)//{{{ | |
270 | +{ | |
271 | + ButtonState state = event->state(); | |
272 | + ButtonState buttons = event->button(); | |
273 | + int modifiers=0; | |
274 | + int button=0; | |
275 | + | |
276 | + //Look at button states | |
277 | + if (buttons & LeftButton) | |
278 | + button|=MOUSE_LEFT; | |
279 | + if (buttons & RightButton) | |
280 | + button|=MOUSE_RIGHT; | |
281 | + if (buttons & MidButton) | |
282 | + button|=MOUSE_MIDDLE; | |
283 | + | |
284 | + //Look for keyboard modifiers | |
285 | + if (state & ShiftButton) | |
286 | + modifiers|=MOUSE_SHIFT; | |
287 | + if (state & ControlButton) | |
288 | + modifiers|=MOUSE_CTRL; | |
289 | + if (state & AltButton) | |
290 | + modifiers|=MOUSE_ALT; | |
291 | + | |
292 | + gui_send_mouse_event(button,event->x(),event->y(),TRUE,modifiers); | |
293 | +#if QT_VERSION>=300 | |
294 | + QByteArray params; | |
295 | + QDataStream stream(params, IO_WriteOnly); | |
296 | + stream << kapp->dcopClient()->appId() << button << modifiers << gui.row << gui.col; | |
297 | + kapp->dcopClient()->emitDCOPSignal("mouseDblClickEvent(QCString, int, int,int,int)", params); | |
298 | +#endif | |
299 | + event->accept(); | |
300 | +}//}}} | |
301 | + | |
302 | +void VimWidget::mouseMoveEvent(QMouseEvent *event){//{{{ | |
303 | + ButtonState state = event->state(); | |
304 | + int modifiers=0; | |
305 | + int button=0; | |
306 | + | |
307 | + gui_mch_mousehide(FALSE); | |
308 | + | |
309 | + //Look at button states | |
310 | + //warning: we use state here, this is important ! | |
311 | + if (state & QMouseEvent::LeftButton || state & QMouseEvent::RightButton || state & QMouseEvent::MidButton) | |
312 | + button|=MOUSE_DRAG; | |
313 | + | |
314 | + //Look for keyboard modifiers | |
315 | + if (state & ShiftButton) | |
316 | + modifiers|=MOUSE_SHIFT; | |
317 | + if (state & ControlButton) | |
318 | + modifiers|=MOUSE_CTRL; | |
319 | + if (state & AltButton) | |
320 | + modifiers|=MOUSE_ALT; | |
321 | + if (button!=MOUSE_DRAG) | |
322 | + gui_mouse_moved(event->x(),event->y()); | |
323 | + else | |
324 | + gui_send_mouse_event(MOUSE_DRAG,event->x(),event->y(),FALSE,modifiers); | |
325 | +}//}}} | |
326 | + | |
327 | +void VimWidget::mouseReleaseEvent(QMouseEvent *event)//{{{ | |
328 | +{ | |
329 | + ButtonState state = event->state(); | |
330 | + int modifiers=0; | |
331 | + | |
332 | + //Look for keyboard modifiers | |
333 | + if (state & ShiftButton) | |
334 | + modifiers|=MOUSE_SHIFT; | |
335 | + if (state & ControlButton) | |
336 | + modifiers|=MOUSE_CTRL; | |
337 | + if (state & AltButton) | |
338 | + modifiers|=MOUSE_ALT; | |
339 | + | |
340 | + gui_send_mouse_event(MOUSE_RELEASE,event->x(),event->y(),FALSE,modifiers); | |
341 | + event->accept(); | |
342 | +}//}}} | |
343 | + | |
344 | +/* | |
345 | + * The main widget (everything but toolbar/menubar) | |
346 | + */ | |
347 | + VimWidget::VimWidget( QWidget *parent, const char *name, WFlags f )//{{{ | |
348 | +:QWidget(parent, name, f) | |
349 | + ,DCOPObject("KVim") | |
350 | +#ifdef FEAT_MZSCHEME | |
351 | + ,mzscheme_timer_id(-1) | |
352 | +#endif | |
353 | +{ | |
354 | + //to be able to show/hide the cursor when moving the mouse | |
355 | + setMouseTracking(true); | |
356 | + painter=new QPainter(this); | |
357 | + | |
358 | + setKeyCompression(true); | |
359 | + setFocusPolicy( QWidget::StrongFocus ); | |
360 | + setAcceptDrops(TRUE); // DND | |
361 | + blink_state = BLINK_NONE; | |
362 | + blink_on_time = 700; | |
363 | + blink_off_time = 400; | |
364 | + blink_wait_time = 250; | |
365 | + connect( &blink_timer, SIGNAL( timeout() ), SLOT( blink_cursor() )); | |
366 | + connect( &wait_timer, SIGNAL( timeout() ), SLOT ( wait_timeout() )); | |
367 | +}//}}} | |
368 | + | |
369 | +void VimWidget::execNormal(QString command)//{{{ | |
370 | +{ | |
371 | + QString cmd("execute 'normal "); | |
372 | + cmd+=command; | |
373 | + cmd+="'"; | |
374 | + QCString unistring = vmw->codec->fromUnicode(cmd); | |
375 | + do_cmdline_cmd((char_u *)(const char*)unistring); | |
376 | + gui_update_screen(); | |
377 | +}//}}} | |
378 | + | |
379 | +void VimWidget::execInsert(QString command)//{{{ | |
380 | +{ | |
381 | + QString cmd("execute 'normal i"); | |
382 | + cmd+=command; | |
383 | + cmd+="'"; | |
384 | + QCString unistring = vmw->codec->fromUnicode(cmd); | |
385 | + do_cmdline_cmd((char_u *)(const char*)unistring); | |
386 | + gui_update_screen(); | |
387 | +}//}}} | |
388 | + | |
389 | +void VimWidget::execRaw(QString command)//{{{ | |
390 | +{ | |
391 | + QString cmd("execute '"); | |
392 | + cmd+=command; | |
393 | + cmd+="'"; | |
394 | + QCString unistring = vmw->codec->fromUnicode(cmd); | |
395 | + do_cmdline_cmd((char_u *)(const char*)unistring); | |
396 | + gui_update_screen(); | |
397 | +}//}}} | |
398 | + | |
399 | +void VimWidget::execCmd(QString command)//{{{ | |
400 | +{ | |
401 | + QCString unistring = vmw->codec->fromUnicode(command); | |
402 | + do_cmdline_cmd((char_u *)(const char*)unistring); | |
403 | + gui_update_screen(); | |
404 | +}//}}} | |
405 | + | |
406 | +QString VimWidget::eval(QString expr)//{{{ | |
407 | +{ | |
408 | +#ifdef FEAT_EVAL | |
409 | + QCString unistring = vmw->codec->fromUnicode(expr); | |
410 | + QString val((const char *)eval_to_string((char_u *)(const char*)unistring,NULL)); | |
411 | + return val; | |
412 | +#else | |
413 | + return QString::null; | |
414 | +#endif | |
415 | +}//}}} | |
416 | + | |
417 | +void VimWidget::wait(long wtime)//{{{ | |
418 | +{ | |
419 | + if ( wait_timer.isActive() ) wait_timer.stop(); | |
420 | + wait_done = false; | |
421 | + wait_timer.start( wtime, true); | |
422 | +}//}}} | |
423 | + | |
424 | +void VimWidget::wait_timeout() //{{{ | |
425 | +{ | |
426 | + wait_done = true; | |
427 | +}//}}} | |
428 | + | |
429 | +void VimWidget::dragEnterEvent (QDragEnterEvent *e)//{{{ | |
430 | +{ | |
431 | +#if (defined(FEAT_WINDOWS) && defined(HAVE_DROP_FILE)) || defined(PROTO) | |
432 | + e->accept(QUriDrag::canDecode(e)); | |
433 | +#else | |
434 | + e->ignore(); | |
435 | +#endif | |
436 | +}//}}} | |
437 | + | |
438 | +void VimWidget::dropEvent (QDropEvent *e) // {{{ | |
439 | +{ | |
440 | +#if (defined(FEAT_WINDOWS) && defined(HAVE_DROP_FILE)) || defined(PROTO) | |
441 | + QStrList urls; | |
442 | + | |
443 | + char_u **fnames; | |
444 | + int redo_dirs = FALSE; | |
445 | + int i; | |
446 | + int n; | |
447 | + int nfiles; | |
448 | + int url = FALSE; | |
449 | + | |
450 | + /* Count how many items there may be and normalize delimiters. */ | |
451 | + | |
452 | + if (QUriDrag::decode(e, urls)) | |
453 | + { | |
454 | + n = urls.count(); | |
455 | + fnames = (char_u **)lalloc((n+1) * sizeof(char_u *), TRUE); | |
456 | + nfiles = 0; | |
457 | +#if QT_VERSION>=300 | |
458 | + QPtrListIterator<char> it(urls); | |
459 | + for (; it.current(); ++it ) | |
460 | + { | |
461 | + KURL u(*it); | |
462 | +#else | |
463 | + for (i=0;i<urls.count();++i) | |
464 | + { | |
465 | + KURL u(urls.at(i)); | |
466 | +#endif | |
467 | + if ( !u.isLocalFile() ) | |
468 | + url = TRUE; | |
469 | + else | |
470 | + { | |
471 | + fnames[nfiles] = (char_u *)strdup((const char *)u.path()); | |
472 | + ++nfiles; | |
473 | + } | |
474 | + } | |
475 | + /* Real files (i.e. not http and not ftp) */ | |
476 | + if (url == FALSE) | |
477 | + { | |
478 | + if (nfiles == 1) | |
479 | + { | |
480 | + if (mch_isdir(fnames[0])) | |
481 | + { | |
482 | + /* Handle dropping a directory on Vim. */ | |
483 | + if (mch_chdir((char *)fnames[0]) == 0) | |
484 | + { | |
485 | + free(fnames[0]); | |
486 | + fnames[0] = NULL; | |
487 | + redo_dirs = TRUE; | |
488 | + } | |
489 | + } | |
490 | + } | |
491 | + else | |
492 | + { | |
493 | + /* Ignore any directories */ | |
494 | + for (i = 0; i < nfiles; ++i) | |
495 | + { | |
496 | + if (mch_isdir(fnames[i])) | |
497 | + { | |
498 | + vim_free(fnames[i]); | |
499 | + fnames[i] = NULL; | |
500 | + } | |
501 | + } | |
502 | + } | |
503 | + | |
504 | + if (0) | |
505 | + { | |
506 | + /* Shift held down, change to first file's directory */ | |
507 | + if (fnames[0] != NULL && vim_chdirfile(fnames[0]) == OK) | |
508 | + redo_dirs = TRUE; | |
509 | + } | |
510 | + else | |
511 | + { | |
512 | + char_u dirname[MAXPATHL]; | |
513 | + char_u *s; | |
514 | + if (mch_dirname(dirname, MAXPATHL) == OK) | |
515 | + for (i = 0; i < nfiles; ++i) | |
516 | + if (fnames[i] != NULL) | |
517 | + { | |
518 | + s = shorten_fname(fnames[i], dirname); | |
519 | + if (s != NULL && (s = vim_strsave(s)) != NULL) | |
520 | + { | |
521 | + vim_free(fnames[i]); | |
522 | + fnames[i] = s; | |
523 | + } | |
524 | + } | |
525 | + } | |
526 | + } | |
527 | + | |
528 | + /* Handle the drop, :edit or :split to get to the file */ | |
529 | + handle_drop(nfiles, fnames, FALSE); | |
530 | + | |
531 | + if (redo_dirs) | |
532 | + shorten_fnames(TRUE); | |
533 | + } | |
534 | + | |
535 | + /* Update the screen display */ | |
536 | + update_screen(NOT_VALID); | |
537 | +#ifdef FEAT_MENU | |
538 | + gui_update_menus(0); | |
539 | +#endif | |
540 | + setcursor(); | |
541 | + out_flush(); | |
542 | + gui_update_cursor(FALSE, FALSE); | |
543 | + gui_mch_flush(); | |
544 | +#endif | |
545 | +} // }}} | |
546 | + | |
547 | +void VimWidget::keyPressEvent( QKeyEvent *e ) // {{{ | |
548 | +{ | |
549 | + gui_keypress(e); | |
550 | +} // }}} | |
551 | + | |
552 | +void gui_keypress(QKeyEvent *e) { // {{{ | |
553 | + int key = (int)e->key(); | |
554 | + int modifiers = 0,i; | |
555 | + uchar string[256],string2[256]; | |
556 | + uchar *s,*d; | |
557 | + Qt::ButtonState state = e->state(); | |
558 | + | |
559 | + QCString unistring = vmw->codec->fromUnicode(e->text()); | |
560 | + if (unistring.length()>0) | |
561 | + strncpy((char*)string, (const char*)unistring,unistring.length()); | |
562 | + string[unistring.length()] = 0; | |
563 | + int len=unistring.length(); | |
564 | + | |
565 | + // ignore certain keys | |
566 | + if (key == Qt::Key_Shift || key == Qt::Key_Alt || key == Qt::Key_Control || key == Qt::Key_Meta | |
567 | + || key == Qt::Key_CapsLock || key == Qt::Key_NumLock || key == Qt::Key_ScrollLock ) | |
568 | + { | |
569 | + e->ignore(); | |
570 | + return; | |
571 | + } | |
572 | + | |
573 | +#ifdef FEAT_MBYTE | |
574 | + if (input_conv.vc_type != CONV_NONE) | |
575 | + { | |
576 | + mch_memmove(string2, string, len); | |
577 | + len = convert_input(string2, len, sizeof(string2)); | |
578 | + s = string2; | |
579 | + } | |
580 | + else | |
581 | +#endif | |
582 | + s = string; | |
583 | + d = string; | |
584 | + for (i = 0; i < len; ++i) | |
585 | + { | |
586 | + *d++ = s[i]; | |
587 | + if (d[-1] == CSI && d + 2 < string + sizeof(string)) | |
588 | + { | |
589 | + /* Turn CSI into K_CSI. */ | |
590 | + *d++ = KS_EXTRA; | |
591 | + *d++ = (int)KE_CSI; | |
592 | + } | |
593 | + } | |
594 | + len = d - string; | |
595 | + | |
596 | + | |
597 | + // change shift-tab (backtab) into S_TAB | |
598 | + if ( key == Qt::Key_BackTab && state & Qt::ShiftButton) | |
599 | + key = Qt::Key_Tab; | |
600 | + | |
601 | + // Change C-@ and C-2 in NUL ? Gtk does this | |
602 | + if ( (key == Qt::Key_2 || key == Qt::Key_At) | |
603 | + && state & Qt::ControlButton ) | |
604 | + { | |
605 | + string[0] = NUL; | |
606 | + len = 1; | |
607 | + } | |
608 | + else if (len == 0 && (key == Qt::Key_Space || key == Qt::Key_Tab)) | |
609 | + { | |
610 | + /* When there are modifiers, these keys get zero length; we need the | |
611 | + * original key here to be able to add a modifier below. */ | |
612 | + string[0] = (key & 0xff); | |
613 | + len = 1; | |
614 | + } | |
615 | + /* Check for Alt/Meta key (Mod1Mask), but not for a BS, DEL or character | |
616 | + * that already has the 8th bit set. | |
617 | + * Don't do this for <S-M-Tab>, that should become K_S_TAB with ALT. */ | |
618 | + if (len == 1 | |
619 | + && (key != Qt::Key_BackSpace && key != Qt::Key_Delete) | |
620 | + && (string[0] & 0x80) == 0 | |
621 | + && (state & Qt::AltButton) | |
622 | + && !(key == Qt::Key_Tab && (state & Qt::ShiftButton))) | |
623 | + { | |
624 | + string[0] |= 0x80; | |
625 | +#ifdef FEAT_MBYTE | |
626 | + if (enc_utf8) // convert to utf-8 | |
627 | + { | |
628 | + string[1] = string[0] & 0xbf; | |
629 | + string[0] = ((unsigned)string[0] >> 6) + 0xc0; | |
630 | + if (string[1] == CSI) | |
631 | + { | |
632 | + string[2] = KS_EXTRA; | |
633 | + string[3] = (int)KE_CSI; | |
634 | + len = 4; | |
635 | + } | |
636 | + else | |
637 | + len = 2; | |
638 | + } | |
639 | +#endif | |
640 | + } | |
641 | + | |
642 | + /* Check for special keys, making sure BS and DEL are recognised. */ | |
643 | + if (len == 0 || key == Qt::Key_BackSpace || key == Qt::Key_Delete) | |
644 | + { | |
645 | + while (special_keys[i].qtkey != 0 && special_keys[i].qtkey != key ) i++; | |
646 | + if (special_keys[i].qtkey != 0) | |
647 | + { | |
648 | + string[0] = CSI; | |
649 | + string[1] = special_keys[i].code0; | |
650 | + string[2] = special_keys[i].code1; | |
651 | + len = -3; | |
652 | + } | |
653 | +/* | |
654 | + for (i = 0; special_keys[i].qtkey != 0 ; i++) | |
655 | + { | |
656 | + if (special_keys[i].qtkey == key ) | |
657 | + { | |
658 | + string[0] = CSI; | |
659 | + string[1] = special_keys[i].code0; | |
660 | + string[2] = special_keys[i].code1; | |
661 | + len = -3; | |
662 | + break; | |
663 | + } | |
664 | + }*/ | |
665 | + } | |
666 | + | |
667 | + if (len == 0) | |
668 | + { | |
669 | + //no need to dump that, that's a QT problem, we can't do anything | |
670 | + //dbf("Unrecognised Key : %X %s", key, e->text().latin1()); | |
671 | + e->ignore(); | |
672 | + return; | |
673 | + } | |
674 | + | |
675 | + | |
676 | + /* Special keys (and a few others) may have modifiers */ | |
677 | + if (len == -3 || key == Qt::Key_Space || key == Qt::Key_Tab || | |
678 | + key == Qt::Key_Return || key == Qt::Key_Enter || | |
679 | + key == Qt::Key_Escape) | |
680 | + { | |
681 | + | |
682 | + modifiers = 0; | |
683 | + if (state & Qt::ShiftButton) modifiers |= MOD_MASK_SHIFT; | |
684 | + if (state & Qt::ControlButton) modifiers |= MOD_MASK_CTRL; | |
685 | + if (state & Qt::AltButton) modifiers |= MOD_MASK_ALT; | |
686 | + | |
687 | + /* | |
688 | + * For some keys a shift modifier is translated into another key | |
689 | + * code. Do we need to handle the case where len != 1 and | |
690 | + * string[0] != CSI? | |
691 | + */ | |
692 | + if (len == -3) | |
693 | + key = TO_SPECIAL(string[1], string[2]); | |
694 | + else | |
695 | + key = string[0]; | |
696 | + | |
697 | + key = simplify_key(key, &modifiers); | |
698 | + if (key == CSI) key=K_CSI; | |
699 | + | |
700 | + if (IS_SPECIAL(key)) | |
701 | + { | |
702 | + string[0] = CSI; | |
703 | + string[1] = K_SECOND(key); | |
704 | + string[2] = K_THIRD(key); | |
705 | + len = 3; | |
706 | + } | |
707 | + else | |
708 | + { | |
709 | + string[0] = key; | |
710 | + len = 1; | |
711 | + } | |
712 | + | |
713 | + | |
714 | + if (modifiers!=0) | |
715 | + { | |
716 | + uchar string2[10]; | |
717 | + string2[0] = CSI; | |
718 | + string2[1] = KS_MODIFIER; | |
719 | + string2[2] = modifiers; | |
720 | + add_to_input_buf(string2, 3); | |
721 | + } | |
722 | + | |
723 | + } /* special keys */ | |
724 | + | |
725 | + if (len == 1 && ((string[0] == Ctrl_C && ctrl_c_interrupts) | |
726 | + || (string[0] == intr_char && intr_char != Ctrl_C))) | |
727 | + { | |
728 | + trash_input_buf(); | |
729 | + got_int = TRUE; | |
730 | + } | |
731 | + | |
732 | + add_to_input_buf(string, len); | |
733 | + if (p_mh) | |
734 | + gui_mch_mousehide(TRUE); | |
735 | + | |
736 | + //DCOP Embedding stuff | |
737 | + //if we are here then the user has type something in the window, thus we can easily imagine that : | |
738 | + // 1 - text has changed (emit textChanged()) | |
739 | + // 2 - characters were interactively inserted (emit charactersInteractivelyInserted()) | |
740 | + // 3 - cursor position has changed ( emit cursorPositionChanged() ) | |
741 | + // 4 - selection has changed ? dunno yet //XXX | |
742 | + // 5 - undo changed too ? (each character typed in makes the undo changes anyway) | |
743 | + // conclusion : this makes a lot of things to send to the vim kpart, maybe too much | |
744 | + // for now i'll just send : keyboardEvent to the kpart with the event string as parameter, | |
745 | + // with current current position | |
746 | + // i'll do the same for mouseEvents | |
747 | +#if QT_VERSION>=300 | |
748 | + QByteArray params; | |
749 | + QDataStream stream(params, IO_WriteOnly); | |
750 | + stream << kapp->dcopClient()->appId() << unistring << gui.row << gui.col; | |
751 | + kapp->dcopClient()->emitDCOPSignal("keyboardEvent(QCString, QCString,int,int)", params); | |
752 | +#endif | |
753 | + e->ignore(); | |
754 | +} // }}} | |
755 | + | |
756 | +#ifdef FEAT_CLIENTSERVER | |
757 | +void VimWidget::serverActivate(WId id) //{{{ | |
758 | +{ | |
759 | + if (serverName == NULL && serverDelayedStartName != NULL) | |
760 | + { | |
761 | + commWindow = id; | |
762 | + (void)serverRegisterName(qt_xdisplay(), serverDelayedStartName); | |
763 | + } | |
764 | + else | |
765 | + serverChangeRegisteredWindow( qt_xdisplay(), id); | |
766 | +}//}}} | |
767 | +#endif | |
768 | + | |
769 | +#ifdef FEAT_XIM | |
770 | +void VimWidget::imStartEvent(QIMEvent *e) | |
771 | +{ | |
772 | + e->accept(); | |
773 | +} | |
774 | + | |
775 | +void VimWidget::imEndEvent(QIMEvent *e) | |
776 | +{ | |
777 | + uchar string[256]; | |
778 | + | |
779 | + QCString unistring = vmw->codec->fromUnicode(e->text()); | |
780 | + if (unistring.length()>0) | |
781 | + strncpy((char*)string, (const char*)unistring,unistring.length()); | |
782 | + string[unistring.length()] = 0; | |
783 | + int len=unistring.length(); | |
784 | + | |
785 | + add_to_input_buf(string, len); | |
786 | + e->accept(); | |
787 | +} | |
788 | + | |
789 | +void VimWidget::imComposeEvent(QIMEvent *e) | |
790 | +{ | |
791 | + //i should do something here, displaying the text somewhere ... (status area ?) | |
792 | + e->accept(); | |
793 | +} | |
794 | +#endif | |
795 | + | |
796 | + | |
797 | +void VimMainWindow::lock() | |
798 | +{ | |
799 | + locked=true; | |
800 | +} | |
801 | + | |
802 | +void VimMainWindow::unlock() | |
803 | +{ | |
804 | + locked=false; | |
805 | +} | |
806 | + | |
807 | +bool VimMainWindow::isLocked() | |
808 | +{ | |
809 | + return locked; | |
810 | +} | |
811 | + | |
812 | +// ->resize VimWidget if not locked | |
813 | +// | |
814 | +void VimMainWindow::resizeEvent ( QResizeEvent *e ) //{{{ | |
815 | +{ | |
816 | + if ( vmw->isLocked() ) return; | |
817 | + //remove toolbar and menubar height | |
818 | + int height = e->size().height(); | |
819 | + int width = e->size().width(); | |
820 | + | |
821 | + if (vmw->menuBar()->isVisible() && vmw->menuBar()->isEnabled() | |
822 | +#if QT_VERSION>=300 | |
823 | + && !vmw->menuBar()->isTopLevelMenu() | |
824 | +#endif | |
825 | + ) | |
826 | + height -= vmw->menuBar()->height(); | |
827 | +#ifdef FEAT_TOOLBAR | |
828 | + if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled() && | |
829 | + (vmw->toolBar()->barPos()==KToolBar::Top || | |
830 | + vmw->toolBar()->barPos()==KToolBar::Bottom)) | |
831 | + height -= vmw->toolBar()->height(); | |
832 | + | |
833 | + if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled() && | |
834 | + (vmw->toolBar()->barPos()==KToolBar::Left || | |
835 | + vmw->toolBar()->barPos()==KToolBar::Right)) | |
836 | + width -= vmw->toolBar()->width(); | |
837 | +#endif | |
838 | + height = ( ((int)(height/gui.char_height))*gui.char_height ); | |
839 | + if (!vmw->isLocked()) gui_resize_shell(width,height); | |
840 | +}//}}} | |
841 | + | |
842 | +void VimWidget::focusInEvent( QFocusEvent * fe ) // {{{ | |
843 | +{ | |
844 | + gui_focus_change(true); | |
845 | + | |
846 | + if (blink_state == BLINK_NONE) | |
847 | + gui_mch_start_blink(); | |
848 | +} // }}} | |
849 | + | |
850 | +void VimWidget::focusOutEvent( QFocusEvent * fe )//{{{ | |
851 | +{ | |
852 | + gui_focus_change(false); | |
853 | + | |
854 | + if (blink_state != BLINK_NONE) | |
855 | + gui_mch_stop_blink(); | |
856 | +}//}}} | |
857 | + | |
858 | +void VimWidget::set_blink_time( long wait, long on, long off)//{{{ | |
859 | +{ | |
860 | + blink_wait_time = wait; | |
861 | + blink_on_time = on; | |
862 | + blink_off_time = off; | |
863 | +}//}}} | |
864 | + | |
865 | +void VimWidget::start_cursor_blinking()//{{{ | |
866 | +{ | |
867 | + if (blink_timer.isActive()) blink_timer.stop(); | |
868 | + | |
869 | + /* Only switch blinking on if none of the times is zero */ | |
870 | + if (blink_wait_time && blink_on_time && blink_off_time && gui.in_focus) | |
871 | + { | |
872 | + blink_state = BLINK_ON; | |
873 | + gui_update_cursor(TRUE, FALSE); | |
874 | + // The first blink appears after wait_time | |
875 | + blink_timer.start( blink_wait_time, true); | |
876 | + } | |
877 | +}//}}} | |
878 | + | |
879 | +void VimWidget::blink_cursor()//{{{ | |
880 | +{ | |
881 | + if (blink_state == BLINK_ON) | |
882 | + { | |
883 | + // set cursor off | |
884 | + gui_undraw_cursor(); | |
885 | + blink_state = BLINK_OFF; | |
886 | + blink_timer.start( blink_off_time, true); | |
887 | + } | |
888 | + else | |
889 | + { | |
890 | + // set cursor on | |
891 | + gui_update_cursor(TRUE, FALSE); | |
892 | + blink_state = BLINK_ON; | |
893 | + blink_timer.start( blink_on_time, true); | |
894 | + } | |
895 | +}//}}} | |
896 | + | |
897 | +void VimWidget::stop_cursor_blinking()//{{{ | |
898 | +{ | |
899 | + if (blink_timer.isActive()) blink_timer.stop(); | |
900 | + | |
901 | + if (blink_state == BLINK_OFF) | |
902 | + gui_update_cursor(TRUE, FALSE); | |
903 | + | |
904 | + blink_state = BLINK_NONE; | |
905 | +}//}}} | |
906 | + | |
907 | +#ifdef FEAT_MZSCHEME | |
908 | +void VimWidget::timerEvent( QTimerEvent * evnt)//{{{ | |
909 | +{ | |
910 | + if (evnt->timerId() == mzscheme_timer_id) | |
911 | + timer_proc(); | |
912 | +}//}}} | |
913 | + | |
914 | +void VimWidget::enable_mzscheme_threads()//{{{ | |
915 | +{ | |
916 | + mzscheme_timer_id = startTimer(p_mzq); | |
917 | +}//}}} | |
918 | + | |
919 | +void VimWidget::disable_mzscheme_threads()//{{{ | |
920 | +{ | |
921 | + killTimer(mzscheme_timer_id); | |
922 | +}//}}} | |
923 | +#endif | |
924 | + | |
925 | +void VimWidget::flash()//{{{ | |
926 | +{ | |
927 | + QPainter p(this); | |
928 | + | |
929 | + p.setRasterOp(Qt::XorROP); | |
930 | + p.fillRect(geometry(),QColor(0xFF,0xFF,0xFF)); | |
931 | + p.flush(); | |
932 | + //FIXME: Make this a little smarter. Maybe add a timer or something | |
933 | + usleep(19000); | |
934 | + p.fillRect(geometry(),QColor(0xFF,0xFF,0xFF)); | |
935 | + p.flush(); | |
936 | + p.end(); | |
937 | +}//}}} | |
938 | + | |
939 | + | |
940 | +/* | |
941 | + * The main Window | |
942 | + */ | |
943 | + VimMainWindow::VimMainWindow ( const char *name , WFlags f)//{{{ | |
944 | +:KMainWindow(0L, name,f) | |
945 | +{ | |
946 | +#ifdef FEAT_CLIENTSERVER | |
947 | + oldFilter = qt_set_x11_event_filter( kvim_x11_event_filter ); | |
948 | +#endif | |
949 | + if (echo_wid_arg== 1) | |
950 | + { | |
951 | + fprintf(stderr, "WID: %ld\n", (long)winId()); | |
952 | + fflush(stderr); | |
953 | + } | |
954 | + | |
955 | + w = new VimWidget(this, "main vim widget"); | |
956 | + gui.w = w; | |
957 | + setFocusProxy(w); | |
958 | + w->setFocus(); | |
959 | + have_tearoff=0; | |
960 | + | |
961 | + finddlg=new KEdFind (this,0,false); | |
962 | + repldlg=new KEdReplace (this,0,false); | |
963 | + QObject::connect( finddlg, SIGNAL(search()), this, SLOT(slotSearch()) ); | |
964 | + QObject::connect( repldlg, SIGNAL(find()), this, SLOT(slotFind()) ); | |
965 | + QObject::connect( repldlg, SIGNAL(replace()), this, SLOT(slotReplace()) ); | |
966 | + QObject::connect( repldlg, SIGNAL(replaceAll()), this, SLOT(slotReplaceAll()) ); | |
967 | + | |
968 | +#ifdef FEAT_TOOLBAR | |
969 | + connect(toolBar(), SIGNAL(clicked(int)), this, SLOT(menu_activated(int))); | |
970 | +#endif | |
971 | +#ifdef FEAT_CLIENTSERVER | |
972 | + w->serverActivate(winId()); | |
973 | + | |
974 | + if (serverName!=NULL) | |
975 | + kapp->dcopClient()->registerAs(QCString((const char*)serverName),false); | |
976 | + else if (serverDelayedStartName!=NULL) | |
977 | + kapp->dcopClient()->registerAs(QCString((const char*)serverDelayedStartName),false); | |
978 | + else if (argServerName!=NULL) | |
979 | + kapp->dcopClient()->registerAs(argServerName->utf8(),false); | |
980 | +#else | |
981 | + if (argServerName!=NULL) | |
982 | + kapp->dcopClient()->registerAs(argServerName->utf8(),false); | |
983 | +#endif | |
984 | + QXEmbed::initialize(); | |
985 | + | |
986 | +}//{{{ | |
987 | + | |
988 | +bool VimMainWindow::queryClose()//{{{ | |
989 | +{ | |
990 | + gui_shell_closed(); | |
991 | + return true; | |
992 | +}//}}} | |
993 | + | |
994 | +bool VimMainWindow::queryExit()//{{{ | |
995 | +{ | |
996 | + return true; | |
997 | +}//}}} | |
998 | + | |
999 | +void VimMainWindow::menu_activated(int dx)//{{{ | |
1000 | +{ | |
1001 | +#ifdef FEAT_MENU | |
1002 | + if (!dx) { // tearoff | |
1003 | + return; | |
1004 | + } | |
1005 | + gui_mch_set_foreground(); | |
1006 | + gui_menu_cb((VimMenu *) dx); | |
1007 | +#endif | |
1008 | +}//}}} | |
1009 | + | |
1010 | + | |
1011 | +void VimMainWindow::clipboard_selection_update(){//{{{ | |
1012 | + if (kapp->clipboard()->ownsSelection()) | |
1013 | + clip_own_selection(&clip_star); | |
1014 | + else | |
1015 | + clip_lose_selection(&clip_star); | |
1016 | +}//}}} | |
1017 | + | |
1018 | +void VimMainWindow::clipboard_data_update(){//{{{ | |
1019 | +#if QT_VERSION>=300 | |
1020 | + if (kapp->clipboard()->ownsClipboard()) | |
1021 | + clip_own_selection(&clip_plus); | |
1022 | + else | |
1023 | + clip_lose_selection(&clip_plus); | |
1024 | +#else | |
1025 | + if (kapp->clipboard()->ownsSelection()) | |
1026 | + clip_own_selection(&clip_star); | |
1027 | + else | |
1028 | + clip_lose_selection(&clip_star); | |
1029 | +#endif | |
1030 | +}//}}} | |
1031 | + | |
1032 | +void VimMainWindow::slotSearch()//{{{ | |
1033 | +{ | |
1034 | + QString find_text; | |
1035 | + bool direction_down = TRUE; | |
1036 | + bool casesensitive = TRUE; | |
1037 | + int flags = FRD_FINDNEXT; | |
1038 | + | |
1039 | + find_text = finddlg->getText(); | |
1040 | + direction_down = !(finddlg->get_direction()); | |
1041 | + casesensitive = finddlg->case_sensitive(); | |
1042 | + // if (casesensitive) find_text = "\\C" + find_text; | |
1043 | + // else find_text = "\\c" + find_text; | |
1044 | + if (casesensitive) flags|=FRD_MATCH_CASE; | |
1045 | + QCString unistring = vmw->codec->fromUnicode(find_text); | |
1046 | + gui_do_findrepl(flags, (char_u *)(const char *)unistring, NULL,(int)direction_down); | |
1047 | +}//}}} | |
1048 | + | |
1049 | +void VimMainWindow::slotFind()//{{{ | |
1050 | +{ | |
1051 | + QString find_text; | |
1052 | + bool direction_down=TRUE; | |
1053 | + bool casesensitive = TRUE; | |
1054 | + int flags = FRD_R_FINDNEXT; | |
1055 | + | |
1056 | + find_text=repldlg->getText(); | |
1057 | + direction_down = !(repldlg->get_direction()); | |
1058 | + casesensitive = repldlg->case_sensitive(); | |
1059 | + // if (casesensitive) find_text = "\\C" + find_text; | |
1060 | + // else find_text = "\\c" + find_text; | |
1061 | + if (casesensitive) flags|=FRD_MATCH_CASE; | |
1062 | + | |
1063 | + QCString unistring = vmw->codec->fromUnicode(find_text); | |
1064 | + gui_do_findrepl(flags, (char_u *)(const char *)unistring, NULL,(int)direction_down); | |
1065 | +}//}}} | |
1066 | + | |
1067 | +void VimMainWindow::slotReplace()//{{{ | |
1068 | +{ | |
1069 | + QString find_text; | |
1070 | + QString repl_text; | |
1071 | + bool direction_down=TRUE; | |
1072 | + bool casesensitive = TRUE; | |
1073 | + int flags = FRD_REPLACE; | |
1074 | + | |
1075 | + find_text=repldlg->getText(); | |
1076 | + repl_text=repldlg->getReplaceText(); | |
1077 | + direction_down = !(repldlg->get_direction()); | |
1078 | + //if (casesensitive) find_text = "\\C" + find_text; | |
1079 | + //else find_text = "\\c" + find_text; | |
1080 | + if (casesensitive) flags|=FRD_MATCH_CASE; | |
1081 | + | |
1082 | + QCString unistring = vmw->codec->fromUnicode(find_text); | |
1083 | + QCString unistring2 = vmw->codec->fromUnicode(repl_text); | |
1084 | + gui_do_findrepl(flags, (char_u *)(const char *)unistring,(char_u *)(const char*)unistring2,(int)direction_down); | |
1085 | +}//}}} | |
1086 | + | |
1087 | +void VimMainWindow::slotReplaceAll()//{{{ | |
1088 | +{ | |
1089 | + QString find_text; | |
1090 | + QString repl_text; | |
1091 | + bool direction_down=TRUE; | |
1092 | + bool casesensitive = TRUE; | |
1093 | + int flags = FRD_REPLACEALL; | |
1094 | + | |
1095 | + find_text=repldlg->getText(); | |
1096 | + repl_text=repldlg->getReplaceText(); | |
1097 | + direction_down = !(repldlg->get_direction()); | |
1098 | + casesensitive = repldlg->case_sensitive(); | |
1099 | + // if (casesensitive) find_text = "\\C" + find_text; | |
1100 | + // else find_text = "\\c" + find_text; | |
1101 | + if (casesensitive) flags|=FRD_MATCH_CASE; | |
1102 | + QCString unistring = vmw->codec->fromUnicode(find_text); | |
1103 | + QCString unistring2 = vmw->codec->fromUnicode(repl_text); | |
1104 | + gui_do_findrepl(flags, (char_u *)(const char *)unistring,(char_u *)(const char*)unistring2,(int)direction_down); | |
1105 | +}//}}} | |
1106 | + | |
1107 | +void VimMainWindow::showAboutKDE() | |
1108 | +{ | |
1109 | + KAboutKDE *kde = new KAboutKDE(this); | |
1110 | + kde->show(); | |
1111 | +} | |
1112 | + | |
1113 | +void VimMainWindow::showAboutApplication()//{{{ | |
1114 | +{ | |
1115 | + KAboutData *aboutData = new KAboutData ( | |
1116 | + "kvim" | |
1117 | + , I18N_NOOP("KVim") | |
1118 | + , VIM_VERSION_SHORT | |
1119 | + , I18N_NOOP("Vim in a KDE interface") | |
1120 | + , 0 | |
1121 | + , "(c) Vim Team, \":help credits\" for more infos.\nType \":help iccf\" to see how you can help the children in Uganda" | |
1122 | + , 0l | |
1123 | + , "http://freehackers.org/kvim" | |
1124 | + , "kvim-dev@freenux.org" | |
1125 | + ); | |
1126 | + | |
1127 | + aboutData->addAuthor("Bram Moolenaar", | |
1128 | + I18N_NOOP("Main vim author"), | |
1129 | + "Bram@vim.org", | |
1130 | + "http://www.vim.org/"); | |
1131 | + aboutData->addAuthor("Thomas Capricelli", | |
1132 | + I18N_NOOP("KDE porting"), | |
1133 | + "orzel@freehackers.org", | |
1134 | + "http://orzel.freehackers.org"); | |
1135 | + aboutData->addAuthor("Philippe Fremy", | |
1136 | + I18N_NOOP("KDE porting"), | |
1137 | + "pfremy@chez.com", | |
1138 | + "http://www.freehackers.org/kvim"); | |
1139 | + aboutData->addAuthor("Mark Westcott", | |
1140 | + I18N_NOOP("Qtopia porting, maintainer of the Qtopia part"), | |
1141 | + "mark@houseoffish.org", | |
1142 | + "http://houseoffish.org"); | |
1143 | + aboutData->addAuthor("Mickael Marchand", | |
1144 | + I18N_NOOP("KDE porting, maintainer"), | |
1145 | + "marchand@kde.org", | |
1146 | + "http://freenux.org"); | |
1147 | + aboutData->addAuthor("Many other people", | |
1148 | + I18N_NOOP("type :help credits for more infos") | |
1149 | + ); | |
1150 | + aboutData->addCredit("Vince Negri", | |
1151 | + I18N_NOOP("Antialiasing support, Color fixes"), | |
1152 | + "vnegri@asl-electronics.co.uk"); | |
1153 | + aboutData->addCredit("Malte Starostik", | |
1154 | + I18N_NOOP("Patch for performance improvement"), | |
1155 | + "malte@kde.org"); | |
1156 | + aboutData->addCredit("Mark Stosberg", | |
1157 | + I18N_NOOP("Provided a FreeBSD box to debug KVim on BSD"), | |
1158 | + "mark@summersault.com" | |
1159 | + ); | |
1160 | + aboutData->addCredit("Henrik Skott", | |
1161 | + I18N_NOOP("Font patch when KDE not configured"), | |
1162 | + "henrik.skott@hem.utfors.se" | |
1163 | + ); | |
1164 | + aboutData->addCredit("Kailash Sethuraman", | |
1165 | + I18N_NOOP("NetBSD configure/compilation fixes") | |
1166 | + ); | |
1167 | + aboutData->setLicenseText( | |
1168 | +"KVim as an extension of Vim follows Vim license : \n\ | |
1169 | +Vim is Charityware. You can use and copy it as much as you like, but you are\n\ | |
1170 | +encouraged to make a donation to orphans in Uganda. Please read the file\n\ | |
1171 | +runtime/doc/uganda.txt for details.\n\ | |
1172 | +\n\ | |
1173 | +There are no restrictions on distributing an unmodified copy of Vim. Parts of\n\ | |
1174 | +Vim may also be distributed, but this text must always be included. You are\n\ | |
1175 | +allowed to include executables that you made from the unmodified Vim sources,\n\ | |
1176 | +your own usage examples and Vim scripts.\n\ | |
1177 | +\n\ | |
1178 | +If you distribute a modified version of Vim, you are encouraged to send the\n\ | |
1179 | +maintainer a copy, including the source code. Or make it available to the\n\ | |
1180 | +maintainer through ftp; let him know where it can be found. If the number of\n\ | |
1181 | +changes is small (e.g., a modified Makefile) e-mailing the diffs will do.\n\ | |
1182 | +When the maintainer asks for it (in any way) you must make your changes,\n\ | |
1183 | +including source code, available to him.\n\ | |
1184 | +\n\ | |
1185 | +The maintainer reserves the right to include any changes in the official\n\ | |
1186 | +version of Vim. This is negotiable. You are not allowed to distribute a\n\ | |
1187 | +modified version of Vim when you are not willing to make the source code\n\ | |
1188 | +available to the maintainer.\n\ | |
1189 | +\n\ | |
1190 | +The current maintainer is Bram Moolenaar <Bram@vim.org>. If this changes, it\n\ | |
1191 | +will be announced in appropriate places (most likely www.vim.org and\n\ | |
1192 | +comp.editors). When it is completely impossible to contact the maintainer,\n\ | |
1193 | +the obligation to send him modified source code ceases.\n\ | |
1194 | +\n\ | |
1195 | +It is not allowed to remove these restrictions from the distribution of the\n\ | |
1196 | +Vim sources or parts of it. These restrictions may also be used for previous\n\ | |
1197 | +Vim releases instead of the text that was included with it."); | |
1198 | + | |
1199 | + KAboutApplication *about = new KAboutApplication(aboutData); | |
1200 | + about->show(); | |
1201 | +}//}}} | |
1202 | + | |
1203 | +void VimMainWindow::showTipOfTheDay() | |
1204 | +{ | |
1205 | +#if QT_VERSION>=300 | |
1206 | + KTipDialog::showTip (vmw,QString::null,true); | |
1207 | +#endif | |
1208 | +} | |
1209 | + | |
1210 | +void VimMainWindow::buffersToolbar() | |
1211 | +{ | |
1212 | + | |
1213 | +} | |
1214 | + | |
1215 | +void VimMainWindow::showBugReport() | |
1216 | +{ | |
1217 | + KBugReport *bug= new KBugReport(this,true); | |
1218 | + bug->show(); | |
1219 | +} | |
1220 | +/* | |
1221 | + * Vim Dialog | |
1222 | + * | |
1223 | + * Returns: | |
1224 | + * 0: Cancel | |
1225 | + * 1- : nb of the pressed button | |
1226 | + */ | |
1227 | + | |
1228 | +VimDialog::VimDialog (int type, /* type of dialog *///{{{ | |
1229 | + char_u * title, /* title of dialog */ | |
1230 | + char_u * message, /* message text */ | |
1231 | + char_u * buttons, /* names of buttons */ | |
1232 | + int def_but, /* default button */ | |
1233 | + char_u *textfield ) /* input field */ | |
1234 | +:QDialog(vmw, "vim generic dialog", true), // true is for "modal" | |
1235 | + mapper(this, "dialog signal mapper") | |
1236 | +{ | |
1237 | + /* | |
1238 | + * Create Icon | |
1239 | + */ | |
1240 | + char ** icon_data; | |
1241 | + switch (type) | |
1242 | + { | |
1243 | + case VIM_GENERIC: | |
1244 | + icon_data = generic_xpm; | |
1245 | + break; | |
1246 | + case VIM_ERROR: | |
1247 | + icon_data = error_xpm; | |
1248 | + break; | |
1249 | + case VIM_WARNING: | |
1250 | + icon_data = alert_xpm; | |
1251 | + break; | |
1252 | + case VIM_INFO: | |
1253 | + icon_data = info_xpm; | |
1254 | + break; | |
1255 | + case VIM_QUESTION: | |
1256 | + icon_data = quest_xpm; | |
1257 | + break; | |
1258 | + default: | |
1259 | + icon_data = generic_xpm; | |
1260 | + }; | |
1261 | + QLabel * icon = new QLabel( this ); | |
1262 | + icon->setPixmap( QPixmap( (const char **) icon_data ) ); | |
1263 | + icon->setFixedSize( icon->sizeHint() ); | |
1264 | + | |
1265 | + QLabel * text = new QLabel( (const char *)message, this ); | |
1266 | + text->setAlignment( AlignHCenter | AlignVCenter | ExpandTabs ); | |
1267 | + | |
1268 | + QStringList buttonText = QStringList::split( DLG_BUTTON_SEP, (char *) buttons); | |
1269 | + int butNb = buttonText.count(); | |
1270 | + | |
1271 | + /* | |
1272 | + * Layout | |
1273 | + */ | |
1274 | + | |
1275 | + QVBoxLayout * vly = new QVBoxLayout( this, 5, 5 ); | |
1276 | + QHBoxLayout * hly1 = new QHBoxLayout( vly, 5); | |
1277 | + hly1->addWidget( icon ); | |
1278 | + hly1->addWidget( text ); | |
1279 | + QHBoxLayout * hly3 = new QHBoxLayout ( vly , 5); | |
1280 | + if (textfield!=NULL) | |
1281 | + { | |
1282 | + entry = new QLineEdit((const char *)textfield,this); | |
1283 | + entry->setText((const char *)textfield); | |
1284 | + hly3->addWidget( entry ); | |
1285 | + ret=textfield; | |
1286 | + } | |
1287 | + else | |
1288 | + entry=NULL; | |
1289 | + | |
1290 | + QHBoxLayout * hly2 = new QHBoxLayout( vly, 15); | |
1291 | + QString s; | |
1292 | + QPushButton * pushButton = 0L; | |
1293 | + for (int i=0; i<butNb; i++) | |
1294 | + { | |
1295 | + s = buttonText[i]; | |
1296 | + pushButton = new QPushButton(s, this ); | |
1297 | + if (s.find('&') != -1) | |
1298 | + pushButton->setAccel(s.at(s.find('&')+1).latin1()); | |
1299 | + | |
1300 | + hly2->addWidget( pushButton ); | |
1301 | + if (i == def_but-1) | |
1302 | + { | |
1303 | + pushButton->setDefault( true ); | |
1304 | + pushButton->setAutoDefault( true ); | |
1305 | + setResult( i+1 ); | |
1306 | + } | |
1307 | + connect(pushButton, SIGNAL(clicked()), &mapper, SLOT(map())); | |
1308 | + mapper.setMapping(pushButton, i+1); | |
1309 | + } | |
1310 | + connect( &mapper, SIGNAL(mapped(int)), this, SLOT(done(int))); | |
1311 | + | |
1312 | + setCaption((const char *) title); | |
1313 | + | |
1314 | + vly->activate(); | |
1315 | +}//}}} | |
1316 | + | |
1317 | +void VimDialog::done(int r) | |
1318 | +{ | |
1319 | + if (entry!=NULL) | |
1320 | + { | |
1321 | + if (r) | |
1322 | + { | |
1323 | + QCString unistring=vmw->codec->fromUnicode(entry->text()); | |
1324 | + STRCPY(ret,(const char*)unistring); | |
1325 | + } | |
1326 | + else | |
1327 | + *ret=NUL; | |
1328 | + } | |
1329 | + QDialog::done(r); | |
1330 | +} | |
1331 | + | |
1332 | +/* | |
1333 | + * ScrollBar pool handling | |
1334 | + */ | |
1335 | +SBPool::SBPool(void)//{{{ | |
1336 | + :mapper(this, "SBPool signal mapper") | |
1337 | +{ | |
1338 | + connect(&mapper, SIGNAL(mapped(int)), this, SLOT(sbUsed(int))); | |
1339 | +}//}}} | |
1340 | + | |
1341 | + | |
1342 | +void SBPool::create(GuiScrollbar * sb, int orient)//{{{ | |
1343 | +{ | |
1344 | + switch(orient) | |
1345 | + { | |
1346 | + case SBAR_HORIZ: | |
1347 | + sb->w = new QScrollBar(QScrollBar::Horizontal, vmw); | |
1348 | + break; | |
1349 | + case SBAR_VERT: | |
1350 | + sb->w = new QScrollBar(QScrollBar::Vertical, vmw); | |
1351 | + break; | |
1352 | + default: | |
1353 | + sb->w = 0; | |
1354 | + return; | |
1355 | + } | |
1356 | + | |
1357 | + connect(sb->w, SIGNAL(valueChanged(int)), &mapper, SLOT(map())); | |
1358 | + mapper.setMapping(sb->w, (int)sb); | |
1359 | +}//}}} | |
1360 | + | |
1361 | + | |
1362 | +void SBPool::sbUsed(int who)//{{{ | |
1363 | +{ | |
1364 | + GuiScrollbar *sb = (GuiScrollbar*)who; | |
1365 | + gui_drag_scrollbar( sb, sb->w->value(), FALSE); | |
1366 | +}//}}} | |
1367 | + | |
1368 | + | |
1369 | +void SBPool::destroy(GuiScrollbar * sb)//{{{ | |
1370 | +{ | |
1371 | + if (!sb->w) return; | |
1372 | + | |
1373 | + delete sb->w; | |
1374 | + sb->w = 0; | |
1375 | +}//}}} | |
1376 | + | |
1377 | +#ifdef FEAT_CLIENTSERVER | |
1378 | +static int kvim_x11_event_filter( XEvent* e)//{{{ | |
1379 | +{ | |
1380 | + if (e->xproperty.type == PropertyNotify | |
1381 | + && e->xproperty.atom == commProperty | |
1382 | + && e->xproperty.window == commWindow | |
1383 | + && e->xproperty.state == PropertyNewValue) | |
1384 | + serverEventProc(qt_xdisplay(), e); | |
1385 | + | |
1386 | + if (oldFilter) return oldFilter( e ); | |
1387 | + return FALSE; | |
1388 | +}//}}} | |
1389 | +#endif | |
1390 | + | |
1391 | +//add some QT 3 fonts usefull functions | |
1392 | +#if QT_VERSION<300 | |
1393 | +QString KVimUtils::toString(QFont *f) | |
1394 | +{ | |
1395 | + QStringList l; | |
1396 | + l.append(f->family()); | |
1397 | + l.append(QString::number(f->pointSize())); | |
1398 | + l.append(QString::number(f->pixelSize())); | |
1399 | + l.append(QString::number((int)f->styleHint())); | |
1400 | + l.append(QString::number(f->weight())); | |
1401 | + l.append(QString::number((int)f->italic())); | |
1402 | + l.append(QString::number((int)f->underline())); | |
1403 | + l.append(QString::number((int)f->strikeOut())); | |
1404 | + l.append(QString::number((int)f->fixedPitch())); | |
1405 | + l.append(QString::number((int)f->rawMode())); | |
1406 | + return l.join(","); | |
1407 | +} | |
1408 | + | |
1409 | +bool KVimUtils::fromString(QFont *f, QString descrip) | |
1410 | +{ | |
1411 | + QStringList l(QStringList::split(',', descrip)); | |
1412 | + | |
1413 | + int count = l.count(); | |
1414 | + if (count != 10 && count != 9) | |
1415 | + return FALSE; | |
1416 | + | |
1417 | + f->setFamily(l[0]); | |
1418 | + f->setPointSize(l[1].toInt()); | |
1419 | + if ( count == 9 ) | |
1420 | + { | |
1421 | + f->setStyleHint((QFont::StyleHint) l[2].toInt()); | |
1422 | + f->setWeight(l[3].toInt()); | |
1423 | + f->setItalic(l[4].toInt()); | |
1424 | + f->setUnderline(l[5].toInt()); | |
1425 | + f->setStrikeOut(l[6].toInt()); | |
1426 | + f->setFixedPitch(l[7].toInt()); | |
1427 | + f->setRawMode(l[8].toInt()); | |
1428 | + } | |
1429 | + else | |
1430 | + { | |
1431 | + f->setPixelSize(l[2].toInt()); | |
1432 | + f->setStyleHint((QFont::StyleHint) l[3].toInt()); | |
1433 | + f->setWeight(l[4].toInt()); | |
1434 | + f->setItalic(l[5].toInt()); | |
1435 | + f->setUnderline(l[6].toInt()); | |
1436 | + f->setStrikeOut(l[7].toInt()); | |
1437 | + f->setFixedPitch(l[8].toInt()); | |
1438 | + f->setRawMode(l[9].toInt()); | |
1439 | + } | |
1440 | + return TRUE; | |
1441 | +} | |
1442 | +#endif | |
1443 | + | |
1444 | +QString KVimUtils::convertEncodingName(QString name) | |
1445 | +{ | |
1446 | + if (name.startsWith("ucs") || name.startsWith("utf-16")) return QString("utf16"); | |
1447 | + if (name=="cp950") return QString("Big5"); | |
1448 | + return QString(); | |
1449 | +} |
@@ -0,0 +1,245 @@ | ||
1 | +/* vi:set ts=8 sts=0 sw=8: | |
2 | + * | |
3 | + * VIM - Vi IMproved by Bram Moolenaar | |
4 | + * | |
5 | + * Do ":help uganda" in Vim to read copying and usage conditions. | |
6 | + * Do ":help credits" in Vim to see a list of people who contributed. | |
7 | + */ | |
8 | + | |
9 | +/* | |
10 | + * Porting to KDE(2) was done by | |
11 | + * | |
12 | + * (C) 2000 by Thomas Capricelli <orzel@freehackers.org> | |
13 | + * | |
14 | + * Please visit http://freehackers.org/kvim for other vim- or | |
15 | + * kde-related coding. | |
16 | + * | |
17 | + * $Id$ | |
18 | + * | |
19 | + */ | |
20 | + | |
21 | +#ifndef GUI_KDE_WIDGET | |
22 | +#define GUI_KDE_WIDGET | |
23 | + | |
24 | +#if 1 | |
25 | +#define dbf( format, args... ) { printf( "%s" " : " format "\n" , __FUNCTION__ , ## args ); fflush(stdout); } | |
26 | +#define db() { printf( "%s\n", __FUNCTION__ );fflush(stdout); } | |
27 | +#else | |
28 | +#define dbf(format, args... ) | |
29 | +#define db() | |
30 | +#endif | |
31 | + | |
32 | +#define UNIX // prevent a warning : a symbol is defined twice in X and Qt | |
33 | + | |
34 | +#include <qdialog.h> | |
35 | +#include <qlabel.h> | |
36 | +#include <qsignalmapper.h> | |
37 | +#include <qtimer.h> | |
38 | +#include <qmainwindow.h> | |
39 | +#include <qapplication.h> | |
40 | +#include <qevent.h> | |
41 | +#include <qlineedit.h> | |
42 | +#include <qpainter.h> | |
43 | +#include <qwidget.h> | |
44 | +#include <qpopupmenu.h> | |
45 | +#include <klocale.h> | |
46 | +#include <kapp.h> | |
47 | +#include <kcmdlineargs.h> | |
48 | +#include <kaboutdata.h> | |
49 | +#include <keditcl.h> | |
50 | +#include <kaboutdata.h> | |
51 | +#if (KDE_VERSION>=290) | |
52 | +#include <kmainwindow.h> | |
53 | +#else | |
54 | +#include <ktmainwindow.h> | |
55 | +#endif | |
56 | +#include <kparts/part.h> | |
57 | +#include <kurl.h> | |
58 | +#include "kvim_iface.h" | |
59 | + | |
60 | +#undef UNIX // prevent a warning | |
61 | +extern "C" { | |
62 | +#include "vim.h" | |
63 | +} | |
64 | + | |
65 | +class QPushButton; | |
66 | +class QDialog; | |
67 | +class QLineEdit; | |
68 | +class QSignalMapper; | |
69 | +class QPaintEvent; | |
70 | + | |
71 | +enum BlinkState { | |
72 | + BLINK_NONE, | |
73 | + BLINK_ON, | |
74 | + BLINK_OFF | |
75 | +}; | |
76 | + | |
77 | +class VimWidget : public QWidget, virtual public KVim | |
78 | +{ | |
79 | + Q_OBJECT | |
80 | + | |
81 | +public: | |
82 | + VimWidget( QWidget *parent=0, const char *name=0, WFlags f=0 ); | |
83 | + virtual void paintEvent( QPaintEvent *); | |
84 | + void draw_string(int x, int y, QString s, int len, int flags); | |
85 | + | |
86 | + /** Init the blinking time */ | |
87 | + void set_blink_time( long, long, long ); | |
88 | + void start_cursor_blinking(); | |
89 | + void stop_cursor_blinking(); | |
90 | + void wait(long); | |
91 | +#ifdef FEAT_CLIENTSERVER | |
92 | + void serverActivate(WId id); | |
93 | +#endif | |
94 | +#ifdef FEAT_MZSCHEME | |
95 | + void enable_mzscheme_threads(); | |
96 | + void disable_mzscheme_threads(); | |
97 | +#endif | |
98 | + void flash(); | |
99 | + | |
100 | + /** DCOP */ | |
101 | + void execNormal(QString command); | |
102 | + void execInsert(QString command); | |
103 | + void execRaw(QString command); | |
104 | + void execCmd(QString command); | |
105 | + QString eval(QString expr); | |
106 | + | |
107 | + bool wait_done; | |
108 | + BlinkState blink_state; | |
109 | + QPainter *painter; | |
110 | + QPopupMenu *menu; | |
111 | + | |
112 | +protected: | |
113 | + virtual void keyPressEvent( QKeyEvent * ); | |
114 | + virtual void mousePressEvent( QMouseEvent *); | |
115 | + virtual void mouseDoubleClickEvent( QMouseEvent *); | |
116 | + virtual void mouseReleaseEvent( QMouseEvent *); | |
117 | + virtual void mouseMoveEvent( QMouseEvent *); | |
118 | + virtual void focusInEvent( QFocusEvent * ); | |
119 | + virtual void focusOutEvent( QFocusEvent * ); | |
120 | + virtual void dragEnterEvent (QDragEnterEvent *); | |
121 | + virtual void dropEvent (QDropEvent *); | |
122 | +#ifdef FEAT_XIM | |
123 | + virtual void imStartEvent ( QIMEvent * ); | |
124 | + virtual void imEndEvent ( QIMEvent * ); | |
125 | + virtual void imComposeEvent ( QIMEvent * ); | |
126 | +#endif | |
127 | +#ifdef FEAT_MZSCHEME | |
128 | + virtual void timerEvent( QTimerEvent * ); | |
129 | +#endif | |
130 | + | |
131 | + /* cursor blinking stuff */ | |
132 | + QTimer blink_timer; | |
133 | + long blink_wait_time, blink_on_time, blink_off_time; | |
134 | + | |
135 | + /* wait for input */ | |
136 | + QTimer wait_timer; | |
137 | + | |
138 | +#ifdef FEAT_MZSCHEME | |
139 | + int mzscheme_timer_id; | |
140 | +#endif | |
141 | + | |
142 | +public slots: | |
143 | + void blink_cursor(); | |
144 | + void wait_timeout(); | |
145 | +}; | |
146 | + | |
147 | +class VimMainWindow : public KMainWindow | |
148 | +{ | |
149 | + Q_OBJECT | |
150 | + | |
151 | +public: | |
152 | + VimMainWindow ( const char *name = 0L, WFlags f = WDestructiveClose ); | |
153 | + | |
154 | + /** called when the widget closes */ | |
155 | +// bool close(bool alsoDelete); | |
156 | + VimWidget *w; | |
157 | + KEdFind *finddlg; | |
158 | + KEdReplace *repldlg; | |
159 | + int have_tearoff; | |
160 | + QTextCodec *codec; | |
161 | + | |
162 | +public slots: | |
163 | + void menu_activated(int dx); | |
164 | + void clipboard_selection_update(); | |
165 | + void clipboard_data_update(); | |
166 | + void slotSearch(); | |
167 | + void slotFind(); | |
168 | + void slotReplace(); | |
169 | + void slotReplaceAll(); | |
170 | + void showAboutApplication(); | |
171 | + void showAboutKDE(); | |
172 | + void showBugReport(); | |
173 | + void showTipOfTheDay(); | |
174 | + void buffersToolbar(); | |
175 | + bool isLocked(); | |
176 | + void lock(); | |
177 | + void unlock(); | |
178 | + | |
179 | +protected: | |
180 | + virtual void wheelEvent (QWheelEvent *); | |
181 | + virtual void resizeEvent ( QResizeEvent *e ); | |
182 | + | |
183 | +#if defined(FEAT_SESSION) | |
184 | + void saveGlobalProperties (KConfig *conf); | |
185 | + void readGlobalProperties (KConfig *conf); | |
186 | +#endif | |
187 | + bool queryClose(); | |
188 | + bool queryExit(); | |
189 | + bool locked; | |
190 | +}; | |
191 | + | |
192 | + | |
193 | +class VimDialog : public QDialog | |
194 | +{ | |
195 | + Q_OBJECT | |
196 | +public: | |
197 | + VimDialog (int type, /* type of dialog */ | |
198 | + unsigned char * title, /* title of dialog */ | |
199 | + unsigned char * message, /* message text */ | |
200 | + unsigned char * buttons, /* names of buttons */ | |
201 | + int def_but, /* default button */ | |
202 | + char_u *textfield); /* input text */ | |
203 | +private: | |
204 | + QSignalMapper mapper; | |
205 | + QLineEdit *entry; | |
206 | + char_u *ret; | |
207 | + int butNb; | |
208 | + | |
209 | +protected slots: | |
210 | + void done(int); | |
211 | +}; | |
212 | + | |
213 | + | |
214 | +/* | |
215 | + * QScrollBar pool | |
216 | + */ | |
217 | +struct GuiScrollbar; | |
218 | + | |
219 | +class SBPool : public QObject | |
220 | +{ | |
221 | + Q_OBJECT | |
222 | +public: | |
223 | + SBPool(void); | |
224 | + void create(GuiScrollbar * sb, int orient); | |
225 | + void destroy(GuiScrollbar * sb); | |
226 | +public slots: | |
227 | + void sbUsed(int who); | |
228 | +private: | |
229 | + QSignalMapper mapper; | |
230 | +}; | |
231 | + | |
232 | +class KVimUtils { | |
233 | +public: | |
234 | + static QString convertEncodingName(QString); | |
235 | +#if QT_VERSION<300 | |
236 | + static bool fromString(QFont*,QString); | |
237 | + static QString toString(QFont*); | |
238 | +#endif | |
239 | +}; | |
240 | + | |
241 | +extern VimMainWindow *vmw; | |
242 | +extern SBPool *sbpool; | |
243 | +extern QString *argServerName; | |
244 | + | |
245 | +#endif // GUI_KDE_WIDGET |
@@ -1,1417 +0,0 @@ | ||
1 | -/* vi:set ts=8 sts=4 sw=4: | |
2 | - * | |
3 | - * VIM - Vi IMproved by Bram Moolenaar | |
4 | - * | |
5 | - * Do ":help uganda" in Vim to read copying and usage conditions. | |
6 | - * Do ":help credits" in Vim to see a list of people who contributed. | |
7 | - */ | |
8 | - | |
9 | -/* | |
10 | - * Porting to KDE(2) was done by | |
11 | - * | |
12 | - * (C) 2000 by Thomas Capricelli <orzel@freehackers.org> | |
13 | - * | |
14 | - * Please visit http://freehackers.org/kvim for other vim- or | |
15 | - * kde-related coding. | |
16 | - * | |
17 | - * $Id$ | |
18 | - * | |
19 | - */ | |
20 | - | |
21 | -#include <assert.h> | |
22 | -#include <qpainter.h> | |
23 | -#include <qevent.h> | |
24 | -#include <qpushbutton.h> | |
25 | -#include <qscrollbar.h> | |
26 | -#include <qlayout.h> | |
27 | -#include <qclipboard.h> | |
28 | -#include <qdragobject.h> | |
29 | -#include <qstrlist.h> | |
30 | -#include <qmenubar.h> | |
31 | -#include <qtextcodec.h> | |
32 | -#if QT_VERSION>=300 | |
33 | -#include <qptrlist.h> | |
34 | -#include <ktip.h> | |
35 | -#endif | |
36 | -#include <kglobal.h> | |
37 | -#include <kconfig.h> | |
38 | -#include <kaboutapplication.h> | |
39 | -#include <dcopclient.h> | |
40 | -#include <kaboutkde.h> | |
41 | -#include <kbugreport.h> | |
42 | -#include <kurldrag.h> | |
43 | -#include <kmenubar.h> | |
44 | -#include <ktoolbar.h> | |
45 | -#include <kstandarddirs.h> | |
46 | -#include "gui_kde_widget.h" | |
47 | -#include <qxembed.h> | |
48 | - | |
49 | -extern "C" { | |
50 | -#include "version.h" | |
51 | -} | |
52 | - | |
53 | -// Pixmap for dialog | |
54 | -#ifdef FEAT_GUI_DIALOG | |
55 | -# include "../../pixmaps/alert.xpm" | |
56 | -# include "../../pixmaps/error.xpm" | |
57 | -# include "../../pixmaps/generic.xpm" | |
58 | -# include "../../pixmaps/info.xpm" | |
59 | -# include "../../pixmaps/quest.xpm" | |
60 | -#endif | |
61 | - | |
62 | -/** | |
63 | - * Keycodes recognized by vim. | |
64 | - */ | |
65 | -struct special_key {//{{{ | |
66 | - int qtkey; | |
67 | - char_u code0; | |
68 | - char_u code1; | |
69 | -} special_keys[] = | |
70 | -{ | |
71 | - { Qt::Key_Up, 'k', 'u' }, | |
72 | - { Qt::Key_Down, 'k', 'd' }, | |
73 | - { Qt::Key_Left, 'k', 'l' }, | |
74 | - { Qt::Key_Right, 'k', 'r' }, | |
75 | - { Qt::Key_F1, 'k', '1' }, | |
76 | - { Qt::Key_F2, 'k', '2' }, | |
77 | - { Qt::Key_F3, 'k', '3' }, | |
78 | - { Qt::Key_F4, 'k', '4' }, | |
79 | - { Qt::Key_F5, 'k', '5' }, | |
80 | - { Qt::Key_F6, 'k', '6' }, | |
81 | - { Qt::Key_F7, 'k', '7' }, | |
82 | - { Qt::Key_F8, 'k', '8' }, | |
83 | - { Qt::Key_F9, 'k', '9' }, | |
84 | - { Qt::Key_F10, 'k', ';' }, | |
85 | - { Qt::Key_F11, 'F', '1' }, | |
86 | - { Qt::Key_F12, 'F', '2' }, | |
87 | - { Qt::Key_F13, 'F', '3' }, | |
88 | - { Qt::Key_F14, 'F', '4' }, | |
89 | - { Qt::Key_F15, 'F', '5' }, | |
90 | - { Qt::Key_F16, 'F', '6' }, | |
91 | - { Qt::Key_F17, 'F', '7' }, | |
92 | - { Qt::Key_F18, 'F', '8' }, | |
93 | - { Qt::Key_F19, 'F', '9' }, | |
94 | - { Qt::Key_F20, 'F', 'A' }, | |
95 | - { Qt::Key_F21, 'F', 'B' }, | |
96 | - { Qt::Key_F22, 'F', 'C' }, | |
97 | - { Qt::Key_F23, 'F', 'D' }, | |
98 | - { Qt::Key_F24, 'F', 'E' }, | |
99 | - { Qt::Key_F25, 'F', 'F' }, | |
100 | - { Qt::Key_F26, 'F', 'G' }, | |
101 | - { Qt::Key_F27, 'F', 'H' }, | |
102 | - { Qt::Key_F28, 'F', 'I' }, | |
103 | - { Qt::Key_F29, 'F', 'J' }, | |
104 | - { Qt::Key_F30, 'F', 'K' }, | |
105 | - { Qt::Key_F31, 'F', 'L' }, | |
106 | - { Qt::Key_F32, 'F', 'M' }, | |
107 | - { Qt::Key_F33, 'F', 'N' }, | |
108 | - { Qt::Key_F34, 'F', 'O' }, | |
109 | - { Qt::Key_F35, 'F', 'P' }, | |
110 | - { Qt::Key_Help, '%', '1' }, | |
111 | - // { Qt::Key_Undo, '&', '8' }, <= hmmm ? | |
112 | - { Qt::Key_BackSpace, 'k', 'b' }, | |
113 | - { Qt::Key_Insert, KS_EXTRA, KE_KINS }, | |
114 | - { Qt::Key_Delete, KS_EXTRA, KE_KDEL }, | |
115 | - { Qt::Key_Home, 'K', '1' }, | |
116 | - { Qt::Key_End, 'K', '4' }, | |
117 | - { Qt::Key_Prior, 'K', '3' }, | |
118 | - { Qt::Key_Next, 'K', '5' }, | |
119 | - { Qt::Key_Print, '%', '9' }, | |
120 | - | |
121 | - { Qt::Key_Plus, 'K', '6'}, | |
122 | - { Qt::Key_Minus, 'K', '7'}, | |
123 | - { Qt::Key_Slash, 'K', '8'}, | |
124 | - { Qt::Key_multiply, 'K', '9'}, | |
125 | - { Qt::Key_Enter, 'K', 'A'}, | |
126 | - { Qt::Key_Period, 'K', 'B'}, | |
127 | - | |
128 | - { Qt::Key_0, 'K', 'C'}, | |
129 | - { Qt::Key_1, 'K', 'D'}, | |
130 | - { Qt::Key_2, 'K', 'E'}, | |
131 | - { Qt::Key_3, 'K', 'F'}, | |
132 | - { Qt::Key_4, 'K', 'G'}, | |
133 | - { Qt::Key_5, 'K', 'H'}, | |
134 | - { Qt::Key_6, 'K', 'I'}, | |
135 | - { Qt::Key_7, 'K', 'J'}, | |
136 | - { Qt::Key_8, 'K', 'K'}, | |
137 | - { Qt::Key_9, 'K', 'L'}, | |
138 | - /* End of list marker: */ | |
139 | - { 0, 0, 0 } | |
140 | -};//}}} | |
141 | - | |
142 | -#ifdef FEAT_CLIENTSERVER | |
143 | -typedef int (*QX11EventFilter) (XEvent*); | |
144 | -extern QX11EventFilter qt_set_x11_event_filter (QX11EventFilter filter); | |
145 | -static QX11EventFilter oldFilter = 0; | |
146 | -static int kvim_x11_event_filter( XEvent* e); | |
147 | -#endif | |
148 | -void gui_keypress(QKeyEvent *e); | |
149 | - | |
150 | -/* | |
151 | - * Return OK if the key with the termcap name "name" is supported. | |
152 | - */ | |
153 | - int | |
154 | -gui_mch_haskey(char_u * name)//{{{ | |
155 | -{ | |
156 | - for (int i=0; special_keys[i].qtkey != 0; i++) | |
157 | - if (name[0] == special_keys[i].code0 && | |
158 | - name[1] == special_keys[i].code1) | |
159 | - return OK; | |
160 | - return FAIL; | |
161 | -}//}}} | |
162 | - | |
163 | -/* | |
164 | - * custom Frame for drawing ... | |
165 | - */ | |
166 | -void VimWidget::paintEvent( QPaintEvent *e)//{{{ | |
167 | -{ | |
168 | - QRect r = e->rect(); | |
169 | - gui_redraw(r.x(), r.y(), r.width(), r.height() ); | |
170 | -}//}}} | |
171 | - | |
172 | -void VimWidget::draw_string(int x, int y, QString s, int len, int flags)//{{{ | |
173 | -{ | |
174 | - gui.current_font->setBold( flags & DRAW_BOLD ); | |
175 | - gui.current_font->setUnderline( flags & DRAW_UNDERL ); | |
176 | - gui.current_font->setItalic(flags & DRAW_ITALIC); | |
177 | - painter->setBackgroundMode( flags & DRAW_TRANSP ? Qt::TransparentMode : Qt::OpaqueMode); | |
178 | - painter->setFont( *(gui.current_font) ); | |
179 | - painter->drawText( x, y, s, len); | |
180 | -}//}}} | |
181 | - | |
182 | -void VimWidget::mousePressEvent(QMouseEvent *event)//{{{ | |
183 | -{ | |
184 | - int button=0; | |
185 | - int modifiers=0; | |
186 | - ButtonState state = event->state(); | |
187 | - ButtonState buttons = event->button(); | |
188 | - | |
189 | - //Look at button states | |
190 | - if(buttons & QMouseEvent::LeftButton) { | |
191 | - button|=MOUSE_LEFT; | |
192 | - } | |
193 | - if(buttons & QMouseEvent::RightButton) { | |
194 | - button|=MOUSE_RIGHT; | |
195 | - } | |
196 | - if(buttons & QMouseEvent::MidButton) { | |
197 | - button|=MOUSE_MIDDLE; | |
198 | - } | |
199 | - //Look for keyboard modifiers | |
200 | - if(state & QMouseEvent::ShiftButton) { | |
201 | - modifiers|=MOUSE_SHIFT; | |
202 | - } | |
203 | - if(state & QMouseEvent::ControlButton){ | |
204 | - modifiers|=MOUSE_CTRL; | |
205 | - } | |
206 | - if(state & QMouseEvent::AltButton){ | |
207 | - modifiers|=MOUSE_ALT; | |
208 | - } | |
209 | - gui_send_mouse_event(button,event->x(),event->y(),FALSE,modifiers); | |
210 | -#if QT_VERSION>=300 | |
211 | - QByteArray params; | |
212 | - QDataStream stream(params, IO_WriteOnly); | |
213 | - stream << kapp->dcopClient()->appId() << button << modifiers << gui.row << gui.col; | |
214 | - kapp->dcopClient()->emitDCOPSignal("mousePEvent(QCString,int,int,int,int)", params); | |
215 | -#endif | |
216 | - event->accept(); | |
217 | -}//}}} | |
218 | - | |
219 | -#if defined(FEAT_SESSION) | |
220 | -void VimMainWindow::saveGlobalProperties (KConfig *conf) | |
221 | -{ | |
222 | - //we write a mksession file to a file written in the user's ~/.kde/share/config/ | |
223 | - //the name of the file in saved in 'conf' | |
224 | - //when restoring app, we source this file | |
225 | -#if 0 //disabled for release | |
226 | - QString filename = KGlobal::dirs()->localkdedir() + KGlobal::dirs()->kde_default("config") + kapp->randomString(10); | |
227 | - QString cmd("mksession "); | |
228 | - cmd+=filename; | |
229 | - do_cmdline_cmd((char_u*)cmd.latin1()); | |
230 | - conf->writePathEntry("sessionfile", filename); | |
231 | - conf->sync(); | |
232 | -#endif | |
233 | -} | |
234 | - | |
235 | -void VimMainWindow::readGlobalProperties (KConfig *conf) | |
236 | -{ | |
237 | -#if 0 | |
238 | - QString filename = conf->readPathEntry("sessionfile"); | |
239 | - if (filename.isNull()) return; | |
240 | - QString cmd("source "); | |
241 | - cmd+=filename; | |
242 | - do_cmdline_cmd((char_u*)cmd.latin1()); | |
243 | -#endif | |
244 | -} | |
245 | -#endif | |
246 | - | |
247 | -void VimMainWindow::wheelEvent (QWheelEvent *event)//{{{ | |
248 | -{ | |
249 | - ButtonState state = event->state(); | |
250 | - int button=0; | |
251 | - int modifiers=0; | |
252 | - | |
253 | - if (event->delta()>0) | |
254 | - button|=MOUSE_4; | |
255 | - else button|=MOUSE_5; | |
256 | - | |
257 | - if(state & ShiftButton) | |
258 | - modifiers|=MOUSE_SHIFT; | |
259 | - if(state & ControlButton) | |
260 | - modifiers|=MOUSE_CTRL; | |
261 | - if(state & AltButton) | |
262 | - modifiers|=MOUSE_ALT; | |
263 | - | |
264 | - gui_send_mouse_event(button,event->x(),event->y(),FALSE,modifiers); | |
265 | -#if QT_VERSION>=300 | |
266 | - QByteArray params; | |
267 | - QDataStream stream(params, IO_WriteOnly); | |
268 | - stream << kapp->dcopClient()->appId() << button << modifiers << gui.row << gui.col; | |
269 | - kapp->dcopClient()->emitDCOPSignal("mouseWhlEvent(QCString, int, int,int,int)", params); | |
270 | -#endif | |
271 | - event->accept(); | |
272 | -}//}}} | |
273 | - | |
274 | -void VimWidget::mouseDoubleClickEvent(QMouseEvent *event)//{{{ | |
275 | -{ | |
276 | - ButtonState state = event->state(); | |
277 | - ButtonState buttons = event->button(); | |
278 | - int modifiers=0; | |
279 | - int button=0; | |
280 | - | |
281 | - //Look at button states | |
282 | - if(buttons & LeftButton) | |
283 | - button|=MOUSE_LEFT; | |
284 | - if(buttons & RightButton) | |
285 | - button|=MOUSE_RIGHT; | |
286 | - if(buttons & MidButton) | |
287 | - button|=MOUSE_MIDDLE; | |
288 | - | |
289 | - //Look for keyboard modifiers | |
290 | - if(state & ShiftButton) | |
291 | - modifiers|=MOUSE_SHIFT; | |
292 | - if(state & ControlButton) | |
293 | - modifiers|=MOUSE_CTRL; | |
294 | - if(state & AltButton) | |
295 | - modifiers|=MOUSE_ALT; | |
296 | - | |
297 | - gui_send_mouse_event(button,event->x(),event->y(),TRUE,modifiers); | |
298 | -#if QT_VERSION>=300 | |
299 | - QByteArray params; | |
300 | - QDataStream stream(params, IO_WriteOnly); | |
301 | - stream << kapp->dcopClient()->appId() << button << modifiers << gui.row << gui.col; | |
302 | - kapp->dcopClient()->emitDCOPSignal("mouseDblClickEvent(QCString, int, int,int,int)", params); | |
303 | -#endif | |
304 | - event->accept(); | |
305 | -}//}}} | |
306 | - | |
307 | -void VimWidget::mouseMoveEvent(QMouseEvent *event){//{{{ | |
308 | - ButtonState state = event->state(); | |
309 | - int modifiers=0; | |
310 | - int button=0; | |
311 | - | |
312 | - gui_mch_mousehide(FALSE); | |
313 | - | |
314 | - //Look at button states | |
315 | - //warning: we use state here, this is important ! | |
316 | - if(state & QMouseEvent::LeftButton || state & QMouseEvent::RightButton || state & QMouseEvent::MidButton) | |
317 | - button|=MOUSE_DRAG; | |
318 | - | |
319 | - //Look for keyboard modifiers | |
320 | - if(state & ShiftButton) | |
321 | - modifiers|=MOUSE_SHIFT; | |
322 | - if(state & ControlButton) | |
323 | - modifiers|=MOUSE_CTRL; | |
324 | - if(state & AltButton) | |
325 | - modifiers|=MOUSE_ALT; | |
326 | - if (button!=MOUSE_DRAG) | |
327 | - gui_mouse_moved(event->x(),event->y()); | |
328 | - else | |
329 | - gui_send_mouse_event(MOUSE_DRAG,event->x(),event->y(),FALSE,modifiers); | |
330 | -}//}}} | |
331 | - | |
332 | -void VimWidget::mouseReleaseEvent(QMouseEvent *event)//{{{ | |
333 | -{ | |
334 | - ButtonState state = event->state(); | |
335 | - int modifiers=0; | |
336 | - | |
337 | - //Look for keyboard modifiers | |
338 | - if(state & ShiftButton) | |
339 | - modifiers|=MOUSE_SHIFT; | |
340 | - if(state & ControlButton) | |
341 | - modifiers|=MOUSE_CTRL; | |
342 | - if(state & AltButton) | |
343 | - modifiers|=MOUSE_ALT; | |
344 | - | |
345 | - gui_send_mouse_event(MOUSE_RELEASE,event->x(),event->y(),FALSE,modifiers); | |
346 | - event->accept(); | |
347 | -}//}}} | |
348 | - | |
349 | -/* | |
350 | - * The main widget (everything but toolbar/menubar) | |
351 | - */ | |
352 | - VimWidget::VimWidget( QWidget *parent, const char *name, WFlags f )//{{{ | |
353 | -:QWidget(parent, name, f) | |
354 | - ,DCOPObject("KVim") | |
355 | -#ifdef FEAT_MZSCHEME | |
356 | - ,mzscheme_timer_id(-1) | |
357 | -#endif | |
358 | -{ | |
359 | - //to be able to show/hide the cursor when moving the mouse | |
360 | - setMouseTracking(true); | |
361 | - painter=new QPainter(this); | |
362 | - | |
363 | - setKeyCompression(true); | |
364 | - setFocusPolicy( QWidget::StrongFocus ); | |
365 | - setAcceptDrops(TRUE); // DND | |
366 | - blink_state = BLINK_NONE; | |
367 | - blink_on_time = 700; | |
368 | - blink_off_time = 400; | |
369 | - blink_wait_time = 250; | |
370 | - connect( &blink_timer, SIGNAL( timeout() ), SLOT( blink_cursor() )); | |
371 | - connect( &wait_timer, SIGNAL( timeout() ), SLOT ( wait_timeout() )); | |
372 | -}//}}} | |
373 | - | |
374 | -void VimWidget::execNormal(QString command)//{{{ | |
375 | -{ | |
376 | - QString cmd("execute 'normal "); | |
377 | - cmd+=command; | |
378 | - cmd+="'"; | |
379 | - QCString unistring = vmw->codec->fromUnicode(cmd); | |
380 | - do_cmdline_cmd((char_u *)(const char*)unistring); | |
381 | - gui_update_screen(); | |
382 | -}//}}} | |
383 | - | |
384 | -void VimWidget::execInsert(QString command)//{{{ | |
385 | -{ | |
386 | - QString cmd("execute 'normal i"); | |
387 | - cmd+=command; | |
388 | - cmd+="'"; | |
389 | - QCString unistring = vmw->codec->fromUnicode(cmd); | |
390 | - do_cmdline_cmd((char_u *)(const char*)unistring); | |
391 | - gui_update_screen(); | |
392 | -}//}}} | |
393 | - | |
394 | -void VimWidget::execRaw(QString command)//{{{ | |
395 | -{ | |
396 | - QString cmd("execute '"); | |
397 | - cmd+=command; | |
398 | - cmd+="'"; | |
399 | - QCString unistring = vmw->codec->fromUnicode(cmd); | |
400 | - do_cmdline_cmd((char_u *)(const char*)unistring); | |
401 | - gui_update_screen(); | |
402 | -}//}}} | |
403 | - | |
404 | -void VimWidget::execCmd(QString command)//{{{ | |
405 | -{ | |
406 | - QCString unistring = vmw->codec->fromUnicode(command); | |
407 | - do_cmdline_cmd((char_u *)(const char*)unistring); | |
408 | - gui_update_screen(); | |
409 | -}//}}} | |
410 | - | |
411 | -QString VimWidget::eval(QString expr)//{{{ | |
412 | -{ | |
413 | -#ifdef FEAT_EVAL | |
414 | - QCString unistring = vmw->codec->fromUnicode(expr); | |
415 | - QString val((const char *)eval_to_string((char_u *)(const char*)unistring,NULL)); | |
416 | - return val; | |
417 | -#else | |
418 | - return QString::null; | |
419 | -#endif | |
420 | -}//}}} | |
421 | - | |
422 | -void VimWidget::wait(long wtime)//{{{ | |
423 | -{ | |
424 | - if ( wait_timer.isActive() ) wait_timer.stop(); | |
425 | - wait_done = false; | |
426 | - wait_timer.start( wtime, true); | |
427 | -}//}}} | |
428 | - | |
429 | -void VimWidget::wait_timeout() //{{{ | |
430 | -{ | |
431 | - wait_done = true; | |
432 | -}//}}} | |
433 | - | |
434 | -void VimWidget::dragEnterEvent (QDragEnterEvent *e)//{{{ | |
435 | -{ | |
436 | -#if (defined(FEAT_WINDOWS) && defined(HAVE_DROP_FILE)) || defined(PROTO) | |
437 | - e->accept(QUriDrag::canDecode(e)); | |
438 | -#else | |
439 | - e->ignore(); | |
440 | -#endif | |
441 | -}//}}} | |
442 | - | |
443 | -void VimWidget::dropEvent (QDropEvent *e) // {{{ | |
444 | -{ | |
445 | -#if (defined(FEAT_WINDOWS) && defined(HAVE_DROP_FILE)) || defined(PROTO) | |
446 | - QStrList urls; | |
447 | - | |
448 | - char_u **fnames; | |
449 | - int redo_dirs = FALSE; | |
450 | - int i; | |
451 | - int n; | |
452 | - int nfiles; | |
453 | - int url = FALSE; | |
454 | - | |
455 | - /* Count how many items there may be and normalize delimiters. */ | |
456 | - | |
457 | - if (QUriDrag::decode(e, urls)) { | |
458 | - n = urls.count(); | |
459 | - fnames = (char_u **)lalloc((n+1) * sizeof(char_u *), TRUE); | |
460 | - nfiles = 0; | |
461 | -#if QT_VERSION>=300 | |
462 | - QPtrListIterator<char> it(urls); | |
463 | - for( ; it.current(); ++it ) { | |
464 | - KURL u(*it); | |
465 | -#else | |
466 | - for (i=0;i<urls.count();++i) { | |
467 | - KURL u(urls.at(i)); | |
468 | -#endif | |
469 | - if ( !u.isLocalFile() ) | |
470 | - url = TRUE; | |
471 | - else { | |
472 | - fnames[nfiles] = (char_u *)strdup((const char *)u.path()); | |
473 | - ++nfiles; | |
474 | - } | |
475 | - } | |
476 | - /* Real files (i.e. not http and not ftp) */ | |
477 | - if (url == FALSE) | |
478 | - { | |
479 | - if (nfiles == 1) | |
480 | - { | |
481 | - if (mch_isdir(fnames[0])) | |
482 | - { | |
483 | - /* Handle dropping a directory on Vim. */ | |
484 | - if (mch_chdir((char *)fnames[0]) == 0) | |
485 | - { | |
486 | - free(fnames[0]); | |
487 | - fnames[0] = NULL; | |
488 | - redo_dirs = TRUE; | |
489 | - } | |
490 | - } | |
491 | - } else { | |
492 | - /* Ignore any directories */ | |
493 | - for (i = 0; i < nfiles; ++i) | |
494 | - { | |
495 | - if (mch_isdir(fnames[i])) | |
496 | - { | |
497 | - vim_free(fnames[i]); | |
498 | - fnames[i] = NULL; | |
499 | - } | |
500 | - } | |
501 | - } | |
502 | - | |
503 | - if (0) | |
504 | - { | |
505 | - /* Shift held down, change to first file's directory */ | |
506 | - if (fnames[0] != NULL && vim_chdirfile(fnames[0]) == OK) | |
507 | - redo_dirs = TRUE; | |
508 | - } else { | |
509 | - char_u dirname[MAXPATHL]; | |
510 | - char_u *s; | |
511 | - if (mch_dirname(dirname, MAXPATHL) == OK) | |
512 | - for (i = 0; i < nfiles; ++i) | |
513 | - if (fnames[i] != NULL) | |
514 | - { | |
515 | - s = shorten_fname(fnames[i], dirname); | |
516 | - if (s != NULL && (s = vim_strsave(s)) != NULL) | |
517 | - { | |
518 | - vim_free(fnames[i]); | |
519 | - fnames[i] = s; | |
520 | - } | |
521 | - } | |
522 | - } | |
523 | - } | |
524 | - | |
525 | - /* Handle the drop, :edit or :split to get to the file */ | |
526 | - handle_drop(nfiles, fnames, FALSE); | |
527 | - | |
528 | - if (redo_dirs) | |
529 | - shorten_fnames(TRUE); | |
530 | - } | |
531 | - | |
532 | - /* Update the screen display */ | |
533 | - update_screen(NOT_VALID); | |
534 | -#ifdef FEAT_MENU | |
535 | - gui_update_menus(0); | |
536 | -#endif | |
537 | - setcursor(); | |
538 | - out_flush(); | |
539 | - gui_update_cursor(FALSE, FALSE); | |
540 | - gui_mch_flush(); | |
541 | -#endif | |
542 | -} // }}} | |
543 | - | |
544 | -void VimWidget::keyPressEvent( QKeyEvent *e ) // {{{ | |
545 | -{ | |
546 | - gui_keypress(e); | |
547 | -} // }}} | |
548 | - | |
549 | -void gui_keypress(QKeyEvent *e) { // {{{ | |
550 | - int key = (int)e->key(); | |
551 | - int modifiers = 0,i; | |
552 | - uchar string[256],string2[256]; | |
553 | - uchar *s,*d; | |
554 | - Qt::ButtonState state = e->state(); | |
555 | - | |
556 | - QCString unistring = vmw->codec->fromUnicode(e->text()); | |
557 | - if (unistring.length()>0) | |
558 | - strncpy((char*)string, (const char*)unistring,unistring.length()); | |
559 | - string[unistring.length()] = 0; | |
560 | - int len=unistring.length(); | |
561 | - | |
562 | - // ignore certain keys | |
563 | - if (key == Qt::Key_Shift || key == Qt::Key_Alt || key == Qt::Key_Control || key == Qt::Key_Meta | |
564 | - || key == Qt::Key_CapsLock || key == Qt::Key_NumLock || key == Qt::Key_ScrollLock ) { | |
565 | - e->ignore(); | |
566 | - return; | |
567 | - } | |
568 | - | |
569 | -#ifdef FEAT_MBYTE | |
570 | - if (input_conv.vc_type != CONV_NONE) | |
571 | - { | |
572 | - mch_memmove(string2, string, len); | |
573 | - len = convert_input(string2, len, sizeof(string2)); | |
574 | - s = string2; | |
575 | - } | |
576 | - else | |
577 | -#endif | |
578 | - s = string; | |
579 | - d = string; | |
580 | - for (i = 0; i < len; ++i) | |
581 | - { | |
582 | - *d++ = s[i]; | |
583 | - if (d[-1] == CSI && d + 2 < string + sizeof(string)) | |
584 | - { | |
585 | - /* Turn CSI into K_CSI. */ | |
586 | - *d++ = KS_EXTRA; | |
587 | - *d++ = (int)KE_CSI; | |
588 | - } | |
589 | - } | |
590 | - len = d - string; | |
591 | - | |
592 | - | |
593 | - // change shift-tab (backtab) into S_TAB | |
594 | - if ( key == Qt::Key_BackTab && state & Qt::ShiftButton) { | |
595 | - key = Qt::Key_Tab; | |
596 | - } | |
597 | - | |
598 | - // Change C-@ and C-2 in NUL ? Gtk does this | |
599 | - if ( (key == Qt::Key_2 || key == Qt::Key_At) | |
600 | - && state & Qt::ControlButton ) { | |
601 | - string[0] = NUL; | |
602 | - len = 1; | |
603 | - } | |
604 | - else if (len == 0 && (key == Qt::Key_Space || key == Qt::Key_Tab)) | |
605 | - { | |
606 | - /* When there are modifiers, these keys get zero length; we need the | |
607 | - * original key here to be able to add a modifier below. */ | |
608 | - string[0] = (key & 0xff); | |
609 | - len = 1; | |
610 | - } | |
611 | - /* Check for Alt/Meta key (Mod1Mask), but not for a BS, DEL or character | |
612 | - * that already has the 8th bit set. | |
613 | - * Don't do this for <S-M-Tab>, that should become K_S_TAB with ALT. */ | |
614 | - if (len == 1 | |
615 | - && (key != Qt::Key_BackSpace && key != Qt::Key_Delete) | |
616 | - && (string[0] & 0x80) == 0 | |
617 | - && (state & Qt::AltButton) | |
618 | - && !(key == Qt::Key_Tab && (state & Qt::ShiftButton))) | |
619 | - { | |
620 | - string[0] |= 0x80; | |
621 | -#ifdef FEAT_MBYTE | |
622 | - if (enc_utf8) // convert to utf-8 | |
623 | - { | |
624 | - string[1] = string[0] & 0xbf; | |
625 | - string[0] = ((unsigned)string[0] >> 6) + 0xc0; | |
626 | - if (string[1] == CSI) | |
627 | - { | |
628 | - string[2] = KS_EXTRA; | |
629 | - string[3] = (int)KE_CSI; | |
630 | - len = 4; | |
631 | - } | |
632 | - else | |
633 | - len = 2; | |
634 | - } | |
635 | -#endif | |
636 | - } | |
637 | - | |
638 | - /* Check for special keys, making sure BS and DEL are recognised. */ | |
639 | - if (len == 0 || key == Qt::Key_BackSpace || key == Qt::Key_Delete) | |
640 | - { | |
641 | - while (special_keys[i].qtkey != 0 && special_keys[i].qtkey != key ) i++; | |
642 | - if (special_keys[i].qtkey != 0) { | |
643 | - string[0] = CSI; | |
644 | - string[1] = special_keys[i].code0; | |
645 | - string[2] = special_keys[i].code1; | |
646 | - len = -3; | |
647 | - } | |
648 | -/* | |
649 | - for (i = 0; special_keys[i].qtkey != 0 ; i++) | |
650 | - { | |
651 | - if (special_keys[i].qtkey == key ) { | |
652 | - string[0] = CSI; | |
653 | - string[1] = special_keys[i].code0; | |
654 | - string[2] = special_keys[i].code1; | |
655 | - len = -3; | |
656 | - break; | |
657 | - } | |
658 | - }*/ | |
659 | - } | |
660 | - | |
661 | - if (len == 0) { | |
662 | - //no need to dump that, that's a QT problem, we can't do anything | |
663 | - //dbf("Unrecognised Key : %X %s", key, e->text().latin1()); | |
664 | - e->ignore(); | |
665 | - return; | |
666 | - } | |
667 | - | |
668 | - | |
669 | - /* Special keys (and a few others) may have modifiers */ | |
670 | - if (len == -3 || key == Qt::Key_Space || key == Qt::Key_Tab || | |
671 | - key == Qt::Key_Return || key == Qt::Key_Enter || | |
672 | - key == Qt::Key_Escape) { | |
673 | - | |
674 | - modifiers = 0; | |
675 | - if (state & Qt::ShiftButton) modifiers |= MOD_MASK_SHIFT; | |
676 | - if (state & Qt::ControlButton) modifiers |= MOD_MASK_CTRL; | |
677 | - if (state & Qt::AltButton) modifiers |= MOD_MASK_ALT; | |
678 | - | |
679 | - /* | |
680 | - * For some keys a shift modifier is translated into another key | |
681 | - * code. Do we need to handle the case where len != 1 and | |
682 | - * string[0] != CSI? | |
683 | - */ | |
684 | - if (len == -3) | |
685 | - key = TO_SPECIAL(string[1], string[2]); | |
686 | - else | |
687 | - key = string[0]; | |
688 | - | |
689 | - key = simplify_key(key, &modifiers); | |
690 | - if (key == CSI) key=K_CSI; | |
691 | - | |
692 | - if (IS_SPECIAL(key)) { | |
693 | - string[0] = CSI; | |
694 | - string[1] = K_SECOND(key); | |
695 | - string[2] = K_THIRD(key); | |
696 | - len = 3; | |
697 | - } else { | |
698 | - string[0] = key; | |
699 | - len = 1; | |
700 | - } | |
701 | - | |
702 | - | |
703 | - if (modifiers!=0) { | |
704 | - uchar string2[10]; | |
705 | - string2[0] = CSI; | |
706 | - string2[1] = KS_MODIFIER; | |
707 | - string2[2] = modifiers; | |
708 | - add_to_input_buf(string2, 3); | |
709 | - } | |
710 | - | |
711 | - } /* special keys */ | |
712 | - | |
713 | - if (len == 1 && ((string[0] == Ctrl_C && ctrl_c_interrupts) | |
714 | - || (string[0] == intr_char && intr_char != Ctrl_C))) | |
715 | - { | |
716 | - trash_input_buf(); | |
717 | - got_int = TRUE; | |
718 | - } | |
719 | - | |
720 | - add_to_input_buf(string, len); | |
721 | - if (p_mh) { | |
722 | - gui_mch_mousehide(TRUE); | |
723 | - } | |
724 | - //DCOP Embedding stuff | |
725 | - //if we are here then the user has type something in the window, thus we can easily imagine that : | |
726 | - // 1 - text has changed (emit textChanged()) | |
727 | - // 2 - characters were interactively inserted (emit charactersInteractivelyInserted()) | |
728 | - // 3 - cursor position has changed ( emit cursorPositionChanged() ) | |
729 | - // 4 - selection has changed ? dunno yet //XXX | |
730 | - // 5 - undo changed too ? (each character typed in makes the undo changes anyway) | |
731 | - // conclusion : this makes a lot of things to send to the vim kpart, maybe too much | |
732 | - // for now i'll just send : keyboardEvent to the kpart with the event string as parameter, | |
733 | - // with current current position | |
734 | - // i'll do the same for mouseEvents | |
735 | -#if QT_VERSION>=300 | |
736 | - QByteArray params; | |
737 | - QDataStream stream(params, IO_WriteOnly); | |
738 | - stream << kapp->dcopClient()->appId() << unistring << gui.row << gui.col; | |
739 | - kapp->dcopClient()->emitDCOPSignal("keyboardEvent(QCString, QCString,int,int)", params); | |
740 | -#endif | |
741 | - e->ignore(); | |
742 | -} // }}} | |
743 | - | |
744 | -#ifdef FEAT_CLIENTSERVER | |
745 | -void VimWidget::serverActivate(WId id) //{{{ | |
746 | -{ | |
747 | - if (serverName == NULL && serverDelayedStartName != NULL) { | |
748 | - commWindow = id; | |
749 | - (void)serverRegisterName(qt_xdisplay(), serverDelayedStartName); | |
750 | - } else { | |
751 | - serverChangeRegisteredWindow( qt_xdisplay(), id ); | |
752 | - } | |
753 | -}//}}} | |
754 | -#endif | |
755 | - | |
756 | -#ifdef FEAT_XIM | |
757 | -void VimWidget::imStartEvent(QIMEvent *e) { | |
758 | - e->accept(); | |
759 | -} | |
760 | - | |
761 | -void VimWidget::imEndEvent(QIMEvent *e) { | |
762 | - uchar string[256]; | |
763 | - | |
764 | - QCString unistring = vmw->codec->fromUnicode(e->text()); | |
765 | - if (unistring.length()>0) | |
766 | - strncpy((char*)string, (const char*)unistring,unistring.length()); | |
767 | - string[unistring.length()] = 0; | |
768 | - int len=unistring.length(); | |
769 | - | |
770 | - add_to_input_buf(string, len); | |
771 | - e->accept(); | |
772 | -} | |
773 | - | |
774 | -void VimWidget::imComposeEvent(QIMEvent *e) { | |
775 | - //i should do something here, displaying the text somewhere ... (status area ?) | |
776 | - e->accept(); | |
777 | -} | |
778 | -#endif | |
779 | - | |
780 | - | |
781 | -void VimMainWindow::lock() | |
782 | -{ | |
783 | - locked=true; | |
784 | -} | |
785 | - | |
786 | -void VimMainWindow::unlock() | |
787 | -{ | |
788 | - locked=false; | |
789 | -} | |
790 | - | |
791 | -bool VimMainWindow::isLocked() | |
792 | -{ | |
793 | - return locked; | |
794 | -} | |
795 | - | |
796 | -// ->resize VimWidget if not locked | |
797 | -// | |
798 | -void VimMainWindow::resizeEvent ( QResizeEvent *e ) //{{{ | |
799 | -{ | |
800 | - if ( vmw->isLocked() ) return; | |
801 | - //remove toolbar and menubar height | |
802 | - int height = e->size().height(); | |
803 | - int width = e->size().width(); | |
804 | - | |
805 | - if (vmw->menuBar()->isVisible() && vmw->menuBar()->isEnabled() | |
806 | -#if QT_VERSION>=300 | |
807 | - && !vmw->menuBar()->isTopLevelMenu() | |
808 | -#endif | |
809 | - ) | |
810 | - height -= vmw->menuBar()->height(); | |
811 | -#ifdef FEAT_TOOLBAR | |
812 | - if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled() && | |
813 | - (vmw->toolBar()->barPos()==KToolBar::Top || | |
814 | - vmw->toolBar()->barPos()==KToolBar::Bottom)) | |
815 | - height -= vmw->toolBar()->height(); | |
816 | - | |
817 | - if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled() && | |
818 | - (vmw->toolBar()->barPos()==KToolBar::Left || | |
819 | - vmw->toolBar()->barPos()==KToolBar::Right)) | |
820 | - width -= vmw->toolBar()->width(); | |
821 | -#endif | |
822 | - height = ( ((int)(height/gui.char_height))*gui.char_height ); | |
823 | - if (!vmw->isLocked()) gui_resize_shell(width,height); | |
824 | -}//}}} | |
825 | - | |
826 | -void VimWidget::focusInEvent( QFocusEvent * fe ) // {{{ | |
827 | -{ | |
828 | - gui_focus_change(true); | |
829 | - | |
830 | - if (blink_state == BLINK_NONE) | |
831 | - gui_mch_start_blink(); | |
832 | -} // }}} | |
833 | - | |
834 | -void VimWidget::focusOutEvent( QFocusEvent * fe )//{{{ | |
835 | -{ | |
836 | - gui_focus_change(false); | |
837 | - | |
838 | - if (blink_state != BLINK_NONE) | |
839 | - gui_mch_stop_blink(); | |
840 | -}//}}} | |
841 | - | |
842 | -void VimWidget::set_blink_time( long wait, long on, long off)//{{{ | |
843 | -{ | |
844 | - blink_wait_time = wait; | |
845 | - blink_on_time = on; | |
846 | - blink_off_time = off; | |
847 | -}//}}} | |
848 | - | |
849 | -void VimWidget::start_cursor_blinking()//{{{ | |
850 | -{ | |
851 | - if (blink_timer.isActive()) blink_timer.stop(); | |
852 | - | |
853 | - /* Only switch blinking on if none of the times is zero */ | |
854 | - if (blink_wait_time && blink_on_time && blink_off_time && gui.in_focus) { | |
855 | - blink_state = BLINK_ON; | |
856 | - gui_update_cursor(TRUE, FALSE); | |
857 | - // The first blink appears after wait_time | |
858 | - blink_timer.start( blink_wait_time, true); | |
859 | - } | |
860 | -}//}}} | |
861 | - | |
862 | -void VimWidget::blink_cursor()//{{{ | |
863 | -{ | |
864 | - if (blink_state == BLINK_ON) { | |
865 | - // set cursor off | |
866 | - gui_undraw_cursor(); | |
867 | - blink_state = BLINK_OFF; | |
868 | - blink_timer.start( blink_off_time, true); | |
869 | - } else { | |
870 | - // set cursor on | |
871 | - gui_update_cursor(TRUE, FALSE); | |
872 | - blink_state = BLINK_ON; | |
873 | - blink_timer.start( blink_on_time, true); | |
874 | - } | |
875 | -}//}}} | |
876 | - | |
877 | -void VimWidget::stop_cursor_blinking()//{{{ | |
878 | -{ | |
879 | - if (blink_timer.isActive()) blink_timer.stop(); | |
880 | - | |
881 | - if (blink_state == BLINK_OFF) | |
882 | - gui_update_cursor(TRUE, FALSE); | |
883 | - | |
884 | - blink_state = BLINK_NONE; | |
885 | -}//}}} | |
886 | - | |
887 | -#ifdef FEAT_MZSCHEME | |
888 | -void VimWidget::timerEvent( QTimerEvent * evnt)//{{{ | |
889 | -{ | |
890 | - if (evnt->timerId() == mzscheme_timer_id) | |
891 | - timer_proc(); | |
892 | -}//}}} | |
893 | - | |
894 | -void VimWidget::enable_mzscheme_threads()//{{{ | |
895 | -{ | |
896 | - mzscheme_timer_id = startTimer(p_mzq); | |
897 | -}//}}} | |
898 | - | |
899 | -void VimWidget::disable_mzscheme_threads()//{{{ | |
900 | -{ | |
901 | - killTimer(mzscheme_timer_id); | |
902 | -}//}}} | |
903 | -#endif | |
904 | - | |
905 | -void VimWidget::flash()//{{{ | |
906 | -{ | |
907 | - QPainter p(this); | |
908 | - | |
909 | - p.setRasterOp(Qt::XorROP); | |
910 | - p.fillRect(geometry(),QColor(0xFF,0xFF,0xFF)); | |
911 | - p.flush(); | |
912 | - //FIXME: Make this a little smarter. Maybe add a timer or something | |
913 | - usleep(19000); | |
914 | - p.fillRect(geometry(),QColor(0xFF,0xFF,0xFF)); | |
915 | - p.flush(); | |
916 | - p.end(); | |
917 | -}//}}} | |
918 | - | |
919 | - | |
920 | -/* | |
921 | - * The main Window | |
922 | - */ | |
923 | - VimMainWindow::VimMainWindow ( const char *name , WFlags f)//{{{ | |
924 | -:KMainWindow(0L, name,f) | |
925 | -{ | |
926 | -#ifdef FEAT_CLIENTSERVER | |
927 | - oldFilter = qt_set_x11_event_filter( kvim_x11_event_filter ); | |
928 | -#endif | |
929 | - if (echo_wid_arg== 1) { | |
930 | - fprintf(stderr, "WID: %ld\n", (long)winId()); | |
931 | - fflush(stderr); | |
932 | - } | |
933 | - | |
934 | - w = new VimWidget(this, "main vim widget"); | |
935 | - gui.w = w; | |
936 | - setFocusProxy(w); | |
937 | - w->setFocus(); | |
938 | - have_tearoff=0; | |
939 | - | |
940 | - finddlg=new KEdFind (this,0,false); | |
941 | - repldlg=new KEdReplace (this,0,false); | |
942 | - QObject::connect( finddlg, SIGNAL(search()), this, SLOT(slotSearch()) ); | |
943 | - QObject::connect( repldlg, SIGNAL(find()), this, SLOT(slotFind()) ); | |
944 | - QObject::connect( repldlg, SIGNAL(replace()), this, SLOT(slotReplace()) ); | |
945 | - QObject::connect( repldlg, SIGNAL(replaceAll()), this, SLOT(slotReplaceAll()) ); | |
946 | - | |
947 | -#ifdef FEAT_TOOLBAR | |
948 | - connect(toolBar(), SIGNAL(clicked(int)), this, SLOT(menu_activated(int))); | |
949 | -#endif | |
950 | -#ifdef FEAT_CLIENTSERVER | |
951 | - w->serverActivate(winId()); | |
952 | - | |
953 | - if (serverName!=NULL) | |
954 | - kapp->dcopClient()->registerAs(QCString((const char*)serverName),false); | |
955 | - else if (serverDelayedStartName!=NULL) | |
956 | - kapp->dcopClient()->registerAs(QCString((const char*)serverDelayedStartName),false); | |
957 | - else if (argServerName!=NULL) | |
958 | - kapp->dcopClient()->registerAs(argServerName->utf8(),false); | |
959 | -#else | |
960 | - if (argServerName!=NULL) | |
961 | - kapp->dcopClient()->registerAs(argServerName->utf8(),false); | |
962 | -#endif | |
963 | - QXEmbed::initialize(); | |
964 | - | |
965 | -}//{{{ | |
966 | - | |
967 | -bool VimMainWindow::queryClose()//{{{ | |
968 | -{ | |
969 | - gui_shell_closed(); | |
970 | - return true; | |
971 | -}//}}} | |
972 | - | |
973 | -bool VimMainWindow::queryExit()//{{{ | |
974 | -{ | |
975 | - return true; | |
976 | -}//}}} | |
977 | - | |
978 | -void VimMainWindow::menu_activated(int dx)//{{{ | |
979 | -{ | |
980 | -#ifdef FEAT_MENU | |
981 | - if (!dx) { // tearoff | |
982 | - return; | |
983 | - } | |
984 | - gui_mch_set_foreground(); | |
985 | - gui_menu_cb((VimMenu *) dx); | |
986 | -#endif | |
987 | -}//}}} | |
988 | - | |
989 | - | |
990 | -void VimMainWindow::clipboard_selection_update(){//{{{ | |
991 | - if(kapp->clipboard()->ownsSelection()) { | |
992 | - clip_own_selection(&clip_star); | |
993 | - } else { | |
994 | - clip_lose_selection(&clip_star); | |
995 | - } | |
996 | -}//}}} | |
997 | - | |
998 | -void VimMainWindow::clipboard_data_update(){//{{{ | |
999 | -#if QT_VERSION>=300 | |
1000 | - if (kapp->clipboard()->ownsClipboard()) { | |
1001 | - clip_own_selection(&clip_plus); | |
1002 | - } else { | |
1003 | - clip_lose_selection(&clip_plus); | |
1004 | - } | |
1005 | -#else | |
1006 | - if (kapp->clipboard()->ownsSelection()) { | |
1007 | - clip_own_selection(&clip_star); | |
1008 | - } else { | |
1009 | - clip_lose_selection(&clip_star); | |
1010 | - } | |
1011 | -#endif | |
1012 | -}//}}} | |
1013 | - | |
1014 | -void VimMainWindow::slotSearch()//{{{ | |
1015 | -{ | |
1016 | - QString find_text; | |
1017 | - bool direction_down = TRUE; | |
1018 | - bool casesensitive = TRUE; | |
1019 | - int flags = FRD_FINDNEXT; | |
1020 | - | |
1021 | - find_text = finddlg->getText(); | |
1022 | - direction_down = !(finddlg->get_direction()); | |
1023 | - casesensitive = finddlg->case_sensitive(); | |
1024 | - // if (casesensitive) find_text = "\\C" + find_text; | |
1025 | - // else find_text = "\\c" + find_text; | |
1026 | - if (casesensitive) flags|=FRD_MATCH_CASE; | |
1027 | - QCString unistring = vmw->codec->fromUnicode(find_text); | |
1028 | - gui_do_findrepl(flags, (char_u *)(const char *)unistring, NULL,(int)direction_down); | |
1029 | -}//}}} | |
1030 | - | |
1031 | -void VimMainWindow::slotFind()//{{{ | |
1032 | -{ | |
1033 | - QString find_text; | |
1034 | - bool direction_down=TRUE; | |
1035 | - bool casesensitive = TRUE; | |
1036 | - int flags = FRD_R_FINDNEXT; | |
1037 | - | |
1038 | - find_text=repldlg->getText(); | |
1039 | - direction_down = !(repldlg->get_direction()); | |
1040 | - casesensitive = repldlg->case_sensitive(); | |
1041 | - // if (casesensitive) find_text = "\\C" + find_text; | |
1042 | - // else find_text = "\\c" + find_text; | |
1043 | - if (casesensitive) flags|=FRD_MATCH_CASE; | |
1044 | - | |
1045 | - QCString unistring = vmw->codec->fromUnicode(find_text); | |
1046 | - gui_do_findrepl(flags, (char_u *)(const char *)unistring, NULL,(int)direction_down); | |
1047 | -}//}}} | |
1048 | - | |
1049 | -void VimMainWindow::slotReplace()//{{{ | |
1050 | -{ | |
1051 | - QString find_text; | |
1052 | - QString repl_text; | |
1053 | - bool direction_down=TRUE; | |
1054 | - bool casesensitive = TRUE; | |
1055 | - int flags = FRD_REPLACE; | |
1056 | - | |
1057 | - find_text=repldlg->getText(); | |
1058 | - repl_text=repldlg->getReplaceText(); | |
1059 | - direction_down = !(repldlg->get_direction()); | |
1060 | - //if (casesensitive) find_text = "\\C" + find_text; | |
1061 | - //else find_text = "\\c" + find_text; | |
1062 | - if (casesensitive) flags|=FRD_MATCH_CASE; | |
1063 | - | |
1064 | - QCString unistring = vmw->codec->fromUnicode(find_text); | |
1065 | - QCString unistring2 = vmw->codec->fromUnicode(repl_text); | |
1066 | - gui_do_findrepl(flags, (char_u *)(const char *)unistring,(char_u *)(const char*)unistring2,(int)direction_down); | |
1067 | -}//}}} | |
1068 | - | |
1069 | -void VimMainWindow::slotReplaceAll()//{{{ | |
1070 | -{ | |
1071 | - QString find_text; | |
1072 | - QString repl_text; | |
1073 | - bool direction_down=TRUE; | |
1074 | - bool casesensitive = TRUE; | |
1075 | - int flags = FRD_REPLACEALL; | |
1076 | - | |
1077 | - find_text=repldlg->getText(); | |
1078 | - repl_text=repldlg->getReplaceText(); | |
1079 | - direction_down = !(repldlg->get_direction()); | |
1080 | - casesensitive = repldlg->case_sensitive(); | |
1081 | - // if (casesensitive) find_text = "\\C" + find_text; | |
1082 | - // else find_text = "\\c" + find_text; | |
1083 | - if (casesensitive) flags|=FRD_MATCH_CASE; | |
1084 | - QCString unistring = vmw->codec->fromUnicode(find_text); | |
1085 | - QCString unistring2 = vmw->codec->fromUnicode(repl_text); | |
1086 | - gui_do_findrepl(flags, (char_u *)(const char *)unistring,(char_u *)(const char*)unistring2,(int)direction_down); | |
1087 | -}//}}} | |
1088 | - | |
1089 | -void VimMainWindow::showAboutKDE() | |
1090 | -{ | |
1091 | - KAboutKDE *kde = new KAboutKDE(this); | |
1092 | - kde->show(); | |
1093 | -} | |
1094 | - | |
1095 | -void VimMainWindow::showAboutApplication()//{{{ | |
1096 | -{ | |
1097 | - KAboutData *aboutData = new KAboutData ( | |
1098 | - "kvim" | |
1099 | - , I18N_NOOP("KVim") | |
1100 | - , VIM_VERSION_SHORT | |
1101 | - , I18N_NOOP("Vim in a KDE interface") | |
1102 | - , 0 | |
1103 | - , "(c) Vim Team, \":help credits\" for more infos.\nType \":help iccf\" to see how you can help the children in Uganda" | |
1104 | - , 0l | |
1105 | - , "http://freehackers.org/kvim" | |
1106 | - , "kvim-dev@freenux.org" | |
1107 | - ); | |
1108 | - | |
1109 | - aboutData->addAuthor("Bram Moolenaar", | |
1110 | - I18N_NOOP("Main vim author"), | |
1111 | - "Bram@vim.org", | |
1112 | - "http://www.vim.org/"); | |
1113 | - aboutData->addAuthor("Thomas Capricelli", | |
1114 | - I18N_NOOP("KDE porting"), | |
1115 | - "orzel@freehackers.org", | |
1116 | - "http://orzel.freehackers.org"); | |
1117 | - aboutData->addAuthor("Philippe Fremy", | |
1118 | - I18N_NOOP("KDE porting"), | |
1119 | - "pfremy@chez.com", | |
1120 | - "http://www.freehackers.org/kvim"); | |
1121 | - aboutData->addAuthor("Mark Westcott", | |
1122 | - I18N_NOOP("Qtopia porting, maintainer of the Qtopia part"), | |
1123 | - "mark@houseoffish.org", | |
1124 | - "http://houseoffish.org"); | |
1125 | - aboutData->addAuthor("Mickael Marchand", | |
1126 | - I18N_NOOP("KDE porting, maintainer"), | |
1127 | - "marchand@kde.org", | |
1128 | - "http://freenux.org"); | |
1129 | - aboutData->addAuthor("Many other people", | |
1130 | - I18N_NOOP("type :help credits for more infos") | |
1131 | - ); | |
1132 | - aboutData->addCredit("Vince Negri", | |
1133 | - I18N_NOOP("Antialiasing support, Color fixes"), | |
1134 | - "vnegri@asl-electronics.co.uk"); | |
1135 | - aboutData->addCredit("Malte Starostik", | |
1136 | - I18N_NOOP("Patch for performance improvement"), | |
1137 | - "malte@kde.org"); | |
1138 | - aboutData->addCredit("Mark Stosberg", | |
1139 | - I18N_NOOP("Provided a FreeBSD box to debug KVim on BSD"), | |
1140 | - "mark@summersault.com" | |
1141 | - ); | |
1142 | - aboutData->addCredit("Henrik Skott", | |
1143 | - I18N_NOOP("Font patch when KDE not configured"), | |
1144 | - "henrik.skott@hem.utfors.se" | |
1145 | - ); | |
1146 | - aboutData->addCredit("Kailash Sethuraman", | |
1147 | - I18N_NOOP("NetBSD configure/compilation fixes") | |
1148 | - ); | |
1149 | - aboutData->setLicenseText( | |
1150 | -"KVim as an extension of Vim follows Vim license : \n\ | |
1151 | -Vim is Charityware. You can use and copy it as much as you like, but you are\n\ | |
1152 | -encouraged to make a donation to orphans in Uganda. Please read the file\n\ | |
1153 | -runtime/doc/uganda.txt for details.\n\ | |
1154 | -\n\ | |
1155 | -There are no restrictions on distributing an unmodified copy of Vim. Parts of\n\ | |
1156 | -Vim may also be distributed, but this text must always be included. You are\n\ | |
1157 | -allowed to include executables that you made from the unmodified Vim sources,\n\ | |
1158 | -your own usage examples and Vim scripts.\n\ | |
1159 | -\n\ | |
1160 | -If you distribute a modified version of Vim, you are encouraged to send the\n\ | |
1161 | -maintainer a copy, including the source code. Or make it available to the\n\ | |
1162 | -maintainer through ftp; let him know where it can be found. If the number of\n\ | |
1163 | -changes is small (e.g., a modified Makefile) e-mailing the diffs will do.\n\ | |
1164 | -When the maintainer asks for it (in any way) you must make your changes,\n\ | |
1165 | -including source code, available to him.\n\ | |
1166 | -\n\ | |
1167 | -The maintainer reserves the right to include any changes in the official\n\ | |
1168 | -version of Vim. This is negotiable. You are not allowed to distribute a\n\ | |
1169 | -modified version of Vim when you are not willing to make the source code\n\ | |
1170 | -available to the maintainer.\n\ | |
1171 | -\n\ | |
1172 | -The current maintainer is Bram Moolenaar <Bram@vim.org>. If this changes, it\n\ | |
1173 | -will be announced in appropriate places (most likely www.vim.org and\n\ | |
1174 | -comp.editors). When it is completely impossible to contact the maintainer,\n\ | |
1175 | -the obligation to send him modified source code ceases.\n\ | |
1176 | -\n\ | |
1177 | -It is not allowed to remove these restrictions from the distribution of the\n\ | |
1178 | -Vim sources or parts of it. These restrictions may also be used for previous\n\ | |
1179 | -Vim releases instead of the text that was included with it."); | |
1180 | - | |
1181 | - KAboutApplication *about = new KAboutApplication(aboutData); | |
1182 | - about->show(); | |
1183 | -}//}}} | |
1184 | - | |
1185 | -void VimMainWindow::showTipOfTheDay() { | |
1186 | -#if QT_VERSION>=300 | |
1187 | - KTipDialog::showTip (vmw,QString::null,true); | |
1188 | -#endif | |
1189 | -} | |
1190 | - | |
1191 | -void VimMainWindow::buffersToolbar() { | |
1192 | - | |
1193 | -} | |
1194 | - | |
1195 | -void VimMainWindow::showBugReport() { | |
1196 | - KBugReport *bug= new KBugReport(this,true); | |
1197 | - bug->show(); | |
1198 | -} | |
1199 | -/* | |
1200 | - * Vim Dialog | |
1201 | - * | |
1202 | - * Returns: | |
1203 | - * 0: Cancel | |
1204 | - * 1- : nb of the pressed button | |
1205 | - */ | |
1206 | - | |
1207 | -VimDialog::VimDialog (int type, /* type of dialog *///{{{ | |
1208 | - char_u * title, /* title of dialog */ | |
1209 | - char_u * message, /* message text */ | |
1210 | - char_u * buttons, /* names of buttons */ | |
1211 | - int def_but, /* default button */ | |
1212 | - char_u *textfield ) /* input field */ | |
1213 | -:QDialog(vmw, "vim generic dialog", true), // true is for "modal" | |
1214 | - mapper(this, "dialog signal mapper") | |
1215 | -{ | |
1216 | - /* | |
1217 | - * Create Icon | |
1218 | - */ | |
1219 | - char ** icon_data; | |
1220 | - switch (type) { | |
1221 | - case VIM_GENERIC: | |
1222 | - icon_data = generic_xpm; | |
1223 | - break; | |
1224 | - case VIM_ERROR: | |
1225 | - icon_data = error_xpm; | |
1226 | - break; | |
1227 | - case VIM_WARNING: | |
1228 | - icon_data = alert_xpm; | |
1229 | - break; | |
1230 | - case VIM_INFO: | |
1231 | - icon_data = info_xpm; | |
1232 | - break; | |
1233 | - case VIM_QUESTION: | |
1234 | - icon_data = quest_xpm; | |
1235 | - break; | |
1236 | - default: | |
1237 | - icon_data = generic_xpm; | |
1238 | - }; | |
1239 | - QLabel * icon = new QLabel( this ); | |
1240 | - icon->setPixmap( QPixmap( (const char **) icon_data ) ); | |
1241 | - icon->setFixedSize( icon->sizeHint() ); | |
1242 | - | |
1243 | - QLabel * text = new QLabel( (const char *)message, this ); | |
1244 | - text->setAlignment( AlignHCenter | AlignVCenter | ExpandTabs ); | |
1245 | - | |
1246 | - QStringList buttonText = QStringList::split( DLG_BUTTON_SEP, (char *) buttons); | |
1247 | - int butNb = buttonText.count(); | |
1248 | - | |
1249 | - /* | |
1250 | - * Layout | |
1251 | - */ | |
1252 | - | |
1253 | - QVBoxLayout * vly = new QVBoxLayout( this, 5, 5 ); | |
1254 | - QHBoxLayout * hly1 = new QHBoxLayout( vly, 5); | |
1255 | - hly1->addWidget( icon ); | |
1256 | - hly1->addWidget( text ); | |
1257 | - QHBoxLayout * hly3 = new QHBoxLayout ( vly , 5); | |
1258 | - if (textfield!=NULL) { | |
1259 | - entry = new QLineEdit((const char *)textfield,this); | |
1260 | - entry->setText((const char *)textfield); | |
1261 | - hly3->addWidget( entry ); | |
1262 | - ret=textfield; | |
1263 | - } else entry=NULL; | |
1264 | - | |
1265 | - QHBoxLayout * hly2 = new QHBoxLayout( vly, 15); | |
1266 | - QString s; | |
1267 | - QPushButton * pushButton = 0L; | |
1268 | - for( int i=0; i<butNb; i++) { | |
1269 | - s = buttonText[i]; | |
1270 | - pushButton = new QPushButton(s, this ); | |
1271 | - if (s.find('&') != -1) { | |
1272 | - pushButton->setAccel( s.at(s.find('&')+1).latin1() ); | |
1273 | - } | |
1274 | - | |
1275 | - hly2->addWidget( pushButton ); | |
1276 | - if (i == def_but-1) { | |
1277 | - pushButton->setDefault( true ); | |
1278 | - pushButton->setAutoDefault( true ); | |
1279 | - setResult( i+1 ); | |
1280 | - } | |
1281 | - connect(pushButton, SIGNAL(clicked()), &mapper, SLOT(map())); | |
1282 | - mapper.setMapping(pushButton, i+1); | |
1283 | - } | |
1284 | - connect( &mapper, SIGNAL(mapped(int)), this, SLOT(done(int))); | |
1285 | - | |
1286 | - setCaption((const char *) title); | |
1287 | - | |
1288 | - vly->activate(); | |
1289 | -}//}}} | |
1290 | - | |
1291 | -void VimDialog::done(int r) { | |
1292 | - if (entry!=NULL) { | |
1293 | - if (r) { | |
1294 | - QCString unistring=vmw->codec->fromUnicode(entry->text()); | |
1295 | - STRCPY(ret,(const char*)unistring); | |
1296 | - } else | |
1297 | - *ret=NUL; | |
1298 | - } | |
1299 | - QDialog::done(r); | |
1300 | -} | |
1301 | - | |
1302 | -/* | |
1303 | - * ScrollBar pool handling | |
1304 | - */ | |
1305 | -SBPool::SBPool(void)//{{{ | |
1306 | - :mapper(this, "SBPool signal mapper") | |
1307 | -{ | |
1308 | - connect(&mapper, SIGNAL(mapped(int)), this, SLOT(sbUsed(int))); | |
1309 | -}//}}} | |
1310 | - | |
1311 | - | |
1312 | -void SBPool::create(GuiScrollbar * sb, int orient)//{{{ | |
1313 | -{ | |
1314 | - switch(orient) { | |
1315 | - case SBAR_HORIZ: | |
1316 | - sb->w = new QScrollBar(QScrollBar::Horizontal, vmw); | |
1317 | - break; | |
1318 | - case SBAR_VERT: | |
1319 | - sb->w = new QScrollBar(QScrollBar::Vertical, vmw); | |
1320 | - break; | |
1321 | - default: | |
1322 | - sb->w = 0; | |
1323 | - return; | |
1324 | - } | |
1325 | - | |
1326 | - connect(sb->w, SIGNAL(valueChanged(int)), &mapper, SLOT(map())); | |
1327 | - mapper.setMapping(sb->w, (int)sb); | |
1328 | -}//}}} | |
1329 | - | |
1330 | - | |
1331 | -void SBPool::sbUsed(int who)//{{{ | |
1332 | -{ | |
1333 | - GuiScrollbar *sb = (GuiScrollbar*)who; | |
1334 | - gui_drag_scrollbar( sb, sb->w->value(), FALSE); | |
1335 | -}//}}} | |
1336 | - | |
1337 | - | |
1338 | -void SBPool::destroy(GuiScrollbar * sb)//{{{ | |
1339 | -{ | |
1340 | - if (!sb->w) return; | |
1341 | - | |
1342 | - delete sb->w; | |
1343 | - sb->w = 0; | |
1344 | -}//}}} | |
1345 | - | |
1346 | -#ifdef FEAT_CLIENTSERVER | |
1347 | -static int kvim_x11_event_filter( XEvent* e)//{{{ | |
1348 | -{ | |
1349 | - if (e->xproperty.type == PropertyNotify | |
1350 | - && e->xproperty.atom == commProperty | |
1351 | - && e->xproperty.window == commWindow | |
1352 | - && e->xproperty.state == PropertyNewValue ) { | |
1353 | - serverEventProc(qt_xdisplay(), e); | |
1354 | - } | |
1355 | - | |
1356 | - if (oldFilter) return oldFilter( e ); | |
1357 | - return FALSE; | |
1358 | -}//}}} | |
1359 | -#endif | |
1360 | - | |
1361 | -//add some QT 3 fonts usefull functions | |
1362 | -#if QT_VERSION<300 | |
1363 | -QString KVimUtils::toString(QFont *f) | |
1364 | -{ | |
1365 | - QStringList l; | |
1366 | - l.append(f->family()); | |
1367 | - l.append(QString::number(f->pointSize())); | |
1368 | - l.append(QString::number(f->pixelSize())); | |
1369 | - l.append(QString::number((int)f->styleHint())); | |
1370 | - l.append(QString::number(f->weight())); | |
1371 | - l.append(QString::number((int)f->italic())); | |
1372 | - l.append(QString::number((int)f->underline())); | |
1373 | - l.append(QString::number((int)f->strikeOut())); | |
1374 | - l.append(QString::number((int)f->fixedPitch())); | |
1375 | - l.append(QString::number((int)f->rawMode())); | |
1376 | - return l.join(","); | |
1377 | -} | |
1378 | - | |
1379 | -bool KVimUtils::fromString(QFont *f, QString descrip) | |
1380 | -{ | |
1381 | - QStringList l(QStringList::split(',', descrip)); | |
1382 | - | |
1383 | - int count = l.count(); | |
1384 | - if (count != 10 && count != 9) { | |
1385 | - return FALSE; | |
1386 | - } | |
1387 | - | |
1388 | - f->setFamily(l[0]); | |
1389 | - f->setPointSize(l[1].toInt()); | |
1390 | - if ( count == 9 ) { | |
1391 | - f->setStyleHint((QFont::StyleHint) l[2].toInt()); | |
1392 | - f->setWeight(l[3].toInt()); | |
1393 | - f->setItalic(l[4].toInt()); | |
1394 | - f->setUnderline(l[5].toInt()); | |
1395 | - f->setStrikeOut(l[6].toInt()); | |
1396 | - f->setFixedPitch(l[7].toInt()); | |
1397 | - f->setRawMode(l[8].toInt()); | |
1398 | - } else { | |
1399 | - f->setPixelSize(l[2].toInt()); | |
1400 | - f->setStyleHint((QFont::StyleHint) l[3].toInt()); | |
1401 | - f->setWeight(l[4].toInt()); | |
1402 | - f->setItalic(l[5].toInt()); | |
1403 | - f->setUnderline(l[6].toInt()); | |
1404 | - f->setStrikeOut(l[7].toInt()); | |
1405 | - f->setFixedPitch(l[8].toInt()); | |
1406 | - f->setRawMode(l[9].toInt()); | |
1407 | - } | |
1408 | - return TRUE; | |
1409 | -} | |
1410 | -#endif | |
1411 | - | |
1412 | -QString KVimUtils::convertEncodingName(QString name) | |
1413 | -{ | |
1414 | - if (name.startsWith("ucs") || name.startsWith("utf-16")) return QString("utf16"); | |
1415 | - if (name=="cp950") return QString("Big5"); | |
1416 | - return QString(); | |
1417 | -} |
@@ -1,245 +0,0 @@ | ||
1 | -/* vi:set ts=8 sts=0 sw=8: | |
2 | - * | |
3 | - * VIM - Vi IMproved by Bram Moolenaar | |
4 | - * | |
5 | - * Do ":help uganda" in Vim to read copying and usage conditions. | |
6 | - * Do ":help credits" in Vim to see a list of people who contributed. | |
7 | - */ | |
8 | - | |
9 | -/* | |
10 | - * Porting to KDE(2) was done by | |
11 | - * | |
12 | - * (C) 2000 by Thomas Capricelli <orzel@freehackers.org> | |
13 | - * | |
14 | - * Please visit http://freehackers.org/kvim for other vim- or | |
15 | - * kde-related coding. | |
16 | - * | |
17 | - * $Id$ | |
18 | - * | |
19 | - */ | |
20 | - | |
21 | -#ifndef GUI_KDE_WIDGET | |
22 | -#define GUI_KDE_WIDGET | |
23 | - | |
24 | -#if 1 | |
25 | -#define dbf( format, args... ) { printf( "%s" " : " format "\n" , __FUNCTION__ , ## args ); fflush(stdout); } | |
26 | -#define db() { printf( "%s\n", __FUNCTION__ );fflush(stdout); } | |
27 | -#else | |
28 | -#define dbf(format, args... ) | |
29 | -#define db() | |
30 | -#endif | |
31 | - | |
32 | -#define UNIX // prevent a warning : a symbol is defined twice in X and Qt | |
33 | - | |
34 | -#include <qdialog.h> | |
35 | -#include <qlabel.h> | |
36 | -#include <qsignalmapper.h> | |
37 | -#include <qtimer.h> | |
38 | -#include <qmainwindow.h> | |
39 | -#include <qapplication.h> | |
40 | -#include <qevent.h> | |
41 | -#include <qlineedit.h> | |
42 | -#include <qpainter.h> | |
43 | -#include <qwidget.h> | |
44 | -#include <qpopupmenu.h> | |
45 | -#include <klocale.h> | |
46 | -#include <kapp.h> | |
47 | -#include <kcmdlineargs.h> | |
48 | -#include <kaboutdata.h> | |
49 | -#include <keditcl.h> | |
50 | -#include <kaboutdata.h> | |
51 | -#if (KDE_VERSION>=290) | |
52 | -#include <kmainwindow.h> | |
53 | -#else | |
54 | -#include <ktmainwindow.h> | |
55 | -#endif | |
56 | -#include <kparts/part.h> | |
57 | -#include <kurl.h> | |
58 | -#include "kvim_iface.h" | |
59 | - | |
60 | -#undef UNIX // prevent a warning | |
61 | -extern "C" { | |
62 | -#include "vim.h" | |
63 | -} | |
64 | - | |
65 | -class QPushButton; | |
66 | -class QDialog; | |
67 | -class QLineEdit; | |
68 | -class QSignalMapper; | |
69 | -class QPaintEvent; | |
70 | - | |
71 | -enum BlinkState { | |
72 | - BLINK_NONE, | |
73 | - BLINK_ON, | |
74 | - BLINK_OFF | |
75 | -}; | |
76 | - | |
77 | -class VimWidget : public QWidget, virtual public KVim | |
78 | -{ | |
79 | - Q_OBJECT | |
80 | - | |
81 | -public: | |
82 | - VimWidget( QWidget *parent=0, const char *name=0, WFlags f=0 ); | |
83 | - virtual void paintEvent( QPaintEvent *); | |
84 | - void draw_string(int x, int y, QString s, int len, int flags); | |
85 | - | |
86 | - /** Init the blinking time */ | |
87 | - void set_blink_time( long, long, long ); | |
88 | - void start_cursor_blinking(); | |
89 | - void stop_cursor_blinking(); | |
90 | - void wait(long); | |
91 | -#ifdef FEAT_CLIENTSERVER | |
92 | - void serverActivate(WId id); | |
93 | -#endif | |
94 | -#ifdef FEAT_MZSCHEME | |
95 | - void enable_mzscheme_threads(); | |
96 | - void disable_mzscheme_threads(); | |
97 | -#endif | |
98 | - void flash(); | |
99 | - | |
100 | - /** DCOP */ | |
101 | - void execNormal(QString command); | |
102 | - void execInsert(QString command); | |
103 | - void execRaw(QString command); | |
104 | - void execCmd(QString command); | |
105 | - QString eval(QString expr); | |
106 | - | |
107 | - bool wait_done; | |
108 | - BlinkState blink_state; | |
109 | - QPainter *painter; | |
110 | - QPopupMenu *menu; | |
111 | - | |
112 | -protected: | |
113 | - virtual void keyPressEvent( QKeyEvent * ); | |
114 | - virtual void mousePressEvent( QMouseEvent *); | |
115 | - virtual void mouseDoubleClickEvent( QMouseEvent *); | |
116 | - virtual void mouseReleaseEvent( QMouseEvent *); | |
117 | - virtual void mouseMoveEvent( QMouseEvent *); | |
118 | - virtual void focusInEvent( QFocusEvent * ); | |
119 | - virtual void focusOutEvent( QFocusEvent * ); | |
120 | - virtual void dragEnterEvent (QDragEnterEvent *); | |
121 | - virtual void dropEvent (QDropEvent *); | |
122 | -#ifdef FEAT_XIM | |
123 | - virtual void imStartEvent ( QIMEvent * ); | |
124 | - virtual void imEndEvent ( QIMEvent * ); | |
125 | - virtual void imComposeEvent ( QIMEvent * ); | |
126 | -#endif | |
127 | -#ifdef FEAT_MZSCHEME | |
128 | - virtual void timerEvent( QTimerEvent * ); | |
129 | -#endif | |
130 | - | |
131 | - /* cursor blinking stuff */ | |
132 | - QTimer blink_timer; | |
133 | - long blink_wait_time, blink_on_time, blink_off_time; | |
134 | - | |
135 | - /* wait for input */ | |
136 | - QTimer wait_timer; | |
137 | - | |
138 | -#ifdef FEAT_MZSCHEME | |
139 | - int mzscheme_timer_id; | |
140 | -#endif | |
141 | - | |
142 | -public slots: | |
143 | - void blink_cursor(); | |
144 | - void wait_timeout(); | |
145 | -}; | |
146 | - | |
147 | -class VimMainWindow : public KMainWindow | |
148 | -{ | |
149 | - Q_OBJECT | |
150 | - | |
151 | -public: | |
152 | - VimMainWindow ( const char *name = 0L, WFlags f = WDestructiveClose ); | |
153 | - | |
154 | - /** called when the widget closes */ | |
155 | -// bool close(bool alsoDelete); | |
156 | - VimWidget *w; | |
157 | - KEdFind *finddlg; | |
158 | - KEdReplace *repldlg; | |
159 | - int have_tearoff; | |
160 | - QTextCodec *codec; | |
161 | - | |
162 | -public slots: | |
163 | - void menu_activated(int dx); | |
164 | - void clipboard_selection_update(); | |
165 | - void clipboard_data_update(); | |
166 | - void slotSearch(); | |
167 | - void slotFind(); | |
168 | - void slotReplace(); | |
169 | - void slotReplaceAll(); | |
170 | - void showAboutApplication(); | |
171 | - void showAboutKDE(); | |
172 | - void showBugReport(); | |
173 | - void showTipOfTheDay(); | |
174 | - void buffersToolbar(); | |
175 | - bool isLocked(); | |
176 | - void lock(); | |
177 | - void unlock(); | |
178 | - | |
179 | -protected: | |
180 | - virtual void wheelEvent (QWheelEvent *); | |
181 | - virtual void resizeEvent ( QResizeEvent *e ); | |
182 | - | |
183 | -#if defined(FEAT_SESSION) | |
184 | - void saveGlobalProperties (KConfig *conf); | |
185 | - void readGlobalProperties (KConfig *conf); | |
186 | -#endif | |
187 | - bool queryClose(); | |
188 | - bool queryExit(); | |
189 | - bool locked; | |
190 | -}; | |
191 | - | |
192 | - | |
193 | -class VimDialog : public QDialog | |
194 | -{ | |
195 | - Q_OBJECT | |
196 | -public: | |
197 | - VimDialog (int type, /* type of dialog */ | |
198 | - unsigned char * title, /* title of dialog */ | |
199 | - unsigned char * message, /* message text */ | |
200 | - unsigned char * buttons, /* names of buttons */ | |
201 | - int def_but, /* default button */ | |
202 | - char_u *textfield); /* input text */ | |
203 | -private: | |
204 | - QSignalMapper mapper; | |
205 | - QLineEdit *entry; | |
206 | - char_u *ret; | |
207 | - int butNb; | |
208 | - | |
209 | -protected slots: | |
210 | - void done(int); | |
211 | -}; | |
212 | - | |
213 | - | |
214 | -/* | |
215 | - * QScrollBar pool | |
216 | - */ | |
217 | -struct GuiScrollbar; | |
218 | - | |
219 | -class SBPool : public QObject | |
220 | -{ | |
221 | - Q_OBJECT | |
222 | -public: | |
223 | - SBPool(void); | |
224 | - void create(GuiScrollbar * sb, int orient); | |
225 | - void destroy(GuiScrollbar * sb); | |
226 | -public slots: | |
227 | - void sbUsed(int who); | |
228 | -private: | |
229 | - QSignalMapper mapper; | |
230 | -}; | |
231 | - | |
232 | -class KVimUtils { | |
233 | -public: | |
234 | - static QString convertEncodingName(QString); | |
235 | -#if QT_VERSION<300 | |
236 | - static bool fromString(QFont*,QString); | |
237 | - static QString toString(QFont*); | |
238 | -#endif | |
239 | -}; | |
240 | - | |
241 | -extern VimMainWindow *vmw; | |
242 | -extern SBPool *sbpool; | |
243 | -extern QString *argServerName; | |
244 | - | |
245 | -#endif // GUI_KDE_WIDGET |
@@ -45,7 +45,7 @@ | ||
45 | 45 | #include <qfont.h> |
46 | 46 | |
47 | 47 | |
48 | -#include "gui_kde_widget.h" | |
48 | +#include "gui_kde_wid.h" | |
49 | 49 | |
50 | 50 | |
51 | 51 | extern "C" { |
@@ -2731,6 +2731,7 @@ | ||
2731 | 2731 | char *save; |
2732 | 2732 | int len; |
2733 | 2733 | int i; |
2734 | + char *p; | |
2734 | 2735 | |
2735 | 2736 | if (obj == NULL || !PyString_Check(obj)) |
2736 | 2737 | { |
@@ -2741,14 +2742,22 @@ | ||
2741 | 2742 | str = PyString_AsString(obj); |
2742 | 2743 | len = PyString_Size(obj); |
2743 | 2744 | |
2744 | - /* Error checking: String must not contain newlines, as we | |
2745 | + /* | |
2746 | + * Error checking: String must not contain newlines, as we | |
2745 | 2747 | * are replacing a single line, and we must replace it with |
2746 | 2748 | * a single line. |
2749 | + * A trailing newline is removed, so that append(f.readlines()) works. | |
2747 | 2750 | */ |
2748 | - if (memchr(str, '\n', len)) | |
2751 | + p = memchr(str, '\n', len); | |
2752 | + if (p != NULL) | |
2749 | 2753 | { |
2750 | - PyErr_SetVim(_("string cannot contain newlines")); | |
2751 | - return NULL; | |
2754 | + if (p == str + len - 1) | |
2755 | + --len; | |
2756 | + else | |
2757 | + { | |
2758 | + PyErr_SetVim(_("string cannot contain newlines")); | |
2759 | + return NULL; | |
2760 | + } | |
2752 | 2761 | } |
2753 | 2762 | |
2754 | 2763 | /* Create a copy of the string, with internal nulls replaced by |
@@ -100,9 +100,9 @@ | ||
100 | 100 | GUI_TESTTARGET = gui |
101 | 101 | KDE |
102 | 102 | GUI_SRC = gui.c pty.c gui_kde.cc gui_kde_x11.cc |
103 | - gui_kde_widget_moc.cc | |
103 | + gui_kde_wid_moc.cc | |
104 | 104 | kvim_iface_skel.cc |
105 | - GUI_OBJ = $BDIR/gui_kde_widget.o | |
105 | + GUI_OBJ = $BDIR/gui_kde_wid.o | |
106 | 106 | GUI_DEFS = -DFEAT_GUI_KDE $NARROW_PROTO |
107 | 107 | GUI_IPATH = $GUI_INC_LOC |
108 | 108 | GUI_LIBS_DIR = $GUI_LIB_LOC |
@@ -218,7 +218,7 @@ | ||
218 | 218 | testclean {virtual}: |
219 | 219 | :del {force} testdir/*.out testdir/test.log |
220 | 220 | |
221 | -CLEANFILES += gui_kde_widget_moc.cc kvim_iface_skel.cc *.kidl | |
221 | +CLEANFILES += gui_kde_wid_moc.cc kvim_iface_skel.cc *.kidl | |
222 | 222 | |
223 | 223 | # When no fetch target exists we are not a child of the ../main.aap recipe, |
224 | 224 | # Use ../main.aap to do the fetching. |
@@ -356,18 +356,18 @@ | ||
356 | 356 | :sys $PERL $PERLLIB/ExtUtils/xsubpp -prototypes -typemap \ |
357 | 357 | $PERLLIB/ExtUtils/typemap if_perl.xs >> $target |
358 | 358 | |
359 | -$BDIR/gui_kde_widget.o: gui_kde_widget.cc | |
360 | - :sys $MOC -o gui_kde_widget_moc.cc gui_kde_widget.h | |
359 | +$BDIR/gui_kde_wid.o: gui_kde_wid.cc | |
360 | + :sys $MOC -o gui_kde_wid_moc.cc gui_kde_wid.h | |
361 | 361 | @try: |
362 | 362 | :sys $KDE_PREFIX/bin/dcopidl kvim_iface.h > kvim_iface.kidl |
363 | 363 | @except: |
364 | 364 | :del {f} kvim_iface.kidl |
365 | 365 | :sys $KDE_PREFIX/bin/dcopidl2cpp --c++-suffix cc --no-stub kvim_iface.kidl |
366 | - :do compile gui_kde_widget.cc | |
366 | + :do compile gui_kde_wid.cc | |
367 | 367 | |
368 | -gui_kde_widget_moc.cc: $BDIR/gui_kde_widget.o | |
368 | +gui_kde_wid_moc.cc: $BDIR/gui_kde_wid.o | |
369 | 369 | |
370 | -kvim_iface_skel.cc: $BDIR/gui_kde_widget.o | |
370 | +kvim_iface_skel.cc: $BDIR/gui_kde_wid.o | |
371 | 371 | |
372 | 372 | |
373 | 373 | auto/osdef.h: auto/config.h osdef.sh osdef1.h.in osdef2.h.in |
@@ -4338,8 +4338,17 @@ | ||
4338 | 4338 | curline = buf->b_ml.ml_locked_high + 1; |
4339 | 4339 | } |
4340 | 4340 | |
4341 | - if (ffdos) | |
4342 | - size += line - 1; | |
4341 | + if (line != 0) | |
4342 | + { | |
4343 | + /* Count extra CR characters. */ | |
4344 | + if (ffdos) | |
4345 | + size += line - 1; | |
4346 | + | |
4347 | + /* Don't count the last line break if 'bin' and 'noeol'. */ | |
4348 | + if (buf->b_p_bin && !buf->b_p_eol) | |
4349 | + size -= ffdos + 1; | |
4350 | + } | |
4351 | + | |
4343 | 4352 | return size; |
4344 | 4353 | } |
4345 | 4354 |
@@ -3606,8 +3606,7 @@ | ||
3606 | 3606 | } |
3607 | 3607 | |
3608 | 3608 | /* Store information on starting dir now if path is relative. |
3609 | - * If path is absolute, we do that later. | |
3610 | - */ | |
3609 | + * If path is absolute, we do that later. */ | |
3611 | 3610 | if (path[0] == '.' |
3612 | 3611 | && (vim_ispathsep(path[1]) || path[1] == NUL) |
3613 | 3612 | && (!tagfile || vim_strchr(p_cpo, CPO_DOTTAG) == NULL) |
@@ -3886,7 +3885,7 @@ | ||
3886 | 3885 | * Return a pointer to an allocated file name or NULL if nothing found. |
3887 | 3886 | * To get all matching files call this function until you get NULL. |
3888 | 3887 | * |
3889 | - * If the passed search_context is NULL, it the returns NULL. | |
3888 | + * If the passed search_context is NULL, NULL is returned. | |
3890 | 3889 | * |
3891 | 3890 | * The search algorithm is depth first. To change this replace the |
3892 | 3891 | * stack with a list (don't forget to leave partly searched directories on the |
@@ -1129,7 +1129,7 @@ | ||
1129 | 1129 | new_last_cmdline = NULL; |
1130 | 1130 | /* Escape all control characters with a CTRL-V */ |
1131 | 1131 | p = vim_strsave_escaped_ext(last_cmdline, |
1132 | - "\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037", Ctrl_V, FALSE); | |
1132 | + (char_u *)"\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037", Ctrl_V, FALSE); | |
1133 | 1133 | if (p != NULL) |
1134 | 1134 | retval = put_in_typebuf(p, TRUE); |
1135 | 1135 | vim_free(p); |
@@ -119,8 +119,8 @@ | ||
119 | 119 | * ~/Library/Vim or ~/Library/Preferences/org.vim.vim/ ? (Dany) |
120 | 120 | */ |
121 | 121 | /* When compiled under MacOS X (including CARBON version) |
122 | - * we use the Unix File path style */ | |
123 | -#if defined(TARGET_API_MAC_OSX) && TARGET_API_MAC_OSX | |
122 | + * we use the Unix File path style. Also when UNIX is defined. */ | |
123 | +#if defined(UNIX) || (defined(TARGET_API_MAC_OSX) && TARGET_API_MAC_OSX) | |
124 | 124 | # undef COLON_AS_PATHSEP |
125 | 125 | # define USE_UNIXFILENAME |
126 | 126 | #else |
@@ -140,14 +140,16 @@ | ||
140 | 140 | #define CASE_INSENSITIVE_FILENAME /* ignore case when comparing file names */ |
141 | 141 | #define SPACE_IN_FILENAME |
142 | 142 | #define BREAKCHECK_SKIP 32 /* call mch_breakcheck() each time, it's |
143 | - quite fast. Did I forgot to update the comment */ | |
143 | + quite fast. Did I forgot to update the | |
144 | + comment */ | |
144 | 145 | |
145 | 146 | |
146 | -#undef USE_FNAME_CASE /* So that :e os_Mac.c, :w, save back the file as os_mac.c */ | |
147 | +#undef USE_FNAME_CASE /* So that :e os_Mac.c, :w, save back the file | |
148 | + as os_mac.c */ | |
147 | 149 | #define BINARY_FILE_IO |
148 | 150 | #define EOL_DEFAULT EOL_MAC |
149 | -#ifndef MACOS_X_UNIX /* I hope that switching these two lines */ | |
150 | -# define USE_CR /* does what I want -- BNF */ | |
151 | +#ifndef MACOS_X_UNIX /* I hope that switching these two lines */ | |
152 | +# define USE_CR /* does what I want -- BNF */ | |
151 | 153 | # define NO_CONSOLE /* don't include console mode */ |
152 | 154 | #endif |
153 | 155 | #define HAVE_AVAIL_MEM |
@@ -16,6 +16,7 @@ | ||
16 | 16 | #define NO_X11_INCLUDES |
17 | 17 | #include "vim.h" |
18 | 18 | |
19 | +#ifdef FEAT_MBYTE | |
19 | 20 | extern char_u *mac_string_convert __ARGS((char_u *ptr, int len, int *lenp, int fail_on_error, int from, int to, int *unconvlenp)); |
20 | 21 | extern int macroman2enc __ARGS((char_u *ptr, long *sizep, long real_size)); |
21 | 22 | extern int enc2macroman __ARGS((char_u *from, size_t fromlen, char_u *to, int *tolenp, int maxtolen, char_u *rest, int *restlenp)); |
@@ -228,3 +229,5 @@ | ||
228 | 229 | *tolenp = l; |
229 | 230 | return OK; |
230 | 231 | } |
232 | + | |
233 | +#endif /* FEAT_MBYTE */ |
@@ -1239,7 +1239,7 @@ | ||
1239 | 1239 | #: ex_docmd.c:4584 |
1240 | 1240 | #, c-format |
1241 | 1241 | msgid "E173: %ld more files to edit" |
1242 | -msgstr "E173: Åñòü íåîòðåäàêòèðîâàííûå ôàéëû (%d)." | |
1242 | +msgstr "E173: Åñòü íåîòðåäàêòèðîâàííûå ôàéëû (%ld)." | |
1243 | 1243 | |
1244 | 1244 | #: ex_docmd.c:4679 |
1245 | 1245 | msgid "E174: Command already exists: add ! to replace it" |
@@ -2446,7 +2446,7 @@ | ||
2446 | 2446 | #: if_cscope.c:589 |
2447 | 2447 | #, c-format |
2448 | 2448 | msgid "E262: error reading cscope connection %ld" |
2449 | -msgstr "E262: îøèáêà ïîëó÷åíèÿ èíôîðìàöèè îò ñîåäèíåíèÿ cscope %d" | |
2449 | +msgstr "E262: îøèáêà ïîëó÷åíèÿ èíôîðìàöèè îò ñîåäèíåíèÿ cscope %ld" | |
2450 | 2450 | |
2451 | 2451 | #: if_cscope.c:694 |
2452 | 2452 | msgid "E561: unknown cscope search type" |
@@ -2524,7 +2524,7 @@ | ||
2524 | 2524 | #: if_cscope.c:1458 |
2525 | 2525 | #, c-format |
2526 | 2526 | msgid "cscope connection %s closed" |
2527 | -msgstr "ñîåäèíåíèå ñ cscope çàêðûòî" | |
2527 | +msgstr "ñîåäèíåíèå ñ cscope %s çàêðûòî" | |
2528 | 2528 | |
2529 | 2529 | #. should not reach here |
2530 | 2530 | #: if_cscope.c:1598 |
@@ -1239,7 +1239,7 @@ | ||
1239 | 1239 | #: ex_docmd.c:4584 |
1240 | 1240 | #, c-format |
1241 | 1241 | msgid "E173: %ld more files to edit" |
1242 | -msgstr "E173: Есть неотредактированные файлы (%d)." | |
1242 | +msgstr "E173: Есть неотредактированные файлы (%ld)." | |
1243 | 1243 | |
1244 | 1244 | #: ex_docmd.c:4679 |
1245 | 1245 | msgid "E174: Command already exists: add ! to replace it" |
@@ -2446,7 +2446,7 @@ | ||
2446 | 2446 | #: if_cscope.c:589 |
2447 | 2447 | #, c-format |
2448 | 2448 | msgid "E262: error reading cscope connection %ld" |
2449 | -msgstr "E262: ошибка получения информации от соединения cscope %d" | |
2449 | +msgstr "E262: ошибка получения информации от соединения cscope %ld" | |
2450 | 2450 | |
2451 | 2451 | #: if_cscope.c:694 |
2452 | 2452 | msgid "E561: unknown cscope search type" |
@@ -2524,7 +2524,7 @@ | ||
2524 | 2524 | #: if_cscope.c:1458 |
2525 | 2525 | #, c-format |
2526 | 2526 | msgid "cscope connection %s closed" |
2527 | -msgstr "соединение с cscope закрыто" | |
2527 | +msgstr "соединение с cscope %s закрыто" | |
2528 | 2528 | |
2529 | 2529 | #. should not reach here |
2530 | 2530 | #: if_cscope.c:1598 |
@@ -3760,10 +3760,11 @@ | ||
3760 | 3760 | * Find quote under the cursor, cursor at end. |
3761 | 3761 | * Returns TRUE if found, else FALSE. |
3762 | 3762 | */ |
3763 | +/*ARGSUSED*/ | |
3763 | 3764 | int |
3764 | 3765 | current_quote(oap, count, include, quotechar) |
3765 | 3766 | oparg_T *oap; |
3766 | - long count; | |
3767 | + long count; /* not used */ | |
3767 | 3768 | int include; /* TRUE == include quote char */ |
3768 | 3769 | int quotechar; /* Quote character */ |
3769 | 3770 | { |