1
1
mirror of https://github.com/qvacua/vimr.git synced 2025-01-08 06:58:50 +03:00

Merge remote-tracking branch 'origin/develop' into update-neovim

This commit is contained in:
Tae Won Ha 2017-06-29 18:27:11 +02:00
commit 64943a1e83
19 changed files with 98 additions and 69 deletions

View File

@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.16.2</string>
<string>SNAPSHOT-211</string>
<key>CFBundleVersion</key>
<string>210</string>
<string>211</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.productivity</string>
<key>LSMinimumSystemVersion</key>

View File

@ -164,6 +164,14 @@ static HlAttrs HlAttrsFromAttrCode(int attr_code) {
return rgb_attrs;
}
static int foreground_for(HlAttrs attrs) {
return attrs.reverse ? attrs.background: attrs.foreground;
}
static int background_for(HlAttrs attrs) {
return attrs.reverse ? attrs.foreground: attrs.background;
}
static void send_colorscheme() {
// It seems that the highlight groupt only gets updated when the screen is redrawn.
// Since there's a guard var, probably it's safe to call it here...
@ -172,15 +180,15 @@ static void send_colorscheme() {
}
HlAttrs visualAttrs = HlAttrsFromAttrCode(highlight_attr[HLF_V]);
HlAttrs dirAttrs = HlAttrsFromAttrCode(highlight_attr[HLF_D]);
int visualFg = visualAttrs.reverse ? visualAttrs.background: visualAttrs.foreground;
int visualBg = visualAttrs.reverse ? visualAttrs.foreground: visualAttrs.background;
NSInteger values[] = {
normal_fg, normal_bg,
visualFg, visualBg
foreground_for(visualAttrs), background_for(visualAttrs),
foreground_for(dirAttrs),
};
NSData *resultData = [NSData dataWithBytes:values length:4 * sizeof(NSInteger)];
NSData *resultData = [NSData dataWithBytes:values length:5 * sizeof(NSInteger)];
[_neovim_server sendMessageWithId:NeoVimServerMsgIdColorSchemeChanged data:resultData];
}

View File

@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.16.2</string>
<string>SNAPSHOT-211</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>210</string>
<string>211</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2016 Tae Won Ha. All rights reserved.</string>
<key>NSPrincipalClass</key>

View File

@ -634,7 +634,7 @@ static CFDataRef local_server_callback(CFMessagePortRef local __unused, SInt32 m
case NeoVimServerMsgIdColorSchemeChanged: {
NSInteger *values = (NSInteger *) data.bytes;
NSMutableArray *array = [NSMutableArray new];
for (int i = 0; i < 4; i++) {
for (int i = 0; i < 5; i++) {
[array addObject:@(values[i])];
}
[_bridge colorSchemeChanged:array];

View File

@ -37,11 +37,13 @@ public class NeoVimView: NSView,
public var visualForeground = NSColor.selectedMenuItemTextColor
public var visualBackground = NSColor.selectedMenuItemColor
public var directoryForeground = NSColor.textColor
public init() {}
public init(_ values: [Int]) {
if values.count < 4 {
preconditionFailure("We need 4 colors!")
if values.count < 5 {
preconditionFailure("We need 5 colors!")
}
let color = ColorUtils.colorIgnoringAlpha
@ -51,6 +53,8 @@ public class NeoVimView: NSView,
self.visualForeground = values[2] < 0 ? Theme.default.visualForeground : color(values[2])
self.visualBackground = values[3] < 0 ? Theme.default.visualBackground : color(values[3])
self.directoryForeground = values[4] < 0 ? Theme.default.directoryForeground : color(values[4])
}
public var description: String {

View File

@ -15,10 +15,10 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>0.16.2</string>
<string>SNAPSHOT-211</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>210</string>
<string>211</string>
</dict>
</plist>

View File

@ -59,7 +59,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, WorkspaceDelegate {
fileprivate func dummyTool(title: String,
color: NSColor,
customToolbar: NSView? = nil,
customToolbar: CustomToolBar? = nil,
customMenu: [NSMenuItem] = []) -> WorkspaceTool
{
let config = WorkspaceTool.Config(title: title,
@ -89,7 +89,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, WorkspaceDelegate {
}
}
class DummyView: NSView {
class DummyView: CustomToolBar {
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")

View File

@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.16.2</string>
<string>SNAPSHOT-211</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>210</string>
<string>211</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSHumanReadableCopyright</key>

View File

@ -1793,7 +1793,7 @@
COMBINE_HIDPI_IMAGES = YES;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 210;
DYLIB_CURRENT_VERSION = 211;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
@ -1818,7 +1818,7 @@
COMBINE_HIDPI_IMAGES = YES;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 210;
DYLIB_CURRENT_VERSION = 211;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
@ -2055,7 +2055,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 210;
CURRENT_PROJECT_VERSION = 211;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
@ -2105,7 +2105,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 210;
CURRENT_PROJECT_VERSION = 211;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;

View File

@ -20,7 +20,7 @@ extension NSColor {
}
}
func darkening(by factor: CGFloat) -> NSColor {
func brightening(by factor: CGFloat) -> NSColor {
guard let color = self.usingColorSpace(.sRGB) else {
// TODO: what to do?
return self

View File

@ -70,18 +70,8 @@ class FileOutlineView: NSOutlineView,
themePrefChanged: state.appearance.usesTheme != self.usesTheme,
themeChanged: state.appearance.theme.mark != self.lastThemeMark,
usesTheme: state.appearance.usesTheme,
forTheme: {
self.theme = state.appearance.theme.payload
self.enclosingScrollView?.backgroundColor = self.theme.background
self.backgroundColor = self.theme.background
self.lastThemeMark = state.appearance.theme.mark
},
forDefaultTheme: {
self.theme = Theme.default
self.enclosingScrollView?.backgroundColor = self.theme.background
self.backgroundColor = self.theme.background
self.lastThemeMark = state.appearance.theme.mark
})
forTheme: { self.updateTheme(state.appearance.theme) },
forDefaultTheme: { self.updateTheme(Marked(Theme.default)) })
self.usesTheme = state.appearance.usesTheme
@ -137,6 +127,13 @@ class FileOutlineView: NSOutlineView,
fatalError("init(coder:) has not been implemented")
}
fileprivate func updateTheme(_ theme: Marked<Theme>) {
self.theme = theme.payload
self.enclosingScrollView?.backgroundColor = self.theme.background
self.backgroundColor = self.theme.background
self.lastThemeMark = theme.mark
}
fileprivate func shouldReloadData(for state: StateType, themeChanged: Bool = false) -> Bool {
if self.isShowHidden != state.fileBrowserShowHidden {
return true
@ -381,9 +378,9 @@ extension FileOutlineView {
cell.text = fileBrowserItem.url.lastPathComponent
let icon = FileUtils.icon(forUrl: fileBrowserItem.url)
cell.image = fileBrowserItem.isHidden
? icon?.tinting(with: NSColor.white.withAlphaComponent(0.4))
: icon
cell.image = fileBrowserItem.isHidden ? icon?.tinting(with: NSColor.white.withAlphaComponent(0.4)) : icon
cell.isDir = fileBrowserItem.isDir
return cell
}
@ -534,6 +531,7 @@ fileprivate class FileBrowserItem: Hashable, Comparable, CustomStringConvertible
}
let url: URL
let isDir: Bool
let isHidden: Bool
var children: [FileBrowserItem] = []
var isChildrenScanned = false
@ -544,6 +542,7 @@ fileprivate class FileBrowserItem: Hashable, Comparable, CustomStringConvertible
// We cache the value here since we often get the value when the file is not there, eg when
// updating because the file gets deleted (in self.prepare() function)
self.isHidden = url.isHidden
self.isDir = url.isDir
}
func child(with url: URL) -> FileBrowserItem? {

View File

@ -32,7 +32,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.16.2</string>
<string>SNAPSHOT-211</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
@ -49,7 +49,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>210</string>
<string>211</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.productivity</string>
<key>LSMinimumSystemVersion</key>

View File

@ -345,15 +345,15 @@ class MainWindow: NSObject,
workspaceTheme.foreground = theme.foreground
workspaceTheme.background = theme.background
workspaceTheme.separator = theme.background.darkening(by: 0.75)
workspaceTheme.separator = theme.background.brightening(by: 0.75)
workspaceTheme.barBackground = theme.background
workspaceTheme.barFocusRing = theme.foreground
workspaceTheme.barButtonHighlight = theme.background.darkening(by: 0.75)
workspaceTheme.barButtonHighlight = theme.background.brightening(by: 0.75)
workspaceTheme.toolbarForeground = theme.foreground
workspaceTheme.toolbarBackground = theme.background.darkening(by: 0.75)
workspaceTheme.toolbarBackground = theme.background.brightening(by: 0.75)
self.workspace.theme = workspaceTheme
}

View File

@ -48,18 +48,8 @@ class OpenedFileList: NSView,
themePrefChanged: state.appearance.usesTheme != self.usesTheme,
themeChanged: state.appearance.theme.mark != self.lastThemeMark,
usesTheme: state.appearance.usesTheme,
forTheme: {
self.theme = state.appearance.theme.payload
self.bufferList.enclosingScrollView?.backgroundColor = self.theme.background
self.bufferList.backgroundColor = self.theme.background
self.lastThemeMark = state.appearance.theme.mark
},
forDefaultTheme: {
self.theme = Theme.default
self.bufferList.enclosingScrollView?.backgroundColor = self.theme.background
self.bufferList.backgroundColor = self.theme.background
self.lastThemeMark = state.appearance.theme.mark
})
forTheme: { self.updateTheme(state.appearance.theme) },
forDefaultTheme: { self.updateTheme(Marked(Theme.default)) })
self.usesTheme = state.appearance.usesTheme
@ -91,6 +81,13 @@ class OpenedFileList: NSView,
fatalError("init(coder:) has not been implemented")
}
fileprivate func updateTheme(_ theme: Marked<Theme>) {
self.theme = theme.payload
self.bufferList.enclosingScrollView?.backgroundColor = self.theme.background
self.bufferList.backgroundColor = self.theme.background
self.lastThemeMark = theme.mark
}
fileprivate func addViews() {
let scrollView = NSScrollView.standardScrollView()
scrollView.borderType = .noBorder
@ -163,8 +160,13 @@ extension OpenedFileList {
let pathInfo = url.pathComponents.dropFirst().dropLast().reversed().joined(separator: " / ") + " /"
let rowText = NSMutableAttributedString(string: "\(name)\(pathInfo)")
rowText.addAttribute(NSForegroundColorAttributeName,
value: NSColor.lightGray,
value: self.theme.foreground,
range: NSRange(location: 0, length: name.characters.count))
rowText.addAttribute(NSForegroundColorAttributeName,
value: self.theme.foreground.brightening(by: 1.15),
range: NSRange(location: name.characters.count, length: pathInfo.characters.count + 3))
return rowText

View File

@ -16,10 +16,13 @@ struct Theme: CustomStringConvertible {
var highlightForeground = NSColor.selectedMenuItemTextColor
var highlightBackground = NSColor.selectedMenuItemColor
var directoryForeground = NSColor.textColor
public var description: String {
return "Theme<" +
"fg: \(self.foreground.hex), bg: \(self.background.hex), " +
"hl-fg: \(self.highlightForeground.hex), hl-bg: \(self.highlightBackground.hex)" +
"dir-fg: \(self.directoryForeground.hex)" +
">"
}
@ -33,5 +36,7 @@ struct Theme: CustomStringConvertible {
self.highlightForeground = neoVimTheme.visualForeground
self.highlightBackground = neoVimTheme.visualBackground
self.directoryForeground = neoVimTheme.directoryForeground
}
}

View File

@ -24,7 +24,11 @@ class ThemedTableRow: NSTableRowView {
open override func drawBackground(in dirtyRect: NSRect) {
if let cell = self.view(atColumn: 0) as? ThemedTableCell {
cell.textField?.textColor = self.themedView?.theme.foreground ?? Theme.default.foreground
if cell.isDir {
cell.textField?.textColor = self.themedView?.theme.directoryForeground ?? Theme.default.directoryForeground
} else {
cell.textField?.textColor = self.themedView?.theme.foreground ?? Theme.default.foreground
}
}
self.themedView?.theme.background.set()
@ -64,6 +68,8 @@ class ThemedTableCell: NSTableCellView {
height: max(self._textField.intrinsicContentSize.height, 16))
}
var isDir = false
var attributedText: NSAttributedString {
get {
return self.textField!.attributedStringValue
@ -130,6 +136,7 @@ class ThemedTableCell: NSTableCellView {
func reset() -> ThemedTableCell {
self.text = ""
self.image = nil
self.isDir = false
return self
}

View File

@ -77,8 +77,9 @@ class WorkspaceToolButton: NSView, NSDraggingSource {
self.dehighlight()
}
self.title.setAttributes([NSForegroundColorAttributeName: self.theme.foreground],
range: NSRange(location: 0, length: self.title.length))
self.title.addAttribute(NSForegroundColorAttributeName,
value: self.theme.foreground,
range: NSRange(location: 0, length: self.title.length))
self.needsDisplay = true
}

View File

@ -15,10 +15,10 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>0.16.2</string>
<string>SNAPSHOT-211</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>210</string>
<string>211</string>
</dict>
</plist>

View File

@ -7,22 +7,25 @@
<description>Most recent changes with links to updates for VimR.</description>
<language>en</language>
<item>
<title>SNAPSHOT-209</title>
<title>SNAPSHOT-211</title>
<description><![CDATA[
<ul>
<li>GH-436: Use colors from the selected <code>colorscheme</code> for tools, e.g. the file browser. Please report issues in <a href="https://github.com/qvacua/vimr/issues/436">#436</a></li>
<li>GH-436: Use colors from the selected <code>colorscheme</code> for tools, e.g. the file browser.<ul>
<li>Use <code>directory</code> color of the selected <code>colorscheme</code> for folders in the file browser</li>
</ul>
</li>
</ul>
]]></description>
<releaseNotesLink>
https://github.com/qvacua/vimr/releases/tag/snapshot/209
https://github.com/qvacua/vimr/releases/tag/snapshot/211
</releaseNotesLink>
<pubDate>2017-06-27T20:04:53.790811</pubDate>
<pubDate>2017-06-29T18:04:13.475054</pubDate>
<minimumSystemVersion>10.10.0</minimumSystemVersion>
<enclosure url="https://github.com/qvacua/vimr/releases/download/snapshot/209/VimR-SNAPSHOT-209.tar.bz2"
sparkle:version="209"
sparkle:shortVersionString="SNAPSHOT-209"
sparkle:dsaSignature="MC0CFEsk/4fYINo6Py7tO05kTChn575DAhUA5pMVsyWq1jD4xmnD7+r3fvah//0="
length="10686723"
<enclosure url="https://github.com/qvacua/vimr/releases/download/snapshot/211/VimR-SNAPSHOT-211.tar.bz2"
sparkle:version="211"
sparkle:shortVersionString="SNAPSHOT-211"
sparkle:dsaSignature="MCwCFBfkMVj9gA0Jo0oezaToCEoKTn0kAhRYoAaumpaFun7kpto8IWPK5kfQNg=="
length="10688763"
type="application/octet-stream"/>
</item>
</channel>