Esempio n. 1
0
    def LoadState(self):
        # Показывать ли номера строк?
        self.lineNumbers = configelements.BooleanElement (self.__config.lineNumbers, self.lineNumbersCheckBox)

        # Шрифт для редактора
        fontOption = FontOption (self.__config.fontName,
                                 self.__config.fontSize,
                                 self.__config.fontIsBold,
                                 self.__config.fontIsItalic)

        self.fontEditor = configelements.FontElement (fontOption, self.fontPicker)

        # Размер табуляции
        self.tabWidth = configelements.IntegerElement (self.__config.tabWidth,
                                                       self.tabWidthSpin,
                                                       self.MIN_TAB_WIDTH,
                                                       self.MAX_TAB_WIDTH)

        if self.__config.homeEndKeys.value == 0:
            self.homeEndCombo.SetSelection (0)
        else:
            self.homeEndCombo.SetSelection (1)

        if StcStyle.checkColorString (self.__config.fontColor.value):
            self.fontColorPicker.SetColour (self.__config.fontColor.value)
        else:
            self.fontColorPicker.SetColour (wx.Color (0, 0, 0))


        if StcStyle.checkColorString (self.__config.backColor.value):
            self.backColorPicker.SetColour (self.__config.backColor.value)
        else:
            self.backColorPicker.SetColour (wx.Color (255, 255, 255))
Esempio n. 2
0
    def LoadState(self):
        # Показывать ли номера строк?
        self.lineNumbers = configelements.BooleanElement(
            self.__config.lineNumbers, self.lineNumbersCheckBox)

        # Шрифт для редактора
        fontOption = FontOption(self.__config.fontName, self.__config.fontSize,
                                self.__config.fontIsBold,
                                self.__config.fontIsItalic)

        self.fontEditor = configelements.FontElement(fontOption,
                                                     self.fontPicker)

        # Размер табуляции
        self.tabWidth = configelements.IntegerElement(self.__config.tabWidth,
                                                      self.tabWidthSpin,
                                                      self.MIN_TAB_WIDTH,
                                                      self.MAX_TAB_WIDTH)

        if self.__config.homeEndKeys.value == 0:
            self.homeEndCombo.SetSelection(0)
        else:
            self.homeEndCombo.SetSelection(1)

        if StcStyle.checkColorString(self.__config.fontColor.value):
            self.fontColorPicker.SetColour(self.__config.fontColor.value)
        else:
            self.fontColorPicker.SetColour(wx.Color(0, 0, 0))

        if StcStyle.checkColorString(self.__config.backColor.value):
            self.backColorPicker.SetColour(self.__config.backColor.value)
        else:
            self.backColorPicker.SetColour(wx.Color(255, 255, 255))
Esempio n. 3
0
 def testDefaultStyle(self):
     style = StcStyle()
     self.assertEqual(style.bold, False)
     self.assertEqual(style.italic, False)
     self.assertEqual(style.underline, False)
     self.assertEqual(style.fore, "#000000")
     self.assertEqual(style.back, "#FFFFFF")
Esempio n. 4
0
 def testCreateStyle_02(self):
     style = StcStyle(bold=True)
     self.assertEqual(style.bold, True)
     self.assertEqual(style.italic, False)
     self.assertEqual(style.underline, False)
     self.assertEqual(style.fore, "#000000")
     self.assertEqual(style.back, "#FFFFFF")
Esempio n. 5
0
 def testCreateStyle_01(self):
     style = StcStyle(fore="#556677")
     self.assertEqual(style.bold, False)
     self.assertEqual(style.italic, False)
     self.assertEqual(style.underline, False)
     self.assertEqual(style.fore, "#556677")
     self.assertEqual(style.back, "#FFFFFF")
Esempio n. 6
0
    def testParse_14(self):
        style = StcStyle.parse("back:#222222,bold,,,underline")

        self.assertEqual(style.bold, True)
        self.assertEqual(style.italic, False)
        self.assertEqual(style.underline, True)
        self.assertEqual(style.fore, "#000000")
        self.assertEqual(style.back, "#222222")
Esempio n. 7
0
    def testParse_12(self):
        style = StcStyle.parse("fore:#AAAAAA,back:#222222,bold,underline")

        self.assertEqual(style.bold, True)
        self.assertEqual(style.italic, False)
        self.assertEqual(style.underline, True)
        self.assertEqual(style.fore, "#AAAAAA")
        self.assertEqual(style.back, "#222222")
Esempio n. 8
0
    def testParse_14 (self):
        style = StcStyle.parse (u"back:#222222,bold,,,underline")

        self.assertEqual (style.bold, True)
        self.assertEqual (style.italic, False)
        self.assertEqual (style.underline, True)
        self.assertEqual (style.fore, u"#000000")
        self.assertEqual (style.back, u"#222222")
Esempio n. 9
0
    def testParse_04(self):
        style = StcStyle.parse("fore:#AAAAAA")

        self.assertEqual(style.bold, False)
        self.assertEqual(style.italic, False)
        self.assertEqual(style.underline, False)
        self.assertEqual(style.fore, "#AAAAAA")
        self.assertEqual(style.back, "#FFFFFF")
Esempio n. 10
0
    def testParse_03 (self):
        style = StcStyle.parse (u"fore:#000000,bold")

        self.assertEqual (style.bold, True)
        self.assertEqual (style.italic, False)
        self.assertEqual (style.underline, False)
        self.assertEqual (style.fore, u"#000000")
        self.assertEqual (style.back, u"#FFFFFF")
Esempio n. 11
0
    def testParse_11(self):
        style = StcStyle.parse(" fore:#AAAAAA , back:#222222 , bold,italic , underline ")

        self.assertEqual(style.bold, True)
        self.assertEqual(style.italic, True)
        self.assertEqual(style.underline, True)
        self.assertEqual(style.fore, "#AAAAAA")
        self.assertEqual(style.back, "#222222")
Esempio n. 12
0
    def testParse_04(self):
        style = StcStyle.parse(u"fore:#AAAAAA")

        self.assertEqual(style.bold, False)
        self.assertEqual(style.italic, False)
        self.assertEqual(style.underline, False)
        self.assertEqual(style.fore, u"#AAAAAA")
        self.assertEqual(style.back, u"#FFFFFF")
Esempio n. 13
0
    def testParse_12 (self):
        style = StcStyle.parse (u"fore:#AAAAAA,back:#222222,bold,underline")

        self.assertEqual (style.bold, True)
        self.assertEqual (style.italic, False)
        self.assertEqual (style.underline, True)
        self.assertEqual (style.fore, u"#AAAAAA")
        self.assertEqual (style.back, u"#222222")
Esempio n. 14
0
    def testParse_09(self):
        style = StcStyle.parse(u"fore:#AAAAAA,back:#222222,bold,italic")

        self.assertEqual(style.bold, True)
        self.assertEqual(style.italic, True)
        self.assertEqual(style.underline, False)
        self.assertEqual(style.fore, u"#AAAAAA")
        self.assertEqual(style.back, u"#222222")
Esempio n. 15
0
    def testParse_03(self):
        style = StcStyle.parse("fore:#000000,bold")

        self.assertEqual(style.bold, True)
        self.assertEqual(style.italic, False)
        self.assertEqual(style.underline, False)
        self.assertEqual(style.fore, "#000000")
        self.assertEqual(style.back, "#FFFFFF")
Esempio n. 16
0
    def testParse_05(self):
        style = StcStyle.parse("FORE:#AAAAAA")

        self.assertEqual(style.bold, False)
        self.assertEqual(style.italic, False)
        self.assertEqual(style.underline, False)
        self.assertEqual(style.fore, "#AAAAAA")
        self.assertEqual(style.back, "#FFFFFF")
Esempio n. 17
0
    def testParse_05 (self):
        style = StcStyle.parse (u"FORE:#AAAAAA")

        self.assertEqual (style.bold, False)
        self.assertEqual (style.italic, False)
        self.assertEqual (style.underline, False)
        self.assertEqual (style.fore, u"#AAAAAA")
        self.assertEqual (style.back, u"#FFFFFF")
Esempio n. 18
0
    def testCheckColorString (self):
        self.assertTrue (StcStyle.checkColorString (u"#000000"))
        self.assertTrue (StcStyle.checkColorString (u" #000000 "))
        self.assertTrue (StcStyle.checkColorString (u"#AA00FF"))
        self.assertTrue (StcStyle.checkColorString (u"#aa00ff"))

        self.assertFalse (StcStyle.checkColorString (u"AA00FF"))
        self.assertFalse (StcStyle.checkColorString (u"#AA00FF0"))
        self.assertFalse (StcStyle.checkColorString (u"#AA00GG"))
        self.assertFalse (StcStyle.checkColorString (u"#A0F"))
Esempio n. 19
0
    def testCheckColorString(self):
        self.assertTrue(StcStyle.checkColorString("#000000"))
        self.assertTrue(StcStyle.checkColorString(" #000000 "))
        self.assertTrue(StcStyle.checkColorString("#AA00FF"))
        self.assertTrue(StcStyle.checkColorString("#aa00ff"))

        self.assertFalse(StcStyle.checkColorString("AA00FF"))
        self.assertFalse(StcStyle.checkColorString("#AA00FF0"))
        self.assertFalse(StcStyle.checkColorString("#AA00GG"))
        self.assertFalse(StcStyle.checkColorString("#A0F"))
Esempio n. 20
0
    def _loadValue(self):
        """
        Получить значение. В производных классах этот метод переопределяется
        """
        style = StcStyle.parse(self.config.get(self.section, self.param))
        if style is None:
            raise ValueError

        return style
Esempio n. 21
0
    def testStcStyle_03(self):
        defaultStyle = StcStyle()

        opt = StcStyleOption(self.config, "Test", "style_03", defaultStyle)
        self.assertEqual(opt.value.fore, "#000000")
        self.assertEqual(opt.value.back, "#FFFFFF")
        self.assertEqual(opt.value.bold, True)
        self.assertEqual(opt.value.italic, False)
        self.assertEqual(opt.value.underline, False)
Esempio n. 22
0
    def _loadValue(self):
        """
        Получить значение. В производных классах этот метод переопределяется
        """
        style = StcStyle.parse(self.config.get(self.section, self.param))
        if style is None:
            raise ValueError

        return style
Esempio n. 23
0
    def testStcStyle_01(self):
        defaultStyle = StcStyle()

        opt = StcStyleOption(self.config, "Test", "style_01", defaultStyle)
        self.assertEqual(opt.value.fore, "#AAAAAA")
        self.assertEqual(opt.value.back, "#111111")
        self.assertEqual(opt.value.bold, True)
        self.assertEqual(opt.value.italic, True)
        self.assertEqual(opt.value.underline, True)
Esempio n. 24
0
 def testToString_06(self):
     style = StcStyle(fore=u"", back=u"", bold=True)
     self.assertEqual(style.tostr(), u"bold")
Esempio n. 25
0
 def testToString_03(self):
     style = StcStyle(bold=True, italic=True)
     self.assertEqual(style.tostr(), "fore:#000000,back:#FFFFFF,bold,italic")
Esempio n. 26
0
 def testToString_07 (self):
     style = StcStyle(fore=u"", back=u"", bold=True, italic=True)
     self.assertEqual (style.tostr(), u"bold,italic")
Esempio n. 27
0
 def testToString_05 (self):
     style = StcStyle(fore=u"#AAAAAA", back=u"#BBBBBB", bold=True)
     self.assertEqual (style.tostr(), u"fore:#AAAAAA,back:#BBBBBB,bold")
Esempio n. 28
0
 def testToString_04 (self):
     style = StcStyle(bold=True, italic=True, underline=True)
     self.assertEqual (style.tostr(), u"fore:#000000,back:#FFFFFF,bold,italic,underline")
Esempio n. 29
0
 def testToString_04(self):
     style = StcStyle(bold=True, italic=True, underline=True)
     self.assertEqual(style.tostr(),
                      "fore:#000000,back:#FFFFFF,bold,italic,underline")
Esempio n. 30
0
 def testToString_01 (self):
     style = StcStyle()
     self.assertEqual (style.tostr(), u"fore:#000000,back:#FFFFFF")
Esempio n. 31
0
 def testToString_06(self):
     style = StcStyle(fore="", back="", bold=True)
     self.assertEqual(style.tostr(), "bold")
Esempio n. 32
0
 def testParse_invalid (self):
     self.assertEqual (StcStyle.parse (u"sdgsgd"), None)
     self.assertEqual (StcStyle.parse (u"fore:#AAAAAA,back:#222222,boldasdfa"), None)
Esempio n. 33
0
class WikiConfig (object):
    """
    Класс, хранящий указатели на настройки, связанные с викиы
    """
    # Секция конфига для параметров, связанных с викистраницей
    WIKI_SECTION = u"Wiki"

    # Секция, куда записывать параметры стилей оформления редактора
    STYLES_SECTION = u"EditorStyles"

    # Имя параметра "Показывать ли код HTML?"
    SHOW_HTML_CODE_PARAM = u"ShowHtmlCode"

    # Имя параметра для размера превьюшек по умолчанию
    THUMB_SIZE_PARAM = u"ThumbSize"

    # Имя параметра, показывающего, надо ли выводить список
    # прикрепленных файлов вместо пустой страницы
    SHOW_ATTACH_BLANK_PARAM = u"ShowAttachInsteadBlank"

    # Размер превьюшек по умолчанию
    THUMB_SIZE_DEFAULT = 250

    # Имя параметра "Стиль ссылок по умолчанию"
    LINK_STYLE_PARAM = u"DefaultLinkStyle"

    # Стиль ссылок по умолчанию ([[... -> ...]] или [[... | ...]])
    LINK_STYLE_DEFAULT = 0

    # Стили редактора
    STYLE_LINK_PARAM = u"link"
    STYLE_LINK_DEFAULT = StcStyle.parse(u"fore:#0000FF,underline")

    STYLE_HEADING_PARAM = u"heading"
    STYLE_HEADING_DEFAULT = StcStyle.parse(u"bold")

    STYLE_COMMAND_PARAM = u"command"
    STYLE_COMMAND_DEFAULT = StcStyle.parse(u"fore:#6A686B")

    COLORIZE_SYNTAX_PARAM = u'ColorizeSyntax'
    COLORIZE_SYNTAX_DEFAULT = True

    RECENT_STYLE_NAME_PARAM = 'RecentStyleName'
    RECENT_STYLE_NAME_DEFAULT = ''

    def __init__(self, config):
        self.config = config

        # Показывать вкладку с HTML-кодом?
        self.showHtmlCodeOptions = BooleanOption(
            self.config,
            WikiConfig.WIKI_SECTION,
            WikiConfig.SHOW_HTML_CODE_PARAM,
            True)

        # Размер превьюшек по умолчанию
        self.thumbSizeOptions = IntegerOption(self.config,
                                              WikiConfig.WIKI_SECTION,
                                              WikiConfig.THUMB_SIZE_PARAM,
                                              WikiConfig.THUMB_SIZE_DEFAULT)

        # Показывать список прикрепленных файлов вместо пустой страницы?
        self.showAttachInsteadBlankOptions = BooleanOption(
            self.config,
            WikiConfig.WIKI_SECTION,
            WikiConfig.SHOW_ATTACH_BLANK_PARAM,
            True)

        # Стиль ссылок по умолчанию
        self.linkStyleOptions = IntegerOption(self.config,
                                              WikiConfig.WIKI_SECTION,
                                              WikiConfig.LINK_STYLE_PARAM,
                                              WikiConfig.LINK_STYLE_DEFAULT)

        # Стили редактора
        self.link = StcStyleOption(self.config,
                                   WikiConfig.STYLES_SECTION,
                                   WikiConfig.STYLE_LINK_PARAM,
                                   WikiConfig.STYLE_LINK_DEFAULT)

        self.heading = StcStyleOption(self.config,
                                      WikiConfig.STYLES_SECTION,
                                      WikiConfig.STYLE_HEADING_PARAM,
                                      WikiConfig.STYLE_HEADING_DEFAULT)

        self.command = StcStyleOption(self.config,
                                      WikiConfig.STYLES_SECTION,
                                      WikiConfig.STYLE_COMMAND_PARAM,
                                      WikiConfig.STYLE_COMMAND_DEFAULT)

        self.colorizeSyntax = BooleanOption(self.config,
                                            self.WIKI_SECTION,
                                            self.COLORIZE_SYNTAX_PARAM,
                                            self.COLORIZE_SYNTAX_DEFAULT)

        self.recentStyleName = StringOption(self.config,
                                            self.WIKI_SECTION,
                                            self.RECENT_STYLE_NAME_PARAM,
                                            self.RECENT_STYLE_NAME_DEFAULT)
Esempio n. 34
0
 def testParse_invalid(self):
     self.assertEqual(StcStyle.parse("sdgsgd"), None)
     self.assertEqual(StcStyle.parse("fore:#AAAAAA,back:#222222,boldasdfa"),
                      None)
Esempio n. 35
0
 def testToString_01(self):
     style = StcStyle()
     self.assertEqual(style.tostr(), "fore:#000000,back:#FFFFFF")
Esempio n. 36
0
 def testToString_02(self):
     style = StcStyle(bold=True)
     self.assertEqual(style.tostr(), "fore:#000000,back:#FFFFFF,bold")
Esempio n. 37
0
 def testToString_02 (self):
     style = StcStyle(bold=True)
     self.assertEqual (style.tostr(), u"fore:#000000,back:#FFFFFF,bold")
Esempio n. 38
0
 def testToString_05(self):
     style = StcStyle(fore="#AAAAAA", back="#BBBBBB", bold=True)
     self.assertEqual(style.tostr(), "fore:#AAAAAA,back:#BBBBBB,bold")
Esempio n. 39
0
 def testToString_03(self):
     style = StcStyle(bold=True, italic=True)
     self.assertEqual(style.tostr(),
                      u"fore:#000000,back:#FFFFFF,bold,italic")
Esempio n. 40
0
class HtmlEditorStylesConfig(object):
    '''
    Класс для хранения настроек стилей редактора HTML
    '''
    HTML_STYLES_SECTION = u'EditorStyles'

    STYLE_TAG_SECTION = u'tag'
    STYLE_TAG_DEFAULT = StcStyle.parse(u'fore:#000080,bold')

    STYLE_TAG_UNKNOWN_SECTION = u'tag_unknown'
    STYLE_TAG_UNKNOWN_DEFAULT = StcStyle.parse(u'fore:#FF0000')

    STYLE_ATTRIBUTE_SECTION = u'attribute'
    STYLE_ATTRIBUTE_DEFAULT = StcStyle.parse(u'fore:#008080')

    STYLE_ATTRIBUTE_UNKNOWN_SECTION = u'attribute_unknown'
    STYLE_ATTRIBUTE_UNKNOWN_DEFAULT = StcStyle.parse(u'fore:#FF0000')

    STYLE_NUMBER_SECTION = u'number'
    STYLE_NUMBER_DEFAULT = StcStyle.parse(u'fore:#000000')

    STYLE_STRING_SECTION = u'string'
    STYLE_STRING_DEFAULT = StcStyle.parse(u'fore:#0000FF')

    STYLE_COMMENT_SECTION = u'comment'
    STYLE_COMMENT_DEFAULT = StcStyle.parse(u'fore:#12B535')

    def __init__(self, config):
        self.config = config

        self.tag = StcStyleOption(self.config,
                                  HtmlEditorStylesConfig.HTML_STYLES_SECTION,
                                  HtmlEditorStylesConfig.STYLE_TAG_SECTION,
                                  HtmlEditorStylesConfig.STYLE_TAG_DEFAULT)

        self.tagUnknown = StcStyleOption(
            self.config, HtmlEditorStylesConfig.HTML_STYLES_SECTION,
            HtmlEditorStylesConfig.STYLE_TAG_UNKNOWN_SECTION,
            HtmlEditorStylesConfig.STYLE_TAG_UNKNOWN_DEFAULT)

        self.attribute = StcStyleOption(
            self.config, HtmlEditorStylesConfig.HTML_STYLES_SECTION,
            HtmlEditorStylesConfig.STYLE_ATTRIBUTE_SECTION,
            HtmlEditorStylesConfig.STYLE_ATTRIBUTE_DEFAULT)

        self.attributeUnknown = StcStyleOption(
            self.config, HtmlEditorStylesConfig.HTML_STYLES_SECTION,
            HtmlEditorStylesConfig.STYLE_ATTRIBUTE_UNKNOWN_SECTION,
            HtmlEditorStylesConfig.STYLE_ATTRIBUTE_UNKNOWN_DEFAULT)

        self.number = StcStyleOption(
            self.config, HtmlEditorStylesConfig.HTML_STYLES_SECTION,
            HtmlEditorStylesConfig.STYLE_NUMBER_SECTION,
            HtmlEditorStylesConfig.STYLE_NUMBER_DEFAULT)

        self.string = StcStyleOption(
            self.config, HtmlEditorStylesConfig.HTML_STYLES_SECTION,
            HtmlEditorStylesConfig.STYLE_STRING_SECTION,
            HtmlEditorStylesConfig.STYLE_STRING_DEFAULT)

        self.comment = StcStyleOption(
            self.config, HtmlEditorStylesConfig.HTML_STYLES_SECTION,
            HtmlEditorStylesConfig.STYLE_COMMENT_SECTION,
            HtmlEditorStylesConfig.STYLE_COMMENT_DEFAULT)
Esempio n. 41
0
 def testToString_07(self):
     style = StcStyle(fore="", back="", bold=True, italic=True)
     self.assertEqual(style.tostr(), "bold,italic")