comparison frontends/sortilege_old/chat.py @ 587:952322b1d490

Remove trailing whitespaces.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 18 Jan 2013 17:55:34 +0100
parents 2a072735e459
children 84a6e83157c2
comparison
equal deleted inserted replaced
586:6a718ede8be1 587:952322b1d490
38 return ord(ascii.ctrl(k)) 38 return ord(ascii.ctrl(k))
39 39
40 class Chat(Window, QuickChat): 40 class Chat(Window, QuickChat):
41 41
42 def __init__(self, to_id, host): 42 def __init__(self, to_id, host):
43 QuickChat.__init__(self, to_id, host) 43 QuickChat.__init__(self, to_id, host)
44 self.__parent=host.stdscr 44 self.__parent=host.stdscr
45 self.to_id=JID(to_id) 45 self.to_id=JID(to_id)
46 self.content=[] 46 self.content=[]
47 self.__scollIdx=0 47 self.__scollIdx=0
48 Window.__init__(self, self.__parent, self.__parent.getmaxyx()[0]-2, self.__parent.getmaxyx()[1]-30, 0,30, code=host.code) 48 Window.__init__(self, self.__parent, self.__parent.getmaxyx()[0]-2, self.__parent.getmaxyx()[1]-30, 0,30, code=host.code)
86 part=0 #part of the text 86 part=0 #part of the text
87 if JID(self.content[idx][1]).short==self.host.profiles[self.host.profile]['whoami'].short: 87 if JID(self.content[idx][1]).short==self.host.profiles[self.host.profile]['whoami'].short:
88 att_header=curses.color_pair(1) 88 att_header=curses.color_pair(1)
89 else: 89 else:
90 att_header=curses.color_pair(2) 90 att_header=curses.color_pair(2)
91 91
92 while (msg): 92 while (msg):
93 if part==0: 93 if part==0:
94 hd=header 94 hd=header
95 att=att_header 95 att=att_header
96 max=self.rWidth-len(header) 96 max=self.rWidth-len(header)
103 if LF != -1 and LF < max: 103 if LF != -1 and LF < max:
104 max = LF 104 max = LF
105 next = max + 1 #we skip the LF 105 next = max + 1 #we skip the LF
106 else: 106 else:
107 next = max 107 next = max
108 108
109 content.insert(part,[att,hd, msg[:max]]) 109 content.insert(part,[att,hd, msg[:max]])
110 msg=msg[next:] #we erase treated part 110 msg=msg[next:] #we erase treated part
111 part=part+1 111 part=part+1
112 112
113 if len(content)>=self.rHeight+self.__scollIdx: 113 if len(content)>=self.rHeight+self.__scollIdx:
114 #all the screen is filled, we can continue 114 #all the screen is filled, we can continue
115 break 115 break
116 116
117 if self.__scollIdx>0 and len(content)<self.rHeight+self.__scollIdx: 117 if self.__scollIdx>0 and len(content)<self.rHeight+self.__scollIdx:
118 self.__scollIdx=abs(len(content)-self.rHeight) #all the log fit on the screen, we must stop here 118 self.__scollIdx=abs(len(content)-self.rHeight) #all the log fit on the screen, we must stop here
119 119
120 idx=0 120 idx=0
121 for line in content[-self.rHeight-self.__scollIdx : -self.__scollIdx or None]: 121 for line in content[-self.rHeight-self.__scollIdx : -self.__scollIdx or None]:
122 self.addYXStr(idx, 0, line[1], line[0]) 122 self.addYXStr(idx, 0, line[1], line[0])
123 self.addYXStr(idx, len(line[1]), line[2]) 123 self.addYXStr(idx, len(line[1]), line[2])
124 idx=idx+1 124 idx=idx+1
125 125
126 self.noutrefresh() 126 self.noutrefresh()
127 127
128 def scrollIdxUp(self): 128 def scrollIdxUp(self):
129 """increment scroll index""" 129 """increment scroll index"""
130 self.__scollIdx = self.__scollIdx + 1 130 self.__scollIdx = self.__scollIdx + 1
131 self.update() 131 self.update()
132 132
133 def scrollIdxDown(self): 133 def scrollIdxDown(self):
134 """decrement scroll index""" 134 """decrement scroll index"""
135 if self.__scollIdx > 0: 135 if self.__scollIdx > 0:
136 self.__scollIdx = self.__scollIdx - 1 136 self.__scollIdx = self.__scollIdx - 1
137 self.update() 137 self.update()
142 timestamp=str(current_time) 142 timestamp=str(current_time)
143 if self.last_history and current_time - float(self.last_history) < 5: #FIXME: Q&D fix to avoid double print on new chat window 143 if self.last_history and current_time - float(self.last_history) < 5: #FIXME: Q&D fix to avoid double print on new chat window
144 return 144 return
145 self.content.append([timestamp,jid.short,msg]) 145 self.content.append([timestamp,jid.short,msg])
146 self.update() 146 self.update()
147 147
148 def handleKey(self, k): 148 def handleKey(self, k):
149 if k == C('p'): 149 if k == C('p'):
150 self.scrollIdxUp() 150 self.scrollIdxUp()
151 elif k == C('n'): 151 elif k == C('n'):
152 self.scrollIdxDown() 152 self.scrollIdxDown()