Mercurial > cgi-bin > hgweb.cgi > ClipMan
comparison src/name/blackcap/clipman/Main.kt @ 41:33fbe3a78d84
Got the settings stuff compiling (untested).
author | David Barts <n5jrn@me.com> |
---|---|
date | Sat, 08 Feb 2020 22:10:01 -0700 |
parents | 5f8475b37e23 |
children | 339e2da5bf83 |
comparison
equal
deleted
inserted
replaced
40:c803a2c89ea0 | 41:33fbe3a78d84 |
---|---|
16 import java.util.logging.Level | 16 import java.util.logging.Level |
17 import java.util.logging.Logger | 17 import java.util.logging.Logger |
18 import javax.swing.* | 18 import javax.swing.* |
19 import javax.swing.text.html.StyleSheet | 19 import javax.swing.text.html.StyleSheet |
20 import kotlin.concurrent.thread | 20 import kotlin.concurrent.thread |
21 import kotlin.math.roundToInt | |
21 import org.jsoup.Jsoup | 22 import org.jsoup.Jsoup |
22 import org.jsoup.nodes.* | 23 import org.jsoup.nodes.* |
23 | 24 |
24 /* name we call ourselves */ | 25 /* name we call ourselves */ |
25 val MYNAME = "ClipMan" | 26 val MYNAME = "ClipMan" |
73 } | 74 } |
74 val piv = if (html == null) { | 75 val piv = if (html == null) { |
75 PasteboardItemView("Plain text", ClipText(contents).apply { | 76 PasteboardItemView("Plain text", ClipText(contents).apply { |
76 contentType = "text/plain" | 77 contentType = "text/plain" |
77 text = plain | 78 text = plain |
78 font = Font(Font.MONOSPACED, Font.PLAIN, MONO_SIZE) | 79 font = Font(settingsDialog.mFamily, Font.PLAIN, settingsDialog.mSize.roundToInt()) |
79 resize() | 80 resize() |
80 }) | 81 }) |
81 } else { | 82 } else { |
82 val (dhtml, style) = preproc(html) | 83 val (dhtml, style) = preproc(html) |
83 val hek = MyEditorKit().apply { | 84 val hek = MyEditorKit().apply { |
106 } | 107 } |
107 } | 108 } |
108 | 109 |
109 private fun preproc(html: String): Pair<String, StyleSheet> { | 110 private fun preproc(html: String): Pair<String, StyleSheet> { |
110 val sty = StyleSheet().apply { | 111 val sty = StyleSheet().apply { |
111 addRule("body { font-family: serif; font-size: ${PROP_SIZE}; }") | 112 addRule("body { font-family: \"%s\"; font-size: %.2f; }".format( |
112 addRule("code, kbd, pre, samp, tt { font-family: monospace; font-size: ${MONO_SIZE}; }") | 113 settingsDialog.pFamily, settingsDialog.pSize)) |
114 addRule("code, kbd, pre, samp, tt { font-family: \"%s\"; font-size: %.2f}; }".format( | |
115 settingsDialog.mFamily, settingsDialog.mSize)) | |
113 } | 116 } |
114 val scrubbed = Jsoup.parse(html).run { | 117 val scrubbed = Jsoup.parse(html).run { |
115 select("style").forEach { | 118 select("style").forEach { |
116 it.dataNodes().forEach { sty.addRule(it.wholeData) } | 119 it.dataNodes().forEach { sty.addRule(it.wholeData) } |
117 } | 120 } |
188 }, BorderLayout.CENTER) | 191 }, BorderLayout.CENTER) |
189 pack() | 192 pack() |
190 setVisible(true) | 193 setVisible(true) |
191 addWindowListener(KillIt()) | 194 addWindowListener(KillIt()) |
192 } | 195 } |
193 } | 196 setMacMenus() |
194 queue.v = PasteboardQueue(con, 10) | 197 } |
198 queue.v = PasteboardQueue(con, settingsDialog.qLength) | |
195 UpdateIt(1000).apply { start() } | 199 UpdateIt(1000).apply { start() } |
196 } | 200 } |