diff options
author | cathook <b01902109@csie.ntu.edu.tw> | 2014-11-25 17:22:26 +0800 |
---|---|---|
committer | cathook <b01902109@csie.ntu.edu.tw> | 2014-11-25 17:22:26 +0800 |
commit | 3e2c81bb68edc8e32c74b3c0d72151e18908b00f (patch) | |
tree | ee54b104b1e406fbc317af762b5f792ea2b6c977 | |
parent | 17ac3088d3c401e800d7f56a12cdd2bed78d5bb8 (diff) | |
download | vim-shrvim-3e2c81bb68edc8e32c74b3c0d72151e18908b00f.tar.gz vim-shrvim-3e2c81bb68edc8e32c74b3c0d72151e18908b00f.tar.zst vim-shrvim-3e2c81bb68edc8e32c74b3c0d72151e18908b00f.zip |
Add readme
-rw-r--r-- | Readme.md | 138 | ||||
-rw-r--r-- | test_tool/.gitignore | 3 | ||||
-rwxr-xr-x | test_tool/fake_server.py | 89 | ||||
l--------- | test_tool/json_package.py | 1 | ||||
l--------- | test_tool/log.py | 1 | ||||
-rwxr-xr-x | test_tool/ping_server.py | 62 | ||||
l--------- | test_tool/tcp_server.py | 1 | ||||
l--------- | test_tool/users_text_manager.py | 1 |
8 files changed, 138 insertions, 158 deletions
diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..b709dad --- /dev/null +++ b/Readme.md @@ -0,0 +1,138 @@ +# ShrVim + +## About + +It is a vim plugin like google-doc, which allows multiple users sharing and +editing a file at the same time without sharing only one cursor. This is useful +when a group needs to create a report with plain-text source such as Markdown, +asciidoc, LaTex, etc. + + + +## Features + +- Each user has its own cursor, so usres can edit the different place in the + file at same time. +- You can see where other cursors are. +- RO/RW authority mechanism let the owner be able to restrict a user being read + only mode. +- Each client can have different encodings. +- Non-ANSI, such as chinese characters are allowed. +- Live update in Insert mode + +## Quick start + +### Client + +#### Install + +Install the vim plugin (in the directory "vim"). Or you can just source the +"shrvim.vim" when you want to use it by: + +``` +:so <filename_of_shrvim.vim> +``` + +#### Connect to the server + +With server name, port and your own identity gived by the owner (the one who +created the server), you can: + +``` +:ShrVimConnect <server_name(ip, url, ...)> <port> <identity> +``` + +#### Sync + +Default it will do sync each time you move the cursor, insert a character, etc, +but it might cause your vim be a little bit lag. So you might set it to be only +sync when you type the command (Detail sees below). + +``` +:ShrVimSync +``` + +#### Close the connection + +``` +:ShrVimDisconnect +``` + +### Server + +#### User list + +Create an file stores the user list (you can use /dev/null if you want to skip +this step). In the file, each row should contains three word to represent a +user: ```<identity> <nickname> <authorith>``` where authority can be only "RO" +or "RW". Empty line is allowed. + +Example: +``` +sadf83 user1 RW +jc84j5 user2 RW + +jkl238 user3 RO +sdjfb8 user4 RO +``` + +This file is optional because you can add/delete the user after starting the +server, it has an simple command-line ui. + +**IMPORTANT:** Each user should have different identity. + +#### Start the server + +``` +server/src/shrvim_server.py <port> <user_list_file> <storage_file> +``` + +Where ```<Storage_file>``` should contains the initial context of the shared +file, and during editing, the server will stores the context of the latest +version into it. If you do not want such the file, you can use /dev/null again. + +After this, you will see a command-line ui. + +#### Stop the server + +Type the command +```exit``` + +## Prerequest + +### Client + +- Vim with +python or +python3 +- python or python3 + +### Server +- python3 + +## Settings + +If your vim supports both +python and +python3, and you want to force this +plugin use python2, you can type: + +``` +:ShrVimTryUsePython2 +``` + +On the opposite, there is a command: + +``` +:ShrVimTryUsePython3 +``` + +About the frequency of syncing, you can setup it by: + +```let [g/b]:shr_vim_auto_sync_level = 3/2/1/0``` (Default 3) + +Where 0 means you shoul always call ```:ShrVimSync``` by manual. And it is a +good idea to map a key to this command like: + +```:map <F5> :ShrVimSync<CR>``` + +## Issues +- Server might be inefficient when too much users online. +- If someone use utf8 to insert an utf8 only character, the one use big5 or + something similar will crash. diff --git a/test_tool/.gitignore b/test_tool/.gitignore deleted file mode 100644 index 22efd1f..0000000 --- a/test_tool/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -__pycache__ -__pycache__/* -__pycache__/*.* diff --git a/test_tool/fake_server.py b/test_tool/fake_server.py deleted file mode 100755 index b27d14d..0000000 --- a/test_tool/fake_server.py +++ /dev/null @@ -1,89 +0,0 @@ -#! /usr/bin/env python3 - -import copy -import log -import sys -import tcp_server -import threading - -from tcp_server import _JSON_TOKEN -from json_package import JSONPackage - -class MODE: # pylint:disable=W0232 - """Enumeration type of mode.""" - NORMAL = 1 # normal mode. - INSERT = 2 # insert mode. - REPLACE = 3 # replace mode. - VISUAL = 4 # visual mode. - LINE_VISUAL = 5 # line visual mode. - BLOCK_VISUAL = 6 # block visual mode. - -counter = 0 - -class _TCPConnectionHandler(threading.Thread): - """A thread to handle a connection. - - Attributes: - _sock: The connection socket. - _users_text_manager: An instance of UsersTextManager. - """ - def __init__(self, sock, users_text_manager): - """Constructor. - - Args: - sock: The connection socket. - users_text_manager: An instance of UsersTextManager. - """ - super(_TCPConnectionHandler, self).__init__() - self._sock = sock - self._users_text_manager = users_text_manager - - def run(self): - """Runs the thread.""" - request = self._receive() - self._handle(request) - self._sock.close() - - - def _handle(self, request): - """Handles the request. - - Args: - request: The request package. - """ - global counter - fake_user1 = copy.deepcopy(request.content) - fake_user1[_JSON_TOKEN.NICKNAME] = 'user1' - del fake_user1[_JSON_TOKEN.TEXT] - fake_user1[_JSON_TOKEN.MODE] = MODE.INSERT - fake_user1[_JSON_TOKEN.CURSORS]['.'] = 0 - counter += 1 - fake_user2 = copy.deepcopy(request.content) - fake_user2[_JSON_TOKEN.NICKNAME] = 'user2' - del fake_user2[_JSON_TOKEN.TEXT] - fake_user2[_JSON_TOKEN.MODE] = MODE.LINE_VISUAL - fake_user2[_JSON_TOKEN.CURSORS]['.'] = 62 - fake_user2[_JSON_TOKEN.CURSORS]['v'] = 3 - request.content[_JSON_TOKEN.OTHERS] = [fake_user1, fake_user2] - log.info(str(request.content) + '\n') - request.send_to(self._sock) - - def _receive(self): - """Receive a request. - - Return: - The request package. - """ - request = JSONPackage() - request.recv_from(self._sock) - return request - - -tcp_server._TCPConnectionHandler = _TCPConnectionHandler - -def main(): - server = tcp_server.TCPServer(int(sys.argv[1]), None) - server.start() - -if __name__ == '__main__': - main() diff --git a/test_tool/json_package.py b/test_tool/json_package.py deleted file mode 120000 index a1b4936..0000000 --- a/test_tool/json_package.py +++ /dev/null @@ -1 +0,0 @@ -../server/src/json_package.py
\ No newline at end of file diff --git a/test_tool/log.py b/test_tool/log.py deleted file mode 120000 index 52e2b3d..0000000 --- a/test_tool/log.py +++ /dev/null @@ -1 +0,0 @@ -../server/src/log.py
\ No newline at end of file diff --git a/test_tool/ping_server.py b/test_tool/ping_server.py deleted file mode 100755 index 5cdf41b..0000000 --- a/test_tool/ping_server.py +++ /dev/null @@ -1,62 +0,0 @@ -#! /usr/bin/env python3 - -import log -import sys -import tcp_server -import threading - -from json_package import JSONPackage - -class _TCPConnectionHandler(threading.Thread): - """A thread to handle a connection. - - Attributes: - _sock: The connection socket. - _users_text_manager: An instance of UsersTextManager. - """ - def __init__(self, sock, users_text_manager): - """Constructor. - - Args: - sock: The connection socket. - users_text_manager: An instance of UsersTextManager. - """ - super(_TCPConnectionHandler, self).__init__() - self._sock = sock - self._users_text_manager = users_text_manager - - def run(self): - """Runs the thread.""" - request = self._receive() - self._handle(request) - self._sock.close() - - - def _handle(self, request): - """Handles the request. - - Args: - request: The request package. - """ - log.info(str(request.content) + '\n') - request.send_to(self._sock) - - def _receive(self): - """Receive a request. - - Return: - The request package. - """ - request = JSONPackage() - request.recv_from(self._sock) - return request - - -tcp_server._TCPConnectionHandler = _TCPConnectionHandler - -def main(): - server = tcp_server.TCPServer(int(sys.argv[1]), None) - server.start() - -if __name__ == '__main__': - main() diff --git a/test_tool/tcp_server.py b/test_tool/tcp_server.py deleted file mode 120000 index 15e5f1d..0000000 --- a/test_tool/tcp_server.py +++ /dev/null @@ -1 +0,0 @@ -../server/src/tcp_server.py
\ No newline at end of file diff --git a/test_tool/users_text_manager.py b/test_tool/users_text_manager.py deleted file mode 120000 index 9887bee..0000000 --- a/test_tool/users_text_manager.py +++ /dev/null @@ -1 +0,0 @@ -../server/src/users_text_manager.py
\ No newline at end of file |