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
178
Issues
178
List
Boards
Labels
Service Desk
Milestones
Merge Requests
8
Merge Requests
8
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
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
d0df65ba
Commit
d0df65ba
authored
Oct 25, 2015
by
Link Mauve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make poezio.text_buffer more Cython-friendly.
parent
0f066ab1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
15 deletions
+13
-15
poezio/text_buffer.py
poezio/text_buffer.py
+13
-15
No files found.
poezio/text_buffer.py
View file @
d0df65ba
...
...
@@ -11,8 +11,6 @@ independantly by their TextWins.
import
logging
log
=
logging
.
getLogger
(
__name__
)
import
collections
from
datetime
import
datetime
from
config
import
config
from
theming
import
get_theme
,
dump_tuple
...
...
@@ -104,16 +102,16 @@ class TextBuffer(object):
if
messages_nb_limit
is
None
:
messages_nb_limit
=
config
.
get
(
'max_messages_in_memory'
)
self
.
messages_nb_limit
=
messages_nb_limit
self
.
_
messages_nb_limit
=
messages_nb_limit
# Message objects
self
.
messages
=
[]
# we keep track of one or more windows
# so we can pass the new messages to them, as they are added, so
# they (the windows) can build the lines from the new message
self
.
windows
=
[]
self
.
_
windows
=
[]
def
add_window
(
self
,
win
):
self
.
windows
.
append
(
win
)
self
.
_
windows
.
append
(
win
)
@
property
def
last_message
(
self
):
...
...
@@ -130,24 +128,24 @@ class TextBuffer(object):
jid
=
jid
,
ack
=
ack
)
self
.
messages
.
append
(
msg
)
while
len
(
self
.
messages
)
>
self
.
messages_nb_limit
:
while
len
(
self
.
messages
)
>
self
.
_
messages_nb_limit
:
self
.
messages
.
pop
(
0
)
ret_val
=
None
ret_val
=
0
show_timestamps
=
config
.
get
(
'show_timestamps'
)
nick_size
=
config
.
get
(
'max_nick_length'
)
for
window
in
self
.
windows
:
# make the associated windows
# build the lines from the new message
for
window
in
self
.
_
windows
:
# make the associated windows
# build the lines from the new message
nb
=
window
.
build_new_message
(
msg
,
history
=
history
,
highlight
=
highlight
,
timestamp
=
show_timestamps
,
nick_size
=
nick_size
)
if
ret_val
is
None
:
if
ret_val
==
0
:
ret_val
=
nb
if
window
.
pos
!=
0
:
window
.
scroll_up
(
nb
)
return
ret_val
or
1
return
min
(
ret_val
,
1
)
def
_find_message
(
self
,
old_id
):
"""
...
...
@@ -161,13 +159,13 @@ class TextBuffer(object):
def
ack_message
(
self
,
old_id
,
jid
):
"""Mark a message as acked"""
return
self
.
edit_ack
(
1
,
old_id
,
jid
)
return
self
.
_
edit_ack
(
1
,
old_id
,
jid
)
def
nack_message
(
self
,
error
,
old_id
,
jid
):
"""Mark a message as errored"""
return
self
.
edit_ack
(
-
1
,
old_id
,
jid
,
append
=
error
)
return
self
.
_
edit_ack
(
-
1
,
old_id
,
jid
,
append
=
error
)
def
edit_ack
(
self
,
value
,
old_id
,
jid
,
append
=
''
):
def
_
edit_ack
(
self
,
value
,
old_id
,
jid
,
append
=
''
):
"""
Edit the ack status of a message, and optionally
append some text.
...
...
@@ -223,7 +221,7 @@ class TextBuffer(object):
return
message
def
del_window
(
self
,
win
):
self
.
windows
.
remove
(
win
)
self
.
_
windows
.
remove
(
win
)
def
__del__
(
self
):
size
=
len
(
self
.
messages
)
...
...
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