diff options
Diffstat (limited to 'config/vim/plugin/pickachu')
-rw-r--r-- | config/vim/plugin/pickachu/__init__.py | 0 | ||||
-rw-r--r-- | config/vim/plugin/pickachu/__pycache__/__init__.cpython-39.pyc | bin | 142 -> 0 bytes | |||
-rw-r--r-- | config/vim/plugin/pickachu/__pycache__/apps.cpython-39.pyc | bin | 1107 -> 0 bytes | |||
-rw-r--r-- | config/vim/plugin/pickachu/__pycache__/main.cpython-39.pyc | bin | 719 -> 0 bytes | |||
-rw-r--r-- | config/vim/plugin/pickachu/__pycache__/processors.cpython-39.pyc | bin | 1896 -> 0 bytes | |||
-rw-r--r-- | config/vim/plugin/pickachu/apps.py | 68 | ||||
-rw-r--r-- | config/vim/plugin/pickachu/main.py | 36 | ||||
-rw-r--r-- | config/vim/plugin/pickachu/processors.py | 80 |
8 files changed, 0 insertions, 184 deletions
diff --git a/config/vim/plugin/pickachu/__init__.py b/config/vim/plugin/pickachu/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/config/vim/plugin/pickachu/__init__.py +++ /dev/null diff --git a/config/vim/plugin/pickachu/__pycache__/__init__.cpython-39.pyc b/config/vim/plugin/pickachu/__pycache__/__init__.cpython-39.pyc Binary files differdeleted file mode 100644 index c18ad9c..0000000 --- a/config/vim/plugin/pickachu/__pycache__/__init__.cpython-39.pyc +++ /dev/null diff --git a/config/vim/plugin/pickachu/__pycache__/apps.cpython-39.pyc b/config/vim/plugin/pickachu/__pycache__/apps.cpython-39.pyc Binary files differdeleted file mode 100644 index c564bcc..0000000 --- a/config/vim/plugin/pickachu/__pycache__/apps.cpython-39.pyc +++ /dev/null diff --git a/config/vim/plugin/pickachu/__pycache__/main.cpython-39.pyc b/config/vim/plugin/pickachu/__pycache__/main.cpython-39.pyc Binary files differdeleted file mode 100644 index c35190e..0000000 --- a/config/vim/plugin/pickachu/__pycache__/main.cpython-39.pyc +++ /dev/null diff --git a/config/vim/plugin/pickachu/__pycache__/processors.cpython-39.pyc b/config/vim/plugin/pickachu/__pycache__/processors.cpython-39.pyc Binary files differdeleted file mode 100644 index 1cf1153..0000000 --- a/config/vim/plugin/pickachu/__pycache__/processors.cpython-39.pyc +++ /dev/null diff --git a/config/vim/plugin/pickachu/apps.py b/config/vim/plugin/pickachu/apps.py deleted file mode 100644 index 00a6826..0000000 --- a/config/vim/plugin/pickachu/apps.py +++ /dev/null @@ -1,68 +0,0 @@ -import vim -import subprocess -from . import processors - -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -# name: apps.py -# description: this function contains a dictionary object -# where you can easily add new apps with processor -# functions to handle their output. Note: a -# processor is optional. -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # - -ZENITY_COMMAND = vim.eval("g:pickachu_default_command") -# Note: This is not the final date format that displays on -# the users' buffer. This is the format we force -# Zenity/Qarma to provide us. -RETURNED_DATE_FORMAT = "%m/%d/%Y" -if ZENITY_COMMAND == 'qarma': - RETURNED_DATE_FORMAT = "MM/dd/yy" - -apps = { - 'date': { - 'cmd': ZENITY_COMMAND, - 'processor': processors.dateProcessor, - 'options': [ - '--calendar', - '--date-format=' + RETURNED_DATE_FORMAT - ] - }, - 'file': { - 'cmd': ZENITY_COMMAND, - 'options': [ - '--file-selection' - ] - }, - 'color': { - 'cmd': ZENITY_COMMAND, - 'options': [ - '--color-selection' - ], - 'processor': processors.colorProcessor - } -} - -def runApp(choosenApp, format=None): - app = apps.get(choosenApp, None) - if app: - output = None - try: - command_array = [app['cmd']] - if app.get('options', False): - for option in app['options']: - command_array.append(option) - # Logging - command_array.append('2> /tmp/pickachu_log') - output = subprocess.check_output(command_array).decode('utf-8') - except: - return None - - if app.get('processor', None): - if format: - return app['processor'](output.rstrip(), format) - else: - return app['processor'](output.rstrip()) - else: - return output.rstrip() - else: - print("App does not exist.") diff --git a/config/vim/plugin/pickachu/main.py b/config/vim/plugin/pickachu/main.py deleted file mode 100644 index d9a42b3..0000000 --- a/config/vim/plugin/pickachu/main.py +++ /dev/null @@ -1,36 +0,0 @@ -import vim -from . import apps - -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -# name: main.py -# description: This file evaluates the command arguments -# provided by the user, calls the runApp function, -# and inserts valid output to the user's buffer. -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # - -DEFAULT_APP = vim.eval('g:pickachu_default_app') - - -def MainFunction(): - # This section is for getting the - # arguments from the user's Vim - # command. - arglength = int(vim.eval('a:0')) - CHOOSEN_APP = DEFAULT_APP - CHOOSEN_FORMAT = None - if arglength > 0: - CHOOSEN_APP = vim.eval('a:1') - if arglength > 1: - CHOOSEN_FORMAT = vim.eval('a:2') - - # We run apps.py's runApp function to get an output. - output = apps.runApp(CHOOSEN_APP, CHOOSEN_FORMAT) - - # Now, if runApp gave us an output, we can use the - # Vim API to print the output to the user's buffer. - if output: - pos_y, pos_x = vim.current.window.cursor - vim.current.line = vim.current.line[:pos_x+1] + output + vim.current.line[pos_x+1:] - vim.current.window.cursor = (pos_y, pos_x + len(output)) - else: - print('Pickachu - Canceled') diff --git a/config/vim/plugin/pickachu/processors.py b/config/vim/plugin/pickachu/processors.py deleted file mode 100644 index 0fe04c1..0000000 --- a/config/vim/plugin/pickachu/processors.py +++ /dev/null @@ -1,80 +0,0 @@ -import vim -from datetime import datetime - -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -# name: processors.py -# description: this file contains functions that process data -# from the runapp function (in app.py). -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # - -DEFAULT_DATE_FORMAT = vim.eval("g:pickachu_default_date_format") -DEFAULT_COLOR_FORMAT = vim.eval("g:pickachu_default_color_format") - -def dateProcessor(input, format=DEFAULT_DATE_FORMAT): - try: - dateObj = datetime.strptime(input, '%m/%d/%Y') - except(ValueError): - dateObj = datetime.strptime(input, '%m/%d/%y') - return dateObj.strftime(format) - -def colorProcessor(input, format=DEFAULT_COLOR_FORMAT): - # The system color picker returned an rgba value - if 'rgba' in input: - strip = input.strip('rgba)(') - array = strip.split(',') - # Round the alpha value to two decimal placed - array[3] = round(float(array[3]), 2) - rgba_string = "rgba(" - values = ",".join(str(x) for x in array) - rgba_string += values + ")" - return rgba_string - # The system color picker returned an rgb value - elif 'rgb' in input: - # RGB as input - if format == 'rgb': - return input - else: - # Strip 'rgb' and parenthesis - strip = input.strip('rgb)(') - array = strip.split(',') - - if format == 'hex': - hex = '#%02x%02x%02x' % (int(array[0]), int(array[1]), int(array[2])) - return hex.upper() - elif format == 'rgba': - rgba_string = "rgba(" - array.append(1) - values = ",".join(str(x) for x in array) - rgba_string += values + ")" - return rgba_string - return array - # The system olor picker returned a hex - elif '#' in input: - # If there is a '#' in input, - # they are most likely using Qarma instead of Zenity - # or any other program that outputs hex - if format == 'hex': - return input - else: - hex = input.lstrip('#') - rgb_array = tuple(int(hex[i:i+2], 16) for i in (0, 2 ,4)) - - if format == 'rgb': - rgb_string = "rgb(" - for i in range(0, len(rgb_array)): - rgb_string += str(rgb_array[i]) - if i < len(rgb_array) - 1: - rgb_string += ", " - else: - rgb_string += ")" - return rgb_string - elif format == 'rgba': - rgba_string = "rgba(" - for i in range(0, len(rgb_array)): - rgba_string += str(rgb_array[i]) - if i < len(rgb_array) - 1: - rgba_string += ", " - else: - rgba_string += ", 1)" - return rgba_string - return None |