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
204
Issues
204
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
0ca75a34
Commit
0ca75a34
authored
Jun 12, 2010
by
louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add missing file
parent
ad8d892a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
114 additions
and
36 deletions
+114
-36
README
README
+3
-0
src/gui.py
src/gui.py
+1
-1
src/message.py
src/message.py
+43
-0
src/window.py
src/window.py
+67
-35
No files found.
README
View file @
0ca75a34
...
...
@@ -42,6 +42,9 @@ http://codingteam.net/project/poezio/doc
Please DO report any bug you encounter and ask for any
feature you want.
If you are testing poezio, and get a crash but no error, please
take a look in the src/errors file.
=======================
Authors
=======================
...
...
src/gui.py
View file @
0ca75a34
...
...
@@ -263,7 +263,7 @@ Avail: Sets your availability to available and (optional) sets your status
def
on_connected
(
self
,
jid
):
"""
W
hen we are connected
authentification confirmation is received
W
e are connected when
authentification confirmation is received
"""
self
.
information
(
_
(
"Welcome on Poezio \o/!"
))
self
.
information
(
_
(
"Your JID is %s"
)
%
jid
)
...
...
src/message.py
0 → 100644
View file @
0ca75a34
#!/usr/bin/python
# -*- coding:utf-8 -*-
#
# Copyright 2010 Le Coz Florent <louizatakk@fedoraproject.org>
#
# This file is part of Poezio.
#
# Poezio is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# Poezio is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Poezio. If not, see <http://www.gnu.org/licenses/>.
from
common
import
debug
from
datetime
import
datetime
class
Message
(
object
):
"""
A message with all the associated data (nickname, time, color, etc)
"""
def
__init__
(
self
,
txt
,
time
=
None
,
nickname
=
None
,
user
=
None
,
color
=
None
):
"""
time is a datetime object, None means 'now'.
If no nickname is specified, it's an information.
user is an User object (used for the color, etc)
"""
self
.
txt
=
txt
self
.
nickname
=
nickname
self
.
time
=
time
self
.
user
=
user
self
.
color
=
color
def
__repr__
(
self
):
return
"<Message txt=%s, nickname=%s, time=%s, user=%s>"
%
(
self
.
txt
,
self
.
nickname
,
str
(
self
.
time
),
str
(
self
.
user
))
def
__str__
(
self
):
return
self
.
__repr__
()
src/window.py
View file @
0ca75a34
...
...
@@ -31,18 +31,17 @@ class Win(object):
try
:
self
.
win
=
parent_win
.
subwin
(
height
,
width
,
y
,
x
)
except
:
#
Happens when the C function subwin fails. The man
#
doesn't give a reason for this to happen, so I can't
#
really fix this.
#
j
ust don't crash when this happens.
#
When resizing in a too little height (less than 3 lines)
#
We don't need to resize the window, since this size
#
just makes no sense
#
J
ust don't crash when this happens.
# (°> also, a penguin
# //\
# V_/_
print
parent_win
,
parent_win
.
height
,
parent_win
.
width
,
height
,
width
,
y
,
x
raise
pass
self
.
win
.
idlok
(
1
)
self
.
win
.
leaveok
(
1
)
self
.
win
.
syncok
(
0
)
#
self.win.syncok(0)
def
refresh
(
self
):
self
.
win
.
noutrefresh
()
...
...
@@ -175,6 +174,22 @@ class TextWin(Win):
self
.
x
=
x
self
.
parent_win
=
parent_win
Win
.
__init__
(
self
,
height
,
width
,
y
,
x
,
parent_win
)
self
.
win
.
scrollok
(
1
)
def
keep_n_lines
(
self
,
messages
):
"""
Keep just self.win.height lines, no more.
So, remove one top line for each "
\n
" found in the messages
"""
messages
=
messages
[::
-
1
]
for
m
in
messages
:
nb
=
m
.
txt
.
count
(
'
\n
'
)
# remove the nb top lines
for
_
in
xrange
(
nb
):
messages
.
pop
(
len
(
messages
)
-
1
)
# remove the last one
debug
(
str
(
nb
)
+
' backslash'
)
debug
(
str
(
len
(
messages
)))
return
messages
[::
-
1
]
def
refresh
(
self
,
room
):
"""
...
...
@@ -182,29 +197,41 @@ class TextWin(Win):
# TODO: keep a position in the room, and display
# the messages from this position (can be used to scroll)
from
common
import
debug
y
=
0
# y = 0
debug
(
"je suis VISIBLE:%s"
%
self
.
visible
)
if
not
self
.
visible
:
return
self
.
win
.
erase
()
self
.
win
.
move
(
0
,
0
)
if
room
.
pos
!=
0
:
messages
=
room
.
messages
[
-
self
.
height
-
room
.
pos
:
-
room
.
pos
]
else
:
messages
=
room
.
messages
[
-
self
.
height
:]
# lines = self.keep_n_lines(messages)
first
=
True
for
message
in
messages
:
# debug(str(message))
self
.
write_time
(
y
,
message
.
time
)
if
first
:
first
=
False
else
:
self
.
win
.
addch
(
'
\n
'
)
self
.
write_time
(
message
.
time
)
if
message
.
nickname
is
not
None
:
x
=
self
.
write_nickname
(
y
,
message
.
nickname
.
encode
(
'utf-8'
),
message
.
user
)
# x =
self
.
write_nickname
(
message
.
nickname
.
encode
(
'utf-8'
),
message
.
user
)
else
:
x
=
11
#
x = 11
self
.
win
.
attron
(
curses
.
color_pair
(
8
))
y
+=
self
.
write_text
(
y
,
x
,
message
.
txt
,
message
.
color
)
# y +=
self
.
write_text
(
message
.
txt
,
message
.
color
)
if
message
.
nickname
is
None
:
self
.
win
.
attroff
(
curses
.
color_pair
(
8
))
# self.win.addnstr(y, x, message.txt, 40)
# self.win
y
+=
1
#
y += 1
self
.
win
.
refresh
()
def
write_text
(
self
,
y
,
x
,
txt
,
color
):
def
write_text
(
self
,
txt
,
color
):
"""
return the number of line written, -1
"""
...
...
@@ -212,48 +239,53 @@ class TextWin(Win):
l
=
0
if
color
:
self
.
win
.
attron
(
curses
.
color_pair
(
color
))
while
txt
!=
''
:
debug
(
txt
)
if
txt
[:
self
.
width
-
x
].
find
(
'
\n
'
)
!=
-
1
:
limit
=
txt
[:
self
.
width
-
x
].
find
(
'
\n
'
)
debug
(
"=================="
+
str
(
limit
))
else
:
limit
=
self
.
width
-
x
self
.
win
.
addnstr
(
y
+
l
,
x
,
txt
,
limit
)
txt
=
txt
[
limit
+
1
:]
l
+=
1
self
.
win
.
addstr
(
txt
)
# while txt != '':
# # debug(txt)
# if txt[:self.width-x].find('\n') != -1:
# limit = txt[:self.width-x].find('\n')
# # debug("=================="+str(limit))
# else:
# limit = self.width-x
# self.win.addnstr(txt, limit)
# txt = txt[limit+1:]
# l += 1
if
color
:
self
.
win
.
attroff
(
curses
.
color_pair
(
color
))
return
l
-
1
#
return l-1
def
write_nickname
(
self
,
y
,
nickname
,
user
):
def
write_nickname
(
self
,
nickname
,
user
):
"""
Write the nickname, using the user's color
and return the number of written characters
"""
if
user
:
self
.
win
.
attron
(
curses
.
color_pair
(
user
.
color
))
self
.
win
.
addstr
(
y
,
11
,
nickname
)
self
.
win
.
addstr
(
nickname
)
if
user
:
self
.
win
.
attroff
(
curses
.
color_pair
(
user
.
color
))
self
.
win
.
addnstr
(
y
,
11
+
len
(
nickname
.
decode
(
'utf-8'
)),
"> "
,
2
)
return
len
(
nickname
.
decode
(
'utf-8'
))
+
13
self
.
win
.
addnstr
(
"> "
,
2
)
#
return len(nickname.decode('utf-8')) + 13
def
write_time
(
self
,
y
,
time
):
def
write_time
(
self
,
time
):
"""
Write the date on the yth line of the window
"""
self
.
win
.
addnstr
(
y
,
0
,
'['
+
time
.
strftime
(
"%H"
),
3
)
# debug(str(self.win.getmaxyx()))
# debug(str(y))
# debug('___________________')
self
.
win
.
addnstr
(
'['
+
time
.
strftime
(
"%H"
),
3
)
self
.
win
.
attron
(
curses
.
color_pair
(
9
))
self
.
win
.
addnstr
(
y
,
3
,
':'
,
1
)
self
.
win
.
addnstr
(
':'
,
1
)
self
.
win
.
attroff
(
curses
.
color_pair
(
9
))
self
.
win
.
add
str
(
y
,
4
,
time
.
strftime
(
'%M'
),
2
)
self
.
win
.
add
nstr
(
time
.
strftime
(
'%M'
),
2
)
self
.
win
.
attron
(
curses
.
color_pair
(
9
))
self
.
win
.
add
str
(
y
,
6
,
':'
,
1
)
self
.
win
.
add
nstr
(
':'
,
1
)
self
.
win
.
attroff
(
curses
.
color_pair
(
9
))
self
.
win
.
add
str
(
y
,
7
,
time
.
strftime
(
'%S'
)
+
"] "
,
3
)
self
.
win
.
add
nstr
(
time
.
strftime
(
'%S'
)
+
"] "
,
3
)
def
resize
(
self
,
height
,
width
,
y
,
x
,
stdscr
,
visible
):
self
.
visible
=
visible
self
.
_resize
(
height
,
width
,
y
,
x
,
stdscr
)
# def redraw(self, room):
...
...
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