1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-10-31 19:04:44 +00:00

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.
This commit is contained in:
Andy McFadden 2019-11-01 19:39:08 -07:00
parent b4213de4c0
commit 0a0208409a
7 changed files with 101 additions and 27 deletions

View File

@ -216,6 +216,13 @@ namespace SourceGen {
} }
lines.Add(str); lines.Add(str);
startIndex = breakIndex + 1; 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; breakIndex = -1;
} }
} }

View File

@ -1,8 +1,8 @@
### 6502bench SourceGen dis65 v1.0 ### ### 6502bench SourceGen dis65 v1.0 ###
{ {
"_ContentVersion":1,"FileDataLength":98,"FileDataCrc32":-80207687,"ProjectProps":{ "_ContentVersion":2,"FileDataLength":98,"FileDataCrc32":-80207687,"ProjectProps":{
"CpuName":"6502","IncludeUndocumentedInstr":false,"EntryFlags":32702671,"AnalysisParams":{ "CpuName":"6502","IncludeUndocumentedInstr":false,"TwoByteBrk":false,"EntryFlags":32702671,"AutoLabelStyle":"Simple","AnalysisParams":{
"AnalyzeUncategorizedData":true,"MinCharsForString":4,"SeekNearbyTargets":true}, "AnalyzeUncategorizedData":true,"DefaultTextScanMode":"LowHighAscii","MinCharsForString":4,"SeekNearbyTargets":true,"SmartPlpHandling":true},
"PlatformSymbolFileIdentifiers":["RT:TestData/TestSyms.sym65"],"ExtensionScriptFileIdentifiers":[],"ProjectSyms":{ "PlatformSymbolFileIdentifiers":["RT:TestData/TestSyms.sym65"],"ExtensionScriptFileIdentifiers":[],"ProjectSyms":{
}}, }},
"AddressMap":[{ "AddressMap":[{
@ -29,7 +29,9 @@
"12":{ "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}, "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":{ "14":{
"Text":"Some non-ASCII stuff:\r\n†•<E280A0>␇","BoxMode":true,"MaxWidth":30,"BackgroundColor":0}}, "Text":"Some non-ASCII stuff:\r\n†•<E280A0>␇\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":{ "Notes":{
"0":{ "0":{
"Text":"And now, a note.","BoxMode":false,"MaxWidth":80,"BackgroundColor":-7278960}, "Text":"And now, a note.","BoxMode":false,"MaxWidth":80,"BackgroundColor":-7278960},
@ -46,4 +48,6 @@
"Label":"bytes","Value":4130,"Source":"User","Type":"LocalOrGlobalAddr"}}, "Label":"bytes","Value":4130,"Source":"User","Type":"LocalOrGlobalAddr"}},
"OperandFormats":{ "OperandFormats":{
"34":{ "34":{
"Length":64,"Format":"Dense","SubFormat":"None","SymbolRef":null}}} "Length":64,"Format":"Dense","SubFormat":"None","SymbolRef":null}},
"LvTables":{
}}

View File

@ -17,7 +17,7 @@
plataddr = $3000 ;address only in platform file plataddr = $3000 ;address only in platform file
;Short, unboxed comment here!! ;Short, unboxed comment here!!
; Two spaces after. More hyp- ;Two spaces after. More hyp-
;hens? ;hens?
* = $1000 * = $1000
lda #$01 ;Comment! lda #$01 ;Comment!
@ -52,11 +52,27 @@ plataddr = $3000 ;address only in platform file
;* * ;* *
;*************************************************************** ;***************************************************************
lda #$07 lda #$07
;***************************** ;***************************************************************
;* Some non-ASCII stuff: * ;* Some non-ASCII stuff: *
;* †•<E280A0>␇ * ;* †•<E280A0>␇ *
;***************************** ;* (right side of box looks pushed over on-screen because font *
;* isn't fully mono) *
;***************************************************************
lda #$08 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 #$09
lda #$0a lda #$0a
lda #$0b lda #$0b

View File

@ -15,7 +15,7 @@
plataddr equ $3000 ;address only in platform file plataddr equ $3000 ;address only in platform file
;Short, unboxed comment here!! ;Short, unboxed comment here!!
; Two spaces after. More hyp- ;Two spaces after. More hyp-
;hens? ;hens?
org $1000 org $1000
lda #$01 ;Comment! lda #$01 ;Comment!
@ -50,11 +50,26 @@ plataddr equ $3000 ;address only in platform file
* * * *
**************************************************************** ****************************************************************
lda #$07 lda #$07
****************************** ****************************************************************
* Some non-ASCII stuff: * * Some non-ASCII stuff: *
* <EFBFBD> * * <EFBFBD> *
****************************** * (right side of box looks pushed over on-screen because font *
* isn't fully mono) *
****************************************************************
lda #$08 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 #$09
lda #$0a lda #$0a
lda #$0b lda #$0b

View File

@ -17,7 +17,7 @@
plataddr = $3000 ;address only in platform file plataddr = $3000 ;address only in platform file
;Short, unboxed comment here!! ;Short, unboxed comment here!!
; Two spaces after. More hyp- ;Two spaces after. More hyp-
;hens? ;hens?
* = $1000 * = $1000
lda #$01 ;Comment! lda #$01 ;Comment!
@ -52,11 +52,27 @@ plataddr = $3000 ;address only in platform file
;* * ;* *
;*************************************************************** ;***************************************************************
lda #$07 lda #$07
;***************************** ;***************************************************************
;* Some non-ASCII stuff: * ;* Some non-ASCII stuff: *
;* †•<E280A0>␇ * ;* †•<E280A0>␇ *
;***************************** ;* (right side of box looks pushed over on-screen because font *
;* isn't fully mono) *
;***************************************************************
lda #$08 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 #$09
lda #$0a lda #$0a
lda #$0b lda #$0b

View File

@ -17,7 +17,7 @@
plataddr = $3000 ;address only in platform file plataddr = $3000 ;address only in platform file
;Short, unboxed comment here!! ;Short, unboxed comment here!!
; Two spaces after. More hyp- ;Two spaces after. More hyp-
;hens? ;hens?
; .segment "SEG000" ; .segment "SEG000"
.org $1000 .org $1000
@ -53,11 +53,27 @@ plataddr = $3000 ;address only in platform file
;* * ;* *
;*************************************************************** ;***************************************************************
lda #$07 lda #$07
;***************************** ;***************************************************************
;* Some non-ASCII stuff: * ;* Some non-ASCII stuff: *
;* †•<E280A0>␇ * ;* †•<E280A0>␇ *
;***************************** ;* (right side of box looks pushed over on-screen because font *
;* isn't fully mono) *
;***************************************************************
lda #$08 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 #$09
lda #$0a lda #$0a
lda #$0b lda #$0b

View File

@ -57,10 +57,10 @@ limitations under the License.
AcceptsReturn="True" TextWrapping="Wrap"/> AcceptsReturn="True" TextWrapping="Wrap"/>
<StackPanel Grid.Row="2" Orientation="Horizontal" Margin="0,20,0,0"> <StackPanel Grid.Row="2" Orientation="Horizontal" Margin="0,20,0,0">
<TextBlock Text="Maximum line width:"/> <TextBlock Text="Maximum line width:" Margin="0,3,0,0"/>
<ComboBox Name="maxWidthComboBox" Width="75" Margin="8,0,0,0" <ComboBox Name="maxWidthComboBox" Width="75" Margin="8,0,0,0"
ItemsSource="{Binding LineWidthItems}" SelectionChanged="MaxWidthComboBox_SelectionChanged"/> ItemsSource="{Binding LineWidthItems}" SelectionChanged="MaxWidthComboBox_SelectionChanged"/>
<CheckBox Content="Render in _box" Margin="40,1,0,0" IsChecked="{Binding RenderInBox}"/> <CheckBox Content="Render in _box" Margin="40,4,0,0" IsChecked="{Binding RenderInBox}"/>
</StackPanel> </StackPanel>
<TextBlock Grid.Row="3" Text="Expected output:" Margin="0,20,0,0"/> <TextBlock Grid.Row="3" Text="Expected output:" Margin="0,20,0,0"/>