Parcourir la source

Improved Text View (significantly less updates)

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@6761 8c9fc860-2736-0410-a75d-ab315db34111
felixf il y a 9 ans
Parent
commit
ba900ed5aa
2 fichiers modifiés avec 20 ajouts et 11 suppressions
  1. 11 7
      source/PET.Mod
  2. 9 4
      source/WMTextView.Mod

+ 11 - 7
source/PET.Mod

@@ -1901,6 +1901,7 @@ TYPE
 			syntaxHighlighterName : ARRAY 32 OF CHAR;
 			syntaxHighlighterName : ARRAY 32 OF CHAR;
 			file : Files.File;
 			file : Files.File;
 			in: Streams.Reader;
 			in: Streams.Reader;
+			
 		BEGIN
 		BEGIN
 			DisableUpdate;
 			DisableUpdate;
 			res := -1;
 			res := -1;
@@ -1960,6 +1961,12 @@ TYPE
 			currentPage.editor.tv.onLinkClicked.Add(LinkClickedHandler);
 			currentPage.editor.tv.onLinkClicked.Add(LinkClickedHandler);
 			text.ReleaseWrite;
 			text.ReleaseWrite;
 
 
+			GetSyntaxHighlighterName(filename, syntaxHighlighterName);
+			IF (syntaxHighlighterName # "") THEN
+				currentPage.editor.highlighting.SetAOC(syntaxHighlighterName);
+				currentPage.splitEditor.highlighting.SetAOC(syntaxHighlighterName);
+			END;
+
 			IF (file # NIL) THEN
 			IF (file # NIL) THEN
 				IF (format = "AUTO") THEN
 				IF (format = "AUTO") THEN
 					decoder := TextUtilities.DecodeAuto(fullname, autoCodecFormat);
 					decoder := TextUtilities.DecodeAuto(fullname, autoCodecFormat);
@@ -1975,9 +1982,9 @@ TYPE
 						decoder.Open(in, res);
 						decoder.Open(in, res);
 						IF res = 0 THEN
 						IF res = 0 THEN
 							currentPage.editor.text.onTextChanged.Remove(currentPage.TextChanged);
 							currentPage.editor.text.onTextChanged.Remove(currentPage.TextChanged);
-							currentPage.editor.SetText(decoder.GetText());
+							text := decoder.GetText();
+							currentPage.editor.SetText(text);
 							currentPage.searchPanel.SetText(decoder.GetText());
 							currentPage.searchPanel.SetText(decoder.GetText());
-							currentPage.splitEditor.SetText(currentPage.editor.text);
 							currentPage.editor.text.onTextChanged.Add(currentPage.TextChanged);
 							currentPage.editor.text.onTextChanged.Add(currentPage.TextChanged);
 							currentPage.editor.text.SetUndoManager(currentPage.editor.undoMgr)
 							currentPage.editor.text.SetUndoManager(currentPage.editor.undoMgr)
 						END;
 						END;
@@ -2003,11 +2010,6 @@ TYPE
 			currentPage.compilerSettings := settings.GetCompilerSettings(filename);
 			currentPage.compilerSettings := settings.GetCompilerSettings(filename);
 			currentPage.options := currentPage.compilerSettings.options;
 			currentPage.options := currentPage.compilerSettings.options;
 
 
-			GetSyntaxHighlighterName(filename, syntaxHighlighterName);
-			IF (syntaxHighlighterName # "") THEN
-				currentPage.editor.highlighting.SetAOC(syntaxHighlighterName);
-				currentPage.splitEditor.highlighting.SetAOC(syntaxHighlighterName);
-			END;
 
 
 			currentPage.CreateSidePanel(currentPage.compilerSettings);
 			currentPage.CreateSidePanel(currentPage.compilerSettings);
 
 
@@ -2281,9 +2283,11 @@ TYPE
 			IF (currentPage # NIL) THEN
 			IF (currentPage # NIL) THEN
 				IF currentPage.splitted THEN
 				IF currentPage.splitted THEN
 					currentPage.splitPanel.visible.Set(FALSE);
 					currentPage.splitPanel.visible.Set(FALSE);
+					currentPage.splitEditor.SetText(NIL);
 					currentPage.editor.SetFocus;
 					currentPage.editor.SetFocus;
 				ELSE
 				ELSE
 					currentPage.splitPanel.visible.Set(TRUE);
 					currentPage.splitPanel.visible.Set(TRUE);
+					currentPage.splitEditor.SetText(currentPage.editor.text);				
 				END;
 				END;
 				currentPage.splitted := ~currentPage.splitted
 				currentPage.splitted := ~currentPage.splitted
 			END
 			END

+ 9 - 4
source/WMTextView.Mod

@@ -6,7 +6,7 @@ IMPORT
 	WMStandardComponents, Strings, WMDropTarget, Raster,
 	WMStandardComponents, Strings, WMDropTarget, Raster,
 	WMRectangles, WMWindowManager, WMProperties,
 	WMRectangles, WMWindowManager, WMProperties,
 	Commands, FileHandlers, Streams, WMPopups, FP1616,
 	Commands, FileHandlers, Streams, WMPopups, FP1616,
-	WMPieMenu, WMEvents, UnicodeBidirectionality, PositionDebugging, ContextualDependency;
+	WMPieMenu, WMEvents, UnicodeBidirectionality, PositionDebugging, ContextualDependency, D := Debugging;
 
 
 CONST
 CONST
 	TraceRenderOptimize = 0;
 	TraceRenderOptimize = 0;
@@ -992,7 +992,7 @@ TYPE
 				leftShift.Set(0); leftShiftI := 0; (* no scrollbars -> don't shift *)
 				leftShift.Set(0); leftShiftI := 0; (* no scrollbars -> don't shift *)
 			END;
 			END;
 			optimize := TRUE;
 			optimize := TRUE;
-			Resized;
+			layout.FullLayout(optimize);
 			optimize := FALSE;
 			optimize := FALSE;
 			UpdateScrollbars;
 			UpdateScrollbars;
 			(*Invalidate;*)
 			(*Invalidate;*)
@@ -1058,12 +1058,16 @@ TYPE
 		END PropertyChanged;
 		END PropertyChanged;
 
 
 		PROCEDURE Resized;
 		PROCEDURE Resized;
+		VAR prevWidth: LONGINT;
 		BEGIN
 		BEGIN
 			ASSERT(IsCallFromSequencer());
 			ASSERT(IsCallFromSequencer());
 			Resized^;
 			Resized^;
+			prevWidth := layout.paperWidth;
 			layout.paperWidth := bounds.GetWidth() - (bordersI.l + bordersI.r);
 			layout.paperWidth := bounds.GetWidth() - (bordersI.l + bordersI.r);
 			borderClip.r := bounds.GetWidth() - bordersI.r; borderClip.b := bounds.GetHeight() - bordersI.b;
 			borderClip.r := bounds.GetWidth() - bordersI.r; borderClip.b := bounds.GetHeight() - bordersI.b;
-			layout.FullLayout(optimize);
+			IF (prevWidth # layout.paperWidth) & (wrapMode.Get()#NoWrap) THEN
+				layout.FullLayout(optimize);
+			END;
 			CheckNumberOfLines;
 			CheckNumberOfLines;
 		END Resized;
 		END Resized;
 
 
@@ -1096,8 +1100,9 @@ TYPE
 			layout.FullLayout(TRUE);
 			layout.FullLayout(TRUE);
 			CheckNumberOfLines;
 			CheckNumberOfLines;
 			ASSERT(((highlighter = NIL) & (state = NIL)) OR ((highlighter # NIL) & (state # NIL)));
 			ASSERT(((highlighter = NIL) & (state = NIL)) OR ((highlighter # NIL) & (state # NIL)));
+
 			text.ReleaseRead;
 			text.ReleaseRead;
-			Invalidate;(*! Redundant ?*)
+			(*Invalidate;(*! Redundant ?*)*)
 			Release;
 			Release;
 		END SetText;
 		END SetText;