]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Support line breaks in multiline comments (refs #2940)
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 29 Mar 2012 07:18:25 +0000 (07:18 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 29 Mar 2012 07:18:25 +0000 (07:18 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@24562 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/MultilineTextNode.java

index c756baa46bbaf2b572747735ef15417b7089c299..d390f13d2453eec748c415268f06c91a62bb29e8 100644 (file)
@@ -150,12 +150,20 @@ public class MultilineTextNode extends TextNode {
         lineMeasurer.setPosition(paragraphStart);\r
 \r
         // Get lines until the entire paragraph has been displayed.\r
-        // boolean noAscent = true;\r
-        while (lineMeasurer.getPosition() < paragraphEnd) {\r
+        int next, limit, charat, position = 0;\r
+        while ((position = lineMeasurer.getPosition()) < paragraphEnd) {\r
+\r
+            // Find possible line break and set it as a limit to the next layout\r
+            next = lineMeasurer.nextOffset(breakWidth);\r
+            limit = next;\r
+            charat = text.indexOf(System.getProperty("line.separator"),position+1);\r
+            if(charat < next && charat != -1){\r
+               limit = charat;\r
+            }\r
 \r
             // Retrieve next layout. A cleverer program would also cache\r
             // these layouts until the component is re-sized.\r
-            TextLayout layout = lineMeasurer.nextLayout(breakWidth);\r
+            TextLayout layout = lineMeasurer.nextLayout(breakWidth, limit, false);\r
 \r
             // Compute pen x position. If the paragraph is right-to-left we\r
             // will align the TextLayouts to the right edge of the panel.\r