diff --git a/AppKit/CPTextView/CPTypesetter.j b/AppKit/CPTextView/CPTypesetter.j index 95cb70153..85c3f1991 100644 --- a/AppKit/CPTextView/CPTypesetter.j +++ b/AppKit/CPTextView/CPTypesetter.j @@ -49,7 +49,23 @@ CPTypesetterParagraphBreakAction = 1 << 4; CPTypesetterContainerBreakAction = 1 << 5; var CPSystemTypesetterFactory, - _sharedSimpleTypesetter; + _sharedSimpleTypesetter, + _CPTypesetterCachedDecimalSeparator = nil; + +/* + Returns the decimal separator of the user's locale, which a decimal tab stop aligns on. +*/ +var _CPTypesetterDecimalSeparator = function() +{ + if (!_CPTypesetterCachedDecimalSeparator) + { + var formatted = (1.5).toLocaleString(); + + _CPTypesetterCachedDecimalSeparator = formatted.length === 3 ? formatted.charAt(1) : @"."; + } + + return _CPTypesetterCachedDecimalSeparator; +}; @implementation CPTypesetter : CPObject @@ -478,7 +494,16 @@ var CPSystemTypesetterFactory, tabAlignment = [nextTab alignment]; // Mathematically offset the tab character's right boundary - if (tabAlignment === CPCenterTextAlignment) + if ([nextTab tabStopType] === CPDecimalTabStopType) + { + // As in Cocoa, the first decimal separator of the user's locale starts at the stop. + // A segment without one ends at the stop, like a right tab. + var separatorIndex = segmentString.indexOf(_CPTypesetterDecimalSeparator()), + widthBeforeSeparator = separatorIndex === -1 ? nextSegmentWidth : [segmentString.substring(0, separatorIndex) sizeWithFont:currentFont inWidth:NULL].width; + + rangeWidth = (tabLocation - widthBeforeSeparator) - lineOrigin.x; + } + else if (tabAlignment === CPCenterTextAlignment) { rangeWidth = (tabLocation - nextSegmentWidth / 2.0) - lineOrigin.x; } diff --git a/Tests/Manual/TextEditor/WORKLIST.md b/Tests/Manual/TextEditor/WORKLIST.md index 94084ac73..003f57b33 100644 --- a/Tests/Manual/TextEditor/WORKLIST.md +++ b/Tests/Manual/TextEditor/WORKLIST.md @@ -61,6 +61,7 @@ TextEditor is a document-based test application and a tutorial. When the app use - The Window menu lists the open document windows, marks the main window with a check mark and brings a window to the front when chosen. Bring All to Front can be tested once documents open in separate browser windows. - The About panel shows the display name from `CPBundleDisplayName`. - Edit > Allow Undo turns undo on and off for the active document. With undo off, Undo and Redo stay disabled, and the check mark follows the document in front. -- The ruler: markers follow the paragraph at the selection; first line, head and right indents change the layout as shown; clicking adds a tab stop, and dragging moves or removes one; the Control-click menu on a tab stop appears (its effect is not yet verified, for lack of tabbed text); the ruler's zero lines up with the start of the text, and markers at 0 are fully visible. +- The ruler: markers follow the paragraph at the selection; first line, head and right indents change the layout as shown; clicking adds a tab stop, and dragging moves or removes one; the Control-click menu changes a tab stop's type; the ruler's zero lines up with the start of the text, and markers at 0 are fully visible. - Text stays inside the visible width, with Cocoa's 5-point line fragment padding. +- Tab characters: the Tab key inserts a tab in the text view, and left, centre, right and decimal tab stops align their columns. - Builds with both the legacy toolchain and capp-build.