From 2542eb02648294256a01ae4ecb6ac81bc8ab5094 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sun, 16 Nov 2014 23:46:08 +0100 Subject: Make sure QRegister::view is properly initialized and cleaned up * it must be initialized after the UI (Interface::main), so I added a View::initialize() function * the old initialize() method was renamed to setup() * use a global instance of QRegister::view so it is guaranteed to be destroyed only after any QRegisters that could still need it * Document API adapted to work with ViewCurrent references --- src/document.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 8ed5007..015c3d6 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -31,42 +31,42 @@ namespace SciTECO { void -Document::edit(ViewCurrent *view) +Document::edit(ViewCurrent &view) { maybe_create_document(); - view->ssm(SCI_SETDOCPOINTER, 0, (sptr_t)doc); - view->ssm(SCI_SETFIRSTVISIBLELINE, first_line); - view->ssm(SCI_SETXOFFSET, xoffset); - view->ssm(SCI_SETSEL, anchor, (sptr_t)dot); + view.ssm(SCI_SETDOCPOINTER, 0, (sptr_t)doc); + view.ssm(SCI_SETFIRSTVISIBLELINE, first_line); + view.ssm(SCI_SETXOFFSET, xoffset); + view.ssm(SCI_SETSEL, anchor, (sptr_t)dot); /* * Default TECO-style character representations. * They are reset on EVERY SETDOCPOINTER call by Scintilla. */ - view->set_representations(); + view.set_representations(); } void -Document::undo_edit(ViewCurrent *view) +Document::undo_edit(ViewCurrent &view) { maybe_create_document(); - view->undo_set_representations(); + view.undo_set_representations(); - view->undo_ssm(SCI_SETSEL, anchor, (sptr_t)dot); - view->undo_ssm(SCI_SETXOFFSET, xoffset); - view->undo_ssm(SCI_SETFIRSTVISIBLELINE, first_line); - view->undo_ssm(SCI_SETDOCPOINTER, 0, (sptr_t)doc); + view.undo_ssm(SCI_SETSEL, anchor, (sptr_t)dot); + view.undo_ssm(SCI_SETXOFFSET, xoffset); + view.undo_ssm(SCI_SETFIRSTVISIBLELINE, first_line); + view.undo_ssm(SCI_SETDOCPOINTER, 0, (sptr_t)doc); } void -Document::update(ViewCurrent *view) +Document::update(ViewCurrent &view) { - anchor = view->ssm(SCI_GETANCHOR); - dot = view->ssm(SCI_GETCURRENTPOS); - first_line = view->ssm(SCI_GETFIRSTVISIBLELINE); - xoffset = view->ssm(SCI_GETXOFFSET); + anchor = view.ssm(SCI_GETANCHOR); + dot = view.ssm(SCI_GETCURRENTPOS); + first_line = view.ssm(SCI_GETFIRSTVISIBLELINE); + xoffset = view.ssm(SCI_GETXOFFSET); } /* -- cgit v1.2.3