/** * @brief Constructor. * @param file_path Path of the file to open. * @param editor The parent object. */ TextEditorWidget::TextEditorWidget(const QString& file_path, TextEditor& editor): QPlainTextEdit(file_path, &editor), line_number_area(new LineNumberArea(*this)), undo_stack(editor.get_undo_stack()), tab_length(2), replace_tab_by_spaces(false) { // Undo/redo system. connect(document(), SIGNAL(undoCommandAdded()), this, SLOT(undo_command_added())); // Line number displaying. connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(update_line_number_area_width(int))); connect(this, SIGNAL(updateRequest(const QRect&, int)), this, SLOT(update_line_number_area(const QRect&, int))); connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlight_current_line())); update_line_number_area_width(0); highlight_current_line(); }