Class: Ruber::SyntaxChecker::SyntaxResultWidget
- Inherits:
-
KDE::Led
- Object
- KDE::Led
- Ruber::SyntaxChecker::SyntaxResultWidget
- Defined in:
- plugins/syntax_checker/syntax_checker.rb,
plugins/syntax_checker/syntax_checker.rb
Overview
KDE::Led
with the ability to jump to the first syntax error on left or middle mouse
click and to popup a menu with a list of all syntax errors in the current document
on right click
Instance Method Summary (collapse)
-
- (nil) contextMenuEvent(event)
Override of
Qt::Widget#contextMenuEvent
. -
- (nil) mouseReleaseEvent(e)
Override of
Qt::Widget#mouseReleaseEvent
.
Instance Method Details
- (nil) contextMenuEvent(event)
Override of Qt::Widget#contextMenuEvent
If the current document contains syntax errors, it displays a menu listing them. Each action in the menu moves the cursor in the editor view to display to the line and column of the corresponding error.
If the current document doesn’t contain syntax errors, the menu will only contain
an entry with text Syntax OK
which does nothing when activated.
639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 |
# File 'plugins/syntax_checker/syntax_checker.rb', line 639 def contextMenuEvent event doc = Ruber[:main_window].current_document view = Ruber[:main_window].active_editor return unless doc and view and (checker = doc.extension :syntax_checker) errors = checker.errors actions = errors.map do |e| a = KDE::Action.new Ruber[:syntax_checker].(e), self end actions << KDE::Action.new('Syntax OK', self) if actions.empty? res = Qt::Menu.exec(actions, event.global_pos) return if !res or errors.empty? idx = actions.index res return unless idx error = errors[idx] view.go_to error.line - 1, (error.column || 0) Ruber[:main_window].. res.text, 4000 nil end |
- (nil) mouseReleaseEvent(e)
Override of Qt::Widget#mouseReleaseEvent
If the event refers to the left button and the current document contains syntax errors, it moves the cursor in the editor view to the position of the first error
613 614 615 616 617 618 619 620 621 622 623 624 625 |
# File 'plugins/syntax_checker/syntax_checker.rb', line 613 def mouseReleaseEvent e return unless e. == Qt::LeftButton or e. == Qt::MidButton doc = Ruber[:main_window].current_document view = Ruber[:main_window].active_editor return unless view and doc and doc.extension(:syntax_checker) checker = doc.extension(:syntax_checker) err = checker.errors.first if err view.go_to err.line - 1, (err.column || 0) Ruber[:main_window].. Ruber[:syntax_checker].(err), 4000 end nil end |