@@ -141,6 +141,7 @@ def __init__(self, cfg, **argv):
141141 :param argv["test"]: Only used in unittests
142142 """
143143 self .visible_text_length = argv ["term_columns" ]
144+ self .endless = cfg ["main" ].getboolean ("endless" )
144145
145146 section_index = str (argv ["section_index" ]) if "section_index" in argv else "1"
146147 str_section = "scrolltext.text " + section_index
@@ -155,24 +156,16 @@ def __init__(self, cfg, **argv):
155156
156157 num_blanks = argv ["blanks" ] if "blanks" in argv else self .visible_text_length
157158 self .blanks = num_blanks * " "
158- self .complete_text = self .blanks + scroll_text + self .blanks
159+ self .complete_text = self .blanks + scroll_text + ( self .blanks if not self . endless else "" )
159160 self .pos = 0
161+ self ._last_pos = 0
160162 self .terminal_pos = len (self .complete_text )
161163 self .right_to_left = scroll_direction
162164 if "test" in argv :
163165 self .scrollspeedsec = 0
164166 else :
165167 self .scrollspeedsec = get_speedsec_float (cfg [str_section ].getint ("speed" ))
166- if not self .right_to_left :
167- self .pos = 0
168- self .terminal_pos = len (self .complete_text )
169- self ._pos_real = 0.
170- self ._last_pos = 0
171- else :
172- self .pos = len (self .complete_text )
173- self .terminal_pos = - 1
174- self ._pos_real = float (self .pos )
175- self ._last_pos = self .pos
168+ self ._set_start_params ()
176169 self .last_time = time ()
177170 self ._text = self .complete_text
178171
@@ -199,7 +192,9 @@ def _next_left_to_right(self):
199192 :rtype: str
200193 """
201194 if self .pos >= self .terminal_pos :
202- return None
195+ if not self .endless :
196+ return None
197+ self ._set_start_params ()
203198 end = self .pos + self .visible_text_length
204199 win_text = self .complete_text [self .pos :end ]
205200 if self .scrollspeedsec == 0 : # Special case for tests
@@ -225,7 +220,9 @@ def _next_right_to_left(self):
225220 :rtype: str
226221 """
227222 if self .pos <= self .terminal_pos :
228- return None
223+ if not self .endless :
224+ return None
225+ self ._set_start_params ()
229226 start = self .pos - self .visible_text_length
230227 win_text = self .complete_text [start :self .pos ]
231228 if self .scrollspeedsec == 0 : # Special case for tests
@@ -241,3 +238,15 @@ def _next_right_to_left(self):
241238 self ._last_pos = self .pos
242239 self ._text = win_text
243240 return self ._text
241+
242+ def _set_start_params (self ):
243+ if not self .right_to_left :
244+ self .pos = 0
245+ self .terminal_pos = len (self .complete_text )
246+ self ._pos_real = 0.
247+ self ._last_pos = 0
248+ else :
249+ self .pos = len (self .complete_text )
250+ self .terminal_pos = - 1
251+ self ._pos_real = float (self .pos )
252+ self ._last_pos = self .pos
0 commit comments