mirror of
https://github.com/coteditor/CotEditor.git
synced 2024-09-11 11:25:57 +03:00
Fix timing to update print page range
This commit is contained in:
parent
1a0a0416d8
commit
2d446204ab
@ -5,6 +5,10 @@ Change Log
|
||||
4.4.3 (unreleased)
|
||||
--------------------------
|
||||
|
||||
### Fixes
|
||||
|
||||
- Fix an issue the total page did not update when changing the print scope option to Selection in CotEditor in the print dialog.
|
||||
|
||||
|
||||
|
||||
4.4.2 (544)
|
||||
|
@ -157,13 +157,17 @@ final class PrintTextView: NSTextView, Themable {
|
||||
/// return the number of pages available for printing
|
||||
override func knowsPageRange(_ range: NSRangePointer) -> Bool {
|
||||
|
||||
// adjust content size based on print setting
|
||||
if let paperContentSize = NSPrintOperation.current?.printInfo.paperContentSize,
|
||||
self.lastPaperContentSize != paperContentSize
|
||||
{
|
||||
self.lastPaperContentSize = paperContentSize
|
||||
self.frame.size = paperContentSize
|
||||
self.layoutManager?.doForegroundLayout()
|
||||
if let printInfo = NSPrintOperation.current?.printInfo {
|
||||
// set scope to print
|
||||
(self.layoutManager as? PrintLayoutManager)?.showsSelectionOnly = printInfo.isSelectionOnly
|
||||
|
||||
// adjust content size based on print setting
|
||||
let paperContentSize = printInfo.paperContentSize
|
||||
if self.lastPaperContentSize != paperContentSize {
|
||||
self.lastPaperContentSize = paperContentSize
|
||||
self.frame.size = paperContentSize
|
||||
self.layoutManager?.doForegroundLayout()
|
||||
}
|
||||
}
|
||||
|
||||
return super.knowsPageRange(range)
|
||||
@ -265,13 +269,10 @@ final class PrintTextView: NSTextView, Themable {
|
||||
private func applyPrintSettings() {
|
||||
|
||||
guard
|
||||
let layoutManager = self.layoutManager as? PrintLayoutManager,
|
||||
let layoutManager = self.layoutManager as? LayoutManager,
|
||||
let printInfo = NSPrintOperation.current?.printInfo
|
||||
else { return assertionFailure() }
|
||||
|
||||
// set scope to print
|
||||
layoutManager.showsSelectionOnly = printInfo.isSelectionOnly
|
||||
|
||||
// set line numbers
|
||||
self.printsLineNumber = printInfo[.printsLineNumbers] ?? false
|
||||
// adjust paddings considering the line numbers
|
||||
|
Loading…
Reference in New Issue
Block a user