From cbe022dffcdd38c74172d048e328f1c5128fc7b8 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Fri, 11 Oct 2019 17:56:21 -0700 Subject: [PATCH] Use ConstructionBase.setproperties instead of hand-coding setconfig --- Project.toml | 1 + src/ElectronDisplay.jl | 20 ++------------------ 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/Project.toml b/Project.toml index 78aca9c..0575352 100644 --- a/Project.toml +++ b/Project.toml @@ -4,6 +4,7 @@ version = "0.8.2-DEV" [deps] Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" +ConstructionBase = "187b0558-2788-49d3-abe0-74a17ed4e7c9" Electron = "a1bb12fb-d4d1-54b4-b10a-ee7951ef7ad3" TableShowUtils = "5e66a065-1f0a-5976-b372-e0b8c017ca10" IteratorInterfaceExtensions = "82899510-4779-5014-852e-03e436cf321d" diff --git a/src/ElectronDisplay.jl b/src/ElectronDisplay.jl index f5d4fce..89a7e83 100644 --- a/src/ElectronDisplay.jl +++ b/src/ElectronDisplay.jl @@ -3,6 +3,7 @@ module ElectronDisplay export electrondisplay using Electron, Base64, Markdown +using ConstructionBase: setproperties import IteratorInterfaceExtensions, TableTraits, TableShowUtils @@ -12,29 +13,12 @@ Base.@kwdef mutable struct ElectronDisplayConfig focus::Bool = true end -""" - setconfig(config; kwargs...) - -Update a copy of `config` based on `kwargs`. -""" -setconfig( - config::ElectronDisplayConfig; - showable = config.showable, - single_window::Bool = config.single_window, - focus::Bool = config.focus, -) = - ElectronDisplayConfig( - showable = showable, - single_window = single_window, - focus = focus, - ) - struct ElectronDisplayType <: Base.AbstractDisplay config::ElectronDisplayConfig end ElectronDisplayType() = ElectronDisplayType(CONFIG) -newdisplay(; config...) = ElectronDisplayType(setconfig(CONFIG; config...)) +newdisplay(; config...) = ElectronDisplayType(setproperties(CONFIG; config...)) electron_showable(m, x) = m ∉ ("application/vnd.dataresource+json", "text/html", "text/markdown") &&