Exemple #1
0
 def test_save(self):
     name = 'TEST save highlighter'
     foreground = 'white'
     background = 'blue'
     terms = ['a','b', 'c']
     h = Highlighter(TEST_SAVE_HIGHLIGHTER, name, foreground, background)
     h.terms = terms
     h.save()
     try:
         with open(TEST_SAVE_HIGHLIGHTER, 'r') as f:
             lines = f.readlines()
             self.assertEqual(lines[0].strip(), name)
             self.assertEqual(lines[1].strip(), foreground)
             self.assertEqual(lines[2].strip(), background)
             self.assertEqual(lines[3].strip(), terms[0])
             self.assertEqual(lines[4].strip(), terms[1])
             self.assertEqual(lines[5].strip(), terms[2])
     except Exception as e:
         self.fail()
Exemple #2
0
    def __init__(self, parent=None):  
        super(Editor, self).__init__(parent)

        self.model = Model.Model()
        self.configs = self.model.read_config('config.ini')

        self.set_ui()

        Highlighter.MarkdownHighlighter(self)

        self.connect(self,SIGNAL("editor_test"),self.editor_test)
Exemple #3
0
 def test_addTerm(self):
     h = Highlighter(TEST_LOAD_HIGHLIGHTER)
     h.addTerm(TERM_B)
     h.addTerm(TERM_C)
     h.addTerm(TERM_A)
     # Terms are added in alphabetical order
     self.assertEqual(h.terms, [TERM_A, TERM_B, TERM_C])
Exemple #4
0
    def __init__(self, name, text, parent=None):
        super(ActivityTab, self).__init__(parent)
        self.name = name
        self.text = text

        self.mainLayout = QtGui.QVBoxLayout()

        self.editor = Editor.Editor()
        self.mainLayout.addWidget(self.editor)
        self.highlight = Highlighter.Highlighter(self.editor.document())
        self.editor.setPlainText(self.text[0])

        #self.setFixedSize(500,500)
        self.setLayout(self.mainLayout)
        self.editor.textCursor().setPosition(0, QtGui.QTextCursor.MoveAnchor)
Exemple #5
0
    def setupUi(self):
        """Initializes the UI componenets for the main window"""
        # Actions
        self.action_manager = ActionManager(self)

        # Menu bar and status bar
        self.setMenuBar(QMenuBar(self))
        self.setStatusBar(QStatusBar(self))
        self.create_menus()
        self.create_toolbars()

        # Set central widget to textedit with highlighter
        self.text_edit = CodeEdit()
        self.text_edit.set_text_changed_handler(self.document_changed_handler)
        self.highlighter = Highlighter(self.text_edit.document())
        self.setCentralWidget(self.text_edit)

        # Create docked widgets
        self.create_docked_widgets()

        # Show window
        self.setWindowTitle('Automark ' + VERSION_NO)
        self.resize(1440, 800)
        self.show()
Exemple #6
0
 def test_load(self):
     h = Highlighter(TEST_LOAD_HIGHLIGHTER)
     self.assertEqual(h.name, 'TEST Highlighter')
     self.assertEqual(h.foreground, 'blue')
     self.assertEqual(h.background, 'yellow')
Exemple #7
0
 def test_removeTerm(self):
     h = Highlighter(TEST_LOAD_HIGHLIGHTER)
     h.terms = ['a', 'b', 'c']
     self.assertTrue(h.containsTerm('b'))
Exemple #8
0
 def test_removeTerm(self):
     h = Highlighter(TEST_LOAD_HIGHLIGHTER)
     h.terms = [TERM_A, TERM_B, TERM_C]
     h.removeTerm(TERM_B)
     self.assertEqual(h.terms, [TERM_A, TERM_C])