Skip to content

Commit 4130474

Browse files
committed
Use standalone non-breaking spaces in upper window
Prevents the occasional collapsing of space-only lines. Closes #17
1 parent 1c01438 commit 4130474

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

Yazmin/GridStoryFacet.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ - (void)setCursorLine:(int)line column:(int)column {
8383
}
8484

8585
- (void)print:(NSString *)text {
86+
87+
// If a standalone space, convert it to a non-breaking space so
88+
// that the text system doesn't get any ideas about collapsing it
89+
if ([text isEqualToString:@" "]) {
90+
const unichar nbsp = 0xa0;
91+
text = [NSString stringWithCharacters:&nbsp length:1];
92+
}
8693
[self.textStorage beginEditing];
8794

8895
// Break into individual lines

Yazmin/ZMachine.mm

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ - (instancetype)initWithStory:(Story *)aStory {
6363
if (0 < len && len <= kMaxStorySize) {
6464
parts->_memory =
6565
new ZMMemory((const uint8_t *)data.bytes, len, *parts->_io);
66-
67-
// parts->_memory->getDictionary().dump();
68-
// parts->_memory->getHeader().dump();
69-
// parts->_memory->dump();
7066
}
7167

7268
parts->_error = new ZMErrorAdapter(story);

YazminTests/StatusLineTests.m

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,37 +69,38 @@ - (void)tearDown {
6969
}
7070

7171
- (void)testTimeStatus {
72+
// Note that the following string tests contain non-breaking spaces
7273
Story *story = [[Story alloc] init];
7374
[story readFromData:data ofType:@"" error:nil];
7475
story.facets[1].widthInCharacters = 40;
7576
story.facets[1].heightInLines = 1;
7677
[story showStatus];
7778
XCTAssertEqualObjects(story.facets[1].textStorage.string,
78-
@" foo 2:03 AM ");
79+
@" foo                           2:03 AM  ");
7980

8081
[story.zMachine setGlobal:8 atIndex:1];
8182
[story.zMachine setGlobal:0 atIndex:2];
8283
[story showStatus];
8384
XCTAssertEqualObjects(story.facets[1].textStorage.string,
84-
@" foo 8:00 AM ");
85+
@" foo                           8:00 AM  ");
8586

8687
[story.zMachine setGlobal:0 atIndex:1];
8788
[story.zMachine setGlobal:11 atIndex:2];
8889
[story showStatus];
8990
XCTAssertEqualObjects(story.facets[1].textStorage.string,
90-
@" foo 12:11 AM ");
91+
@" foo                           12:11 AM ");
9192

9293
[story.zMachine setGlobal:12 atIndex:1];
9394
[story.zMachine setGlobal:11 atIndex:2];
9495
[story showStatus];
9596
XCTAssertEqualObjects(story.facets[1].textStorage.string,
96-
@" foo 12:11 PM ");
97+
@" foo                           12:11 PM ");
9798

9899
[story.zMachine setGlobal:111 atIndex:1];
99100
[story.zMachine setGlobal:99 atIndex:2];
100101
[story showStatus];
101102
XCTAssertEqualObjects(story.facets[1].textStorage.string,
102-
@" foo 99:99 PM ");
103+
@" foo                           99:99 PM ");
103104

104105
[story close];
105106
}

0 commit comments

Comments
 (0)