From 0a0208409ac74d9b1a7b4b325e507d07cd7c24e0 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Fri, 1 Nov 2019 19:39:08 -0700 Subject: [PATCH] Tweak line folding code Some style guides say you should only put one space between sentences, but I and many others still put two. The line-folding code was only eating one of them when they straddled the end of the line, which looked a little funny because the following line was indented by one space. This tweaks the code to eat both spaces. Regression test updated. Also, nudge some UI elements so they line up. --- SourceGen/MultiLineComment.cs | 7 +++++ .../SGTestData/2013-notes-and-comments.dis65 | 14 ++++++---- .../Expected/2013-notes-and-comments_64tass.S | 26 +++++++++++++++---- .../2013-notes-and-comments_Merlin32.S | 25 ++++++++++++++---- .../Expected/2013-notes-and-comments_acme.S | 26 +++++++++++++++---- .../Expected/2013-notes-and-comments_cc65.S | 26 +++++++++++++++---- SourceGen/WpfGui/EditLongComment.xaml | 4 +-- 7 files changed, 101 insertions(+), 27 deletions(-) diff --git a/SourceGen/MultiLineComment.cs b/SourceGen/MultiLineComment.cs index aac2f11..d4dfef8 100644 --- a/SourceGen/MultiLineComment.cs +++ b/SourceGen/MultiLineComment.cs @@ -216,6 +216,13 @@ namespace SourceGen { } lines.Add(str); startIndex = breakIndex + 1; + if (adj == 0 && startIndex < workString.Length && + workString[startIndex] == ' ') { + // We broke on a space, and are now starting a line on a space, + // which looks weird (and happens commonly at the end of a + // sentence). Eat one more space. + startIndex++; + } breakIndex = -1; } } diff --git a/SourceGen/SGTestData/2013-notes-and-comments.dis65 b/SourceGen/SGTestData/2013-notes-and-comments.dis65 index e5cef77..e07fe95 100644 --- a/SourceGen/SGTestData/2013-notes-and-comments.dis65 +++ b/SourceGen/SGTestData/2013-notes-and-comments.dis65 @@ -1,8 +1,8 @@ ### 6502bench SourceGen dis65 v1.0 ### { -"_ContentVersion":1,"FileDataLength":98,"FileDataCrc32":-80207687,"ProjectProps":{ -"CpuName":"6502","IncludeUndocumentedInstr":false,"EntryFlags":32702671,"AnalysisParams":{ -"AnalyzeUncategorizedData":true,"MinCharsForString":4,"SeekNearbyTargets":true}, +"_ContentVersion":2,"FileDataLength":98,"FileDataCrc32":-80207687,"ProjectProps":{ +"CpuName":"6502","IncludeUndocumentedInstr":false,"TwoByteBrk":false,"EntryFlags":32702671,"AutoLabelStyle":"Simple","AnalysisParams":{ +"AnalyzeUncategorizedData":true,"DefaultTextScanMode":"LowHighAscii","MinCharsForString":4,"SeekNearbyTargets":true,"SmartPlpHandling":true}, "PlatformSymbolFileIdentifiers":["RT:TestData/TestSyms.sym65"],"ExtensionScriptFileIdentifiers":[],"ProjectSyms":{ }}, "AddressMap":[{ @@ -29,7 +29,9 @@ "12":{ "Text":"\r\nChoppy\r\n\r\nbox\r\n\r\ncomment\r\n\r\n64 cols\r\n\r\n","BoxMode":true,"MaxWidth":64,"BackgroundColor":0}, "14":{ -"Text":"Some non-ASCII stuff:\r\n†•�␇","BoxMode":true,"MaxWidth":30,"BackgroundColor":0}}, +"Text":"Some non-ASCII stuff:\r\n†•�␇\r\n(right side of box looks pushed over on-screen because font isn\u0027t fully mono)","BoxMode":true,"MaxWidth":64,"BackgroundColor":0}, +"16":{ +"Text":"Specific line break case at end of. Sentence.\r\nAlternate version for semicolon zz. Output.\r\n\r\nSame thing but with three spaces zz. Three!\r\nAgain with the three spces between. Things.\r\n\r\nTry to make it the very last thing.. ","BoxMode":true,"MaxWidth":40,"BackgroundColor":0}}, "Notes":{ "0":{ "Text":"And now, a note.","BoxMode":false,"MaxWidth":80,"BackgroundColor":-7278960}, @@ -46,4 +48,6 @@ "Label":"bytes","Value":4130,"Source":"User","Type":"LocalOrGlobalAddr"}}, "OperandFormats":{ "34":{ -"Length":64,"Format":"Dense","SubFormat":"None","SymbolRef":null}}} +"Length":64,"Format":"Dense","SubFormat":"None","SymbolRef":null}}, +"LvTables":{ +}} diff --git a/SourceGen/SGTestData/Expected/2013-notes-and-comments_64tass.S b/SourceGen/SGTestData/Expected/2013-notes-and-comments_64tass.S index ab4e8ad..c97de79 100644 --- a/SourceGen/SGTestData/Expected/2013-notes-and-comments_64tass.S +++ b/SourceGen/SGTestData/Expected/2013-notes-and-comments_64tass.S @@ -17,7 +17,7 @@ plataddr = $3000 ;address only in platform file ;Short, unboxed comment here!! -; Two spaces after. More hyp- +;Two spaces after. More hyp- ;hens? * = $1000 lda #$01 ;Comment! @@ -52,11 +52,27 @@ plataddr = $3000 ;address only in platform file ;* * ;*************************************************************** lda #$07 -;***************************** -;* Some non-ASCII stuff: * -;* †•�␇ * -;***************************** +;*************************************************************** +;* Some non-ASCII stuff: * +;* †•�␇ * +;* (right side of box looks pushed over on-screen because font * +;* isn't fully mono) * +;*************************************************************** lda #$08 +;*************************************** +;* Specific line break case at end * +;* of. Sentence. * +;* Alternate version for semicolon zz. * +;* Output. * +;* * +;* Same thing but with three spaces * +;* zz. Three! * +;* Again with the three spces between. * +;* Things. * +;* * +;* Try to make it the very last * +;* thing.. * +;*************************************** lda #$09 lda #$0a lda #$0b diff --git a/SourceGen/SGTestData/Expected/2013-notes-and-comments_Merlin32.S b/SourceGen/SGTestData/Expected/2013-notes-and-comments_Merlin32.S index 8e479ce..e6a2fd0 100644 --- a/SourceGen/SGTestData/Expected/2013-notes-and-comments_Merlin32.S +++ b/SourceGen/SGTestData/Expected/2013-notes-and-comments_Merlin32.S @@ -15,7 +15,7 @@ plataddr equ $3000 ;address only in platform file ;Short, unboxed comment here!! -; Two spaces after. More hyp- +;Two spaces after. More hyp- ;hens? org $1000 lda #$01 ;Comment! @@ -50,11 +50,26 @@ plataddr equ $3000 ;address only in platform file * * **************************************************************** lda #$07 -****************************** -* Some non-ASCII stuff: * -* †•�␇ * -****************************** +**************************************************************** +* Some non-ASCII stuff: * +* †•�␇ * +* (right side of box looks pushed over on-screen because font * +* isn't fully mono) * +**************************************************************** lda #$08 +**************************************** +* Specific line break case at end of. * +* Sentence. * +* Alternate version for semicolon zz. * +* Output. * +* * +* Same thing but with three spaces zz. * +* Three! * +* Again with the three spces between. * +* Things. * +* * +* Try to make it the very last thing.. * +**************************************** lda #$09 lda #$0a lda #$0b diff --git a/SourceGen/SGTestData/Expected/2013-notes-and-comments_acme.S b/SourceGen/SGTestData/Expected/2013-notes-and-comments_acme.S index 9d9155b..3e04379 100644 --- a/SourceGen/SGTestData/Expected/2013-notes-and-comments_acme.S +++ b/SourceGen/SGTestData/Expected/2013-notes-and-comments_acme.S @@ -17,7 +17,7 @@ plataddr = $3000 ;address only in platform file ;Short, unboxed comment here!! -; Two spaces after. More hyp- +;Two spaces after. More hyp- ;hens? * = $1000 lda #$01 ;Comment! @@ -52,11 +52,27 @@ plataddr = $3000 ;address only in platform file ;* * ;*************************************************************** lda #$07 -;***************************** -;* Some non-ASCII stuff: * -;* †•�␇ * -;***************************** +;*************************************************************** +;* Some non-ASCII stuff: * +;* †•�␇ * +;* (right side of box looks pushed over on-screen because font * +;* isn't fully mono) * +;*************************************************************** lda #$08 +;*************************************** +;* Specific line break case at end * +;* of. Sentence. * +;* Alternate version for semicolon zz. * +;* Output. * +;* * +;* Same thing but with three spaces * +;* zz. Three! * +;* Again with the three spces between. * +;* Things. * +;* * +;* Try to make it the very last * +;* thing.. * +;*************************************** lda #$09 lda #$0a lda #$0b diff --git a/SourceGen/SGTestData/Expected/2013-notes-and-comments_cc65.S b/SourceGen/SGTestData/Expected/2013-notes-and-comments_cc65.S index 0cc26f0..c79f288 100644 --- a/SourceGen/SGTestData/Expected/2013-notes-and-comments_cc65.S +++ b/SourceGen/SGTestData/Expected/2013-notes-and-comments_cc65.S @@ -17,7 +17,7 @@ plataddr = $3000 ;address only in platform file ;Short, unboxed comment here!! -; Two spaces after. More hyp- +;Two spaces after. More hyp- ;hens? ; .segment "SEG000" .org $1000 @@ -53,11 +53,27 @@ plataddr = $3000 ;address only in platform file ;* * ;*************************************************************** lda #$07 -;***************************** -;* Some non-ASCII stuff: * -;* †•�␇ * -;***************************** +;*************************************************************** +;* Some non-ASCII stuff: * +;* †•�␇ * +;* (right side of box looks pushed over on-screen because font * +;* isn't fully mono) * +;*************************************************************** lda #$08 +;*************************************** +;* Specific line break case at end * +;* of. Sentence. * +;* Alternate version for semicolon zz. * +;* Output. * +;* * +;* Same thing but with three spaces * +;* zz. Three! * +;* Again with the three spces between. * +;* Things. * +;* * +;* Try to make it the very last * +;* thing.. * +;*************************************** lda #$09 lda #$0a lda #$0b diff --git a/SourceGen/WpfGui/EditLongComment.xaml b/SourceGen/WpfGui/EditLongComment.xaml index 608c1ce..9cbbb56 100644 --- a/SourceGen/WpfGui/EditLongComment.xaml +++ b/SourceGen/WpfGui/EditLongComment.xaml @@ -57,10 +57,10 @@ limitations under the License. AcceptsReturn="True" TextWrapping="Wrap"/> - + - +