/[papo]/gnue/common/src/cursing/TextBox.py
ViewVC logotype

Diff of /gnue/common/src/cursing/TextBox.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by styxman, Fri Nov 15 15:32:55 2002 UTC revision 1.1.2.1 by anthonyl, Tue Mar 4 22:09:33 2003 UTC
# Line 16  Line 16 
16  # write to the Free Software Foundation, Inc., 59 Temple Place  # write to the Free Software Foundation, Inc., 59 Temple Place
17  # - Suite 330, Boston, MA 02111-1307, USA.  # - Suite 330, Boston, MA 02111-1307, USA.
18  #  #
19  # Copyright 2002 Free Software Foundation  # Copyright 2002-2003 Free Software Foundation
20  #  #
21  # FILE:  # FILE:
22  # TextBox.py  # TextBox.py
# Line 64  class TextBox(Control): Line 64  class TextBox(Control):
64      self.laststart = 0      self.laststart = 0
65      self.EDITABLE = 1      self.EDITABLE = 1
66    
67      self.SetColor(sio.C_TEXTBOX)      self.SetColor('TEXTBOX', 'TEXTBOX_FOCUS')
68    
69    def Run(self, v1, v2, v3):    def Run(self, v1, v2, v3):
70      Container = self.PARENT.Screen()      Container = self.PARENT.Screen()
# Line 90  class TextBox(Control): Line 90  class TextBox(Control):
90        self.Paint(0,0,0)        self.Paint(0,0,0)
91      while 1:      while 1:
92        ch = Container.GetChar()        ch = Container.GetChar()
93          curses.curs_set(1)
94        if self.PARENT.BreakOrder(ch) :        if self.PARENT.BreakOrder(ch) :
95  ##        try:          try:
96  ##          curses.curs_set(0)            curses.curs_set(0)
97  ##        except:          except:
98  ##          pass            pass
99          return          return 1
100    
101        ch = self.PARENT.KeystrokeHook(ch)        ch = self.PARENT.KeystrokeHook(ch)
102        if ch == None:        if ch == None:
103  ##        try:  #        try:
104  ##          curses.curs_set(0)  #          curses.curs_set(0)
105  ##        except:  #        except:
106            continue  #          pass
107            continue
108          elif ch == -1:
109            try:
110              curses.curs_set(0)
111            except:
112              pass
113            return
114        else:        else:
115    
116          Depth = self.DEPTH          Depth = self.DEPTH
# Line 158  class TextBox(Control): Line 166  class TextBox(Control):
166      return 1      return 1
167    
168    def Paint(self, v1, v2, v3):    def Paint(self, v1, v2, v3):
169      Container = self.PARENT.Screen()      Container = self.PARENT.SCREEN
170      TextLen = len(self.TEXT)      TextLen = len(self.TEXT)
171    
172        if self.FOCUS:
173          color = self.FOCUSCOLOR
174        else:
175          color = self.COLOR
176      if self.PASSWORD:      if self.PASSWORD:
177        Text = "*" * TextLen        Text = "*" * TextLen
178      else:      else:
# Line 169  class TextBox(Control): Line 181  class TextBox(Control):
181      W = self.W      W = self.W
182      Depth = self.DEPTH      Depth = self.DEPTH
183      Visuals = ''      Visuals = ''
     self.LoLight()  
184    
185      if TextLen <= W or Depth < W:      if TextLen <= W or Depth < W:
186        Visuals = Text + ((W - TextLen) * "_")        Visuals = Text + ((W - TextLen) * "_")
187        if len(Visuals) > W:        if len(Visuals) > W:
188          Visuals = Visuals[:W-1] + ">"          Visuals = Visuals[:W-1] + ">"
189        Container.PrintAt(self._ABSY, self._ABSX, Visuals)        Container.PrintAt(self._ABSY, self._ABSX, Visuals, color)
190        Container.GotoYX(self._ABSY, self._ABSX+ Depth)        Container.GotoYX(self._ABSY, self._ABSX+ Depth)
191      else:      else:
192        if Depth >= W:        if Depth >= W:
193          Visuals = "<" + Text[Depth - (W - 1):] + (((W - 1) - TextLen) * "_")          Visuals = "<" + Text[Depth - (W - 1):] + (((W - 1) - TextLen) * "_")
194          if len(Visuals) > W:          if len(Visuals) > W:
195            Visuals = Visuals[:W]            Visuals = Visuals[:W]
196          Container.PrintAt(self._ABSY, self._ABSX, Visuals)          Container.PrintAt(self._ABSY, self._ABSX, Visuals, self.FOCUS and self.FOCUSCOLOR or self.COLOR)
197          Container.GotoYX(self._ABSY, self._ABSX+  W)          Container.GotoYX(self._ABSY, self._ABSX+  W)
198    
199    def SetCursor(self, location):    def SetCursor(self, location):
# Line 193  class TextBox(Control): Line 204  class TextBox(Control):
204      self.Paint(None, None, None)      self.Paint(None, None, None)
205    
206    def LostFocus(self, v1, v2, v3):    def LostFocus(self, v1, v2, v3):
207        self.FOCUS = 0
208      curses.curs_set(0)      curses.curs_set(0)
209      self.SetColor(sio.C_TEXTBOX)      if self.PARENT.VISIBLE:
210      Container = self.PARENT.Screen()        self.Paint(0,0,0)
     self.Paint(None, None, None)  
211    
212    def GotFocus(self, v1, v2, v3):    def GotFocus(self, v1, v2, v3):
213      self.SetColor(sio.C_TEXTBOX_FOCUS)      self.FOCUS = 1
214      Container = self.PARENT.Screen()      Container = self.PARENT.Screen()
215      curses.curs_set(1)      curses.curs_set(1)
216      Container.GotoYX(self._ABSY, self._ABSX+ self.DEPTH)      Container.GotoYX(self._ABSY, self._ABSX+ self.DEPTH)
217      self.Paint(None, None, None)      self.Paint(None, None, None)
218    
219    def SetValue(self, newText):    def SetValue(self, newText, repaint=1):
220      self.TEXT = newText      self.TEXT = newText
221      self.Paint(0,0,0)      if self.PARENT.VISIBLE:
222          self.Paint(0,0,0)
223    
224    def GetValue(self):    def GetValue(self):
225      return self.TEXT      return self.TEXT

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.1.2.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26