Skip to content

Commit eae70b6

Browse files
nicoraffovim-scripts
authored andcommitted
Version 2.1: See above
1 parent 0fcdf37 commit eae70b6

15 files changed

+1911
-1198
lines changed

autoload/conque_term.vim

Lines changed: 438 additions & 216 deletions
Large diffs are not rendered by default.

autoload/conque_term/conque.py

Lines changed: 332 additions & 166 deletions
Large diffs are not rendered by default.

autoload/conque_term/conque_globals.py

Lines changed: 83 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# FILE: autoload/conque_term/conque_globals.py {{{
1+
# FILE: autoload/conque_term/conque_globals.py
22
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
33
# WEBSITE: http://conque.googlecode.com
4-
# MODIFIED: 2010-11-15
5-
# VERSION: 2.0, for Vim 7.0
4+
# MODIFIED: 2011-04-04
5+
# VERSION: 2.1, for Vim 7.0
66
# LICENSE:
77
# Conque - Vim terminal/console emulator
8-
# Copyright (C) 2009-2010 Nico Raffo
8+
# Copyright (C) 2009-2011 Nico Raffo
99
#
1010
# MIT License
1111
#
@@ -25,67 +25,70 @@
2525
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2626
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2727
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28-
# THE SOFTWARE. }}}
28+
# THE SOFTWARE.
2929

3030
"""Common global constants and functions for Conque."""
3131

3232
import sys
33-
import os
3433
import re
3534

3635

3736

3837

38+
# PYTHON VERSION
39+
CONQUE_PYTHON_VERSION = sys.version_info[0]
3940

41+
# Encoding
4042

43+
try:
44+
# Vim's character encoding
45+
import vim
46+
CONQUE_VIM_ENCODING = vim.eval('&encoding')
4147

48+
except:
49+
CONQUE_VIM_ENCODING = 'utf-8'
4250

4351

52+
def u(str_val, str_encoding='utf-8', errors='strict'):
53+
""" Foolhardy attempt to make unicode string syntax compatible with both python 2 and 3. """
4454

55+
if not str_val:
56+
str_val = ''
4557

58+
if CONQUE_PYTHON_VERSION == 3:
59+
return str_val
4660

61+
else:
62+
return unicode(str_val, str_encoding, errors)
4763

64+
def uchr(str):
65+
""" Foolhardy attempt to make unicode string syntax compatible with both python 2 and 3. """
4866

67+
if CONQUE_PYTHON_VERSION == 3:
68+
return chr(str)
4969

70+
else:
71+
return unichr(str)
72+
73+
74+
# Logging
5075

5176

52-
# shared memory size
53-
CONQUE_SOLE_BUFFER_LENGTH = 1000
54-
CONQUE_SOLE_INPUT_SIZE = 1000
55-
CONQUE_SOLE_STATS_SIZE = 1000
56-
CONQUE_SOLE_COMMANDS_SIZE = 255
57-
CONQUE_SOLE_RESCROLL_SIZE = 255
58-
CONQUE_SOLE_RESIZE_SIZE = 255
5977

60-
# interval of screen redraw
61-
# larger number means less frequent
62-
CONQUE_SOLE_SCREEN_REDRAW = 100
6378

64-
# interval of full buffer redraw
65-
# larger number means less frequent
66-
CONQUE_SOLE_BUFFER_REDRAW = 500
6779

68-
# interval of full output bucket replacement
69-
# larger number means less frequent, 1 = every time
70-
CONQUE_SOLE_MEM_REDRAW = 1000
7180

72-
# PYTHON VERSION
73-
CONQUE_PYTHON_VERSION = sys.version_info[0]
7481

7582

76-
def u(str_val, str_encoding='latin-1', errors='strict'):
77-
"""foolhardy attempt to make unicode string syntax compatible with both python 2 and 3"""
7883

79-
if not str_val:
80-
str_val = ''
8184

82-
if CONQUE_PYTHON_VERSION == 3:
83-
return str_val
8485

85-
else:
86-
return unicode(str_val, str_encoding, errors)
8786

88-
# Escape sequence settings {{{
87+
88+
89+
90+
91+
# Unix escape sequence settings
8992

9093
CONQUE_CTL = {
9194
1: 'soh', # start of heading
@@ -209,7 +212,7 @@ def u(str_val, str_encoding='latin-1', errors='strict'):
209212
0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF
210213
]
211214

212-
# Font codes {{{
215+
# Font codes
213216
CONQUE_FONT = {
214217
0: {'description': 'Normal (default)', 'attributes': {'cterm': 'NONE', 'ctermfg': 'NONE', 'ctermbg': 'NONE', 'gui': 'NONE', 'guifg': 'NONE', 'guibg': 'NONE'}, 'normal': True},
215218
1: {'description': 'Bold', 'attributes': {'cterm': 'BOLD', 'gui': 'BOLD'}, 'normal': False},
@@ -257,31 +260,60 @@ def u(str_val, str_encoding='latin-1', errors='strict'):
257260
106: {'description': 'Set background color to Cyan', 'attributes': {'ctermbg': '14', 'guibg': '#009999'}, 'normal': False},
258261
107: {'description': 'Set background color to White', 'attributes': {'ctermbg': '15', 'guibg': '#ffffff'}, 'normal': False}
259262
}
260-
# }}}
263+
261264

262265
# regular expression matching (almost) all control sequences
263-
CONQUE_SEQ_REGEX = re.compile(u("(\x1b\[?\??#?[0-9;]*[a-zA-Z0-9@=>]|\x1b\][0-9];.*?\x07|[\x01-\x0f]|\x1b\([AB0])"), re.UNICODE)
264-
CONQUE_SEQ_REGEX_CTL = re.compile(u("^[\x01-\x0f]$"), re.UNICODE)
265-
CONQUE_SEQ_REGEX_CSI = re.compile(u("^\x1b\["), re.UNICODE)
266-
CONQUE_SEQ_REGEX_TITLE = re.compile(u("^\x1b\]"), re.UNICODE)
267-
CONQUE_SEQ_REGEX_HASH = re.compile(u("^\x1b#"), re.UNICODE)
268-
CONQUE_SEQ_REGEX_ESC = re.compile(u("^\x1b.$"), re.UNICODE)
269-
CONQUE_SEQ_REGEX_CHAR = re.compile(u("^\x1b\("), re.UNICODE)
266+
CONQUE_SEQ_REGEX = re.compile("(\x1b\[?\??#?[0-9;]*[a-zA-Z0-9@=>]|\x1b\][0-9];.*?\x07|[\x01-\x0f]|\x1b\([AB0])")
267+
CONQUE_SEQ_REGEX_CTL = re.compile("^[\x01-\x0f]$")
268+
CONQUE_SEQ_REGEX_CSI = re.compile("^\x1b\[")
269+
CONQUE_SEQ_REGEX_TITLE = re.compile("^\x1b\]")
270+
CONQUE_SEQ_REGEX_HASH = re.compile("^\x1b#")
271+
CONQUE_SEQ_REGEX_ESC = re.compile("^\x1b.$")
272+
CONQUE_SEQ_REGEX_CHAR = re.compile("^\x1b[()]")
270273

271274
# match table output
272275
CONQUE_TABLE_OUTPUT = re.compile("^\s*\|\s.*\s\|\s*$|^\s*\+[=+-]+\+\s*$")
273276

274-
# }}}
275-
276-
# Windows subprocess config {{{
277-
278-
CONQUE_SEQ_REGEX_VK = re.compile(u("(\x1b\[\d{1,3}VK)"), re.UNICODE)
279-
280-
# }}}
281-
277+
# basic terminal colors
282278
CONQUE_COLOR_SEQUENCE = (
283279
'000', '009', '090', '099', '900', '909', '990', '999',
284280
'000', '00f', '0f0', '0ff', 'f00', 'f0f', 'ff0', 'fff'
285281
)
286282

287-
# vim:foldmethod=marker
283+
284+
# Windows subprocess constants
285+
286+
# shared memory size
287+
CONQUE_SOLE_BUFFER_LENGTH = 1000
288+
CONQUE_SOLE_INPUT_SIZE = 1000
289+
CONQUE_SOLE_STATS_SIZE = 1000
290+
CONQUE_SOLE_COMMANDS_SIZE = 255
291+
CONQUE_SOLE_RESCROLL_SIZE = 255
292+
CONQUE_SOLE_RESIZE_SIZE = 255
293+
294+
# interval of screen redraw
295+
# larger number means less frequent
296+
CONQUE_SOLE_SCREEN_REDRAW = 50
297+
298+
# interval of full buffer redraw
299+
# larger number means less frequent
300+
CONQUE_SOLE_BUFFER_REDRAW = 500
301+
302+
# interval of full output bucket replacement
303+
# larger number means less frequent, 1 = every time
304+
CONQUE_SOLE_MEM_REDRAW = 1000
305+
306+
# maximum number of lines with terminal colors
307+
# ignored if g:ConqueTerm_Color = 2
308+
CONQUE_MAX_SYNTAX_LINES = 200
309+
310+
# windows input splitting on special keys
311+
CONQUE_WIN32_REGEX_VK = re.compile("(\x1b\[[0-9;]+VK)")
312+
313+
# windows attribute string splitting
314+
CONQUE_WIN32_REGEX_ATTR = re.compile("((.)\\2*)", re.DOTALL)
315+
316+
# special key attributes
317+
CONQUE_VK_ATTR_CTRL_PRESSED = u('1024')
318+
319+

0 commit comments

Comments
 (0)