Bläddra i källkod

Patched a bug in Texts: Update attributes only when they are different for consecutive pieces

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@7231 8c9fc860-2736-0410-a75d-ab315db34111
felixf 8 år sedan
förälder
incheckning
7546ad533a
2 ändrade filer med 15 tillägg och 12 borttagningar
  1. 14 11
      source/Texts.Mod
  2. 1 1
      source/WMTextView.Mod

+ 14 - 11
source/Texts.Mod

@@ -65,7 +65,7 @@ TYPE
 
 		PROCEDURE IsEqual*(attr : Attributes) : BOOLEAN;
 		BEGIN
-			RETURN (attr # NIL) & (color = attr.color) & (bgcolor = attr.bgcolor) & (voff = attr.voff) &
+			RETURN (attr=SELF) OR (attr # NIL) & (color = attr.color) & (bgcolor = attr.bgcolor) & (voff = attr.voff) &
 				( (fontInfo = NIL) & (attr.fontInfo = NIL) OR fontInfo.IsEqual(attr.fontInfo))
 		END IsEqual;
 
@@ -1007,7 +1007,7 @@ TYPE
 			is forwarded to the attributeChanger as context.
 		 [Must hold write lock] *)
 		PROCEDURE UpdateAttributes*(pos, len : LONGINT; attributeChanger : AttributeChangerProc; userData : ANY);
-		VAR al, ar, bl, br, cur : Piece;
+		VAR al, ar, bl, br, cur : Piece; attributes: Attributes;
 		BEGIN
 			IF len = 0 THEN RETURN END;
 			(* don't do illegal changes *)
@@ -1019,16 +1019,19 @@ TYPE
 			GetSplittedPos(pos + len, bl, br);
 			cur := ar;
 			IF um # NIL THEN um.BeginObjectChange(pos) END;
-			WHILE cur # br DO
-				IF um # NIL THEN
-					IF cur.attributes = NIL THEN
-						um.ObjectChanged(cur.startpos, cur.len, 102, NIL)
-					ELSE
-						um.ObjectChanged(cur.startpos, cur.len, 102, cur.attributes.Clone())
-					END
-				END;
+			WHILE (cur # br)  DO
 				attributeChanger(cur.attributes, userData);
-				cur := cur.next
+				attributes := cur.attributes;
+				REPEAT
+					IF um # NIL THEN
+						IF cur.attributes = NIL THEN
+							um.ObjectChanged(cur.startpos, cur.len, 102, NIL)
+						ELSE
+							um.ObjectChanged(cur.startpos, cur.len, 102, cur.attributes.Clone())
+						END
+					END;
+					cur := cur.next;
+				UNTIL (cur = br) OR (cur.attributes # attributes);
 			END;
 			IF um # NIL THEN
 				IF userData # NIL THEN

+ 1 - 1
source/WMTextView.Mod

@@ -2725,6 +2725,7 @@ TYPE
 		BEGIN
 			IF modifierFlags * Inputs.Ctrl # {} THEN (* CTRL pressed -> Resize Font*)
 				text.AcquireWrite;
+				IF dz > 0 THEN dz := 1 ELSIF dz<0 THEN dz := -1 END;
 				NEW(ddz, dz); 
 				text.UpdateAttributes(0, text.GetLength(), ChangeAttribute, ddz);
 				text.ReleaseWrite;
@@ -4217,7 +4218,6 @@ BEGIN
 		newSize := currentSize + value * currentSize DIV 4;
 	END;
 	IF (newSize < 8) THEN newSize := 8; END;
-	TRACE(currentSize, value, newSize);
 END GetNewSize;
 
 TYPE