Beispiel #1
0
    def create_keybindings_file():
        """
        Create a default keybindings file with comments. This function is
        called when Power Format Pack cannot find an existing
        keybindings file. Override any changes made to an existing file.
        """

        config_path = os.path.join(PrefHelper.get_addons_folder(),
                                   const.FOLDER_NAME, const.CONFIG_FILENAME)
        c = utility.get_config_parser(config_path)

        contents = c.get(const.CONFIG_KEYBINDINGS, "help_text")
        contents += u"\n\n{\n"

        for key, value in sorted(
                PrefHelper.get_default_keybindings().iteritems()):
            contents += u"    \"{}\": \"{}\",\n".format(key, value)

        contents += u"    \"_version\": \"{}\"\n".format(const.VERSION)
        contents += u"}"

        try:
            with codecs.open(PrefHelper.get_keybindings_path(),
                             "w",
                             encoding="utf8") as f:
                f.write(contents)
        except IOError as e:
            raise e
Beispiel #2
0
    def create_keybindings_file():
        """
        Create a default keybindings file with comments. This function is
        called when Power Format Pack cannot find an existing
        keybindings file. Override any changes made to an existing file.
        """

        config_path = os.path.join(PrefHelper.get_addons_folder(),
                                   const.FOLDER_NAME,
                                   const.CONFIG_FILENAME)
        c = utility.get_config_parser(config_path)

        contents = c.get(const.CONFIG_KEYBINDINGS, "help_text")
        contents += u"\n\n{\n"

        for key, value in sorted(PrefHelper.get_default_keybindings().iteritems()):
            contents += u"    \"{}\": \"{}\",\n".format(key, value)

        contents += u"    \"_version\": \"{}\"\n".format(const.VERSION)
        contents += u"}"

        try:
            with codecs.open(PrefHelper.get_keybindings_path(), "w", encoding="utf8") as f:
                f.write(contents)
        except IOError as e:
            raise e
Beispiel #3
0
    def __init__(self, other, parent_window, fixed=False):
        super(OrderedList, self).__init__(parent_window)
        self.editor_instance = other
        config_path = os.path.join(PrefHelper.get_addons_folder(),
                                   const.FOLDER_NAME,
                                   const.CONFIG_FILENAME)
        self.c = utility.get_config_parser(config_path)

        if not fixed:
            self.show_dialog_window()
        else:
            self.insert_ordered_list(
                    preferences.PREFS["fixed_ol_type"][0], 1)
Beispiel #4
0
    def __init__(self, other, parent_window, selected_text):
        self.editor_instance = other
        self.parent_window = parent_window
        self.selected_text = selected_text
        self.c = utility.get_config_parser()
        self.p = preferences.PREFS

        if self.p.get(const.STYLE_TABLE):
            self.TABLE_STYLING = \
                u"style='font-size: 1em; width: 100%; border-collapse: collapse;'"
            self.HEAD_STYLING = \
                u"align=\"{0}\" style=\"width: {1}%; padding: 5px;" \
                + u"border-bottom: 2px solid #00B3FF\""
            self.BODY_STYLING = \
                u"style='text-align: {0}; padding: 5px;" \
                + u"border-bottom: 1px solid #B0B0B0'"
        else:
            self.TABLE_STYLING = self.HEAD_STYLING = self.BODY_STYLING = u""

        self.setup()
Beispiel #5
0
    def __init__(self, other, parent_window, selected_text):
        self.editor_instance    = other
        self.parent_window      = parent_window
        self.selected_text      = selected_text
        self.c                  = utility.get_config_parser()
        self.p                  = preferences.PREFS

        if self.p.get(const.STYLE_TABLE):
            self.TABLE_STYLING = \
                u"style='font-size: 1em; width: 100%; border-collapse: collapse;'"
            self.HEAD_STYLING = \
                u"align=\"{0}\" style=\"width: {1}%; padding: 5px;" \
                + u"border-bottom: 2px solid #00B3FF\""
            self.BODY_STYLING = \
                u"style='text-align: {0}; padding: 5px;" \
                + u"border-bottom: 1px solid #B0B0B0'"
        else:
            self.TABLE_STYLING = self.HEAD_STYLING = self.BODY_STYLING = u""

        self.setup()
Beispiel #6
0
 def __init__(self, other, parent_window, note, html,
              current_field, selected_html):
     assert isinstance(html, unicode), "Input `html` is not Unicode"
     assert isinstance(selected_html, unicode), "Input `selected_html` is not Unicode"
     self.c                              = utility.get_config_parser()
     self.editor_instance                = other
     self.parent_window                  = parent_window
     self.col                            = mw.col
     self.note                           = note
     self.html                           = html
     self.cancel_html                    = ""
     self.current_field                  = current_field
     self.selected_html                  = selected_html
     self.current_note_id_and_field      = str(self.note.id) + \
                                           "-{:03}".format(self.current_field)
     self._id                            = None
     self.isconverted                    = None
     self.md                             = None
     self._lastmodified                  = None
     self.has_data                       = self.get_data_from_field()
     if not self.has_data:
         self.remove_warn_msg(self.editor_instance, self.current_field)
     const.MARKDOWN_PREFS["isconverted"] = self.isconverted
Beispiel #7
0
 def __init__(self, other, parent_window, note, html, current_field,
              selected_html):
     # assert isinstance(html, unicode), "Input `html` is not Unicode"
     # assert isinstance(selected_html, unicode), "Input `selected_html` is not Unicode"
     self.c = utility.get_config_parser()
     self.p = preferences.PREFS
     self.editor_instance = other
     self.parent_window = parent_window
     self.col = mw.col
     self.note = note
     self.html = html
     self.cancel_html = ""
     self.current_field = current_field
     self.selected_html = selected_html
     self.current_note_id_and_field      = str(self.note.id) + \
                                           "-{:03}".format(self.current_field)
     self._id = None
     self.isconverted = None
     self.md = None
     self._lastmodified = None
     self.has_data = self.get_data_from_field()
     if not self.has_data:
         self.remove_warn_msg(self.editor_instance, self.current_field)
     const.MARKDOWN_PREFS["isconverted"] = self.isconverted
Beispiel #8
0
 def __init__(self, main_window, preferences):
     super(ExtraButtons_Options, self).__init__()
     self.main_window = main_window
     self.radio_buttons = list()
     self.c = utility.get_config_parser()
Beispiel #9
0
 def __init__(self, main_window, preferences):
     super(ExtraButtons_Options, self).__init__()
     self.main_window = main_window
     self.radio_buttons = list()
     self.c = utility.get_config_parser()