Skip to content

Commit

Permalink
Merge pull request #29 from gojuukaze/fix-28
Browse files Browse the repository at this point in the history
Fix 28
  • Loading branch information
gojuukaze authored Dec 28, 2022
2 parents 093b9bd + b6e4862 commit ba5d978
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 20 deletions.
Binary file added docs/_static/scroll.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/draw.rst
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ v2开始会启动线程自动刷新,因此结束程序时必须手动调用sto

View的属性
------------
View的属性包括: ``width``, ``visibility``, ``gravity``
View的属性包括: ``width`` , ``visibility`` , ``gravity``

TextView在上述基础上增加了:``text``, ``back``, ``style``, ``fore``, ``weight``
TextView在上述基础上增加了:``text`` , ``back`` , ``style`` , ``fore`` , ``weight`` , ``weight`` ,

关于属性的说明参照::doc:`/Properties`

2 changes: 1 addition & 1 deletion docs/extensions/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ scroll
文档查看:https://github.com/gojuukaze/terminal_layout/tree/master/terminal_layout/extensions/scroll


.. image:: ../_static/input.gif
.. image:: ../_static/scroll.gif


4 changes: 1 addition & 3 deletions docs/getStarted.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,4 @@
ctl.draw()
ctl.stop()
``LayoutCtl`` , ``TableLayout`` , ``TextView`` 是该项目重要的元素,接下来会一一介绍他们。

阅读 :doc:`/draw` , :doc:`/keyListener` 熟悉如何使用terminal_layout
``LayoutCtl`` , ``TableLayout`` , ``TextView`` 是该项目重要的元素,阅读 :doc:`/draw` , :doc:`/keyListener` 熟悉如何使用它们
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "terminal_layout"
version = "2.1.4"
version = "2.1.6"
authors = [
{ name="gojuukaze", email="[email protected]" },
]
Expand All @@ -24,6 +24,7 @@ classifiers = [
dependencies = [
"colorama==0.4.4",
'colored==1.3.93',
"backports.shutil_get_terminal_size==1.0.0"
]

[project.urls]
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

setup(
name="terminal_layout",
version="2.1.4",
version="2.1.6",
description="The project help you to quickly build layouts in terminal (命令行ui布局工具)",
long_description=open("README.rst", encoding='utf-8').read(),

url="https://github.com/gojuukaze/terminal_layout",
author="gojuukaze",
author_email="[email protected]",

packages=find_packages(exclude=['demo', 'tests']),
packages=find_packages(exclude=['demo*', 'tests*']),
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
include_package_data=True,
platforms="OSX, Linux",
Expand Down
34 changes: 23 additions & 11 deletions terminal_layout/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,31 +122,43 @@ def __radd__(self, other):

def __getitem__(self, item):
"""
只支持 s[:i] , s[-i:] (i>0) 两种形式
>>> s=String('a啊啊')
>>> s[:2]
'a'
>>> s[:3]
'a啊'
>>> s[-1:]
''
>>> s[-2:]
'啊'
:rtype: str
"""
start = item.start or 0
if start != 0:
raise TypeError('slice start must be 0 or None')
stop = item.stop
if start > 0:
raise TypeError('Slice start must be less than or equal to 0')
stop = item.stop or 0
if stop is None or stop < 0:
raise TypeError('slice stop must be positive integer')
raise TypeError('Slice start must be greater than or equal to 0')

s = ''
for c in self.char_list:
length = len(c)
if stop >= length:
s += str(c)
if start<0:
cl=reversed(self.char_list)
length=-start
else:
cl=self.char_list
length=stop
s=[]
for c in cl:
tmp = len(c)
length-=tmp
if length>=0:
s.append(str(c))
else:
break
stop -= length

return s
return ''.join(s if stop>0 else reversed(s))

def insert_into_char_list(self, i, s):

Expand Down

0 comments on commit ba5d978

Please sign in to comment.