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
171
Issues
171
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
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
6018d243
Commit
6018d243
authored
Sep 15, 2010
by
louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes some crashes, and stuff
parent
cdcfddcb
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
152 additions
and
24 deletions
+152
-24
src/gui.py
src/gui.py
+4
-3
src/tab.py
src/tab.py
+64
-0
src/window.py
src/window.py
+84
-21
No files found.
src/gui.py
View file @
6018d243
...
...
@@ -35,8 +35,7 @@ import theme
import
multiuserchat
as
muc
from
handler
import
Handler
from
config
import
config
from
tab
import
MucTab
,
InfoTab
,
PrivateTab
from
window
import
Window
from
tab
import
MucTab
,
InfoTab
,
PrivateTab
,
RosterInfoTab
from
user
import
User
from
room
import
Room
from
message
import
Message
...
...
@@ -74,7 +73,9 @@ class Gui(object):
self
.
stdscr
=
curses
.
initscr
()
self
.
init_curses
(
self
.
stdscr
)
self
.
xmpp
=
xmpp
self
.
tabs
=
[
InfoTab
(
self
.
stdscr
,
"lol info"
)]
default_tab
=
InfoTab
(
self
.
stdscr
,
"Info"
)
if
self
.
xmpp
.
anon
\
else
RosterInfoTab
(
self
.
stdscr
,
"Roster"
)
self
.
tabs
=
[
default_tab
]
# a unique buffer used to store global informations
# that are displayed in almost all tabs, in an
# information window.
...
...
src/tab.py
View file @
6018d243
...
...
@@ -355,3 +355,67 @@ class PrivateTab(Tab):
def
get_room
(
self
):
return
self
.
_room
class
RosterInfoTab
(
Tab
):
"""
A tab, splitted in two, containg the roster and infos
"""
def
__init__
(
self
,
stdscr
,
roster
):
Tab
.
__init__
(
self
,
stdscr
)
self
.
name
=
"Roster"
self
.
roster
=
roster
roster_width
=
self
.
width
//
2
info_width
=
self
.
width
-
roster_width
-
1
self
.
v_separator
=
window
.
VerticalSeparator
(
self
.
height
-
2
,
1
,
0
,
roster_width
,
stdscr
,
self
.
visible
)
self
.
tab_win
=
window
.
GlobalInfoBar
(
1
,
self
.
width
,
self
.
height
-
2
,
0
,
stdscr
,
self
.
visible
)
self
.
info_win
=
window
.
TextWin
(
self
.
height
-
2
,
info_width
,
0
,
roster_width
+
1
,
stdscr
,
self
.
visible
)
self
.
roster_win
=
window
.
RosterWin
(
self
.
height
-
2
,
roster_width
,
0
,
0
,
stdscr
,
self
.
visible
)
self
.
input
=
window
.
Input
(
1
,
self
.
width
,
self
.
height
-
1
,
0
,
stdscr
,
self
.
visible
)
self
.
set_color_state
(
theme
.
COLOR_TAB_NORMAL
)
def
resize
(
self
,
stdscr
):
Tab
.
resize
(
self
,
stdscr
)
roster_width
=
self
.
width
//
2
info_width
=
self
.
width
-
roster_width
-
1
self
.
v_separator
.
resize
(
self
.
height
-
2
,
1
,
0
,
roster_width
,
stdscr
,
self
.
visible
)
self
.
tab_win
.
resize
(
1
,
self
.
width
,
self
.
height
-
2
,
0
,
stdscr
,
self
.
visible
)
self
.
info_win
.
resize
(
self
.
height
-
2
,
info_width
,
0
,
roster_width
+
1
,
stdscr
,
self
.
visible
)
self
.
roster_win
.
resize
(
self
.
height
-
2
,
roster_width
,
0
,
0
,
stdscr
,
self
.
visible
)
self
.
input
.
resize
(
1
,
self
.
width
,
self
.
height
-
1
,
0
,
stdscr
,
self
.
visible
)
def
refresh
(
self
,
tabs
,
informations
):
self
.
v_separator
.
refresh
()
self
.
roster_win
.
refresh
(
self
.
roster
)
self
.
info_win
.
refresh
(
informations
)
self
.
tab_win
.
refresh
(
tabs
,
tabs
[
0
])
self
.
input
.
refresh
()
def
get_name
(
self
):
return
self
.
name
def
get_color_state
(
self
):
return
self
.
_color_state
def
set_color_state
(
self
,
color
):
self
.
_color_state
=
color
def
on_input
(
self
,
key
):
return
self
.
input
.
do_command
(
key
)
def
on_lose_focus
(
self
):
self
.
_color_state
=
theme
.
COLOR_TAB_NORMAL
def
on_gain_focus
(
self
):
self
.
_color_state
=
theme
.
COLOR_TAB_CURRENT
def
add_message
(
self
):
return
False
def
on_scroll_down
(
self
):
debug
(
'TODO DOWN'
)
def
on_scroll_up
(
self
):
debug
(
'TODO UP'
)
def
on_info_win_size_changed
(
self
):
return
src/window.py
View file @
6018d243
...
...
@@ -39,7 +39,7 @@ class Win(object):
def
_resize
(
self
,
height
,
width
,
y
,
x
,
parent_win
):
self
.
height
,
self
.
width
,
self
.
x
,
self
.
y
=
height
,
width
,
x
,
y
try
:
self
.
win
=
parent_win
.
sub
win
(
height
,
width
,
y
,
x
)
self
.
win
=
curses
.
new
win
(
height
,
width
,
y
,
x
)
except
:
from
common
import
debug
debug
(
'%s %s %s %s %s
\n
'
%
(
height
,
width
,
y
,
x
,
parent_win
))
...
...
@@ -312,14 +312,8 @@ class TextWin(Win):
on each change. (thanks weechat :o)
"""
def
__init__
(
self
,
height
,
width
,
y
,
x
,
parent_win
,
visible
):
self
.
visible
=
visible
self
.
height
=
height
self
.
width
=
width
self
.
y
=
y
self
.
x
=
x
self
.
parent_win
=
parent_win
Win
.
__init__
(
self
,
height
,
width
,
y
,
x
,
parent_win
)
self
.
win
.
scrollok
(
1
)
self
.
visible
=
visible
def
build_lines_from_messages
(
self
,
messages
):
"""
...
...
@@ -445,7 +439,7 @@ class TextWin(Win):
try
:
splitted
=
shlex
.
split
(
txt
)
except
ValueError
:
txt
+=
'"'
txt
=
txt
.
replace
(
'"'
,
''
)
splitted
=
shlex
.
split
(
txt
)
for
word
in
splitted
:
if
word
in
list
(
special_words
.
keys
()):
...
...
@@ -882,20 +876,21 @@ class Input(Win):
def
clear_text
(
self
):
self
.
win
.
erase
()
class
Window
(
object
):
"""
The whole "screen" that can be seen at once in the terminal.
It contains an userlist, an input zone, a topic zone and a chat zone
"""
# class RosterWin(Win):
# def __init__(self, height, width, y, x, parent_win, visible):
# Win.__init__(self, height, width, y, x, parent_win)
# self.visible = visible
# def resize(self, height, width, y, x, stdscr, visible):
# self._resize(height, width, y, x, stdscr)
# self.visible = visible
# TODO JidWindow
# elif jid:
# room = jid.split('/')[0]
# nick = '/'.join(jid.split('/')[1:])
# topic = _('%(nick)s from room %(room)s' % {'nick': nick, 'room':room})
# self.addnstr(0, 0, topic + " "*(self.width-len(topic)), self.width-1
# , curses.color_pair(theme.COLOR_PRIVATE_ROOM_BAR))
# def refresh(self, roster):
# g_lock.acquire()
# self.win.erase()
# self.addnstr('teub', 4)
# self.win.refresh()
# g_lock.release()
class
VerticalSeparator
(
Win
):
"""
...
...
@@ -922,3 +917,71 @@ class VerticalSeparator(Win):
if
not
self
.
visible
:
return
self
.
rewrite_line
()
class
RosterWin
(
Win
):
"""
"""
def
__init__
(
self
,
height
,
width
,
y
,
x
,
parent_win
,
visible
):
self
.
visible
=
visible
Win
.
__init__
(
self
,
height
,
width
,
y
,
x
,
parent_win
)
self
.
pos
=
0
# position in the contact list
def
resize
(
self
,
height
,
width
,
y
,
x
,
stdscr
,
visible
):
self
.
_resize
(
height
,
width
,
y
,
x
,
stdscr
)
def
refresh
(
self
,
roster
=
None
):
"""
We get the roster object
"""
if
not
self
.
visible
or
not
roster
:
return
g_lock
.
acquire
()
self
.
win
.
erase
()
# TODO, two ways of scrolling
# currently: always centered
if
self
.
pos
>
self
.
height
//
2
and
\
self
.
pos
+
self
.
height
//
2
<
len
(
roster
.
getContacts
()):
# We are centered
begin
=
True
end
=
True
pos
=
self
.
height
//
2
contacts
=
roster
.
getContacts
()[
self
.
pos
-
pos
:
self
.
pos
+
pos
+
1
]
elif
self
.
pos
<=
self
.
height
//
2
:
# we are at the beginning of the list
pos
=
self
.
pos
contacts
=
roster
.
getContacts
()[:
self
.
height
]
begin
=
False
if
self
.
height
<
len
(
roster
.
getContacts
()):
end
=
True
else
:
end
=
False
else
:
# we are at the end of the list
pos
=
self
.
height
-
(
len
(
roster
.
getContacts
())
-
self
.
pos
)
contacts
=
roster
.
getContacts
()[
-
self
.
height
:]
begin
=
True
end
=
False
cpt
=
0
# ipair ou chais plus quoi
for
contact
in
contacts
:
if
cpt
==
pos
:
self
.
draw_contact_line
(
contact
,
cpt
,
0
,
3
)
else
:
self
.
draw_contact_line
(
contact
,
cpt
,
0
)
cpt
+=
1
if
end
:
self
.
win
.
addstr
(
self
.
height
-
1
,
0
,
'++++'
)
if
begin
:
self
.
win
.
addstr
(
0
,
0
,
'++++'
)
self
.
win
.
refresh
()
g_lock
.
release
()
def
draw_contact_line
(
self
,
contact
,
x
,
y
,
color
=
None
):
"""
Draw on a line all informations about one contact
Use 'color' to draw the jid/display_name to show what is
is currently selected contact in the list
"""
if
color
:
self
.
win
.
addstr
(
x
,
y
,
contact
.
getJid
().
full
,
curses
.
color_pair
(
color
))
else
:
self
.
win
.
addstr
(
x
,
y
,
contact
.
getJid
().
full
)
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