<commit_before>#!/usr/bin/python3
#-*- encoding: utf-8
"""
The main class that starts and runs Suplemon.
"""

__version__ = "0.1.6"

import os
import sys
import time

import ui
import modules

from helpers import *
from logger import *
from config import *
from editor import *
from file import *

class App:
    def __init__(self):
        self.version = __version__
        self.inited = 0
        self.running = 0

        # Set default variables
        self.path = os.path.dirname(os.path.realpath(__file__))
        self.files = []
        self.current_file = 0
        self.status_msg = ""
        self.last_input = None
        self.global_buffer = []
        self.init_keys()

        # Load core components
        self.logger = Logger()
        self.config = Config(self)
        self.config.load()
        self.ui = ui.UI(self) # Load user interface

        # Load extension modules
        self.modules = modules.ModuleLoader(self)
        self.modules.load()

        # Indicate that windows etc. have been created.
        self.inited = 1

    def init_keys(self):
        self.key_bindings = {
            "^H": self.help,               # Ctrl + H
            "^S": self.save_file,          # Ctrl + S
            "^E": self.run_command,        # Ctrl + E
            "^F": self.find,               # Ctrl + F
            "^G": self.go_to,              # Ctrl + G
            "^O": self.open,               # Ctrl + O
            "^K": self.close_file,         # Ctrl + K
            "^N": self.new_file,           # Ctrl + N
            "^X": self.ask_exit,           # Ctrl + X
            554: self.prev_file,           # Ctrl + Page Up
            549: self.next_file,           # Ctrl + Page Down
            265: self.save_file_as,        # F1
            266: self.reload_file,         # F2
            272: self.toggle_mouse,        # F8
            275: self.toggle_fullscreen,   # F12
        }

    def set_key_binding(self, key, callback):
        self.key_bindings[key] = callback

    def log(self, text, log_type=LOG_ERROR):
        """Add text to the log buffer."""
        self.logger.log(text, log_type)

    def load(self):
        
        """Load the app."""
        if sys.version_info[0] < 3 or (sys.version_info[0] == 3 and sys.version_info[1] < 3):
            ver = ".".join(map(str, sys.version_info[0:2]))
            self.log("Running Suplemon with Python "+ver+" wich isn't officialy supported. Please use Python 3.3 or higher.", LOG_WARNING)
        self.ui.load()
        self.load_files()
        loaded = True

    def exit(self):
        """Stop the main loop and exit."""
        self.running = 0

    def run(self):
        """Run the app."""
        # Load ui and files etc
        self.load()
        self.running = 1
        # Initial render
        self.get_editor().resize()
        self.ui.refresh()
        # Start mainloop
        self.main_loop()
        # Unload ui
        self.ui.unload()

    def main_loop(self):
        """Run the terminal IO loop until exit() is called."""
        while self.running:
            # Update ui before refreshing it
            self.ui.update()
            # See if we have input to process
            event = self.ui.get_input()
            if event:<commit_msg>Fixed typo.<commit_after>#!/usr/bin/python3
#-*- encoding: utf-8
"""
The main class that starts and runs Suplemon.
"""

__version__ = "0.1.6"

import os
import sys
import time

import ui
import modules

from helpers import *
from logger import *
from config import *
from editor import *
from file import *

class App:
    def __init__(self):
        self.version = __version__
        self.inited = 0
        self.running = 0

        # Set default variables
        self.path = os.path.dirname(os.path.realpath(__file__))
        self.files = []
        self.current_file = 0
        self.status_msg = ""
        self.last_input = None
        self.global_buffer = []
        self.init_keys()

        # Load core components
        self.logger = Logger()
        self.config = Config(self)
        self.config.load()
        self.ui = ui.UI(self) # Load user interface

        # Load extension modules
        self.modules = modules.ModuleLoader(self)
        self.modules.load()

        # Indicate that windows etc. have been created.
        self.inited = 1

    def init_keys(self):
        self.key_bindings = {
            "^H": self.help,               # Ctrl + H
            "^S": self.save_file,          # Ctrl + S
            "^E": self.run_command,        # Ctrl + E
            "^F": self.find,               # Ctrl + F
            "^G": self.go_to,              # Ctrl + G
            "^O": self.open,               # Ctrl + O
            "^K": self.close_file,         # Ctrl + K
            "^N": self.new_file,           # Ctrl + N
            "^X": self.ask_exit,           # Ctrl + X
            554: self.prev_file,           # Ctrl + Page Up
            549: self.next_file,           # Ctrl + Page Down
            265: self.save_file_as,        # F1
            266: self.reload_file,         # F2
            272: self.toggle_mouse,        # F8
            275: self.toggle_fullscreen,   # F12
        }

    def set_key_binding(self, key, callback):
        self.key_bindings[key] = callback

    def log(self, text, log_type=LOG_ERROR):
        """Add text to the log buffer."""
        self.logger.log(text, log_type)

    def load(self):
        """Load the app."""
        if sys.version_info[0] < 3 or (sys.version_info[0] == 3 and sys.version_info[1] < 3):
            ver = ".".join(map(str, sys.version_info[0:2]))
            self.log("Running Suplemon with Python "+ver+" which isn't officialy supported. Please use Python 3.3 or higher.", LOG_WARNING)
        self.ui.load()
        self.load_files()
        loaded = True

    def exit(self):
        """Stop the main loop and exit."""
        self.running = 0

    def run(self):
        """Run the app."""
        # Load ui and files etc
        self.load()
        self.running = 1
        # Initial render
        self.get_editor().resize()
        self.ui.refresh()
        # Start mainloop
        self.main_loop()
        # Unload ui
        self.ui.unload()

    def main_loop(self):
        """Run the terminal IO loop until exit() is called."""
        while self.running:
            # Update ui before refreshing it
            self.ui.update()
            # See if we have input to process
            event = self.ui.get_input()
            if event:
{'fraction_non_alphanumeric': 0.11457055214723927, 'fraction_numerical': 0.013496932515337423, 'mean_word_length': 1.5897537728355837, 'pattern_counts': {'":': 18, '<': 7, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1227269', 'n_tokens_mistral': 2008, 'n_tokens_neox': 1909, 'n_words': 536}