<commit_before>from .scrolled_text_panel import ScrolledTextPanel
from .tools import *
from .view import View

PADDING_LEFT_RIGHT = 20
PADDING_TOP_BOTTOM = 20



class MessageView(View):
  def __init__(self, display, width=480, height=480, maxheight=480):
    View.__init__(self, display)
    
    self.display = display
    self.width = width
    self.height = height
    self.maxheight = maxheight
    self.setHeight(height)
    self.old_screen = display.screen.copy()
    self.old_screen.set_alpha(86)
    self.old_screen = self.blurSurface(self.old_screen)
    self.display_size = display.getSize()
    self.hmiddle = self.display_size[0] / 2
    self.vmiddle = self.display_size[1] / 2
    self.button = None
    
    self.message_box = pygame.Surface((width, self.height))
    self.message_border = pygame.Rect(0, 0, width, self.height)
    
    self.box_x = self.hmiddle - width / 2
    self.box_y = self.vmiddle - height / 2
    
    # long text for checking scrolled text panel
    dummy_text = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, " \
                 "sed diam nonumy eirmod tempor invidunt ut labore et dolore " \
                 "magna aliquyam erat, sed diam voluptua. At vero eos et " \
                 "accusam et justo duo dolores et ea rebum. Stet clita kasd " \
                 "gubergren, no sea takimata sanctus est Lorem ipsum dolor " \
                 "sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing " \
                 "elitr, sed diam nonumy eirmod tempor invidunt ut labore et " \
                 "dolore magna aliquyam erat, sed diam voluptua. At vero eos " \
                 "et accusam et justo duo dolores et ea rebum. Stet clita " \
                 "kasd gubergren, no sea takimata sanctus est Lorem ipsum " \
                 "dolor sit amet. \n" \
                 "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, " \
                 "sed diam nonumy eirmod tempor invidunt ut labore et dolore " \
                 "magna aliquyam erat, sed diam voluptua. At vero eos et " \
                 "accusam et justo duo dolores et ea rebum. Stet clita kasd " \
                 "gubergren, no sea takimata sanctus est Lorem ipsum dolor " \
                 "sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing " \
                 "elitr, sed diam nonumy eirmod tempor invidunt ut labore et " \
                 "dolore magna aliquyam erat, sed diam voluptua. At vero eos " \
                 "et accusam et justo duo dolores et ea rebum. Stet clita " \
                 "kasd gubergren, no sea takimata sanctus est Lorem ipsum " \
                 "dolor sit amet. \n" \
                 "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, " \
                 "sed diam nonumy eirmod tempor invidunt ut labore et dolore " \
                 "magna aliquyam erat, sed diam voluptua. At vero eos et " \
                 "accusam et justo duo dolores et ea rebum. Stet clita kasd " \
                 "gubergren, no sea takimata sanctus est Lorem ipsum dolor " \
                 "sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing " \
                 "elitr, sed diam nonumy eirmod tempor invidunt ut labore et " \
                 "dolore magna aliquyam erat, sed diam voluptua. At vero eos " \
                 "et accusam et justo duo dolores et ea rebum. Stet clita " \
                 "kasd gubergren, no sea takimata sanctus est Lorem ipsum " \
                 "dolor sit amet. \n" \
                 "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, " \
                 "sed diam nonumy eirmod tempor invidunt ut labore et dolore " \
                 "magna aliquyam erat, sed diam voluptua. At vero eos et " \
                 "accusam et justo duo dolores et ea rebum. Stet clita kasd " \
                 "gubergren, no sea takimata sanctus est Lorem ipsum dolor " \
                 "sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing " \
                 "elitr, sed diam nonumy eirmod tempor invidunt ut labore et " \
                 "dolore magna aliquyam erat, sed diam voluptua. At vero eos " \
                 "et accusam et justo duo dolores et ea rebum. Stet clita " \
                 "kasd gubergren, no sea takimata sanctus est Lorem ipsum " \
                 "dolor sit amet."
    
    self.setText(dummy_text)
  
  # setting some automatically formatted and rendered text onto the screen
  def setText(self, text):
    
    self.scrolled_text = ScrolledTextPanel(self.display, self.box_x + PADDING_LEFT_RIGHT, self.box_y + PADDING_TOP_BOTTOM,
                                              self.width - 2 * PADDING_LEFT_RIGHT,
                                              self.height - 2 * PADDING_TOP_BOTTOM)
    self.scrolled_text.setLabel('information')
    self.scrolled_text.addText(text)

    button_height = 0
    if self.button is not None:
      button_height = self.button.getHeight() + PADDING_TOP_BOTTOM
    # calculate new height through the text and adjust the message box
    self.setHeight(self.scrolled_text.getHeight() + button_height + 2 * \
                   PADDING_TOP_BOTTOM)
    self.message_box = pygame.Surface((self.width, self.height))
    self.message_border = pygame.Rect(0, 0, self.width, self.height)
    self.box_y = self.vmiddle - self.height / 2
    #self.scrolled_text.setNewScreen(self.message_box)
    self.scrolled_text = ScrolledTextPanel(self.display, self.box_x + PADDING_LEFT_RIGHT, self.box_y + PADDING_TOP_BOTTOM,
                                              self.width - 2 *
                                              PADDING_LEFT_RIGHT,
                                              self.height - 2 *
                                              PADDING_TOP_BOTTOM - button_height)
    self.scrolled_text.setLabel('information')
    self.scrolled_text.addText(text)
    self.tab_position = 0
    self.tab_order = [self.scrolled_text]
    if self.display.accessibility:
      self.scrolled_text.setFocus(True)<commit_msg>deleted long dummy text in MessageView, replaced by short "No text"<commit_after>from .scrolled_text_panel import ScrolledTextPanel
from .tools import *
from .view import View

PADDING_LEFT_RIGHT = 20
PADDING_TOP_BOTTOM = 20



class MessageView(View):
  def __init__(self, display, width=480, height=480, maxheight=480):
    View.__init__(self, display)
    
    self.display = display
    self.width = width
    self.height = height
    self.maxheight = maxheight
    self.setHeight(height)
    self.old_screen = display.screen.copy()
    self.old_screen.set_alpha(86)
    self.old_screen = self.blurSurface(self.old_screen)
    self.display_size = display.getSize()
    self.hmiddle = self.display_size[0] / 2
    self.vmiddle = self.display_size[1] / 2
    self.button = None
    
    self.message_box = pygame.Surface((width, self.height))
    self.message_border = pygame.Rect(0, 0, width, self.height)
    
    self.box_x = self.hmiddle - width / 2
    self.box_y = self.vmiddle - height / 2
    
    # # long text for checking scrolled text panel
    # dummy_text = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, " \
    #              "sed diam nonumy eirmod tempor invidunt ut labore et dolore " \
    #              "magna aliquyam erat, sed diam voluptua. At vero eos et " \
    #              "accusam et justo duo dolores et ea rebum. Stet clita kasd " \
    #              "gubergren, no sea takimata sanctus est Lorem ipsum dolor " \
    #              "sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing " \
    #              "elitr, sed diam nonumy eirmod tempor invidunt ut labore et " \
    #              "dolore magna aliquyam erat, sed diam voluptua. At vero eos " \
    #              "et accusam et justo duo dolores et ea rebum. Stet clita " \
    #              "kasd gubergren, no sea takimata sanctus est Lorem ipsum " \
    #              "dolor sit amet. \n" \
    #              "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, " \
    #              "sed diam nonumy eirmod tempor invidunt ut labore et dolore " \
    #              "magna aliquyam erat, sed diam voluptua. At vero eos et " \
    #              "accusam et justo duo dolores et ea rebum. Stet clita kasd " \
    #              "gubergren, no sea takimata sanctus est Lorem ipsum dolor " \
    #              "sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing " \
    #              "elitr, sed diam nonumy eirmod tempor invidunt ut labore et " \
    #              "dolore magna aliquyam erat, sed diam voluptua. At vero eos " \
    #              "et accusam et justo duo dolores et ea rebum. Stet clita " \
    #              "kasd gubergren, no sea takimata sanctus est Lorem ipsum " \
    #              "dolor sit amet. \n" \
    #              "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, " \
    #              "sed diam nonumy eirmod tempor invidunt ut labore et dolore " \
    #              "magna aliquyam erat, sed diam voluptua. At vero eos et " \
    #              "accusam et justo duo dolores et ea rebum. Stet clita kasd " \
    #              "gubergren, no sea takimata sanctus est Lorem ipsum dolor " \
    #              "sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing " \
    #              "elitr, sed diam nonumy eirmod tempor invidunt ut labore et " \
    #              "dolore magna aliquyam erat, sed diam voluptua. At vero eos " \
    #              "et accusam et justo duo dolores et ea rebum. Stet clita " \
    #              "kasd gubergren, no sea takimata sanctus est Lorem ipsum " \
    #              "dolor sit amet. \n" \
    #              "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, " \
    #              "sed diam nonumy eirmod tempor invidunt ut labore et dolore " \
    #              "magna aliquyam erat, sed diam voluptua. At vero eos et " \
    #              "accusam et justo duo dolores et ea rebum. Stet clita kasd " \
    #              "gubergren, no sea takimata sanctus est Lorem ipsum dolor " \
    #              "sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing " \
    #              "elitr, sed diam nonumy eirmod tempor invidunt ut labore et " \
    #              "dolore magna aliquyam erat, sed diam voluptua. At vero eos " \
    #              "et accusam et justo duo dolores et ea rebum. Stet clita " \
    #              "kasd gubergren, no sea takimata sanctus est Lorem ipsum " \
    #              "dolor sit amet."
    
    dummy_text = "No text"
    self.setText(dummy_text)
  
  
  # setting some automatically formatted and rendered text onto the screen
  def setText(self, text):
    
    self.scrolled_text = ScrolledTextPanel(self.display, self.box_x + PADDING_LEFT_RIGHT, self.box_y + PADDING_TOP_BOTTOM,
                                              self.width - 2 * PADDING_LEFT_RIGHT,
                                              self.height - 2 * PADDING_TOP_BOTTOM)
    self.scrolled_text.setLabel('information')
    self.scrolled_text.addText(text)

    button_height = 0
    if self.button is not None:
      button_height = self.button.getHeight() + PADDING_TOP_BOTTOM
    # calculate new height through the text and adjust the message box
    self.setHeight(self.scrolled_text.getHeight() + button_height + 2 * \
                   PADDING_TOP_BOTTOM)
    self.message_box = pygame.Surface((self.width, self.height))
    self.message_border = pygame.Rect(0, 0, self.width, self.height)
    self.box_y = self.vmiddle - self.height / 2
    #self.scrolled_text.setNewScreen(self.message_box)
    self.scrolled_text = ScrolledTextPanel(self.display, self.box_x + PADDING_LEFT_RIGHT, self.box_y + PADDING_TOP_BOTTOM,
                                              self.width - 2 *
                                              PADDING_LEFT_RIGHT,
                                              self.height - 2 *
                                              PADDING_TOP_BOTTOM - button_height)
    self.scrolled_text.setLabel('information')
    self.scrolled_text.addText(text)
    self.tab_position = 0
    self.tab_order = [self.scrolled_text]
    if self.display.accessibility:
      self.scrolled_text.setFocus(True)
{'fraction_non_alphanumeric': 0.07389525368248773, 'fraction_numerical': 0.005400981996726678, 'mean_word_length': 1.8667604973023693, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 56, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5486702', 'n_tokens_mistral': 3975, 'n_tokens_neox': 3864, 'n_words': 1140}