mirror of
https://github.com/powerline/powerline.git
synced 2025-07-26 23:35:04 +02:00
Release 2.8
This commit is contained in:
commit
e8bf337ba5
11
.travis.yml
11
.travis.yml
@ -20,20 +20,11 @@ install: tests/install.sh
|
|||||||
script: tests/test.sh
|
script: tests/test.sh
|
||||||
jobs:
|
jobs:
|
||||||
include:
|
include:
|
||||||
- stage: UCS2 python
|
|
||||||
python: "2.7"
|
|
||||||
env: >-
|
|
||||||
USE_UCS2_PYTHON=1
|
|
||||||
UCS2_PYTHON_VARIANT="2.7"
|
|
||||||
- stage: Old Python
|
|
||||||
python: "2.6"
|
|
||||||
- python: "3.2"
|
|
||||||
- stage: PyPy
|
- stage: PyPy
|
||||||
python: "pypy"
|
python: "pypy"
|
||||||
- python: "pypy3"
|
- python: "pypy3"
|
||||||
- stage: Latest Python
|
- stage: Latest Python
|
||||||
python: "2.7"
|
python: "3.6"
|
||||||
- python: "3.6"
|
|
||||||
- stage: Intermediate versions
|
- stage: Intermediate versions
|
||||||
python: "3.3"
|
python: "3.3"
|
||||||
- python: "3.4"
|
- python: "3.4"
|
||||||
|
@ -5,3 +5,4 @@ recursive-include powerline/dist *.*
|
|||||||
recursive-include client *.*
|
recursive-include client *.*
|
||||||
recursive-include docs/source *.rst *.py
|
recursive-include docs/source *.rst *.py
|
||||||
include docs/Makefile
|
include docs/Makefile
|
||||||
|
include LICENSE
|
||||||
|
34
README.rst
34
README.rst
@ -51,14 +51,38 @@ Features
|
|||||||
hassle for me / what happened to the original vim-powerline project / …*
|
hassle for me / what happened to the original vim-powerline project / …*
|
||||||
|
|
||||||
You should check out some of the Powerline derivatives. The most lightweight
|
You should check out some of the Powerline derivatives. The most lightweight
|
||||||
and feature-rich alternative is currently Bailey Ling’s `vim-airline
|
and feature-rich alternative is currently the `vim-airline
|
||||||
<https://github.com/vim-airline/vim-airline>`_ project.
|
<https://github.com/vim-airline/vim-airline>`_ project.
|
||||||
|
|
||||||
------
|
Configuration
|
||||||
|
-------------
|
||||||
|
|
||||||
* Consult the `documentation
|
Basic powerline configuration is done via `JSON` files located at `.config/powerline/`. It is a good idea to start by copying the default configuration located at `powerline_root/powerline/config_files/` to `.config/powerline/`.
|
||||||
<https://powerline.readthedocs.org/en/latest/>`_ for more information and
|
If you installed the powerline from the AUR or via pip, `powerline_root` should be `/usr/lib/python3.6/site-packages/` or something similar, depending on your python version.
|
||||||
installation instructions.
|
|
||||||
|
This should yield you the following directory structure:
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
.config/powerline/
|
||||||
|
├── colorschemes
|
||||||
|
│ ├── ...
|
||||||
|
│ └── wm
|
||||||
|
| └── default.json // Your configuration goes here
|
||||||
|
├── colors.json
|
||||||
|
├── config.json
|
||||||
|
└── themes
|
||||||
|
├── ...
|
||||||
|
└── wm
|
||||||
|
└── default.json // Your configuration goes here
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
The files in the subdirectories of `themes` are used to specify which segments shall be shown; the files in subdirectories of `colorschemes` are used to specify which colors (as defined in `colors.json`) shall be used to display a segment.
|
||||||
|
|
||||||
|
Note that your local configuration only overrides the global configuration, it does not replace it, i.e. if you don't configure something locally, the global default will be used instead.
|
||||||
|
|
||||||
|
* Consult the `documentation <https://powerline.readthedocs.org/en/latest/configuration.html#quick-setup-guide>`_ for more details. See also the `segment reference <https://powerline.readthedocs.org/en/latest/configuration/segments.html>`_ for available segments and their configuration.
|
||||||
* Check out `powerline-fonts <https://github.com/powerline/fonts>`_ for
|
* Check out `powerline-fonts <https://github.com/powerline/fonts>`_ for
|
||||||
pre-patched versions of popular, open source coding fonts.
|
pre-patched versions of popular, open source coding fonts.
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ if test -n "$OSTYPE" ; then
|
|||||||
elif test "${OSTYPE#darwin}" ; then
|
elif test "${OSTYPE#darwin}" ; then
|
||||||
darwin=1
|
darwin=1
|
||||||
fi
|
fi
|
||||||
elif which uname >/dev/null ; then
|
elif command -v uname >/dev/null ; then
|
||||||
if uname -o | grep -iqF linux ; then
|
if uname -o | grep -iqF linux ; then
|
||||||
use_filesystem=
|
use_filesystem=
|
||||||
elif uname -o | grep -iqF darwin ; then
|
elif uname -o | grep -iqF darwin ; then
|
||||||
|
@ -53,7 +53,7 @@ Common configuration is a subdictionary that is a value of ``common`` key in
|
|||||||
|
|
||||||
``ambiwidth``
|
``ambiwidth``
|
||||||
Tells powerline what to do with characters with East Asian Width Class
|
Tells powerline what to do with characters with East Asian Width Class
|
||||||
Ambigious (such as Euro, Registered Sign, Copyright Sign, Greek
|
Ambiguous (such as Euro, Registered Sign, Copyright Sign, Greek
|
||||||
letters, Cyrillic letters). Valid values: any positive integer; it is
|
letters, Cyrillic letters). Valid values: any positive integer; it is
|
||||||
suggested that this option is only set it to 1 (default) or 2.
|
suggested that this option is only set it to 1 (default) or 2.
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ Common configuration is a subdictionary that is a value of ``common`` key in
|
|||||||
|
|
||||||
``interval``
|
``interval``
|
||||||
Number, determines time (in seconds) between checks for changed
|
Number, determines time (in seconds) between checks for changed
|
||||||
configuration. Checks are done in a seprate thread. Use ``null`` to check
|
configuration. Checks are done in a separate thread. Use ``null`` to check
|
||||||
for configuration changes on ``.render()`` call in main thread.
|
for configuration changes on ``.render()`` call in main thread.
|
||||||
Defaults to ``None``.
|
Defaults to ``None``.
|
||||||
|
|
||||||
@ -245,7 +245,7 @@ Color definitions
|
|||||||
gradient, and the value is a list containing one or two items, second item
|
gradient, and the value is a list containing one or two items, second item
|
||||||
is optional:
|
is optional:
|
||||||
|
|
||||||
* A list of cterm color indicies.
|
* A list of cterm color indices.
|
||||||
* A list of hex color strings.
|
* A list of hex color strings.
|
||||||
|
|
||||||
It is expected that gradients are defined from least alert color to most
|
It is expected that gradients are defined from least alert color to most
|
||||||
@ -388,7 +388,7 @@ ascii Theme without any unicode characters at all
|
|||||||
|
|
||||||
``cursor_columns``
|
``cursor_columns``
|
||||||
Space reserved for user input in shell bindings. Unlike :ref:`cursor_space
|
Space reserved for user input in shell bindings. Unlike :ref:`cursor_space
|
||||||
<config-themes-cursor_space>` it is measured in absolute amout of columns.
|
<config-themes-cursor_space>` it is measured in absolute amount of columns.
|
||||||
|
|
||||||
.. _config-themes-segment_data:
|
.. _config-themes-segment_data:
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ with any coding font.
|
|||||||
|
|
||||||
mv PowerlineSymbols.otf ~/.local/share/fonts/
|
mv PowerlineSymbols.otf ~/.local/share/fonts/
|
||||||
|
|
||||||
#. Update font cache for the path the font was moved to (root priveleges may be
|
#. Update font cache for the path the font was moved to (root privileges may be
|
||||||
needed to update cache for the system-wide paths)::
|
needed to update cache for the system-wide paths)::
|
||||||
|
|
||||||
fc-cache -vf ~/.local/share/fonts/
|
fc-cache -vf ~/.local/share/fonts/
|
||||||
|
@ -37,8 +37,8 @@ Features
|
|||||||
hassle for me / what happened to the original vim-powerline project / …*
|
hassle for me / what happened to the original vim-powerline project / …*
|
||||||
|
|
||||||
You should check out some of the Powerline derivatives. The most lightweight
|
You should check out some of the Powerline derivatives. The most lightweight
|
||||||
and feature-rich alternative is currently Bailey Ling’s `vim-airline
|
and feature-rich alternative is currently the `vim-airline
|
||||||
<https://github.com/bling/vim-airline>`_ project.
|
<https://github.com/vim-airline/vim-airline>`_ project.
|
||||||
|
|
||||||
Screenshots
|
Screenshots
|
||||||
-----------
|
-----------
|
||||||
|
@ -17,6 +17,22 @@ statusline:
|
|||||||
set showtabline=2 " Always display the tabline, even if there is only one tab
|
set showtabline=2 " Always display the tabline, even if there is only one tab
|
||||||
set noshowmode " Hide the default mode text (e.g. -- INSERT -- below the statusline)
|
set noshowmode " Hide the default mode text (e.g. -- INSERT -- below the statusline)
|
||||||
|
|
||||||
|
.. _tips-and-tricks-vscode:
|
||||||
|
|
||||||
|
VS-Code
|
||||||
|
=======
|
||||||
|
|
||||||
|
Useful settings
|
||||||
|
---------------
|
||||||
|
|
||||||
|
To make powerline work in the internal terminal, add the following settings;
|
||||||
|
where the shell command needs to be adjusted according to your preferred shell.
|
||||||
|
|
||||||
|
.. code-block:: json
|
||||||
|
|
||||||
|
"terminal.integrated.shell.linux": "/bin/bash"
|
||||||
|
"terminal.integrated.inheritEnv": true
|
||||||
|
|
||||||
.. _tips-and-tricks-urxvt:
|
.. _tips-and-tricks-urxvt:
|
||||||
|
|
||||||
Rxvt-unicode
|
Rxvt-unicode
|
||||||
|
@ -53,7 +53,7 @@ diagnose this problem you may do the following:
|
|||||||
startup or, at least, that it was cleaned after update. While different
|
startup or, at least, that it was cleaned after update. While different
|
||||||
``$POWERLINE_COMMAND`` variable should not cause any troubles most of time
|
``$POWERLINE_COMMAND`` variable should not cause any troubles most of time
|
||||||
(and when it will cause troubles are rather trivial) spoiled
|
(and when it will cause troubles are rather trivial) spoiled
|
||||||
``$PROMPT_COMMAND`` may lead to strange error messages or absense of exit
|
``$PROMPT_COMMAND`` may lead to strange error messages or absence of exit
|
||||||
code reporting.
|
code reporting.
|
||||||
|
|
||||||
These are the sources which may keep outdated environment variables:
|
These are the sources which may keep outdated environment variables:
|
||||||
|
@ -130,6 +130,46 @@ root <repository-root>`)::
|
|||||||
IPython prompt
|
IPython prompt
|
||||||
==============
|
==============
|
||||||
|
|
||||||
|
For IPython>=7.0, add the following line to
|
||||||
|
:file:`~/.ipython/profile_default/ipython_config.py` file in the used profile:
|
||||||
|
|
||||||
|
|
||||||
|
.. code-block:: Python
|
||||||
|
|
||||||
|
from powerline.bindings.ipython.since_7 import PowerlinePrompts
|
||||||
|
c.TerminalInteractiveShell.prompts_class = PowerlinePrompts
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
If certain graphical/colored elements are not showing, make sure `c.TerminalInteractiveShell.simple_prompt`
|
||||||
|
is set to `False` in your config.
|
||||||
|
Setting ``simple_prompt`` to False after IPython-5.0 is required regardless
|
||||||
|
of whether you use ``c.InteractiveShellApp.extensions`` setting or
|
||||||
|
``c.TerminalInteractiveShell.prompts_class``. But you probably already have
|
||||||
|
this line because ``simple_prompt`` is set to ``False`` by default and IPython
|
||||||
|
is not very useful without it.
|
||||||
|
|
||||||
|
For IPython>=5.0 and <7.0 it is suggested to use
|
||||||
|
|
||||||
|
.. code-block:: Python
|
||||||
|
|
||||||
|
from powerline.bindings.ipython.since_5 import PowerlinePrompts
|
||||||
|
c = get_config()
|
||||||
|
c.TerminalInteractiveShell.simple_prompt = False
|
||||||
|
c.TerminalInteractiveShell.prompts_class = PowerlinePrompts
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
For IPython>=5.0 and <7.0 you may use the below set up, but it is deprecated.
|
||||||
|
For IPython>=0.11 add the following line to
|
||||||
|
:file:`~/.ipython/profile_default/ipython_config.py` file in the used profile:
|
||||||
|
|
||||||
|
.. code-block:: Python
|
||||||
|
|
||||||
|
c = get_config()
|
||||||
|
c.InteractiveShellApp.extensions = [
|
||||||
|
'powerline.bindings.ipython.post_0_11'
|
||||||
|
]
|
||||||
|
|
||||||
For IPython<0.11 add the following lines to :file:`.ipython/ipy_user_conf.py`:
|
For IPython<0.11 add the following lines to :file:`.ipython/ipy_user_conf.py`:
|
||||||
|
|
||||||
.. code-block:: Python
|
.. code-block:: Python
|
||||||
@ -141,31 +181,6 @@ For IPython<0.11 add the following lines to :file:`.ipython/ipy_user_conf.py`:
|
|||||||
# create skeleton ipy_user_conf.py file):
|
# create skeleton ipy_user_conf.py file):
|
||||||
powerline_setup()
|
powerline_setup()
|
||||||
|
|
||||||
For IPython>=0.11 add the following line to
|
|
||||||
:file:`~/.ipython/profile_default/ipython_config.py` file in the used profile:
|
|
||||||
|
|
||||||
.. code-block:: Python
|
|
||||||
|
|
||||||
c = get_config()
|
|
||||||
c.InteractiveShellApp.extensions = [
|
|
||||||
'powerline.bindings.ipython.post_0_11'
|
|
||||||
]
|
|
||||||
|
|
||||||
For IPython>=5.0 you may use the above set up, but it is deprecated. It is
|
|
||||||
suggested to use
|
|
||||||
|
|
||||||
.. code-block:: Python
|
|
||||||
|
|
||||||
from powerline.bindings.ipython.since_5 import PowerlinePrompts
|
|
||||||
c = get_config()
|
|
||||||
c.TerminalInteractiveShell.simple_prompt = False
|
|
||||||
c.TerminalInteractiveShell.prompts_class = PowerlinePrompts
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
Setting ``simple_prompt`` to False after IPython-5.0 is required regardless
|
|
||||||
of whether you use ``c.InteractiveShellApp.extensions`` setting or
|
|
||||||
``c.TerminalInteractiveShell.prompts_class``. But you probably already have
|
|
||||||
this line because IPython is not very useful without it.
|
|
||||||
|
|
||||||
IPython=0.11* is not supported and does not work. IPython<0.10 was not
|
IPython=0.11* is not supported and does not work. IPython<0.10 was not
|
||||||
tested (not installable by pip).
|
tested (not installable by pip).
|
||||||
|
@ -380,8 +380,8 @@ def gen_module_attr_getter(pl, import_paths, imported_modules):
|
|||||||
|
|
||||||
:return:
|
:return:
|
||||||
Attribute value or ``None``. Note: there is no way to distinguish
|
Attribute value or ``None``. Note: there is no way to distinguish
|
||||||
between successfull import of attribute equal to ``None`` and
|
between successful import of attribute equal to ``None`` and
|
||||||
unsuccessfull import.
|
unsuccessful import.
|
||||||
'''
|
'''
|
||||||
oldpath = sys.path
|
oldpath = sys.path
|
||||||
sys.path = import_paths + sys.path
|
sys.path = import_paths + sys.path
|
||||||
@ -473,7 +473,7 @@ class Powerline(object):
|
|||||||
|
|
||||||
__init__ function only stores the arguments and runs this function. This
|
__init__ function only stores the arguments and runs this function. This
|
||||||
function exists for powerline to be able to reload itself: it is easier
|
function exists for powerline to be able to reload itself: it is easier
|
||||||
to make ``__init__`` store arguments and call overriddable ``init`` than
|
to make ``__init__`` store arguments and call overridable ``init`` than
|
||||||
tell developers that each time they override Powerline.__init__ in
|
tell developers that each time they override Powerline.__init__ in
|
||||||
subclasses they must store actual arguments.
|
subclasses they must store actual arguments.
|
||||||
'''
|
'''
|
||||||
@ -706,7 +706,7 @@ class Powerline(object):
|
|||||||
'''Run component-specific setup
|
'''Run component-specific setup
|
||||||
|
|
||||||
:param set components:
|
:param set components:
|
||||||
Set of the enabled componets or None.
|
Set of the enabled components or None.
|
||||||
|
|
||||||
Should be overridden by subclasses.
|
Should be overridden by subclasses.
|
||||||
'''
|
'''
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
_powerline_columns_fallback() {
|
_powerline_columns_fallback() {
|
||||||
if which stty &>/dev/null ; then
|
if command -v stty &>/dev/null ; then
|
||||||
local cols="$(stty size 2>/dev/null)"
|
local cols="$(stty size 2>/dev/null)"
|
||||||
if ! test -z "$cols" ; then
|
if ! test -z "$cols" ; then
|
||||||
echo "${cols#* }"
|
echo "${cols#* }"
|
||||||
@ -138,7 +138,7 @@ _powerline_setup_prompt() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if test -z "${POWERLINE_CONFIG_COMMAND}" ; then
|
if test -z "${POWERLINE_CONFIG_COMMAND}" ; then
|
||||||
if which powerline-config >/dev/null ; then
|
if command -v powerline-config >/dev/null ; then
|
||||||
POWERLINE_CONFIG_COMMAND=powerline-config
|
POWERLINE_CONFIG_COMMAND=powerline-config
|
||||||
else
|
else
|
||||||
POWERLINE_CONFIG_COMMAND="$(dirname "$BASH_SOURCE")/../../../scripts/powerline-config"
|
POWERLINE_CONFIG_COMMAND="$(dirname "$BASH_SOURCE")/../../../scripts/powerline-config"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
function powerline-setup
|
function powerline-setup
|
||||||
function _powerline_columns_fallback
|
function _powerline_columns
|
||||||
if which stty >/dev/null
|
if which stty >/dev/null
|
||||||
if stty size >/dev/null
|
if stty size >/dev/null
|
||||||
stty size | cut -d' ' -f2
|
stty size | cut -d' ' -f2
|
||||||
@ -10,17 +10,6 @@ function powerline-setup
|
|||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
function _powerline_columns
|
|
||||||
# Hack: `test "" -eq 0` is true, as well as `test 0 -eq 0`
|
|
||||||
# Note: at fish startup `$COLUMNS` is equal to zero, meaning that it may
|
|
||||||
# not be used.
|
|
||||||
if test "$COLUMNS" -eq 0
|
|
||||||
_powerline_columns_fallback
|
|
||||||
else
|
|
||||||
echo "$COLUMNS"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if test -z "$POWERLINE_CONFIG_COMMAND"
|
if test -z "$POWERLINE_CONFIG_COMMAND"
|
||||||
if which powerline-config >/dev/null
|
if which powerline-config >/dev/null
|
||||||
set -g POWERLINE_CONFIG_COMMAND powerline-config
|
set -g POWERLINE_CONFIG_COMMAND powerline-config
|
||||||
@ -70,6 +59,8 @@ function powerline-setup
|
|||||||
env \$POWERLINE_COMMAND $POWERLINE_COMMAND_ARGS shell right $addargs
|
env \$POWERLINE_COMMAND $POWERLINE_COMMAND_ARGS shell right $addargs
|
||||||
$rpromptpast
|
$rpromptpast
|
||||||
end
|
end
|
||||||
|
function fish_mode_prompt
|
||||||
|
end
|
||||||
function _powerline_set_columns --on-signal WINCH
|
function _powerline_set_columns --on-signal WINCH
|
||||||
set -g _POWERLINE_COLUMNS $columnsexpr
|
set -g _POWERLINE_COLUMNS $columnsexpr
|
||||||
end
|
end
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
# vim:fileencoding=utf-8:noet
|
# vim:fileencoding=utf-8:noet
|
||||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
from __future__ import (unicode_literals, division,
|
||||||
|
absolute_import, print_function)
|
||||||
|
|
||||||
from weakref import ref
|
from weakref import ref
|
||||||
from warnings import warn
|
from warnings import warn
|
||||||
@ -80,7 +81,7 @@ if has_prompt_manager:
|
|||||||
if has_prompt_manager:
|
if has_prompt_manager:
|
||||||
renderer_module = '.pre_5'
|
renderer_module = '.pre_5'
|
||||||
else:
|
else:
|
||||||
renderer_module = '.since_5'
|
renderer_module = '.since_7'
|
||||||
super(ConfigurableIPythonPowerline, self).init(
|
super(ConfigurableIPythonPowerline, self).init(
|
||||||
renderer_module=renderer_module)
|
renderer_module=renderer_module)
|
||||||
|
|
||||||
@ -106,13 +107,15 @@ def load_ipython_extension(ip):
|
|||||||
powerline = ConfigurableIPythonPowerline(ip)
|
powerline = ConfigurableIPythonPowerline(ip)
|
||||||
powerline.setup(ip, shutdown_hook)
|
powerline.setup(ip, shutdown_hook)
|
||||||
else:
|
else:
|
||||||
from powerline.bindings.ipython.since_5 import PowerlinePrompts
|
from powerline.bindings.ipython.since_7 import PowerlinePrompts
|
||||||
ip.prompts_class = PowerlinePrompts
|
ip.prompts_class = PowerlinePrompts
|
||||||
ip.prompts = PowerlinePrompts(ip)
|
ip.prompts = PowerlinePrompts(ip)
|
||||||
warn(DeprecationWarning(
|
warn(DeprecationWarning(
|
||||||
'post_0_11 extension is deprecated since IPython 5, use\n'
|
'post_0_11 extension is deprecated since IPython 5, use\n'
|
||||||
' from powerline.bindings.ipython.since_5 import PowerlinePrompts\n'
|
' from powerline.bindings.ipython.since_7 import PowerlinePrompts\n'
|
||||||
' c.TerminalInteractiveShell.prompts_class = PowerlinePrompts\n'
|
' c.TerminalInteractiveShell.prompts_class = PowerlinePrompts\n'
|
||||||
|
'or check: \n'
|
||||||
|
'https://powerline.readthedocs.io/en/master/usage/other.html\n'
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
||||||
|
81
powerline/bindings/ipython/since_7.py
Normal file
81
powerline/bindings/ipython/since_7.py
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
# vim:fileencoding=utf-8:noet
|
||||||
|
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||||
|
|
||||||
|
from weakref import ref
|
||||||
|
|
||||||
|
from IPython.terminal.prompts import Prompts
|
||||||
|
from pygments.token import Token # NOQA
|
||||||
|
|
||||||
|
from powerline.ipython import IPythonPowerline
|
||||||
|
from powerline.renderers.ipython.since_7 import PowerlinePromptStyle
|
||||||
|
from powerline.bindings.ipython.post_0_11 import PowerlineMagics, ShutdownHook
|
||||||
|
|
||||||
|
|
||||||
|
class ConfigurableIPythonPowerline(IPythonPowerline):
|
||||||
|
def init(self, ip):
|
||||||
|
config = ip.config.Powerline
|
||||||
|
self.config_overrides = config.get('config_overrides')
|
||||||
|
self.theme_overrides = config.get('theme_overrides', {})
|
||||||
|
self.config_paths = config.get('config_paths')
|
||||||
|
super(ConfigurableIPythonPowerline, self).init(
|
||||||
|
renderer_module='.since_7')
|
||||||
|
|
||||||
|
def do_setup(self, ip, prompts, shutdown_hook):
|
||||||
|
prompts.powerline = self
|
||||||
|
|
||||||
|
msfn_missing = ()
|
||||||
|
saved_msfn = getattr(ip, '_make_style_from_name', msfn_missing)
|
||||||
|
|
||||||
|
if hasattr(saved_msfn, 'powerline_original'):
|
||||||
|
saved_msfn = saved_msfn.powerline_original
|
||||||
|
|
||||||
|
def _make_style_from_name(ip, name):
|
||||||
|
prev_style = saved_msfn(name)
|
||||||
|
new_style = PowerlinePromptStyle(lambda: prev_style)
|
||||||
|
return new_style
|
||||||
|
|
||||||
|
_make_style_from_name.powerline_original = saved_msfn
|
||||||
|
|
||||||
|
if not isinstance(ip._style, PowerlinePromptStyle):
|
||||||
|
prev_style = ip._style
|
||||||
|
ip._style = PowerlinePromptStyle(lambda: prev_style)
|
||||||
|
|
||||||
|
if not isinstance(saved_msfn, type(self.init)):
|
||||||
|
_saved_msfn = saved_msfn
|
||||||
|
saved_msfn = lambda: _saved_msfn(ip)
|
||||||
|
|
||||||
|
if saved_msfn is not msfn_missing:
|
||||||
|
ip._make_style_from_name = _make_style_from_name
|
||||||
|
|
||||||
|
magics = PowerlineMagics(ip, self)
|
||||||
|
ip.register_magics(magics)
|
||||||
|
|
||||||
|
if shutdown_hook:
|
||||||
|
shutdown_hook.powerline = ref(self)
|
||||||
|
|
||||||
|
|
||||||
|
class PowerlinePrompts(Prompts):
|
||||||
|
'''Class that returns powerline prompts
|
||||||
|
'''
|
||||||
|
def __init__(self, shell):
|
||||||
|
shutdown_hook = ShutdownHook(shell)
|
||||||
|
powerline = ConfigurableIPythonPowerline(shell)
|
||||||
|
self.shell = shell
|
||||||
|
powerline.do_setup(shell, self, shutdown_hook)
|
||||||
|
self.last_output_count = None
|
||||||
|
self.last_output = {}
|
||||||
|
|
||||||
|
for prompt in ('in', 'continuation', 'rewrite', 'out'):
|
||||||
|
exec((
|
||||||
|
'def {0}_prompt_tokens(self, *args, **kwargs):\n'
|
||||||
|
' if self.last_output_count != self.shell.execution_count:\n'
|
||||||
|
' self.last_output.clear()\n'
|
||||||
|
' self.last_output_count = self.shell.execution_count\n'
|
||||||
|
' if "{0}" not in self.last_output:\n'
|
||||||
|
' self.last_output["{0}"] = self.powerline.render('
|
||||||
|
' side="left",'
|
||||||
|
' matcher_info="{1}",'
|
||||||
|
' segment_info=self.shell,'
|
||||||
|
' ) + [(Token.Generic.Prompt, " ")]\n'
|
||||||
|
' return self.last_output["{0}"]'
|
||||||
|
).format(prompt, 'in2' if prompt == 'continuation' else prompt))
|
@ -22,7 +22,7 @@ if __name__ == '__main__':
|
|||||||
bars = []
|
bars = []
|
||||||
|
|
||||||
for screen in get_connected_xrandr_outputs(powerline.pl):
|
for screen in get_connected_xrandr_outputs(powerline.pl):
|
||||||
command = [args.bar_command, '-g', '{0}x{1}+{2}'.format(screen['width'], args.height, screen['x'])] + args.args[1:]
|
command = [args.bar_command, '-g', '{0}x{1}+{2}+{3}'.format(screen['width'], args.height, screen['x'], screen['y'])] + args.args[1:]
|
||||||
process = subprocess.Popen(command, stdin=subprocess.PIPE)
|
process = subprocess.Popen(command, stdin=subprocess.PIPE)
|
||||||
bars.append((screen['name'], process, int(screen['width']) / 5))
|
bars.append((screen['name'], process, int(screen['width']) / 5))
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
_POWERLINE_SOURCED="$_"
|
_POWERLINE_SOURCED="$_"
|
||||||
_powerline_columns_fallback() {
|
_powerline_columns_fallback() {
|
||||||
if which stty >/dev/null ; then
|
if command -v stty >/dev/null ; then
|
||||||
# Ksh does not have “local” built-in
|
# Ksh does not have “local” built-in
|
||||||
_powerline_cols="$(stty size 2>/dev/null)"
|
_powerline_cols="$(stty size 2>/dev/null)"
|
||||||
if ! test -z "$_powerline_cols" ; then
|
if ! test -z "$_powerline_cols" ; then
|
||||||
@ -220,7 +220,7 @@ _powerline_init_tmux_support() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if test -z "${POWERLINE_CONFIG_COMMAND}" ; then
|
if test -z "${POWERLINE_CONFIG_COMMAND}" ; then
|
||||||
if which powerline-config >/dev/null ; then
|
if command -v powerline-config >/dev/null ; then
|
||||||
POWERLINE_CONFIG_COMMAND=powerline-config
|
POWERLINE_CONFIG_COMMAND=powerline-config
|
||||||
else
|
else
|
||||||
POWERLINE_CONFIG_COMMAND="$(dirname "$_POWERLINE_SOURCED")/../../../scripts/powerline-config"
|
POWERLINE_CONFIG_COMMAND="$(dirname "$_POWERLINE_SOURCED")/../../../scripts/powerline-config"
|
||||||
|
@ -79,6 +79,7 @@ def get_tmux_version(pl):
|
|||||||
if version_string == 'master':
|
if version_string == 'master':
|
||||||
return TmuxVersionInfo(float('inf'), 0, version_string)
|
return TmuxVersionInfo(float('inf'), 0, version_string)
|
||||||
major, minor = version_string.split('.')
|
major, minor = version_string.split('.')
|
||||||
|
major = NON_DIGITS.subn('', major)[0]
|
||||||
suffix = DIGITS.subn('', minor)[0] or None
|
suffix = DIGITS.subn('', minor)[0] or None
|
||||||
minor = NON_DIGITS.subn('', minor)[0]
|
minor = NON_DIGITS.subn('', minor)[0]
|
||||||
return TmuxVersionInfo(int(major), int(minor), suffix)
|
return TmuxVersionInfo(int(major), int(minor), suffix)
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
set -g status on
|
set -g status on
|
||||||
set -g status-interval 2
|
set -g status-interval 2
|
||||||
set -g status-left-length 20
|
set -g status-left-length 20
|
||||||
set -g status-right '#(env "$POWERLINE_COMMAND" $POWERLINE_COMMAND_ARGS tmux right -R pane_id=\"`tmux display -p "#""D"`\")'
|
set -g status-right '#(env "$POWERLINE_COMMAND" $POWERLINE_COMMAND_ARGS tmux right -R pane_id=#{pane_id})'
|
||||||
set -g status-right-length 150
|
set -g status-right-length 150
|
||||||
set -g window-status-format "#[$_POWERLINE_WINDOW_COLOR]$_POWERLINE_LEFT_HARD_DIVIDER_SPACES#I#F #[$_POWERLINE_WINDOW_DIVIDER_COLOR]$_POWERLINE_LEFT_SOFT_DIVIDER#[default]#W $_POWERLINE_LEFT_HARD_DIVIDER_SPACES"
|
set -g window-status-format "#[$_POWERLINE_WINDOW_COLOR]$_POWERLINE_LEFT_HARD_DIVIDER_SPACES#I#F #[$_POWERLINE_WINDOW_DIVIDER_COLOR]$_POWERLINE_LEFT_SOFT_DIVIDER#[default]#W $_POWERLINE_LEFT_HARD_DIVIDER_SPACES"
|
||||||
set -g window-status-current-format "#[$_POWERLINE_WINDOW_CURRENT_HARD_DIVIDER_COLOR]$_POWERLINE_LEFT_HARD_DIVIDER#[$_POWERLINE_WINDOW_CURRENT_COLOR]#I#F $_POWERLINE_LEFT_SOFT_DIVIDER#[$_POWERLINE_WINDOW_NAME_COLOR]#W #[$_POWERLINE_WINDOW_CURRENT_HARD_DIVIDER_NEXT_COLOR]$_POWERLINE_LEFT_HARD_DIVIDER"
|
set -g window-status-current-format "#[$_POWERLINE_WINDOW_CURRENT_HARD_DIVIDER_COLOR]$_POWERLINE_LEFT_HARD_DIVIDER#[$_POWERLINE_WINDOW_CURRENT_COLOR]#I#F $_POWERLINE_LEFT_SOFT_DIVIDER#[$_POWERLINE_WINDOW_NAME_COLOR]#W #[$_POWERLINE_WINDOW_CURRENT_HARD_DIVIDER_NEXT_COLOR]$_POWERLINE_LEFT_HARD_DIVIDER"
|
||||||
|
|
||||||
# Legacy status-left definition to be overwritten for tmux Versions 1.8+
|
# Legacy status-left definition to be overwritten for tmux Versions 1.8+
|
||||||
set -g status-left "#[$_POWERLINE_SESSION_COLOR] #S #[$_POWERLINE_SESSION_HARD_DIVIDER_NEXT_COLOR]$_POWERLINE_LEFT_HARD_DIVIDER#(env \"\$POWERLINE_COMMAND\" tmux left -R pane_id=\"`tmux display -p '#''D'`\")"
|
set -g status-left "#[$_POWERLINE_SESSION_COLOR] #S #[$_POWERLINE_SESSION_HARD_DIVIDER_NEXT_COLOR]$_POWERLINE_LEFT_HARD_DIVIDER#(env \"\$POWERLINE_COMMAND\" tmux left -R pane_id=#{pane_id})"
|
||||||
# vim: ft=tmux
|
# vim: ft=tmux
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
set -g status-right '#(env "$POWERLINE_COMMAND" $POWERLINE_COMMAND_ARGS tmux right -R pane_id="`tmux display -p "#""D"`" --width=`tmux display -p "#""{client_width}"` -R width_adjust=`tmux show-options -g status-left-length | cut -d" " -f 2`)'
|
set -g status-right '#(env "$POWERLINE_COMMAND" $POWERLINE_COMMAND_ARGS tmux right -R pane_id=#{pane_id} --width=#{client_width} -R width_adjust=#{status-left-length})'
|
||||||
set -g status-left "#[$_POWERLINE_SESSION_COLOR] #S #[$_POWERLINE_SESSION_HARD_DIVIDER_NEXT_COLOR]$_POWERLINE_LEFT_HARD_DIVIDER#(env \"\$POWERLINE_COMMAND\" tmux left --width=`tmux display -p '#''{client_width}'` -R width_adjust=`tmux show-options -g status-right-length | cut -d' ' -f2` -R pane_id=\"`tmux display -p '#''D'`\")"
|
set -g status-left "#[$_POWERLINE_SESSION_COLOR] #S #[$_POWERLINE_SESSION_HARD_DIVIDER_NEXT_COLOR]$_POWERLINE_LEFT_HARD_DIVIDER#(env \"\$POWERLINE_COMMAND\" tmux left --width=#{client_width} -R width_adjust=#{status-right-length} -R pane_id=#{pane_id})"
|
||||||
# vim: ft=tmux
|
# vim: ft=tmux
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# powerline_tmux_1.8_plus.conf
|
# powerline_tmux_1.8_plus.conf
|
||||||
# tmux Version 1.8 introduces the 'client_prefix' format variable, applicable
|
# tmux Version 1.8 introduces the 'client_prefix' format variable, applicable
|
||||||
# for versions 1.8+
|
# for versions 1.8+
|
||||||
set -qg status-left "#{?client_prefix,#[fg=$_POWERLINE_SESSION_PREFIX_FG]#[bg=$_POWERLINE_SESSION_PREFIX_BG]#[$_POWERLINE_SESSION_PREFIX_ATTR],#[fg=$_POWERLINE_SESSION_FG]#[bg=$_POWERLINE_SESSION_BG]#[$_POWERLINE_SESSION_ATTR]} #S #{?client_prefix,#[fg=$_POWERLINE_SESSION_PREFIX_BG],#[fg=$_POWERLINE_SESSION_BG]}#[bg=$_POWERLINE_BACKGROUND_BG]#[nobold]$_POWERLINE_LEFT_HARD_DIVIDER#(env \$POWERLINE_COMMAND \$POWERLINE_COMMAND_ARGS tmux left --width=`tmux display -p '#''{client_width}'` -R width_adjust=`tmux show-options -g status-right-length | cut -d' ' -f2` -R pane_id=\"`tmux display -p '#''D'`\")"
|
set -qg status-left "#{?client_prefix,#[fg=$_POWERLINE_SESSION_PREFIX_FG]#[bg=$_POWERLINE_SESSION_PREFIX_BG]#[$_POWERLINE_SESSION_PREFIX_ATTR],#[fg=$_POWERLINE_SESSION_FG]#[bg=$_POWERLINE_SESSION_BG]#[$_POWERLINE_SESSION_ATTR]} #S #{?client_prefix,#[fg=$_POWERLINE_SESSION_PREFIX_BG],#[fg=$_POWERLINE_SESSION_BG]}#[bg=$_POWERLINE_BACKGROUND_BG]#[nobold]$_POWERLINE_LEFT_HARD_DIVIDER#(env \$POWERLINE_COMMAND \$POWERLINE_COMMAND_ARGS tmux left --width=#{client_width} -R width_adjust=#{status-right-length} -R pane_id=#{pane_id})"
|
||||||
# vim: ft=tmux
|
# vim: ft=tmux
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
# Starting from tmux-2.1 escaping of dollar signs inside #() is harmful
|
# Starting from tmux-2.1 escaping of dollar signs inside #() is harmful
|
||||||
set -qg status-left "#{?client_prefix,#[fg=$_POWERLINE_SESSION_PREFIX_FG]#[bg=$_POWERLINE_SESSION_PREFIX_BG]#[$_POWERLINE_SESSION_PREFIX_ATTR],#[fg=$_POWERLINE_SESSION_FG]#[bg=$_POWERLINE_SESSION_BG]#[$_POWERLINE_SESSION_ATTR]} #S #{?client_prefix,#[fg=$_POWERLINE_SESSION_PREFIX_BG],#[fg=$_POWERLINE_SESSION_BG]}#[bg=$_POWERLINE_BACKGROUND_BG]#[nobold]$_POWERLINE_LEFT_HARD_DIVIDER#(env $POWERLINE_COMMAND $POWERLINE_COMMAND_ARGS tmux left --width=`tmux display -p '#''{client_width}'` -R width_adjust=`tmux show-options -g status-right-length | cut -d' ' -f2` -R pane_id=\"`tmux display -p '#''D'`\")"
|
set -qg status-left "#{?client_prefix,#[fg=$_POWERLINE_SESSION_PREFIX_FG]#[bg=$_POWERLINE_SESSION_PREFIX_BG]#[$_POWERLINE_SESSION_PREFIX_ATTR],#[fg=$_POWERLINE_SESSION_FG]#[bg=$_POWERLINE_SESSION_BG]#[$_POWERLINE_SESSION_ATTR]} #S #{?client_prefix,#[fg=$_POWERLINE_SESSION_PREFIX_BG],#[fg=$_POWERLINE_SESSION_BG]}#[bg=$_POWERLINE_BACKGROUND_BG]#[nobold]$_POWERLINE_LEFT_HARD_DIVIDER#(env $POWERLINE_COMMAND $POWERLINE_COMMAND_ARGS tmux left --width=#{client_width} -R width_adjust=#{status-right-length} -R pane_id=#{pane_id})"
|
||||||
set -g window-status-format "#[$_POWERLINE_WINDOW_COLOR]$_POWERLINE_LEFT_HARD_DIVIDER_SPACES#I#{?window_flags,#F, } #[$_POWERLINE_WINDOW_DIVIDER_COLOR]$_POWERLINE_LEFT_SOFT_DIVIDER#[default]#W $_POWERLINE_LEFT_HARD_DIVIDER_SPACES"
|
set -g window-status-format "#[$_POWERLINE_WINDOW_COLOR]$_POWERLINE_LEFT_HARD_DIVIDER_SPACES#I#{?window_flags,#F, } #[$_POWERLINE_WINDOW_DIVIDER_COLOR]$_POWERLINE_LEFT_SOFT_DIVIDER#[default]#W $_POWERLINE_LEFT_HARD_DIVIDER_SPACES"
|
||||||
|
@ -47,7 +47,7 @@ def get_argparser(ArgumentParser=ConfigArgParser):
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-p', '--config-path', action='append', metavar='PATH',
|
'-p', '--config-path', action='append', metavar='PATH',
|
||||||
help='Path to configuration directory. If it is present '
|
help='Path to configuration directory. If it is present '
|
||||||
'then configuration files will only be seeked in the provided path. '
|
'then configuration files will only be sought in the provided path. '
|
||||||
'May be provided multiple times to search in a list of directories.'
|
'May be provided multiple times to search in a list of directories.'
|
||||||
)
|
)
|
||||||
subparsers = parser.add_subparsers()
|
subparsers = parser.add_subparsers()
|
||||||
|
@ -146,13 +146,13 @@ def get_argparser(ArgumentParser=argparse.ArgumentParser):
|
|||||||
help='Like above, but provides argument for renderer. Is supposed '
|
help='Like above, but provides argument for renderer. Is supposed '
|
||||||
'to be used only by shell bindings to provide various data like '
|
'to be used only by shell bindings to provide various data like '
|
||||||
'last-exit-code or last-pipe-status (they are not using '
|
'last-exit-code or last-pipe-status (they are not using '
|
||||||
'`--renderer-arg\' for historical resons: `--renderer-arg\' '
|
'`--renderer-arg\' for historical reasons: `--renderer-arg\' '
|
||||||
'was added later).'
|
'was added later).'
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-p', '--config-path', action='append', metavar='PATH',
|
'-p', '--config-path', action='append', metavar='PATH',
|
||||||
help='Path to configuration directory. If it is present then '
|
help='Path to configuration directory. If it is present then '
|
||||||
'configuration files will only be seeked in the provided path. '
|
'configuration files will only be sought in the provided path. '
|
||||||
'May be provided multiple times to search in a list of directories.'
|
'May be provided multiple times to search in a list of directories.'
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
"critical:failure": { "fg": "solarized:base3", "bg": "solarized:red", "attrs": [] },
|
"critical:failure": { "fg": "solarized:base3", "bg": "solarized:red", "attrs": [] },
|
||||||
"critical:success": { "fg": "solarized:base3", "bg": "solarized:green", "attrs": [] },
|
"critical:success": { "fg": "solarized:base3", "bg": "solarized:green", "attrs": [] },
|
||||||
"background": { "fg": "solarized:base3", "bg": "solarized:base02", "attrs": [] },
|
"background": { "fg": "solarized:base3", "bg": "solarized:base02", "attrs": [] },
|
||||||
"background:divider": { "fg": "solarized:base1", "bg": "solarized:base02", "attrs": [] },
|
"background:divider": { "fg": "solarized:base1", "bg": "solarized:base03", "attrs": [] },
|
||||||
"user": { "fg": "solarized:base3", "bg": "solarized:blue", "attrs": ["bold"] },
|
"user": { "fg": "solarized:base3", "bg": "solarized:blue", "attrs": ["bold"] },
|
||||||
"virtualenv": { "fg": "solarized:base3", "bg": "solarized:green", "attrs": [] },
|
"virtualenv": { "fg": "solarized:base3", "bg": "solarized:green", "attrs": [] },
|
||||||
"branch": { "fg": "solarized:base1", "bg": "solarized:base02", "attrs": [] },
|
"branch": { "fg": "solarized:base1", "bg": "solarized:base02", "attrs": [] },
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
"file_size": "information:unimportant",
|
"file_size": "information:unimportant",
|
||||||
"file_format": "information:unimportant",
|
"file_format": "information:unimportant",
|
||||||
"file_encoding": "file_format",
|
"file_encoding": "file_format",
|
||||||
|
"file_bom": "file_format",
|
||||||
"file_type": "file_format",
|
"file_type": "file_format",
|
||||||
"branch": "information:additional",
|
"branch": "information:additional",
|
||||||
"file_scheme": "file_name",
|
"file_scheme": "file_name",
|
||||||
|
@ -227,7 +227,7 @@ _strwidth_documentation = (
|
|||||||
character sets because they have explicit fullwidth or wide
|
character sets because they have explicit fullwidth or wide
|
||||||
counterparts. All of ASCII is an example of East Asian
|
counterparts. All of ASCII is an example of East Asian
|
||||||
Narrow characters.
|
Narrow characters.
|
||||||
A 1 or 2 Ambigious: characters that may sometimes be wide and
|
A 1 or 2 Ambiguous: characters that may sometimes be wide and
|
||||||
sometimes narrow. Ambiguous characters require additional
|
sometimes narrow. Ambiguous characters require additional
|
||||||
information not contained in the character code to further
|
information not contained in the character code to further
|
||||||
resolve their width. This information is usually defined in
|
resolve their width. This information is usually defined in
|
||||||
|
@ -154,7 +154,7 @@ def get_file_status(directory, dirstate_file, file_path, ignore_file_name, get_f
|
|||||||
except OSError as e:
|
except OSError as e:
|
||||||
if getattr(e, 'errno', None) != errno.ENOENT:
|
if getattr(e, 'errno', None) != errno.ENOENT:
|
||||||
raise
|
raise
|
||||||
# Do not call get_func again for a non-existant file
|
# Do not call get_func again for a non-existent file
|
||||||
if keypath not in file_status_cache:
|
if keypath not in file_status_cache:
|
||||||
file_status_cache[keypath] = get_func(directory, file_path)
|
file_status_cache[keypath] = get_func(directory, file_path)
|
||||||
return file_status_cache[keypath]
|
return file_status_cache[keypath]
|
||||||
|
@ -171,7 +171,7 @@ except ImportError:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def ignore_event(path, name):
|
def ignore_event(path, name):
|
||||||
# Ignore changes to the index.lock file, since they happen
|
# Ignore changes to the index.lock file, since they happen
|
||||||
# frequently and dont indicate an actual change in the working tree
|
# frequently and don't indicate an actual change in the working tree
|
||||||
# status
|
# status
|
||||||
return path.endswith('.git') and name == 'index.lock'
|
return path.endswith('.git') and name == 'index.lock'
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ class INotifyFileWatcher(INotify):
|
|||||||
|
|
||||||
def process_event(self, wd, mask, cookie, name):
|
def process_event(self, wd, mask, cookie, name):
|
||||||
if wd == -1 and (mask & self.Q_OVERFLOW):
|
if wd == -1 and (mask & self.Q_OVERFLOW):
|
||||||
# We missed some INOTIFY events, so we dont
|
# We missed some INOTIFY events, so we don't
|
||||||
# know the state of any tracked files.
|
# know the state of any tracked files.
|
||||||
for path in tuple(self.modified):
|
for path in tuple(self.modified):
|
||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
@ -114,7 +114,7 @@ class INotifyFileWatcher(INotify):
|
|||||||
self.expire_watches()
|
self.expire_watches()
|
||||||
if path not in self.watches:
|
if path not in self.watches:
|
||||||
# Try to re-add the watch, it will fail if the file does not
|
# Try to re-add the watch, it will fail if the file does not
|
||||||
# exist/you dont have permission
|
# exist/you don't have permission
|
||||||
self.watch(path)
|
self.watch(path)
|
||||||
return True
|
return True
|
||||||
self.read(get_name=False)
|
self.read(get_name=False)
|
||||||
@ -187,7 +187,7 @@ class INotifyTreeWatcher(INotify):
|
|||||||
raise NoSuchDir('The dir {0} does not exist'.format(base))
|
raise NoSuchDir('The dir {0} does not exist'.format(base))
|
||||||
return
|
return
|
||||||
if e.errno == errno.EACCES:
|
if e.errno == errno.EACCES:
|
||||||
# We silently ignore entries for which we dont have permission,
|
# We silently ignore entries for which we don't have permission,
|
||||||
# unless they are the top level dir
|
# unless they are the top level dir
|
||||||
if top_level:
|
if top_level:
|
||||||
raise NoSuchDir('You do not have permission to monitor {0}'.format(base))
|
raise NoSuchDir('You do not have permission to monitor {0}'.format(base))
|
||||||
@ -235,7 +235,7 @@ class INotifyTreeWatcher(INotify):
|
|||||||
|
|
||||||
def process_event(self, wd, mask, cookie, name):
|
def process_event(self, wd, mask, cookie, name):
|
||||||
if wd == -1 and (mask & self.Q_OVERFLOW):
|
if wd == -1 and (mask & self.Q_OVERFLOW):
|
||||||
# We missed some INOTIFY events, so we dont
|
# We missed some INOTIFY events, so we don't
|
||||||
# know the state of any tracked dirs.
|
# know the state of any tracked dirs.
|
||||||
self.watch_tree()
|
self.watch_tree()
|
||||||
self.modified = True
|
self.modified = True
|
||||||
|
@ -401,7 +401,7 @@ def check_segment_function(function_name, data, context, echoerr):
|
|||||||
context='Error while checking theme (key {key})'.format(key=context.key),
|
context='Error while checking theme (key {key})'.format(key=context.key),
|
||||||
context_mark=function_name.mark,
|
context_mark=function_name.mark,
|
||||||
problem=(
|
problem=(
|
||||||
'found highlight group definition in addition to sentense stating that '
|
'found highlight group definition in addition to sentence stating that '
|
||||||
'no highlight groups are used'
|
'no highlight groups are used'
|
||||||
),
|
),
|
||||||
problem_mark=mark,
|
problem_mark=mark,
|
||||||
@ -425,7 +425,7 @@ def check_segment_function(function_name, data, context, echoerr):
|
|||||||
context='Error while checking theme (key {key})'.format(key=context.key),
|
context='Error while checking theme (key {key})'.format(key=context.key),
|
||||||
context_mark=function_name.mark,
|
context_mark=function_name.mark,
|
||||||
problem=(
|
problem=(
|
||||||
'found sentense stating that no highlight groups are used '
|
'found sentence stating that no highlight groups are used '
|
||||||
'in addition to highlight group definition'
|
'in addition to highlight group definition'
|
||||||
),
|
),
|
||||||
problem_mark=mark,
|
problem_mark=mark,
|
||||||
|
@ -264,7 +264,7 @@ class Spec(object):
|
|||||||
:param func msg_func:
|
:param func msg_func:
|
||||||
Callable like ``msg_func`` from :py:meth:`Spec.check_func`. Should
|
Callable like ``msg_func`` from :py:meth:`Spec.check_func`. Should
|
||||||
accept one problematic item and is not used for :py:class:`Spec`
|
accept one problematic item and is not used for :py:class:`Spec`
|
||||||
object indicies in ``item_func`` method.
|
object indices in ``item_func`` method.
|
||||||
|
|
||||||
:return: proceed, hadproblem.
|
:return: proceed, hadproblem.
|
||||||
'''
|
'''
|
||||||
@ -515,7 +515,7 @@ class Spec(object):
|
|||||||
optional. Each element in this list describes element with the same
|
optional. Each element in this list describes element with the same
|
||||||
index in the checked value. Check out :py:meth:`Spec.check_tuple`
|
index in the checked value. Check out :py:meth:`Spec.check_tuple`
|
||||||
for more details, but note that there list of specifications is
|
for more details, but note that there list of specifications is
|
||||||
replaced with start and end indicies in ``self.specs``.
|
replaced with start and end indices in ``self.specs``.
|
||||||
|
|
||||||
:return: self.
|
:return: self.
|
||||||
'''
|
'''
|
||||||
@ -633,7 +633,7 @@ class Spec(object):
|
|||||||
|
|
||||||
Check out :py:meth:`Spec.check_either` method documentation for more
|
Check out :py:meth:`Spec.check_either` method documentation for more
|
||||||
details, but note that there a list of specs was replaced by start and
|
details, but note that there a list of specs was replaced by start and
|
||||||
end indicies in ``self.specs``.
|
end indices in ``self.specs``.
|
||||||
|
|
||||||
:return: self.
|
:return: self.
|
||||||
'''
|
'''
|
||||||
|
@ -114,7 +114,7 @@ class Renderer(object):
|
|||||||
Object used for logging.
|
Object used for logging.
|
||||||
:param int ambiwidth:
|
:param int ambiwidth:
|
||||||
Width of the characters with east asian width unicode attribute equal to
|
Width of the characters with east asian width unicode attribute equal to
|
||||||
``A`` (Ambigious).
|
``A`` (Ambiguous).
|
||||||
:param dict options:
|
:param dict options:
|
||||||
Various options. Are normally not used by base renderer, but all options
|
Various options. Are normally not used by base renderer, but all options
|
||||||
are recorded as attributes.
|
are recorded as attributes.
|
||||||
@ -173,7 +173,7 @@ class Renderer(object):
|
|||||||
self.width_data = {
|
self.width_data = {
|
||||||
'N': 1, # Neutral
|
'N': 1, # Neutral
|
||||||
'Na': 1, # Narrow
|
'Na': 1, # Narrow
|
||||||
'A': ambiwidth, # Ambigious
|
'A': ambiwidth, # Ambiguous
|
||||||
'H': 1, # Half-width
|
'H': 1, # Half-width
|
||||||
'W': 2, # Wide
|
'W': 2, # Wide
|
||||||
'F': 2, # Fullwidth
|
'F': 2, # Fullwidth
|
||||||
@ -356,7 +356,7 @@ class Renderer(object):
|
|||||||
segments_priority = iter(segments_priority)
|
segments_priority = iter(segments_priority)
|
||||||
if current_width > width and len(segments) > 100:
|
if current_width > width and len(segments) > 100:
|
||||||
# When there are too many segments use faster, but less correct
|
# When there are too many segments use faster, but less correct
|
||||||
# algorythm for width computation
|
# algorithm for width computation
|
||||||
diff = current_width - width
|
diff = current_width - width
|
||||||
for segment in segments_priority:
|
for segment in segments_priority:
|
||||||
segments.remove(segment)
|
segments.remove(segment)
|
||||||
|
@ -21,7 +21,7 @@ class I3barRenderer(Renderer):
|
|||||||
segment = {
|
segment = {
|
||||||
'full_text': contents,
|
'full_text': contents,
|
||||||
'separator': False,
|
'separator': False,
|
||||||
'separator_block_width': 0, # no seperators
|
'separator_block_width': 0, # no separators
|
||||||
}
|
}
|
||||||
|
|
||||||
if fg is not None:
|
if fg is not None:
|
||||||
|
91
powerline/renderers/ipython/since_7.py
Normal file
91
powerline/renderers/ipython/since_7.py
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
# vim:fileencoding=utf-8:noet
|
||||||
|
import operator
|
||||||
|
|
||||||
|
try:
|
||||||
|
from __builtin__ import reduce
|
||||||
|
except ImportError:
|
||||||
|
from functools import reduce
|
||||||
|
|
||||||
|
from pygments.token import Token
|
||||||
|
from prompt_toolkit.styles import DynamicStyle
|
||||||
|
|
||||||
|
from powerline.renderers.ipython import IPythonRenderer
|
||||||
|
from powerline.ipython import IPythonInfo
|
||||||
|
from powerline.colorscheme import ATTR_BOLD, ATTR_ITALIC, ATTR_UNDERLINE
|
||||||
|
|
||||||
|
used_styles = []
|
||||||
|
seen = set()
|
||||||
|
|
||||||
|
class PowerlinePromptStyle(DynamicStyle):
|
||||||
|
@property
|
||||||
|
def style_rules(self):
|
||||||
|
return (self.get_style() or self._dummy).style_rules + used_styles
|
||||||
|
|
||||||
|
def invalidation_hash(self):
|
||||||
|
return (h + 1 for h in tuple(super(PowerlinePromptStyle, self).invalidation_hash()))
|
||||||
|
|
||||||
|
|
||||||
|
class IPythonPygmentsRenderer(IPythonRenderer):
|
||||||
|
reduce_initial = []
|
||||||
|
|
||||||
|
def __init__(self, **kwargs):
|
||||||
|
super(IPythonPygmentsRenderer, self).__init__(**kwargs)
|
||||||
|
self.character_translations[ord(' ')] = ' '
|
||||||
|
|
||||||
|
def get_segment_info(self, segment_info, mode):
|
||||||
|
return super(IPythonPygmentsRenderer, self).get_segment_info(
|
||||||
|
IPythonInfo(segment_info), mode)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def hl_join(segments):
|
||||||
|
return reduce(operator.iadd, segments, [])
|
||||||
|
|
||||||
|
def hl(self, escaped_contents, fg=None, bg=None, attrs=None, *args, **kwargs):
|
||||||
|
'''Output highlighted chunk.
|
||||||
|
|
||||||
|
This implementation outputs a list containing a single pair
|
||||||
|
(:py:class:`string`,
|
||||||
|
:py:class:`powerline.lib.unicode.unicode`).
|
||||||
|
'''
|
||||||
|
guifg = None
|
||||||
|
guibg = None
|
||||||
|
att = []
|
||||||
|
if fg is not None and fg is not False:
|
||||||
|
guifg = fg[1]
|
||||||
|
if bg is not None and bg is not False:
|
||||||
|
guibg = bg[1]
|
||||||
|
if attrs:
|
||||||
|
att = []
|
||||||
|
if attrs & ATTR_BOLD:
|
||||||
|
att.append('bold')
|
||||||
|
if attrs & ATTR_ITALIC:
|
||||||
|
att.append('italic')
|
||||||
|
if attrs & ATTR_UNDERLINE:
|
||||||
|
att.append('underline')
|
||||||
|
|
||||||
|
fg = (('%06x' % guifg) if guifg is not None else '')
|
||||||
|
bg = (('%06x' % guibg) if guibg is not None else '')
|
||||||
|
name = (
|
||||||
|
'pl'
|
||||||
|
+ ''.join(('_a' + attr for attr in att))
|
||||||
|
+ '_f' + fg + '_b' + bg
|
||||||
|
)
|
||||||
|
|
||||||
|
global seen
|
||||||
|
if not (name in seen):
|
||||||
|
global used_styles
|
||||||
|
used_styles += [('pygments.' + name,
|
||||||
|
''.join((' ' + attr for attr in att))
|
||||||
|
+ (' fg:#' + fg if fg != '' else ' fg:')
|
||||||
|
+ (' bg:#' + bg if bg != '' else ' bg:'))]
|
||||||
|
seen.add(name)
|
||||||
|
return [((name,), escaped_contents)]
|
||||||
|
|
||||||
|
def hlstyle(self, *args, **kwargs):
|
||||||
|
return []
|
||||||
|
|
||||||
|
def get_client_id(self, segment_info):
|
||||||
|
return id(self)
|
||||||
|
|
||||||
|
|
||||||
|
renderer = IPythonPygmentsRenderer
|
@ -2,6 +2,7 @@
|
|||||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
import re
|
||||||
|
|
||||||
from powerline.lib.shell import asrun, run_cmd
|
from powerline.lib.shell import asrun, run_cmd
|
||||||
from powerline.lib.unicode import out_u
|
from powerline.lib.unicode import out_u
|
||||||
@ -160,7 +161,7 @@ class CmusPlayerSegment(PlayerSegment):
|
|||||||
cmus = with_docstring(CmusPlayerSegment(),
|
cmus = with_docstring(CmusPlayerSegment(),
|
||||||
('''Return CMUS player information
|
('''Return CMUS player information
|
||||||
|
|
||||||
Requires cmus-remote command be acessible from $PATH.
|
Requires cmus-remote command be accessible from $PATH.
|
||||||
|
|
||||||
{0}
|
{0}
|
||||||
''').format(_common_args.format('cmus')))
|
''').format(_common_args.format('cmus')))
|
||||||
@ -174,19 +175,29 @@ class MpdPlayerSegment(PlayerSegment):
|
|||||||
if password:
|
if password:
|
||||||
host = password + '@' + host
|
host = password + '@' + host
|
||||||
now_playing = run_cmd(pl, [
|
now_playing = run_cmd(pl, [
|
||||||
'mpc', 'current',
|
'mpc',
|
||||||
'-f', '%album%\n%artist%\n%title%\n%time%',
|
|
||||||
'-h', host,
|
'-h', host,
|
||||||
'-p', str(port)
|
'-p', str(port)
|
||||||
], strip=False)
|
], strip=False)
|
||||||
if not now_playing:
|
album = run_cmd(pl, [
|
||||||
|
'mpc', 'current',
|
||||||
|
'-f', '%album%',
|
||||||
|
'-h', host,
|
||||||
|
'-p', str(port)
|
||||||
|
])
|
||||||
|
if not now_playing or now_playing.count("\n") != 3:
|
||||||
return
|
return
|
||||||
now_playing = now_playing.split('\n')
|
now_playing = re.match(
|
||||||
|
r"(.*) - (.*)\n\[([a-z]+)\] +[#0-9\/]+ +([0-9\:]+)\/([0-9\:]+)",
|
||||||
|
now_playing
|
||||||
|
)
|
||||||
return {
|
return {
|
||||||
'album': now_playing[0],
|
'state': _convert_state(now_playing[3]),
|
||||||
|
'album': album,
|
||||||
'artist': now_playing[1],
|
'artist': now_playing[1],
|
||||||
'title': now_playing[2],
|
'title': now_playing[2],
|
||||||
'total': now_playing[3],
|
'elapsed': now_playing[4],
|
||||||
|
'total': now_playing[5]
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
@ -217,7 +228,7 @@ mpd = with_docstring(MpdPlayerSegment(),
|
|||||||
('''Return Music Player Daemon information
|
('''Return Music Player Daemon information
|
||||||
|
|
||||||
Requires ``mpd`` Python module (e.g. |python-mpd2|_ or |python-mpd|_ Python
|
Requires ``mpd`` Python module (e.g. |python-mpd2|_ or |python-mpd|_ Python
|
||||||
package) or alternatively the ``mpc`` command to be acessible from $PATH.
|
package) or alternatively the ``mpc`` command to be accessible from $PATH.
|
||||||
|
|
||||||
.. |python-mpd| replace:: ``python-mpd``
|
.. |python-mpd| replace:: ``python-mpd``
|
||||||
.. _python-mpd: https://pypi.python.org/pypi/python-mpd
|
.. _python-mpd: https://pypi.python.org/pypi/python-mpd
|
||||||
@ -242,9 +253,20 @@ except ImportError:
|
|||||||
pl.error('Could not add {0} segment: requires dbus module', player_name)
|
pl.error('Could not add {0} segment: requires dbus module', player_name)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
def _get_dbus_player_status(pl, bus_name, player_path, iface_prop,
|
def _get_dbus_player_status(pl,
|
||||||
iface_player, player_name='player'):
|
bus_name=None,
|
||||||
|
iface_prop='org.freedesktop.DBus.Properties',
|
||||||
|
iface_player='org.mpris.MediaPlayer2.Player',
|
||||||
|
player_path='/org/mpris/MediaPlayer2',
|
||||||
|
player_name='player'):
|
||||||
bus = dbus.SessionBus()
|
bus = dbus.SessionBus()
|
||||||
|
|
||||||
|
if bus_name is None:
|
||||||
|
for service in bus.list_names():
|
||||||
|
if re.match('org.mpris.MediaPlayer2.', service):
|
||||||
|
bus_name = service
|
||||||
|
break
|
||||||
|
|
||||||
try:
|
try:
|
||||||
player = bus.get_object(bus_name, player_path)
|
player = bus.get_object(bus_name, player_path)
|
||||||
iface = dbus.Interface(player, iface_prop)
|
iface = dbus.Interface(player, iface_prop)
|
||||||
@ -272,13 +294,19 @@ else:
|
|||||||
title = out_u(title)
|
title = out_u(title)
|
||||||
if artist:
|
if artist:
|
||||||
artist = out_u(artist[0])
|
artist = out_u(artist[0])
|
||||||
|
|
||||||
|
length = info.get('mpris:length')
|
||||||
|
# avoid parsing `None` length values, that would
|
||||||
|
# raise an error otherwise
|
||||||
|
parsed_length = length and _convert_seconds(length / 1e6)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'state': state,
|
'state': state,
|
||||||
'album': album,
|
'album': album,
|
||||||
'artist': artist,
|
'artist': artist,
|
||||||
'title': title,
|
'title': title,
|
||||||
'elapsed': elapsed,
|
'elapsed': elapsed,
|
||||||
'total': _convert_seconds(info.get('mpris:length') / 1e6),
|
'total': parsed_length,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -604,4 +632,3 @@ Requires version >= 2.3.0 and ``mocp`` executable in ``$PATH``.
|
|||||||
|
|
||||||
{0}
|
{0}
|
||||||
''').format(_common_args.format('mocp')))
|
''').format(_common_args.format('mocp')))
|
||||||
|
|
||||||
|
@ -21,22 +21,40 @@ def jobnum(pl, segment_info, show_zero=False):
|
|||||||
else:
|
else:
|
||||||
return str(jobnum)
|
return str(jobnum)
|
||||||
|
|
||||||
|
try:
|
||||||
|
import signal
|
||||||
|
exit_codes = dict((k, v) for v, k in reversed(sorted(signal.__dict__.items())) \
|
||||||
|
if v.startswith('SIG') and not v.startswith('SIG_'))
|
||||||
|
except ImportError:
|
||||||
|
exit_codes = dict()
|
||||||
|
|
||||||
@requires_segment_info
|
@requires_segment_info
|
||||||
def last_status(pl, segment_info):
|
def last_status(pl, segment_info, signal_names=True):
|
||||||
'''Return last exit code.
|
'''Return last exit code.
|
||||||
|
|
||||||
|
:param bool signal_names:
|
||||||
|
If True (default), translate signal numbers to human-readable names.
|
||||||
|
|
||||||
Highlight groups used: ``exit_fail``
|
Highlight groups used: ``exit_fail``
|
||||||
'''
|
'''
|
||||||
if not segment_info['args'].last_exit_code:
|
if not segment_info['args'].last_exit_code:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
try:
|
||||||
|
if signal_names and segment_info['args'].last_exit_code - 128 in exit_codes:
|
||||||
|
return [{'contents': exit_codes[segment_info['args'].last_exit_code - 128], 'highlight_groups': ['exit_fail']}]
|
||||||
|
except TypeError:
|
||||||
|
pass
|
||||||
return [{'contents': str(segment_info['args'].last_exit_code), 'highlight_groups': ['exit_fail']}]
|
return [{'contents': str(segment_info['args'].last_exit_code), 'highlight_groups': ['exit_fail']}]
|
||||||
|
|
||||||
|
|
||||||
@requires_segment_info
|
@requires_segment_info
|
||||||
def last_pipe_status(pl, segment_info):
|
def last_pipe_status(pl, segment_info, signal_names=True):
|
||||||
'''Return last pipe status.
|
'''Return last pipe status.
|
||||||
|
|
||||||
|
:param bool signal_names:
|
||||||
|
If True (default), translate signal numbers to human-readable names.
|
||||||
|
|
||||||
Highlight groups used: ``exit_fail``, ``exit_success``
|
Highlight groups used: ``exit_fail``, ``exit_success``
|
||||||
'''
|
'''
|
||||||
last_pipe_status = (
|
last_pipe_status = (
|
||||||
@ -44,18 +62,22 @@ def last_pipe_status(pl, segment_info):
|
|||||||
or (segment_info['args'].last_exit_code,)
|
or (segment_info['args'].last_exit_code,)
|
||||||
)
|
)
|
||||||
if any(last_pipe_status):
|
if any(last_pipe_status):
|
||||||
return [
|
try:
|
||||||
{
|
return [{
|
||||||
|
'contents': exit_codes[status - 128] if signal_names and \
|
||||||
|
status - 128 in exit_codes else str(status),
|
||||||
|
'highlight_groups': ['exit_fail' if status else 'exit_success'],
|
||||||
|
'draw_inner_divider': True
|
||||||
|
} for status in last_pipe_status]
|
||||||
|
except TypeError:
|
||||||
|
return [{
|
||||||
'contents': str(status),
|
'contents': str(status),
|
||||||
'highlight_groups': ['exit_fail' if status else 'exit_success'],
|
'highlight_groups': ['exit_fail' if status else 'exit_success'],
|
||||||
'draw_inner_divider': True
|
'draw_inner_divider': True
|
||||||
}
|
} for status in last_pipe_status]
|
||||||
for status in last_pipe_status
|
|
||||||
]
|
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
@requires_segment_info
|
@requires_segment_info
|
||||||
def mode(pl, segment_info, override={'vicmd': 'COMMND', 'viins': 'INSERT'}, default=None):
|
def mode(pl, segment_info, override={'vicmd': 'COMMND', 'viins': 'INSERT'}, default=None):
|
||||||
'''Return the current mode.
|
'''Return the current mode.
|
||||||
|
@ -352,6 +352,18 @@ def file_encoding(pl, segment_info):
|
|||||||
return vim_getbufoption(segment_info, 'fileencoding') or None
|
return vim_getbufoption(segment_info, 'fileencoding') or None
|
||||||
|
|
||||||
|
|
||||||
|
@requires_segment_info
|
||||||
|
@add_divider_highlight_group('background:divider')
|
||||||
|
def file_bom(pl, segment_info):
|
||||||
|
'''Return BOM of the current file
|
||||||
|
|
||||||
|
:return: Byte order mark or None if unknown or missing BOM
|
||||||
|
|
||||||
|
Divider highlight group used: ``background:divider``.
|
||||||
|
'''
|
||||||
|
return 'bom' if vim_getbufoption(segment_info, 'bomb') else None
|
||||||
|
|
||||||
|
|
||||||
@requires_segment_info
|
@requires_segment_info
|
||||||
@add_divider_highlight_group('background:divider')
|
@add_divider_highlight_group('background:divider')
|
||||||
def file_type(pl, segment_info):
|
def file_type(pl, segment_info):
|
||||||
@ -458,7 +470,7 @@ def col_current(pl, segment_info):
|
|||||||
|
|
||||||
@window_cached
|
@window_cached
|
||||||
def virtcol_current(pl, gradient=True):
|
def virtcol_current(pl, gradient=True):
|
||||||
'''Return current visual column with concealed characters ingored
|
'''Return current visual column with concealed characters ignored
|
||||||
|
|
||||||
:param bool gradient:
|
:param bool gradient:
|
||||||
Determines whether it should show textwidth-based gradient (gradient level is ``virtcol * 100 / textwidth``).
|
Determines whether it should show textwidth-based gradient (gradient level is ``virtcol * 100 / textwidth``).
|
||||||
@ -752,7 +764,7 @@ def csv_col_current(pl, segment_info, display_name='auto', name_format=' ({colum
|
|||||||
:param bool or str name:
|
:param bool or str name:
|
||||||
May be ``True``, ``False`` and ``"auto"``. In the first case value from
|
May be ``True``, ``False`` and ``"auto"``. In the first case value from
|
||||||
the first raw will always be displayed. In the second case it will never
|
the first raw will always be displayed. In the second case it will never
|
||||||
be displayed. In thi last case ``csv.Sniffer().has_header()`` will be
|
be displayed. In the last case ``csv.Sniffer().has_header()`` will be
|
||||||
used to detect whether current file contains header in the first column.
|
used to detect whether current file contains header in the first column.
|
||||||
:param str name_format:
|
:param str name_format:
|
||||||
String used to format column name (in case ``display_name`` is set to
|
String used to format column name (in case ``display_name`` is set to
|
||||||
|
51
powerline/segments/vim/plugin/coc.py
Normal file
51
powerline/segments/vim/plugin/coc.py
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
# vim:fileencoding=utf-8:noet
|
||||||
|
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||||
|
|
||||||
|
try:
|
||||||
|
import vim
|
||||||
|
except ImportError:
|
||||||
|
vim = object()
|
||||||
|
|
||||||
|
from powerline.bindings.vim import vim_command_exists
|
||||||
|
from powerline.theme import requires_segment_info
|
||||||
|
|
||||||
|
# coc_status's format: E1 W2
|
||||||
|
def parse_coc_status(coc_status):
|
||||||
|
# type(coc_status) is tuple
|
||||||
|
errors_count = 0
|
||||||
|
warnings_count = 0
|
||||||
|
if len(coc_status) <= 0:
|
||||||
|
return errors_count, warnings_count
|
||||||
|
status_str = coc_status[0]
|
||||||
|
if len(status_str) <= 0:
|
||||||
|
return errors_count, warnings_count
|
||||||
|
status_list = status_str.split(' ')
|
||||||
|
for item in status_list:
|
||||||
|
if len(item) > 0 and item[0] == 'E':
|
||||||
|
errors_count = int(item[1:])
|
||||||
|
if len(item) > 0 and item[0] == 'W':
|
||||||
|
warnings_count = int(item[1:])
|
||||||
|
return errors_count, warnings_count
|
||||||
|
|
||||||
|
@requires_segment_info
|
||||||
|
def coc(segment_info, pl):
|
||||||
|
'''Show whether coc.nvim has found any errors or warnings
|
||||||
|
|
||||||
|
Highlight groups used: ``coc:warning`` or ``warning``, ``coc:error`` or ``error``.
|
||||||
|
'''
|
||||||
|
segments = []
|
||||||
|
if not vim_command_exists('CocCommand'):
|
||||||
|
return segments
|
||||||
|
coc_status = vim.eval('coc#status()'),
|
||||||
|
errors_count, warnings_count = parse_coc_status(coc_status)
|
||||||
|
if errors_count > 0:
|
||||||
|
segments.append({
|
||||||
|
'contents': 'E:' + str(errors_count),
|
||||||
|
'highlight_groups': ['coc:error', 'error'],
|
||||||
|
})
|
||||||
|
if warnings_count > 0:
|
||||||
|
segments.append({
|
||||||
|
'contents': 'W:' + str(warnings_count),
|
||||||
|
'highlight_groups': ['coc:warning', 'warning'],
|
||||||
|
})
|
||||||
|
return segments
|
9
setup.py
9
setup.py
@ -59,7 +59,7 @@ else:
|
|||||||
|
|
||||||
|
|
||||||
def get_version():
|
def get_version():
|
||||||
base_version = '2.7'
|
base_version = '2.8'
|
||||||
base_version += '.dev9999'
|
base_version += '.dev9999'
|
||||||
try:
|
try:
|
||||||
return base_version + '+git.' + str(subprocess.check_output(['git', 'rev-parse', 'HEAD']).strip())
|
return base_version + '+git.' + str(subprocess.check_output(['git', 'rev-parse', 'HEAD']).strip())
|
||||||
@ -82,11 +82,10 @@ setup(
|
|||||||
'Natural Language :: English',
|
'Natural Language :: English',
|
||||||
'Operating System :: Microsoft :: Windows',
|
'Operating System :: Microsoft :: Windows',
|
||||||
'Operating System :: POSIX',
|
'Operating System :: POSIX',
|
||||||
'Programming Language :: Python :: 2.6',
|
|
||||||
'Programming Language :: Python :: 2.7',
|
|
||||||
'Programming Language :: Python :: 3.2',
|
|
||||||
'Programming Language :: Python :: 3.3',
|
|
||||||
'Programming Language :: Python :: 3.4',
|
'Programming Language :: Python :: 3.4',
|
||||||
|
'Programming Language :: Python :: 3.5',
|
||||||
|
'Programming Language :: Python :: 3.6',
|
||||||
|
'Programming Language :: Python :: 3.7',
|
||||||
'Programming Language :: Python :: Implementation :: CPython',
|
'Programming Language :: Python :: Implementation :: CPython',
|
||||||
'Programming Language :: Python :: Implementation :: PyPy',
|
'Programming Language :: Python :: Implementation :: PyPy',
|
||||||
],
|
],
|
||||||
|
@ -42,7 +42,7 @@ def urllib_read(query_url):
|
|||||||
if query_url.startswith('http://ipv'):
|
if query_url.startswith('http://ipv'):
|
||||||
if query_url.startswith('http://ipv4.icanhazip.com'):
|
if query_url.startswith('http://ipv4.icanhazip.com'):
|
||||||
return '127.0.0.1'
|
return '127.0.0.1'
|
||||||
elif query_url.startswith('http://ipv4.icanhazip.com'):
|
elif query_url.startswith('http://ipv6.icanhazip.com'):
|
||||||
return '2001:4801:7818:6:abc5:ba2c:ff10:275f'
|
return '2001:4801:7818:6:abc5:ba2c:ff10:275f'
|
||||||
elif query_url.startswith('http://geoip.nekudo.com/api/'):
|
elif query_url.startswith('http://geoip.nekudo.com/api/'):
|
||||||
return '{"city":"Meppen","country":{"name":"Germany", "code":"DE"},"location":{"accuracy_radius":100,"latitude":52.6833,"longitude":7.3167,"time_zone":"Europe\/Berlin"},"ip":"82.145.55.16"}'
|
return '{"city":"Meppen","country":{"name":"Germany", "code":"DE"},"location":{"accuracy_radius":100,"latitude":52.6833,"longitude":7.3167,"time_zone":"Europe\/Berlin"},"ip":"82.145.55.16"}'
|
||||||
|
@ -143,7 +143,7 @@ rm_test_root() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
if ! which realpath ; then
|
if ! command -v realpath ; then
|
||||||
realpath() {
|
realpath() {
|
||||||
$PYTHON -c 'import os, sys; print(os.path.realpath(sys.argv[1]))' "$1"
|
$PYTHON -c 'import os, sys; print(os.path.realpath(sys.argv[1]))' "$1"
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,8 @@ vterm_setup() {
|
|||||||
|
|
||||||
mkdir "$TEST_ROOT/path"
|
mkdir "$TEST_ROOT/path"
|
||||||
|
|
||||||
ln -s "$(which "${PYTHON}")" "$TEST_ROOT/path/python"
|
ln -s "$(command -v "${PYTHON}")" "$TEST_ROOT/path/python"
|
||||||
ln -s "$(which bash)" "$TEST_ROOT/path"
|
ln -s "$(command -v bash)" "$TEST_ROOT/path"
|
||||||
|
|
||||||
cp -r "$ROOT/tests/terminfo" "$TEST_ROOT"
|
cp -r "$ROOT/tests/terminfo" "$TEST_ROOT"
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ if test "$TRAVIS" = true ; then
|
|||||||
workon cpython-ucs2-$UCS2_PYTHON_VARIANT
|
workon cpython-ucs2-$UCS2_PYTHON_VARIANT
|
||||||
set -e
|
set -e
|
||||||
else
|
else
|
||||||
LIBRARY_PATH="$(ldd "$(which python)" | grep libpython | sed 's/^.* => //;s/ .*$//')"
|
LIBRARY_PATH="$(ldd "$(command -v python)" | grep libpython | sed 's/^.* => //;s/ .*$//')"
|
||||||
LIBRARY_DIR="$(dirname "${LIBRARY_PATH}")"
|
LIBRARY_DIR="$(dirname "${LIBRARY_PATH}")"
|
||||||
export LD_LIBRARY_PATH="$LIBRARY_DIR${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH"
|
export LD_LIBRARY_PATH="$LIBRARY_DIR${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH"
|
||||||
fi
|
fi
|
||||||
|
@ -13,20 +13,20 @@ cp -r "$TEST_STATIC_ROOT/powerline" "$TEST_ROOT"
|
|||||||
|
|
||||||
export PYTHONPATH="$ROOT${PYTHONPATH:+:}$PYTHONPATH"
|
export PYTHONPATH="$ROOT${PYTHONPATH:+:}$PYTHONPATH"
|
||||||
|
|
||||||
ln -s "$(which "${PYTHON}")" "$TEST_PATH"/python
|
ln -s "$(command -v "${PYTHON}")" "$TEST_PATH"/python
|
||||||
ln -s "$(which cat)" "$TEST_PATH"
|
ln -s "$(command -v cat)" "$TEST_PATH"
|
||||||
ln -s "$(which sh)" "$TEST_PATH"
|
ln -s "$(command -v sh)" "$TEST_PATH"
|
||||||
ln -s "$(which env)" "$TEST_PATH"
|
ln -s "$(command -v env)" "$TEST_PATH"
|
||||||
if which socat ; then
|
if command -v socat ; then
|
||||||
ln -s "$(which socat)" "$TEST_PATH"
|
ln -s "$(command -v socat)" "$TEST_PATH"
|
||||||
fi
|
fi
|
||||||
for pexe in powerline powerline.sh powerline.py ; do
|
for pexe in powerline powerline.sh powerline.py ; do
|
||||||
if test -e scripts/$pexe ; then
|
if test -e scripts/$pexe ; then
|
||||||
ln -s "$PWD/scripts/$pexe" $TEST_ROOT/path
|
ln -s "$PWD/scripts/$pexe" $TEST_ROOT/path
|
||||||
elif test -e client/$pexe ; then
|
elif test -e client/$pexe ; then
|
||||||
ln -s "$PWD/client/$pexe" $TEST_ROOT/path
|
ln -s "$PWD/client/$pexe" $TEST_ROOT/path
|
||||||
elif which $pexe ; then
|
elif command -v $pexe ; then
|
||||||
ln -s "$(which $pexe)" $TEST_ROOT/path
|
ln -s "$(command -v $pexe)" $TEST_ROOT/path
|
||||||
else
|
else
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
@ -12,11 +12,11 @@ cp -r "$TEST_STATIC_ROOT/powerline" "$TEST_ROOT"
|
|||||||
|
|
||||||
export PYTHONPATH="$ROOT${PYTHONPATH:+:}$PYTHONPATH"
|
export PYTHONPATH="$ROOT${PYTHONPATH:+:}$PYTHONPATH"
|
||||||
|
|
||||||
ln -s "$(which "${PYTHON}")" "$TEST_PATH"/python
|
ln -s "$(command -v "${PYTHON}")" "$TEST_PATH"/python
|
||||||
ln -s "$(which sed)" "$TEST_PATH"
|
ln -s "$(command -v sed)" "$TEST_PATH"
|
||||||
ln -s "$(which cat)" "$TEST_PATH"
|
ln -s "$(command -v cat)" "$TEST_PATH"
|
||||||
ln -s "$(which mkdir)" "$TEST_PATH"
|
ln -s "$(command -v mkdir)" "$TEST_PATH"
|
||||||
ln -s "$(which basename)" "$TEST_PATH"
|
ln -s "$(command -v basename)" "$TEST_PATH"
|
||||||
ln -s "$TEST_PATH/lemonbar" "$TEST_PATH/bar-aint-recursive"
|
ln -s "$TEST_PATH/lemonbar" "$TEST_PATH/bar-aint-recursive"
|
||||||
|
|
||||||
DEPRECATED_SCRIPT="$ROOT/powerline/bindings/bar/powerline-bar.py"
|
DEPRECATED_SCRIPT="$ROOT/powerline/bindings/bar/powerline-bar.py"
|
||||||
@ -169,7 +169,7 @@ else
|
|||||||
if test "${script_args}" = "$args" ; then
|
if test "${script_args}" = "$args" ; then
|
||||||
script_args=
|
script_args=
|
||||||
fi
|
fi
|
||||||
expected_args="$command -g 1920x$height+0${script_args:+ }$script_args${NL}$command -g 1920x$height+1${script_args:+ }$script_args"
|
expected_args="$command -g 1920x$height+0+0${script_args:+ }$script_args${NL}$command -g 1920x$height+1+0${script_args:+ }$script_args"
|
||||||
if test "$expected_args" != "$received_args" ; then
|
if test "$expected_args" != "$received_args" ; then
|
||||||
echo "args:${NL}<$received_args>"
|
echo "args:${NL}<$received_args>"
|
||||||
echo "expected:${NL}<$expected_args>"
|
echo "expected:${NL}<$expected_args>"
|
||||||
|
@ -3,11 +3,12 @@
|
|||||||
|
|
||||||
enter_suite vterm
|
enter_suite vterm
|
||||||
|
|
||||||
for t in "$ROOT"/tests/test_in_vterm/test_*.sh ; do
|
# (Disabled)
|
||||||
test_name="${t##*/test_}"
|
#for t in "$ROOT"/tests/test_in_vterm/test_*.sh ; do
|
||||||
if ! "$t" ; then
|
# test_name="${t##*/test_}"
|
||||||
fail "${test_name%.sh}" F "Failed running $t"
|
# if ! "$t" ; then
|
||||||
fi
|
# fail "${test_name%.sh}" F "Failed running $t"
|
||||||
done
|
# fi
|
||||||
|
#done
|
||||||
|
|
||||||
exit_suite
|
exit_suite
|
||||||
|
@ -27,30 +27,30 @@ mkdir "$TEST_ROOT/fish_home/fish"
|
|||||||
mkdir "$TEST_ROOT/fish_home/fish/generated_completions"
|
mkdir "$TEST_ROOT/fish_home/fish/generated_completions"
|
||||||
cp -r "$ROOT/tests/test_shells/ipython_home" "$TEST_ROOT"
|
cp -r "$ROOT/tests/test_shells/ipython_home" "$TEST_ROOT"
|
||||||
|
|
||||||
ln -s "$(which env)" "$TEST_ROOT/path"
|
ln -s "$(command -v env)" "$TEST_ROOT/path"
|
||||||
ln -s "$(which git)" "$TEST_ROOT/path"
|
ln -s "$(command -v git)" "$TEST_ROOT/path"
|
||||||
ln -s "$(which sleep)" "$TEST_ROOT/path"
|
ln -s "$(command -v sleep)" "$TEST_ROOT/path"
|
||||||
ln -s "$(which cat)" "$TEST_ROOT/path"
|
ln -s "$(command -v cat)" "$TEST_ROOT/path"
|
||||||
ln -s "$(which false)" "$TEST_ROOT/path"
|
ln -s "$(command -v false)" "$TEST_ROOT/path"
|
||||||
ln -s "$(which true)" "$TEST_ROOT/path"
|
ln -s "$(command -v true)" "$TEST_ROOT/path"
|
||||||
ln -s "$(which kill)" "$TEST_ROOT/path"
|
ln -s "$(command -v kill)" "$TEST_ROOT/path"
|
||||||
ln -s "$(which echo)" "$TEST_ROOT/path"
|
ln -s "$(command -v echo)" "$TEST_ROOT/path"
|
||||||
ln -s "$(which which)" "$TEST_ROOT/path"
|
ln -s "$(command -v which)" "$TEST_ROOT/path"
|
||||||
ln -s "$(which dirname)" "$TEST_ROOT/path"
|
ln -s "$(command -v dirname)" "$TEST_ROOT/path"
|
||||||
ln -s "$(which wc)" "$TEST_ROOT/path"
|
ln -s "$(command -v wc)" "$TEST_ROOT/path"
|
||||||
ln -s "$(which stty)" "$TEST_ROOT/path"
|
ln -s "$(command -v stty)" "$TEST_ROOT/path"
|
||||||
ln -s "$(which cut)" "$TEST_ROOT/path"
|
ln -s "$(command -v cut)" "$TEST_ROOT/path"
|
||||||
ln -s "$(which bc)" "$TEST_ROOT/path"
|
ln -s "$(command -v bc)" "$TEST_ROOT/path"
|
||||||
ln -s "$(which expr)" "$TEST_ROOT/path"
|
ln -s "$(command -v expr)" "$TEST_ROOT/path"
|
||||||
ln -s "$(which mktemp)" "$TEST_ROOT/path"
|
ln -s "$(command -v mktemp)" "$TEST_ROOT/path"
|
||||||
ln -s "$(which grep)" "$TEST_ROOT/path"
|
ln -s "$(command -v grep)" "$TEST_ROOT/path"
|
||||||
ln -s "$(which sed)" "$TEST_ROOT/path"
|
ln -s "$(command -v sed)" "$TEST_ROOT/path"
|
||||||
ln -s "$(which rm)" "$TEST_ROOT/path"
|
ln -s "$(command -v rm)" "$TEST_ROOT/path"
|
||||||
ln -s "$(which tr)" "$TEST_ROOT/path"
|
ln -s "$(command -v tr)" "$TEST_ROOT/path"
|
||||||
ln -s "$(which uname)" "$TEST_ROOT/path"
|
ln -s "$(command -v uname)" "$TEST_ROOT/path"
|
||||||
ln -s "$(which test)" "$TEST_ROOT/path"
|
ln -s "$(command -v test)" "$TEST_ROOT/path"
|
||||||
ln -s "$(which pwd)" "$TEST_ROOT/path"
|
ln -s "$(command -v pwd)" "$TEST_ROOT/path"
|
||||||
ln -s "$(which hostname)" "$TEST_ROOT/path"
|
ln -s "$(command -v hostname)" "$TEST_ROOT/path"
|
||||||
ln -s "$ROOT/tests/test_shells/bgscript.sh" "$TEST_ROOT/path"
|
ln -s "$ROOT/tests/test_shells/bgscript.sh" "$TEST_ROOT/path"
|
||||||
ln -s "$ROOT/tests/test_shells/waitpid.sh" "$TEST_ROOT/path"
|
ln -s "$ROOT/tests/test_shells/waitpid.sh" "$TEST_ROOT/path"
|
||||||
|
|
||||||
@ -62,8 +62,8 @@ if test -e "$ROOT/scripts/powerline" ; then
|
|||||||
ln -s "$ROOT/scripts/powerline" "$TEST_ROOT/path"
|
ln -s "$ROOT/scripts/powerline" "$TEST_ROOT/path"
|
||||||
elif test -e client/powerline ; then
|
elif test -e client/powerline ; then
|
||||||
ln -s "$ROOT/client/powerline" "$TEST_ROOT/path"
|
ln -s "$ROOT/client/powerline" "$TEST_ROOT/path"
|
||||||
elif which powerline ; then
|
elif command -v powerline ; then
|
||||||
ln -s "$(which powerline)" "$TEST_ROOT/path"
|
ln -s "$(command -v powerline)" "$TEST_ROOT/path"
|
||||||
else
|
else
|
||||||
echo "Executable powerline was not found"
|
echo "Executable powerline was not found"
|
||||||
exit 1
|
exit 1
|
||||||
@ -75,9 +75,9 @@ if test "$(
|
|||||||
HAS_C_CLIENT=1
|
HAS_C_CLIENT=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if which socat ; then
|
if command -v socat ; then
|
||||||
HAS_SOCAT=1
|
HAS_SOCAT=1
|
||||||
ln -s "$(which socat)" "$TEST_ROOT/path"
|
ln -s "$(command -v socat)" "$TEST_ROOT/path"
|
||||||
ln -s "$ROOT/client/powerline.sh" "$TEST_ROOT/path"
|
ln -s "$ROOT/client/powerline.sh" "$TEST_ROOT/path"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -97,8 +97,8 @@ test_shell() {
|
|||||||
echo "Skipping test, C client not available"
|
echo "Skipping test, C client not available"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
if which "$test_binding" ; then
|
if command -v "$test_binding" ; then
|
||||||
ln -s "$(which "$test_binding")" "$TEST_ROOT/path"
|
ln -s "$(command -v "$test_binding")" "$TEST_ROOT/path"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! "${PYTHON}" "$ROOT/tests/test_in_vterm/test_shells.py" \
|
if ! "${PYTHON}" "$ROOT/tests/test_in_vterm/test_shells.py" \
|
||||||
|
@ -6,8 +6,8 @@ enter_suite tmux final
|
|||||||
|
|
||||||
vterm_setup
|
vterm_setup
|
||||||
|
|
||||||
ln -s "$(which env)" "$TEST_ROOT/path"
|
ln -s "$(command -v env)" "$TEST_ROOT/path"
|
||||||
ln -s "$(which cut)" "$TEST_ROOT/path"
|
ln -s "$(command -v cut)" "$TEST_ROOT/path"
|
||||||
ln -s "$ROOT/scripts/powerline-render" "$TEST_ROOT/path"
|
ln -s "$ROOT/scripts/powerline-render" "$TEST_ROOT/path"
|
||||||
ln -s "$ROOT/scripts/powerline-config" "$TEST_ROOT/path"
|
ln -s "$ROOT/scripts/powerline-config" "$TEST_ROOT/path"
|
||||||
|
|
||||||
@ -17,10 +17,10 @@ test_tmux() {
|
|||||||
# occasionally.
|
# occasionally.
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
if ! which "${POWERLINE_TMUX_EXE}" ; then
|
if ! command -v "${POWERLINE_TMUX_EXE}" ; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
ln -sf "$(which "${POWERLINE_TMUX_EXE}")" "$TEST_ROOT/path/tmux"
|
ln -sf "$(command -v "${POWERLINE_TMUX_EXE}")" "$TEST_ROOT/path/tmux"
|
||||||
f="$ROOT/tests/test_in_vterm/test_tmux.py"
|
f="$ROOT/tests/test_in_vterm/test_tmux.py"
|
||||||
if ! "${PYTHON}" "$f" ; then
|
if ! "${PYTHON}" "$f" ; then
|
||||||
local test_name="$("$POWERLINE_TMUX_EXE" -V 2>&1 | cut -d' ' -f2)"
|
local test_name="$("$POWERLINE_TMUX_EXE" -V 2>&1 | cut -d' ' -f2)"
|
||||||
|
@ -12,10 +12,10 @@ test_vim() {
|
|||||||
# Can only link with cpython
|
# Can only link with cpython
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
if ! which "$POWERLINE_VIM_EXE" ; then
|
if ! command -v "$POWERLINE_VIM_EXE" ; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
ln -sf "$(which "${POWERLINE_VIM_EXE}")" "$TEST_ROOT/path/vim"
|
ln -sf "$(command -v "${POWERLINE_VIM_EXE}")" "$TEST_ROOT/path/vim"
|
||||||
f="$ROOT/tests/test_in_vterm/test_vim.py"
|
f="$ROOT/tests/test_in_vterm/test_vim.py"
|
||||||
if ! "${PYTHON}" "$f" ; then
|
if ! "${PYTHON}" "$f" ; then
|
||||||
local test_name="$(LANG=C "$POWERLINE_VIM_EXE" --cmd 'echo version' --cmd qa 2>&1 | tail -n2)"
|
local test_name="$(LANG=C "$POWERLINE_VIM_EXE" --cmd 'echo version' --cmd qa 2>&1 | tail -n2)"
|
||||||
|
@ -424,7 +424,7 @@ class TestLib(TestCase):
|
|||||||
width_data = {
|
width_data = {
|
||||||
'N': 1, # Neutral
|
'N': 1, # Neutral
|
||||||
'Na': 1, # Narrow
|
'Na': 1, # Narrow
|
||||||
'A': 1, # Ambigious
|
'A': 1, # Ambiguous
|
||||||
'H': 1, # Half-width
|
'H': 1, # Half-width
|
||||||
'W': 2, # Wide
|
'W': 2, # Wide
|
||||||
'F': 2, # Fullwidth
|
'F': 2, # Fullwidth
|
||||||
|
@ -37,6 +37,13 @@ class TestShell(TestCase):
|
|||||||
self.assertEqual(shell.last_status(pl=pl, segment_info=segment_info), [
|
self.assertEqual(shell.last_status(pl=pl, segment_info=segment_info), [
|
||||||
{'contents': '10', 'highlight_groups': ['exit_fail']}
|
{'contents': '10', 'highlight_groups': ['exit_fail']}
|
||||||
])
|
])
|
||||||
|
segment_info['args'].last_exit_code = 137
|
||||||
|
self.assertEqual(shell.last_status(pl=pl, segment_info=segment_info), [
|
||||||
|
{'contents': 'SIGKILL', 'highlight_groups': ['exit_fail']}
|
||||||
|
])
|
||||||
|
self.assertEqual(shell.last_status(pl=pl, segment_info=segment_info, signal_names=False), [
|
||||||
|
{'contents': '137', 'highlight_groups': ['exit_fail']}
|
||||||
|
])
|
||||||
segment_info['args'].last_exit_code = 0
|
segment_info['args'].last_exit_code = 0
|
||||||
self.assertEqual(shell.last_status(pl=pl, segment_info=segment_info), None)
|
self.assertEqual(shell.last_status(pl=pl, segment_info=segment_info), None)
|
||||||
segment_info['args'].last_exit_code = None
|
segment_info['args'].last_exit_code = None
|
||||||
@ -72,6 +79,19 @@ class TestShell(TestCase):
|
|||||||
{'contents': '0', 'highlight_groups': ['exit_success'], 'draw_inner_divider': True},
|
{'contents': '0', 'highlight_groups': ['exit_success'], 'draw_inner_divider': True},
|
||||||
{'contents': '0', 'highlight_groups': ['exit_success'], 'draw_inner_divider': True},
|
{'contents': '0', 'highlight_groups': ['exit_success'], 'draw_inner_divider': True},
|
||||||
])
|
])
|
||||||
|
segment_info['args'].last_pipe_status = [137, 0, 0]
|
||||||
|
self.assertEqual(shell.last_pipe_status(pl=pl, segment_info=segment_info), [
|
||||||
|
{'contents': 'SIGKILL', 'highlight_groups': ['exit_fail'], 'draw_inner_divider': True},
|
||||||
|
{'contents': '0', 'highlight_groups': ['exit_success'], 'draw_inner_divider': True},
|
||||||
|
{'contents': '0', 'highlight_groups': ['exit_success'], 'draw_inner_divider': True},
|
||||||
|
])
|
||||||
|
|
||||||
|
self.assertEqual(shell.last_pipe_status(pl=pl, segment_info=segment_info, signal_names=False), [
|
||||||
|
{'contents': '137', 'highlight_groups': ['exit_fail'], 'draw_inner_divider': True},
|
||||||
|
{'contents': '0', 'highlight_groups': ['exit_success'], 'draw_inner_divider': True},
|
||||||
|
{'contents': '0', 'highlight_groups': ['exit_success'], 'draw_inner_divider': True},
|
||||||
|
])
|
||||||
|
|
||||||
segment_info['args'].last_pipe_status = [0, 0, 2]
|
segment_info['args'].last_pipe_status = [0, 0, 2]
|
||||||
self.assertEqual(shell.last_pipe_status(pl=pl, segment_info=segment_info), [
|
self.assertEqual(shell.last_pipe_status(pl=pl, segment_info=segment_info), [
|
||||||
{'contents': '0', 'highlight_groups': ['exit_success'], 'draw_inner_divider': True},
|
{'contents': '0', 'highlight_groups': ['exit_success'], 'draw_inner_divider': True},
|
||||||
@ -447,68 +467,69 @@ class TestNet(TestCommon):
|
|||||||
self.assertEqual(self.module.internal_ip(pl=pl, interface='default_gateway', ipv=4), None)
|
self.assertEqual(self.module.internal_ip(pl=pl, interface='default_gateway', ipv=4), None)
|
||||||
self.assertEqual(self.module.internal_ip(pl=pl, interface='default_gateway', ipv=6), None)
|
self.assertEqual(self.module.internal_ip(pl=pl, interface='default_gateway', ipv=6), None)
|
||||||
|
|
||||||
def test_network_load(self):
|
# TODO: fix network load
|
||||||
def gb(interface):
|
#def test_network_load(self):
|
||||||
return None
|
# def gb(interface):
|
||||||
|
# return None
|
||||||
f = [gb]
|
#
|
||||||
|
# f = [gb]
|
||||||
def _get_bytes(interface):
|
#
|
||||||
return f[0](interface)
|
# def _get_bytes(interface):
|
||||||
|
# return f[0](interface)
|
||||||
pl = Pl()
|
#
|
||||||
|
# pl = Pl()
|
||||||
with replace_attr(self.module, '_get_bytes', _get_bytes):
|
#
|
||||||
self.module.network_load.startup(pl=pl)
|
# with replace_attr(self.module, '_get_bytes', _get_bytes):
|
||||||
try:
|
# self.module.network_load.startup(pl=pl)
|
||||||
self.assertEqual(self.module.network_load(pl=pl, interface='eth0'), None)
|
# try:
|
||||||
sleep(self.module.network_load.interval)
|
# self.assertEqual(self.module.network_load(pl=pl, interface='eth0'), None)
|
||||||
self.assertEqual(self.module.network_load(pl=pl, interface='eth0'), None)
|
# sleep(self.module.network_load.interval)
|
||||||
while 'prev' not in self.module.network_load.interfaces.get('eth0', {}):
|
# self.assertEqual(self.module.network_load(pl=pl, interface='eth0'), None)
|
||||||
sleep(0.1)
|
# while 'prev' not in self.module.network_load.interfaces.get('eth0', {}):
|
||||||
self.assertEqual(self.module.network_load(pl=pl, interface='eth0'), None)
|
# sleep(0.1)
|
||||||
|
# self.assertEqual(self.module.network_load(pl=pl, interface='eth0'), None)
|
||||||
l = [0, 0]
|
#
|
||||||
|
# l = [0, 0]
|
||||||
def gb2(interface):
|
#
|
||||||
l[0] += 1200
|
# def gb2(interface):
|
||||||
l[1] += 2400
|
# l[0] += 1200
|
||||||
return tuple(l)
|
# l[1] += 2400
|
||||||
f[0] = gb2
|
# return tuple(l)
|
||||||
|
# f[0] = gb2
|
||||||
while not self.module.network_load.interfaces.get('eth0', {}).get('prev', (None, None))[1]:
|
#
|
||||||
sleep(0.1)
|
# while not self.module.network_load.interfaces.get('eth0', {}).get('prev', (None, None))[1]:
|
||||||
self.assertEqual(self.module.network_load(pl=pl, interface='eth0'), [
|
# sleep(0.1)
|
||||||
{'divider_highlight_group': 'network_load:divider', 'contents': 'DL 1 KiB/s', 'highlight_groups': ['network_load_recv', 'network_load']},
|
# self.assertEqual(self.module.network_load(pl=pl, interface='eth0'), [
|
||||||
{'divider_highlight_group': 'network_load:divider', 'contents': 'UL 2 KiB/s', 'highlight_groups': ['network_load_sent', 'network_load']},
|
# {'divider_highlight_group': 'network_load:divider', 'contents': 'DL 1 KiB/s', 'highlight_groups': ['network_load_recv', 'network_load']},
|
||||||
])
|
# {'divider_highlight_group': 'network_load:divider', 'contents': 'UL 2 KiB/s', 'highlight_groups': ['network_load_sent', 'network_load']},
|
||||||
self.assertEqual(self.module.network_load(pl=pl, interface='eth0', recv_format='r {value}', sent_format='s {value}'), [
|
# ])
|
||||||
{'divider_highlight_group': 'network_load:divider', 'contents': 'r 1 KiB/s', 'highlight_groups': ['network_load_recv', 'network_load']},
|
# self.assertEqual(self.module.network_load(pl=pl, interface='eth0', recv_format='r {value}', sent_format='s {value}'), [
|
||||||
{'divider_highlight_group': 'network_load:divider', 'contents': 's 2 KiB/s', 'highlight_groups': ['network_load_sent', 'network_load']},
|
# {'divider_highlight_group': 'network_load:divider', 'contents': 'r 1 KiB/s', 'highlight_groups': ['network_load_recv', 'network_load']},
|
||||||
])
|
# {'divider_highlight_group': 'network_load:divider', 'contents': 's 2 KiB/s', 'highlight_groups': ['network_load_sent', 'network_load']},
|
||||||
self.assertEqual(self.module.network_load(pl=pl, recv_format='r {value}', sent_format='s {value}', suffix='bps', interface='eth0'), [
|
# ])
|
||||||
{'divider_highlight_group': 'network_load:divider', 'contents': 'r 1 Kibps', 'highlight_groups': ['network_load_recv', 'network_load']},
|
# self.assertEqual(self.module.network_load(pl=pl, recv_format='r {value}', sent_format='s {value}', suffix='bps', interface='eth0'), [
|
||||||
{'divider_highlight_group': 'network_load:divider', 'contents': 's 2 Kibps', 'highlight_groups': ['network_load_sent', 'network_load']},
|
# {'divider_highlight_group': 'network_load:divider', 'contents': 'r 1 Kibps', 'highlight_groups': ['network_load_recv', 'network_load']},
|
||||||
])
|
# {'divider_highlight_group': 'network_load:divider', 'contents': 's 2 Kibps', 'highlight_groups': ['network_load_sent', 'network_load']},
|
||||||
self.assertEqual(self.module.network_load(pl=pl, recv_format='r {value}', sent_format='s {value}', si_prefix=True, interface='eth0'), [
|
# ])
|
||||||
{'divider_highlight_group': 'network_load:divider', 'contents': 'r 1 kB/s', 'highlight_groups': ['network_load_recv', 'network_load']},
|
# self.assertEqual(self.module.network_load(pl=pl, recv_format='r {value}', sent_format='s {value}', si_prefix=True, interface='eth0'), [
|
||||||
{'divider_highlight_group': 'network_load:divider', 'contents': 's 2 kB/s', 'highlight_groups': ['network_load_sent', 'network_load']},
|
# {'divider_highlight_group': 'network_load:divider', 'contents': 'r 1 kB/s', 'highlight_groups': ['network_load_recv', 'network_load']},
|
||||||
])
|
# {'divider_highlight_group': 'network_load:divider', 'contents': 's 2 kB/s', 'highlight_groups': ['network_load_sent', 'network_load']},
|
||||||
self.assertEqual(self.module.network_load(pl=pl, recv_format='r {value}', sent_format='s {value}', recv_max=0, interface='eth0'), [
|
# ])
|
||||||
{'divider_highlight_group': 'network_load:divider', 'contents': 'r 1 KiB/s', 'highlight_groups': ['network_load_recv_gradient', 'network_load_gradient', 'network_load_recv', 'network_load'], 'gradient_level': 100},
|
# self.assertEqual(self.module.network_load(pl=pl, recv_format='r {value}', sent_format='s {value}', recv_max=0, interface='eth0'), [
|
||||||
{'divider_highlight_group': 'network_load:divider', 'contents': 's 2 KiB/s', 'highlight_groups': ['network_load_sent', 'network_load']},
|
# {'divider_highlight_group': 'network_load:divider', 'contents': 'r 1 KiB/s', 'highlight_groups': ['network_load_recv_gradient', 'network_load_gradient', 'network_load_recv', 'network_load'], 'gradient_level': 100},
|
||||||
])
|
# {'divider_highlight_group': 'network_load:divider', 'contents': 's 2 KiB/s', 'highlight_groups': ['network_load_sent', 'network_load']},
|
||||||
|
# ])
|
||||||
class ApproxEqual(object):
|
#
|
||||||
def __eq__(self, i):
|
# class ApproxEqual(object):
|
||||||
return abs(i - 50.0) < 1
|
# def __eq__(self, i):
|
||||||
|
# return abs(i - 50.0) < 1
|
||||||
self.assertEqual(self.module.network_load(pl=pl, recv_format='r {value}', sent_format='s {value}', sent_max=4800, interface='eth0'), [
|
#
|
||||||
{'divider_highlight_group': 'network_load:divider', 'contents': 'r 1 KiB/s', 'highlight_groups': ['network_load_recv', 'network_load']},
|
# self.assertEqual(self.module.network_load(pl=pl, recv_format='r {value}', sent_format='s {value}', sent_max=4800, interface='eth0'), [
|
||||||
{'divider_highlight_group': 'network_load:divider', 'contents': 's 2 KiB/s', 'highlight_groups': ['network_load_sent_gradient', 'network_load_gradient', 'network_load_sent', 'network_load'], 'gradient_level': ApproxEqual()},
|
# {'divider_highlight_group': 'network_load:divider', 'contents': 'r 1 KiB/s', 'highlight_groups': ['network_load_recv', 'network_load']},
|
||||||
])
|
# {'divider_highlight_group': 'network_load:divider', 'contents': 's 2 KiB/s', 'highlight_groups': ['network_load_sent_gradient', 'network_load_gradient', 'network_load_sent', 'network_load'], 'gradient_level': ApproxEqual()},
|
||||||
finally:
|
# ])
|
||||||
self.module.network_load.shutdown()
|
# finally:
|
||||||
|
# self.module.network_load.shutdown()
|
||||||
|
|
||||||
|
|
||||||
class TestEnv(TestCommon):
|
class TestEnv(TestCommon):
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
|
from powerline.bindings.ipython.since_7 import PowerlinePrompts
|
||||||
import os
|
import os
|
||||||
c = get_config()
|
c = get_config()
|
||||||
c.InteractiveShellApp.extensions = ['powerline.bindings.ipython.post_0_11']
|
c.TerminalInteractiveShell.simple_prompt = False
|
||||||
|
c.TerminalIPythonApp.display_banner = False
|
||||||
|
c.TerminalInteractiveShell.prompts_class = PowerlinePrompts
|
||||||
c.TerminalInteractiveShell.autocall = 1
|
c.TerminalInteractiveShell.autocall = 1
|
||||||
c.Powerline.config_paths = [os.path.abspath('powerline/config_files')]
|
c.Powerline.config_paths = [os.path.abspath('powerline/config_files')]
|
||||||
c.Powerline.theme_overrides = {
|
c.Powerline.theme_overrides = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user