コード例 #1
0
    def reconfigure_settings(self, overwrite_with_default=False):
        if overwrite_with_default:
            _settings = load_settings_data(default=True)
        else:
            _settings = load_settings_data()
        font_family = _settings['font_family']
        bg_color = _settings['textarea_background_color']
        font_color = _settings['font_color']
        top_spacing = _settings['text_top_lineheight']
        bottom_spacing = _settings['text_bottom_lineheight']
        insertion_blink = 300 if _settings['insertion_blink'] else 0
        insertion_color = _settings['insertion_color']
        tab_size_spaces = _settings['tab_size']
        padding_x = _settings['textarea_padding_x']
        padding_y = _settings['textarea_padding_y']
        text_wrap = _settings['text_wrap']
        border = _settings['textarea_border']
        text_selection_bg = _settings['text_selection_bg']
        scrollx_clr = _settings['horizontal_scrollbar_color']
        troughx_clr = _settings['horizontal_scrollbar_trough_color']
        scrollx_width = _settings['horizontal_scrollbar_width']
        scrollx_active_bg = _settings['horizontal_scrollbar_active_bg']
        menu_fg = _settings['menu_fg']
        menu_bg = _settings['menu_bg']

        font_style = tk_font.Font(family=font_family,
                                  size=_settings['font_size'])

        self.textarea.configure(font=font_style,
                                bg=bg_color,
                                pady=padding_y,
                                padx=padding_x,
                                fg=font_color,
                                spacing1=top_spacing,
                                spacing3=bottom_spacing,
                                insertbackground=insertion_color,
                                selectbackground=text_selection_bg,
                                insertofftime=insertion_blink,
                                bd=border,
                                highlightthickness=border,
                                wrap=text_wrap)

        self.set_new_tab_width(tab_size_spaces)
        self.menubar.reconfigure_settings()
        self.linenumbers.font_color = menu_fg
        self.linenumbers.config(bg=bg_color, highlightbackground=bg_color)
        self.statusbar._label.config(bg=bg_color)
        self.linenumbers.redraw()

        if overwrite_with_default:
            MsgBox = tk.messagebox.askquestion(
                'Reset Settings?',
                'Are you sure you want to reset the editor settings to their default value?',
                icon='warning')
            if MsgBox == 'yes':
                store_settings_data(_settings)
            else:
                self.save('config/settings.yaml')
コード例 #2
0
    def load_new_theme(self, path):

        with open(path) as new_theme_config:
            new_config = yaml.load(new_theme_config, Loader=yaml.FullLoader)

        self.comment_color = new_config['comment_color']
        self.string_color = new_config['string_color']
        self.number_color = new_config['number_color']
        self.keyword_color = new_config['keyword_color']
        self.function_color = new_config['function_color']
        self.class_color = new_config['class_color']
        self.object_color = new_config['object_color']

        settings = load_settings_data()
        settings['menu_fg'] = new_config['comment_color']
        settings['menu_bg'] = new_config['bg_color']
        settings['font_color'] = new_config['font_color']
        settings['textarea_background_color'] = new_config['bg_color']
        settings['menubar_active_bg'] = new_config['menu_bg_active']
        settings['menubar_active_fg'] = new_config['menu_fg_active']
        settings['menu_active_bg'] = new_config['menu_bg_active']
        settings['menu_active_fg'] = new_config['menu_fg_active']
        store_settings_data(settings)

        self.parent.reconfigure_settings()
        self.syntax_theme_configuration()
        self.initial_highlight()
コード例 #3
0
    def __init__(self, parent, *args, **kwargs):
        tk.Listbox.__init__(self, parent, *args, **kwargs)

        self.settings = load_settings_data()
        self.font_family = self.settings['font_family']
        self.parent = parent

        # setting tk.RIGHT click menu bar
        self.right_click_menu = tk.Menu(parent,
                                        font=self.font_family,
                                        fg='#d5c4a1',
                                        bg='#2e2724',
                                        activebackground='#9c8383',
                                        bd=0,
                                        tearoff=0)

        self.right_click_menu.add_command(label='Cut',
                                          accelerator='Ctrl+X',
                                          command=self.cut)

        self.right_click_menu.add_command(label='Copy',
                                          accelerator='Ctrl+C',
                                          command=self.copy)

        self.right_click_menu.add_command(label='Paste',
                                          accelerator='Ctrl+V',
                                          command=self.paste)

        self.right_click_menu.add_command(label='Bold',
                                          accelerator='Ctrl+B',
                                          command=self.bold)

        self.right_click_menu.add_command(label='Highlight',
                                          accelerator='Ctrl+H',
                                          command=self.hightlight)
コード例 #4
0
 def __init__(self, *args, **kwargs):
     settings = load_settings_data()
     super().__init__(bg=settings["menu_bg"],
                      fg=settings['menu_fg'],
                      activeforeground=settings['menu_active_fg'],
                      activebackground=settings['menu_active_bg'],
                      activeborderwidth=0,
                      bd=0,
                      *args, **kwargs)
コード例 #5
0
    def __init__(self, parent, text_widget, initial_content):
        self.settings = load_settings_data()

        self.parent = parent
        self.text = text_widget
        self.font_family = self.parent.font_family
        self.font_size = self.parent.font_size
        self.previousContent = initial_content
        self.lexer = PythonLexer

        self.comment_tokens = [
            "Token.Comment.Single",
        ]
        self.string_tokens = [
            "Token.Name.Function", "Token.Name.Class", "Token.String",
            "Token.Literal.String.Single", "Token.Literal.String.Double"
        ]
        self.object_tokens = [
            "Token.Name.Class",
            "Token.Name.Function",
        ]
        self.number_tokens = [
            "Token.Keyword.Constant",
            "Token.Literal.String.Interpol",
            "Token.Literal.Number.Integer",
            "Token.Literal.Number.Float",
            "Token.Name.Decorator",
        ]
        self.keyword_tokens = [
            "Token.Operator",
            "Token.Operator.Word",
            "Token.Keyword.Namespace",
        ]
        self.function_tokens = [
            "Token.Keyword",
            "Token.Name.Builtin",
            "Token.Literal.String.Affix",
            "Token.Name.Function.Magic",
        ]
        self.class_tokens = [
            "Token.Name.Builtin.Pseudo",
        ]
        self.variable_tokens = [
            "Token.Name.Namespace",
        ]

        self.comment_color = '#928374'
        self.string_color = '#b8bb26'
        self.number_color = '#d3869b'
        self.keyword_color = '#fe8019'
        self.function_color = '#8ec87c'
        self.class_color = '#d3869b'
        self.object_color = '#b8bb26'
コード例 #6
0
    def reconfigure_settings(self):
        settings = load_settings_data()
        for field in self.menu_fields:
            field.configure(bg=settings['menu_bg'],
                            fg=settings['menu_fg'],
                            activeforeground=settings['menu_active_fg'],
                            activebackground=settings['menu_active_bg'],
                            background = settings['textarea_background_color'],)

        self._menubar.configure(bg=settings['menu_bg'],
                                fg=settings['menu_fg'],
                                background = settings['textarea_background_color'],
                                activeforeground= settings['menubar_active_fg'],
                                activebackground= settings['menubar_active_bg'],)
コード例 #7
0
    def change_font_size(self, delta):
        self.font_size = self.font_size + delta
        min_font_size = 6
        self.font_size = min_font_size if self.font_size < min_font_size else self.font_size
        self.font_style = tk_font.Font(family=self.font_family,
                                       size=self.font_size)

        self.italics = tk_font.Font(family=self.font_family,
                                    size=self.font_size,
                                    slant='italic')

        self.textarea.configure(font=self.font_style)
        self.syntax_highlighter.text.tag_configure("Token.Name.Builtin.Pseudo",font=self.italics)
        self.set_new_tab_width()
        
        _settings = load_settings_data()
        _settings['font_size'] = self.font_size
        store_settings_data(_settings)

        if self.filename == 'config/settings.yaml':
            self.clear_and_replace_textarea()
コード例 #8
0
    def __init__(self, parent):
        self._parent = parent
        self.syntax = parent.syntax_highlighter
        self.settings = load_settings_data()
        font_specs = ('Droid Sans Fallback', 12)

        # setting up basic features in menubar
        menubar = tk.Menu(parent.master,
                          font=font_specs,
                          fg=self.settings['menu_fg'],
                          bg=self.settings['menu_bg'],
                          activeforeground=self.settings['menubar_active_fg'],
                          activebackground=self.settings['menubar_active_bg'],
                          activeborderwidth=0,
                          bd=0)

        parent.master.config(menu=menubar)
        self._menubar = menubar
        # adding features file dropdown in menubar
        file_dropdown = Menu(menubar, font=font_specs, tearoff=0)
        # new file creation feature
        file_dropdown.add_command(label='New File',
                                  accelerator='Ctrl+N',
                                  command=parent.new_file)
        # open file feature
        file_dropdown.add_command(label='Open File',
                                  accelerator='Ctrl+O',
                                  command=parent.open_file)
        # save file feature
        file_dropdown.add_command(label='Save',
                                  accelerator='Ctrl+S',
                                  command=parent.save)
        # Save as feature
        file_dropdown.add_command(label='Save As',
                                  accelerator='Ctrl+Shift+S',
                                  command=parent.save_as)
        # exit feature
        file_dropdown.add_separator()
        file_dropdown.add_command(label='Exit', command=parent.on_closing)

        # adding featues to settings dropdown in menubar
        # Edit settings feature
        settings_dropdown = Menu(menubar, font=font_specs, tearoff=0)
        settings_dropdown.add_command(label='Edit Settings',
                                      command=parent.open_settings_file)
        # reset settings feature
        settings_dropdown.add_command(label='Reset Settings to Default',
                                      command=parent.reset_settings_file)

        #view dropdown menu
        view_dropdown = Menu(menubar, font=font_specs, tearoff=0)
        view_dropdown.add_command(label='Hide Menu Bar',
                                  accelerator='Alt',
                                  command=self.hide_menu)

        view_dropdown.add_command(label='Hide Status Bar',
                                  command=parent.hide_status_bar)

        view_dropdown.add_command(label='Toggle Line Numbers',
                                  accelerator='Ctrl+Shift+L',
                                  command=parent.toggle_linenumbers)

        view_dropdown.add_command(label='Enter Quiet Mode',
                                  accelerator='Ctrl+Q',
                                  command=self.enter_quiet_mode)

        #tools dropdown menu
        tools_dropdown = Menu(menubar, font=font_specs, tearoff=0)
        tools_dropdown.add_command(label='Open Color Selector',
                                   accelerator='Ctrl+M',
                                   command=self.open_color_picker)

        tools_dropdown.add_command(label='Run Selected File',
                                   accelerator='Ctrl+R',
                                   command=parent.run)

        #syntax dropdown menu
        syntax_dropdown = Menu(menubar, font=font_specs, tearoff=0)
        syntax_dropdown.add_command(label='Monokai', command=self.load_monokai)

        syntax_dropdown.add_command(label='Monokai Pro',
                                    command=self.load_monokai_pro)

        syntax_dropdown.add_command(label='Gruvbox', command=self.load_gruvbox)

        syntax_dropdown.add_command(label='Solarized',
                                    command=self.load_solarized)

        # menubar add buttons
        menubar.add_cascade(label='File', menu=file_dropdown)
        menubar.add_cascade(label='View', menu=view_dropdown)
        menubar.add_cascade(label='Settings', menu=settings_dropdown)
        menubar.add_cascade(label='Tools', menu=tools_dropdown)
        menubar.add_cascade(label='Color Schemes', menu=syntax_dropdown)
        # menubar.add_cascade(label='About', menu=about_dropdown)

        self.menu_fields = [
            field
            for field in (file_dropdown, view_dropdown, settings_dropdown,
                          tools_dropdown, syntax_dropdown)
        ]
コード例 #9
0
    def __init__(self, *args, **kwargs):
        tk.Frame.__init__(self, *args, **kwargs)
        master.title('untitled - Quiet Text')
        # defined size of the editer window
        master.geometry('1920x1080')

        # start editor according to defined settings in settings.yaml
        self.settings = load_settings_data()

        self.font_family = self.settings['font_family']
        self.bg_color = self.settings['textarea_background_color']
        self.font_color = self.settings['font_color']
        self.tab_size = self.settings['tab_size']
        self.font_size = int(self.settings['font_size'])
        self.top_spacing = self.settings['text_top_lineheight']
        self.bottom_spacing = self.settings['text_bottom_lineheight']
        self.padding_x = self.settings['textarea_padding_x']
        self.padding_y = self.settings['textarea_padding_y']
        self.insertion_blink = 300 if self.settings['insertion_blink'] else 0
        self.insertion_color = self.settings['insertion_color']
        self.tab_size_spaces = self.settings['tab_size']
        self.text_wrap = self.settings['text_wrap']
        self.autoclose_parens = self.settings['autoclose_parentheses']
        self.autoclose_curlybraces = self.settings['autoclose_curlybraces']
        self.autoclose_squarebrackets = self.settings[
            'autoclose_squarebrackets']
        self.autoclose_singlequotes = self.settings['autoclose_singlequotes']
        self.autoclose_doublequotes = self.settings['autoclose_doublequotes']
        self.border = self.settings['textarea_border']
        self.text_selection_bg = self.settings['text_selection_bg']
        self.scrollx_clr = self.settings['horizontal_scrollbar_color']
        self.troughx_clr = self.settings['horizontal_scrollbar_trough_color']
        self.scrollx_width = self.settings['horizontal_scrollbar_width']
        self.scrollx_active_bg = self.settings[
            'horizontal_scrollbar_active_bg']
        self.scrolly_clr = self.settings['vertical_scrollbar_color']
        self.troughy_clr = self.settings['vertical_scrollbar_trough_color']
        self.scrolly_width = self.settings['vertical_scrollbar_width']
        self.scrolly_active_bg = self.settings['vertical_scrollbar_active_bg']
        self.menu_fg = self.settings['menu_fg']
        self.menu_bg = self.settings['menu_bg']

        master.tk_setPalette(background=self.bg_color, foreground='black')
        self.font_style = tk_font.Font(family=self.font_family,
                                       size=self.settings['font_size'])

        #configuration of the file dialog text colors.

        self.italics = tk_font.Font(family=self.font_family, slant='italic')
        self.master = master
        self.filename = None

        self.textarea = CustomText(self)

        self.scrolly = tk.Scrollbar(master,
                                    command=self.textarea.yview,
                                    bg=self.scrolly_clr,
                                    troughcolor=self.troughy_clr,
                                    bd=0,
                                    width=self.scrolly_width,
                                    highlightthickness=0,
                                    activebackground=self.scrolly_active_bg,
                                    orient='vertical')

        self.scrollx = tk.Scrollbar(master,
                                    command=self.textarea.xview,
                                    bg=self.scrollx_clr,
                                    troughcolor=self.troughx_clr,
                                    bd=0,
                                    width=self.scrollx_width,
                                    highlightthickness=0,
                                    activebackground=self.scrollx_active_bg,
                                    orient='horizontal')

        self.textarea.configure(yscrollcommand=self.scrolly.set,
                                xscrollcommand=self.scrollx.set,
                                bg=self.bg_color,
                                fg=self.font_color,
                                wrap=self.text_wrap,
                                spacing1=self.top_spacing,
                                spacing3=self.bottom_spacing,
                                selectbackground=self.text_selection_bg,
                                insertbackground=self.insertion_color,
                                insertofftime=self.insertion_blink,
                                bd=self.border,
                                highlightthickness=self.border,
                                highlightbackground='black',
                                font=self.font_family,
                                undo=True,
                                autoseparators=True,
                                maxundo=-1,
                                padx=self.padding_x,
                                pady=self.padding_y)

        self.initial_content = self.textarea.get("1.0", tk.END)

        #retrieving the font from the text area and setting a tab width
        self._font = tk_font.Font(font=self.textarea['font'])
        self._tab_width = self._font.measure(' ' * self.tab_size_spaces)
        self.textarea.config(tabs=(self._tab_width, ))

        self.menu_hidden = 1
        self.context_menu = ContextMenu(self)
        self.statusbar = Statusbar(self)
        self.linenumbers = TextLineNumbers(self)
        self.syntax_highlighter = SyntaxHighlighting(self, self.textarea,
                                                     self.initial_content)
        self.menubar = Menubar(self)

        self.linenumbers.attach(self.textarea)
        self.scrolly.pack(side=tk.RIGHT, fill=tk.Y)
        self.scrollx.pack(side=tk.BOTTOM, fill='both')
        self.linenumbers.pack(side=tk.LEFT, fill=tk.Y)
        self.textarea.pack(side=tk.RIGHT, fill='both', expand=True)

        self.textarea.tag_configure('find_match', background='#75715e')
        self.textarea.find_match_index = None
        self.textarea.find_search_starting_index = 1.0

        self.tags_configured = False
        #calling function to bind hotkeys.
        self.bind_shortcuts()
        self.control_key = False