Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
iogf committed Apr 10, 2020
2 parents 682cf45 + c8108a5 commit 25a36d3
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,5 +139,5 @@ Documentation
The vy docs may be outdated sometimes, i struggle to do my best to keep it all fine. There also
exists many features which weren't documented yet.

### [The Smoking Snake Book](https://github.com/iogf/vy/wiki)
### [Vy Book](https://github.com/iogf/vy/wiki)

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from distutils.core import setup

setup(name="vy",
version="4.1.0",
version="4.2.0",
description="A vim-like in python made from scratch.",
packages=["vyapp",
"vyapp.plugins",
Expand Down
50 changes: 25 additions & 25 deletions vyapp/plugins/blink_pair.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,30 @@ class BlinkPair:
setup={'background':'pink',
'foreground':'black'}
max=1500
timeout=1000

def __init__(self, area, *pairs):
self.pairs = pairs
self.area = area

self.area.tag_config('(BLINK)', **self.setup)
self.id = self.area.hook('blink-pair', '-1',
'<FocusIn>', lambda e: self.scale())

self.area.hook('blink-pair', '-1', '<FocusOut>',
lambda e: self.area.after_cancel(self.id))

def scale(self):
self.id = self.area.after(self.timeout, self.scale)
index0 = 'insert -%sc' % self.max
index1 = 'insert +%sc' % self.max

if self.area.tag_ranges('(BLINK)'):
self.area.tag_remove('(BLINK)', index0, index1)
for lhs, lhr in self.pairs:
index = self.area.case_pair(
'insert', self.max, lhs, lhr)
if index: self.area.tag_add(
'(BLINK)', index, '%s +1c' % index)
timeout=2000
pairs = ('(', ')'), ('[', ']'), ('{', '}')

def __init__(self, area):
area.tag_config('(BLINK)', **self.setup)

@classmethod
def scale(cls):
loop = lambda: root.after(cls.timeout, cls.scale)
root.after_idle(loop)
area = root.focus_get()
if isinstance(area, AreaVi):
cls.blink(area)

@classmethod
def blink(cls, area):
index0 = 'insert -%sc' % cls.max
index1 = 'insert +%sc' % cls.max

area.tag_remove('(BLINK)', index0, index1)
for lhs, lhr in cls.pairs:
index = area.case_pair('insert', cls.max, lhs, lhr)
if index:
area.tag_add('(BLINK)', index, '%s +1c' % index)

install = BlinkPair
root.bind('<<Started>>', lambda event: BlinkPair.scale())
2 changes: 1 addition & 1 deletion vyapp/vyrc
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ autoload(data_del)
# Used to highlight pairs of character like () {} [].
# It is useful when playing with lisp things.
from vyapp.plugins import blink_pair
autoload(blink_pair, ('(', ')'), ('[', ']'), ('{', '}'))
autoload(blink_pair)

# Used to complete words when Control-q is issued on insert mode.
from vyapp.plugins import word_completion
Expand Down

0 comments on commit 25a36d3

Please sign in to comment.