Update of /cvsroot/freevo/freevo/src
In directory sc8-pr-cvs1:/tmp/cvs-serv19103

Modified Files:
        osd.py 
Log Message:
support spaces inside a string after a \n

Index: osd.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/osd.py,v
retrieving revision 1.122
retrieving revision 1.123
diff -C2 -d -r1.122 -r1.123
*** osd.py      11 Jan 2004 20:23:31 -0000      1.122
--- osd.py      12 Jan 2004 19:10:35 -0000      1.123
***************
*** 11,14 ****
--- 11,17 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.123  2004/01/12 19:10:35  dischi
+ # support spaces inside a string after a \n
+ #
  # Revision 1.122  2004/01/11 20:23:31  dischi
  # move skin font handling to osd to avoid duplicate code
***************
*** 716,720 ****
                                    ellipses, word_splitter):
          """
!         calculate _one_ line for drawstringframed
          """
          c = 0                           # num of chars fitting
--- 719,725 ----
                                    ellipses, word_splitter):
          """
!         calculate _one_ line for drawstringframed. Returns a list:
!         width used, string to draw, rest that didn't fit and True if this
!         function stopped because of a \n.
          """
          c = 0                           # num of chars fitting
***************
*** 734,743 ****
                  if width <= max_width:
                      # ok, text fits
!                     return (width, string, '')
                  # ok, only draw the ellipses, shorten them first
                  while(ellipses_size > max_width):
                      ellipses = ellipses[:-1]
                      ellipses_size = font.stringsize(ellipses)
!                 return (ellipses_size, ellipses, string)
          else:
              ellipses_size = 0
--- 739,748 ----
                  if width <= max_width:
                      # ok, text fits
!                     return (width, string, '', False)
                  # ok, only draw the ellipses, shorten them first
                  while(ellipses_size > max_width):
                      ellipses = ellipses[:-1]
                      ellipses_size = font.stringsize(ellipses)
!                 return (ellipses_size, ellipses, string, False)
          else:
              ellipses_size = 0
***************
*** 755,762 ****
              if ls == c:
                  # everything fits
!                 return (width, string, '')
              if string[c] == '\n':
                  # linebreak, we have to stop
!                 return (width, string[:c], string[c+1:])
              if not hard and string[c] in word_splitter:
                  # rememeber the last space for mode == 'soft' (not hard)
--- 760,767 ----
              if ls == c:
                  # everything fits
!                 return (width, string, '', False)
              if string[c] == '\n':
                  # linebreak, we have to stop
!                 return (width, string[:c], string[c+1:], True)
              if not hard and string[c] in word_splitter:
                  # rememeber the last space for mode == 'soft' (not hard)
***************
*** 785,789 ****
  
          # calc the matching and rest string and return all this
!         return (width+ellipses_size, string[:c]+ellipses, string[c:])
  
              
--- 790,794 ----
  
          # calc the matching and rest string and return all this
!         return (width+ellipses_size, string[:c]+ellipses, string[c:], False)
  
              
***************
*** 799,803 ****
  
          Parameters:
!         - string: the string to be drawn. Supports '\n' and '\t' too.
          - x,y: the posistion
          - width, height: the frame dimensions,
--- 804,809 ----
  
          Parameters:
!         - string: the string to be drawn, supports also '\n'. \t is not supported
!           by pygame, you need to replace it first
          - x,y: the posistion
          - width, height: the frame dimensions,
***************
*** 810,813 ****
--- 816,823 ----
          - mode: the way we should break lines/truncate. Can be 'hard'(based on chars)
            or 'soft' (based on words)
+ 
+         font can also be a skin font object. If so, this functions also supports
+         shadow and border. fgcolor and bgcolor will also be taken from the skin
+         font if set to None when calling this function.
          """
          if not string:
***************
*** 866,879 ****
              if num_lines_left == 1:
                  current_ellipses = ellipses
!             (w, s, r) = self.__drawstringframed_line__(string, width, font, hard,
!                                                        current_ellipses, ' ')
              if s == '' and not hard:
                  # nothing fits? Try to break words at ' -_' and no ellipses
!                 (w, s, r) = self.__drawstringframed_line__(string, width, font, hard,
!                                                            None, ' -_')
                  if s == '':
                      # still nothing? Use the 'hard' way
!                     (w, s, r) = self.__drawstringframed_line__(string, width, font,
!                                                                'hard', None, ' ')
  
              lines.append((w, s))
--- 876,895 ----
              if num_lines_left == 1:
                  current_ellipses = ellipses
!             #
!             # __drawstringframed_line__ returns a list:
!             # width of the text drawn (w), string which is drawn (s),
!             # rest that does not fit (r) and True if the breaking was because
!             # of a \n (n)
!             #
!             (w, s, r, n) = self.__drawstringframed_line__(string, width, font, hard,
!                                                           current_ellipses, ' ')
              if s == '' and not hard:
                  # nothing fits? Try to break words at ' -_' and no ellipses
!                 (w, s, r, n) = self.__drawstringframed_line__(string, width, font, 
hard,
!                                                               None, ' -_')
                  if s == '':
                      # still nothing? Use the 'hard' way
!                     (w, s, r, n) = self.__drawstringframed_line__(string, width, 
font,
!                                                                   'hard', None, ' ')
  
              lines.append((w, s))
***************
*** 882,887 ****
                  num_lines_left -= 1
                  r = r[1:]
  
-             string = r.strip()
              num_lines_left -= 1
  
--- 898,908 ----
                  num_lines_left -= 1
                  r = r[1:]
+                 n = True
+ 
+             if n:
+                 string = r
+             else:
+                 string = r.strip()
  
              num_lines_left -= 1
  




-------------------------------------------------------
This SF.net email is sponsored by: Perforce Software.
Perforce is the Fast Software Configuration Management System offering
advanced branching capabilities and atomic changes on 50+ platforms.
Free Eval! http://www.perforce.com/perforce/loadprog.html
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to