diff options
author | cathook <b01902109@csie.ntu.edu.tw> | 2014-11-19 19:20:55 +0800 |
---|---|---|
committer | cathook <b01902109@csie.ntu.edu.tw> | 2014-11-19 19:20:55 +0800 |
commit | e8a48909eabbfcc6693590fa6b42eade6431c2ca (patch) | |
tree | 70b26715df64e90f4119c06e1c9ceaf1e39a2bb8 | |
parent | 9ab365e6b680abe7af6079b6030c8cc718a0a062 (diff) | |
download | vim-shrvim-e8a48909eabbfcc6693590fa6b42eade6431c2ca.tar.gz vim-shrvim-e8a48909eabbfcc6693590fa6b42eade6431c2ca.tar.zst vim-shrvim-e8a48909eabbfcc6693590fa6b42eade6431c2ca.zip |
Rename the Shared_Vim to ShrVim
-rw-r--r-- | server/src/cmd_ui.py | 10 | ||||
-rwxr-xr-x | server/src/shrvim_server.py (renamed from server/src/shared_vim_server.py) | 30 | ||||
-rw-r--r-- | vim/plugin/shrvim.vim (renamed from vim/plugin/shared_vim.vim) | 80 |
3 files changed, 60 insertions, 60 deletions
diff --git a/server/src/cmd_ui.py b/server/src/cmd_ui.py index 94cbf61..dba21ba 100644 --- a/server/src/cmd_ui.py +++ b/server/src/cmd_ui.py @@ -25,26 +25,26 @@ class CmdUI(cmd.Cmd): # pylint: disable=R0904 Attributes: _users_text_manager: An instance of UsersTextManager. _tcp_server: An instance of TcpServer. - _shared_vim_server: An instance of SharedVimServer. + _shrvim_server: An instance of ShrVimServer. _exit_flag: Whether this UI should stop or not. _thread: Instance of Thread. _init_cmds: Initialize commands. """ def __init__(self, - init_cmds, users_text_manager, tcp_server, shared_vim_server): + init_cmds, users_text_manager, tcp_server, shrvim_server): """Constructor. Args: init_cmds: Lists of commands to run after startup. users_text_manager: An instance of UsersTextManager. tcp_server: An instance of TCPServer. - shared_vim_server: An instance of SharedVimServer. + shrvim_server: An instance of ShrVimServer. """ super(CmdUI, self).__init__() self.prompt = PROMPT self._users_text_manager = users_text_manager self._tcp_server = tcp_server - self._shared_vim_server = shared_vim_server + self._shrvim_server = shrvim_server self._stop_flag = False self._thread = None self._init_cmds = init_cmds @@ -173,7 +173,7 @@ class CmdUI(cmd.Cmd): # pylint: disable=R0904 """Exits the program.""" try: _split_text(text, 0) - self._shared_vim_server.stop() + self._shrvim_server.stop() except _SplitTextError: self.write('Format error!\n' '[usage] exit\n') diff --git a/server/src/shared_vim_server.py b/server/src/shrvim_server.py index 9ec7fcd..36ef111 100755 --- a/server/src/shared_vim_server.py +++ b/server/src/shrvim_server.py @@ -36,11 +36,11 @@ class _Args(object): self.saved_filename = sys.argv[3] -class _SharedVimServerError(Exception): - """Error raised by SharedVimServer.""" +class _ShrVimServerError(Exception): + """Error raised by ShrVimServer.""" pass -class SharedVimServer(threading.Thread): +class ShrVimServer(threading.Thread): """Main class. Attributes: @@ -50,11 +50,11 @@ class SharedVimServer(threading.Thread): """ def __init__(self): """Constructor.""" - super(SharedVimServer, self).__init__() + super(ShrVimServer, self).__init__() try: self._args = _Args() except _ArgsError as e: - raise _SharedVimServerError(str(e) + '\n' + _Args.DOCUMENT) + raise _ShrVimServerError(str(e) + '\n' + _Args.DOCUMENT) self._users_text_manager = UsersTextManager(self._args.saved_filename) self._tcp_server = TCPServer(self._args.port, self._users_text_manager) self._cmd_ui = CmdUI(['load %s' % self._args.user_list_filename], @@ -82,15 +82,15 @@ class _SignalHandler(object): SIGTERM, SIGINT - Exit the program. Attributes: - _shared_vim_server: Instance of SharedVimServer. + _shrvim_server: Instance of ShrVimServer. """ - def __init__(self, shared_vim_server): + def __init__(self, shrvim_server): """Constructor. Args: - shared_vim_server: Instance of SharedVimServer. + shrvim_server: Instance of ShrVimServer. """ - self._shared_vim_server = shared_vim_server + self._shrvim_server = shrvim_server signal.signal(signal.SIGTERM, self._handler) signal.signal(signal.SIGINT, self._handler) @@ -101,17 +101,17 @@ class _SignalHandler(object): number: The signal number to be handle. """ if number in (signal.SIGTERM, signal.SIGINT): - self._shared_vim_server.stop() + self._shrvim_server.stop() def main(): """Program entry point.""" try: - shared_vim_server = SharedVimServer() - _SignalHandler(shared_vim_server) - shared_vim_server.start() - shared_vim_server.join() - except _SharedVimServerError as e: + shrvim_server = ShrVimServer() + _SignalHandler(shrvim_server) + shrvim_server.start() + shrvim_server.join() + except _ShrVimServerError as e: print(e) sys.exit(1) diff --git a/vim/plugin/shared_vim.vim b/vim/plugin/shrvim.vim index d1fdf9d..0d2b4fe 100644 --- a/vim/plugin/shared_vim.vim +++ b/vim/plugin/shrvim.vim @@ -1,40 +1,40 @@ """""""""""""""""""""""""""""""""""" Commands """""""""""""""""""""""""""""""""" -command! -nargs=0 SharedVimTryUsePython3 call _SharedVimTryUsePython3(1) -command! -nargs=0 SharedVimTryUsePython2 call _SharedVimTryUsePython2(1) -command! -nargs=+ SharedVimConnect call _SharedVimCallPythonFunc('connect', [<f-args>]) -command! -nargs=0 SharedVimDisconnect call _SharedVimCallPythonFunc('disconnect', []) -command! -nargs=0 SharedVimSync call _SharedVimCallPythonFunc('sync', []) -command! -nargs=0 SharedVimShowInfo call _SharedVimCallPythonFunc('show_info', []) -command! -nargs=1 SharedVimSetTimeout call _SharedVimCallPythonFunc('set_bvar', ['TIMEOUT', <f-args>]) -command! -nargs=1 SharedVimSetNumOfGroups call _SharedVimCallPythonFunc('set_bvar', ['NUM_GROUPS', <f-args>]) +command! -nargs=0 ShrVimTryUsePython3 call _ShrVimTryUsePython3(1) +command! -nargs=0 ShrVimTryUsePython2 call _ShrVimTryUsePython2(1) +command! -nargs=+ ShrVimConnect call _ShrVimCallPythonFunc('connect', [<f-args>]) +command! -nargs=0 ShrVimDisconnect call _ShrVimCallPythonFunc('disconnect', []) +command! -nargs=0 ShrVimSync call _ShrVimCallPythonFunc('sync', []) +command! -nargs=0 ShrVimShowInfo call _ShrVimCallPythonFunc('show_info', []) +command! -nargs=1 ShrVimSetTimeout call _ShrVimCallPythonFunc('set_bvar', ['TIMEOUT', <f-args>]) +command! -nargs=1 ShrVimSetNumOfGroups call _ShrVimCallPythonFunc('set_bvar', ['NUM_GROUPS', <f-args>]) """"""""""""""""""""""""""""""""""""" Setup """""""""""""""""""""""""""""""""""" " Highlight for other users. for i in range(0, 100) - exec 'hi SharedVimNor' . i . ' ctermbg=darkyellow' - exec 'hi SharedVimIns' . i . ' ctermbg=darkred' - exec 'hi SharedVimVbk' . i . ' ctermbg=darkblue' + exec 'hi ShrVimNor' . i . ' ctermbg=darkyellow' + exec 'hi ShrVimIns' . i . ' ctermbg=darkred' + exec 'hi ShrVimVbk' . i . ' ctermbg=darkblue' endfor -let g:shared_vim_auto_sync_level = 3 +let g:shrvim_auto_sync_level = 3 " Auto commands -autocmd! InsertLeave * call _SharedVimAutoSync(1) -autocmd! CursorMoved * call _SharedVimAutoSync(1) -autocmd! CursorHold * call _SharedVimAutoSync(1) -autocmd! InsertEnter * call _SharedVimAutoSync(2) -autocmd! CursorMovedI * call _SharedVimAutoSync(3) -autocmd! CursorHoldI * call _SharedVimAutoSync(3) +autocmd! InsertLeave * call _ShrVimAutoSync(1) +autocmd! CursorMoved * call _ShrVimAutoSync(1) +autocmd! CursorHold * call _ShrVimAutoSync(1) +autocmd! InsertEnter * call _ShrVimAutoSync(2) +autocmd! CursorMovedI * call _ShrVimAutoSync(3) +autocmd! CursorHoldI * call _ShrVimAutoSync(3) """"""""""""""""""""""""""""""""""" Functions """""""""""""""""""""""""""""""""" -function! _SharedVimTryUsePython3(show_err) +function! _ShrVimTryUsePython3(show_err) if has('python3') - command! -nargs=* SharedVimPython python3 <args> - call _SharedVimSetup() + command! -nargs=* ShrVimPython python3 <args> + call _ShrVimSetup() return 1 else if a:show_err @@ -45,10 +45,10 @@ function! _SharedVimTryUsePython3(show_err) endfunction -function! _SharedVimTryUsePython2(show_err) +function! _ShrVimTryUsePython2(show_err) if has('python') - command! -nargs=* SharedVimPython python <args> - call _SharedVimSetup() + command! -nargs=* ShrVimPython python <args> + call _ShrVimSetup() return 1 else if a:show_err @@ -59,31 +59,31 @@ function! _SharedVimTryUsePython2(show_err) endfunction -function! _SharedVimCallPythonFunc(func_name, args) - if exists('g:shared_vim_setupped') && g:shared_vim_setupped == 1 +function! _ShrVimCallPythonFunc(func_name, args) + if exists('g:shrvim_setupped') && g:shrvim_setupped == 1 if len(a:args) == 0 - exe 'SharedVimPython ' . a:func_name . '()' + exe 'ShrVimPython ' . a:func_name . '()' else let args_str = '"' . join(a:args, '", "') . '"' - exe 'SharedVimPython ' . a:func_name . '(' . args_str . ')' + exe 'ShrVimPython ' . a:func_name . '(' . args_str . ')' endif endif endfunction -function! _SharedVimAutoSync(level) - let level = g:shared_vim_auto_sync_level - if exists('b:shared_vim_auto_sync_level') - let level = b:shared_vim_auto_sync_level +function! _ShrVimAutoSync(level) + let level = g:shrvim_auto_sync_level + if exists('b:shrvim_auto_sync_level') + let level = b:shrvim_auto_sync_level endif if a:level <= level - SharedVimSync + ShrVimSync endif endfunction -function! _SharedVimSetup() -SharedVimPython << EOF +function! _ShrVimSetup() +ShrVimPython << EOF # python << EOF # ^^ Force vim highlighting the python code below. import json @@ -127,13 +127,13 @@ class VARNAMES: # pylint: disable=W0232 USERS = 'users' # List of users. # Name of the normal cursor group. -NORMAL_CURSOR_GROUP = lambda x: 'SharedVimNor%d' % x +NORMAL_CURSOR_GROUP = lambda x: 'ShrVimNor%d' % x # Name of the insert cursor group. -INSERT_CURSOR_GROUP = lambda x: 'SharedVimIns%d' % x +INSERT_CURSOR_GROUP = lambda x: 'ShrVimIns%d' % x # Name of the visual group. -VISUAL_GROUP = lambda x: 'SharedVimVbk%d' % x +VISUAL_GROUP = lambda x: 'ShrVimVbk%d' % x DEFAULT_TIMEOUT = 1 @@ -1034,6 +1034,6 @@ endfunction """""""""""""""""""""""""""""""" Initialize """""""""""""""""""""""""""""""""""" -if _SharedVimTryUsePython3(0) || _SharedVimTryUsePython2(0) - let g:shared_vim_setupped = 1 +if _ShrVimTryUsePython3(0) || _ShrVimTryUsePython2(0) + let g:shrvim_setupped = 1 endif |