Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
poezio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
203
Issues
203
List
Boards
Labels
Service Desk
Milestones
Merge Requests
9
Merge Requests
9
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
poezio
poezio
Commits
a6e33a0c
Commit
a6e33a0c
authored
Mar 25, 2021
by
mathieui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: windows: drop the DummyWi
now TAB_WIN must be set for a Win to be instanciated
parent
9ae60e58
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
22 deletions
+21
-22
poezio/windows/base_wins.py
poezio/windows/base_wins.py
+20
-21
poezio/windows/image.py
poezio/windows/image.py
+1
-1
No files found.
poezio/windows/base_wins.py
View file @
a6e33a0c
...
...
@@ -9,41 +9,35 @@ A Tab (see the poezio.tabs module) is composed of multiple Windows
from
__future__
import
annotations
TAB_WIN
:
_CursesWindow
=
None
import
logging
log
=
logging
.
getLogger
(
__name__
)
import
curses
import
logging
import
string
from
contextlib
import
contextmanager
from
typing
import
Optional
,
Tuple
,
TYPE_CHECKING
from
typing
import
Optional
,
Tuple
,
TYPE_CHECKING
,
cast
from
poezio.theming
import
to_curses_attr
,
read_tuple
from
poezio.ui.consts
import
FORMAT_CHAR
log
=
logging
.
getLogger
(
__name__
)
if
TYPE_CHECKING
:
from
_curses
import
_CursesWindow
# pylint: disable=E0611
class
DummyWin
:
def
__getattribute__
(
self
,
name
:
str
):
if
name
!=
'__bool__'
:
return
lambda
*
args
,
**
kwargs
:
(
0
,
0
)
else
:
return
object
.
__getattribute__
(
self
,
name
)
def
__bool__
(
self
)
->
bool
:
return
False
class
Win
:
__slots__
=
(
'_win'
,
'height'
,
'width'
,
'y'
,
'x'
)
width
:
int
height
:
int
x
:
int
y
:
int
def
__init__
(
self
)
->
None
:
self
.
_win
:
_CursesWindow
=
None
if
TAB_WIN
is
None
:
raise
ValueError
self
.
_win
:
_CursesWindow
=
TAB_WIN
self
.
height
,
self
.
width
=
0
,
0
def
_resize
(
self
,
height
:
int
,
width
:
int
,
y
:
int
,
x
:
int
)
->
None
:
...
...
@@ -52,11 +46,11 @@ class Win:
return
self
.
height
,
self
.
width
,
self
.
x
,
self
.
y
=
height
,
width
,
x
,
y
try
:
if
TAB_WIN
is
None
:
raise
ValueError
(
'TAB_WIN is None'
)
self
.
_win
=
TAB_WIN
.
derwin
(
height
,
width
,
y
,
x
)
except
:
log
.
debug
(
'DEBUG: mvwin returned ERR. Please investigate'
)
if
self
.
_win
is
None
:
self
.
_win
=
DummyWin
()
def
resize
(
self
,
height
:
int
,
width
:
int
,
y
:
int
,
x
:
int
)
->
None
:
"""
...
...
@@ -85,12 +79,14 @@ class Win:
if
color
is
None
and
attr
is
None
:
yield
None
return
mode
:
int
if
color
is
not
None
:
mode
=
to_curses_attr
(
color
)
if
attr
is
not
None
:
mode
=
mode
|
attr
else
:
mode
=
attr
# attr cannot be none here
mode
=
cast
(
int
,
attr
)
self
.
_win
.
attron
(
mode
)
yield
None
self
.
_win
.
attroff
(
mode
)
...
...
@@ -179,3 +175,6 @@ class Win:
self
.
addnstr
(
' '
*
size
,
size
,
to_curses_attr
(
color
))
else
:
self
.
addnstr
(
' '
*
size
,
size
)
TAB_WIN
:
Optional
[
_CursesWindow
]
=
None
poezio/windows/image.py
View file @
a6e33a0c
...
...
@@ -9,7 +9,7 @@ try:
from
PIL
import
Image
HAS_PIL
=
True
except
ImportError
:
class
Image
:
class
Image
:
# type: ignore
class
Image
:
pass
HAS_PIL
=
False
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment