Mercurial > vim
annotate runtime/autoload/context.vim @ 34538:c865c2f93a04 v9.1.0171
patch 9.1.0171: Small split-move related improvements
Commit: https://github.com/vim/vim/commit/5cac1a9bee0798d70a7fd80363a1f697759638e8
Author: Sean Dewar <6256228+seandewar@users.noreply.github.com>
Date: Tue Mar 12 21:11:39 2024 +0100
patch 9.1.0171: Small split-move related improvements
Problem: small improvements can be made to split-move related
functions.
Solution: apply them (Sean Dewar):
- Improve some doc comments (frame_flatten should still work for non-current
tabpages, despite the topframe check, which looks benign, though I'm unsure if
it's still needed; see #2467).
- f_win_splitmove should check_split_disallowed on wp, not targetwin, as that's
what win_splitmove checks (though it's probably unnecessary to check
b_locked_split at all; see #14109, which I hope to get around to finishing at
some point).
- Make winframe_restore restore window positions for the altframe, which
winframe_remove changes. This doesn't affect the prior behaviour, as we called
win_comp_pos after, but as win_comp_pos only works for curtab, and
winframe_remove supports non-current tabpages, we should undo it. Regardless,
this should mean we don't need win_comp_pos anymore; adjust tests to check
that window positions remain unchanged.
I'm not sure win_comp_pos is needed after last_status anyway if it doesn't
steal rows from another frame to make room for a new statusline, which
shouldn't be the case after winframe_remove? To be safe, I'll leave it as is.
closes: #14185
Signed-off-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 12 Mar 2024 21:15:03 +0100 |
parents | d81556766132 |
children |
rev | line source |
---|---|
29756 | 1 vim9script |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
29756 | 3 # Language: ConTeXt typesetting engine |
4 # Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com> | |
5 # Former Maintainers: Nikolai Weibull <now@bitwi.se> | |
34018
d81556766132
runtime(context): update ConTeXt keywords and other minor fixes (#13778)
Christian Brabandt <cb@256bit.org>
parents:
30547
diff
changeset
|
6 # Latest Revision: 2023 Dec 26 |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 |
29756 | 8 # Typesetting {{{ |
9 import autoload './typeset.vim' | |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 |
29756 | 11 export def ConTeXtCmd(path: string): list<string> |
30547 | 12 var cmd = ['mtxrun', '--script', 'context', '--nonstopmode', '--autogenerate'] |
13 if !empty(get(g:, 'context_extra_options', '')) | |
14 cmd += g:context_extra_options | |
15 endif | |
16 cmd->add(path) | |
17 return cmd | |
29756 | 18 enddef |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 |
29756 | 20 export def Typeset(bufname: string, env = {}, Cmd = ConTeXtCmd): bool |
21 return typeset.TypesetBuffer(bufname, Cmd, env, 'ConTeXt') | |
22 enddef | |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 |
29756 | 24 export def JobStatus() |
25 typeset.JobStatus('ConTeXt') | |
26 enddef | |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 |
29756 | 28 export def StopJobs() |
29 typeset.StopJobs('ConTeXt') | |
30 enddef | |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 |
29756 | 32 export def Log(bufname: string) |
33 execute 'edit' typeset.LogPath(bufname) | |
34 enddef | |
35 # }}} | |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 |
29756 | 37 # Completion {{{ |
38 def BinarySearch(base: string, keywords: list<string>): list<string> | |
39 const pat = '^' .. base | |
40 const len = len(keywords) | |
41 var res = [] | |
42 var lft = 0 | |
43 var rgt = len | |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
44 |
29756 | 45 # Find the leftmost index matching base |
46 while lft < rgt | |
47 var i = (lft + rgt) / 2 | |
48 if keywords[i] < base | |
49 lft = i + 1 | |
50 else | |
51 rgt = i | |
52 endif | |
53 endwhile | |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
54 |
29756 | 55 while lft < len && keywords[lft] =~ pat |
56 add(res, keywords[lft]) | |
57 lft += 1 | |
58 endwhile | |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
59 |
29756 | 60 return res |
61 enddef | |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
62 |
29756 | 63 var isMetaPostBlock = false |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
64 |
29756 | 65 var MP_KEYWORDS: list<string> = [] |
66 var CTX_KEYWORDS: list<string> = [] | |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
67 |
29756 | 68 # Complete only MetaPost keywords in MetaPost blocks, and complete only |
69 # ConTeXt keywords otherwise. | |
70 export def Complete(findstart: number, base: string): any | |
71 if findstart == 1 | |
72 if len(synstack(line("."), 1)) > 0 && synIDattr(synstack(line("."), 1)[0], "name") ==# 'contextMPGraphic' | |
73 isMetaPostBlock = true | |
74 return match(getline('.'), '\S\+\%' .. col('.') .. 'c') | |
75 endif | |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
76 |
29756 | 77 # Complete only \commands starting with a backslash |
78 isMetaPostBlock = false | |
79 var pos = match(getline('.'), '\\\zs\S\+\%' .. col('.') .. 'c') | |
80 return (pos == -1) ? -3 : pos | |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
81 endif |
29756 | 82 |
83 if isMetaPostBlock | |
84 if empty(MP_KEYWORDS) | |
85 MP_KEYWORDS = sort(syntaxcomplete#OmniSyntaxList(['mf\w\+', 'mp\w\+'])) | |
86 endif | |
87 return BinarySearch(base, MP_KEYWORDS) | |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
88 endif |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
89 |
29756 | 90 if empty(CTX_KEYWORDS) |
91 CTX_KEYWORDS = sort(syntaxcomplete#OmniSyntaxList([ | |
92 'context\w\+', 'texAleph', 'texEtex', 'texLuatex', 'texOmega', | |
93 'texPdftex', 'texTex', 'texXeTeX' | |
94 ])) | |
95 endif | |
96 return BinarySearch(base, CTX_KEYWORDS) | |
97 enddef | |
98 # }}} | |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
99 |
29756 | 100 # vim: sw=2 fdm=marker |