Mercurial > cgi-bin > hgweb.cgi > ClipMan
changeset 62:c56a0747c256 default tip
Add make plain feature.
author | David Barts <n5jrn@me.com> |
---|---|
date | Thu, 28 Apr 2022 20:53:39 -0700 |
parents | fd93b545db4d |
children | |
files | build.xml src/name/blackcap/clipman/Menus.kt |
diffstat | 2 files changed, 25 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/build.xml Sun Apr 03 16:58:01 2022 -0700 +++ b/build.xml Thu Apr 28 20:53:39 2022 -0700 @@ -83,6 +83,8 @@ <target name="clean"> <delete includeEmptyDirs="true" failonerror="false"> <fileset dir="${dist.home}" includes="**/*"/> + <fileset file="${work.jar}"/> + <fileset file="${jar.name}"/> </delete> </target>
--- a/src/name/blackcap/clipman/Menus.kt Sun Apr 03 16:58:01 2022 -0700 +++ b/src/name/blackcap/clipman/Menus.kt Thu Apr 28 20:53:39 2022 -0700 @@ -28,6 +28,7 @@ "Edit.Coerce" -> onlyIfSelected { Application.coerceDialog.setVisible(true) } "Edit.Find" -> Application.searchDialog.setVisible(true) "Edit.FindAgain" -> Application.searchDialog.find() + "Edit.Plain" -> onlyIfSelected { if (suitedForCoercing(it)) { makePlain(it.contents) } } "Edit.Troff" -> onlyIfSelected { if (suitedForCoercing(it)) { troffize(it.contents) } } "Help.About" -> showAboutDialog() else -> throw RuntimeException("unexpected actionCommand!") @@ -109,6 +110,12 @@ addActionListener(Application.menuItemListener) makeShortcut(KeyEvent.VK_T) })) + add(Application.styledRequired.add(JMenuItem("Make Plain").apply { + setEnabled(false) + actionCommand = "Edit.Plain" + addActionListener(Application.menuItemListener) + makeShortcut(KeyEvent.VK_P) + })) add(JMenuItem("Find…").apply { actionCommand = "Edit.Find" addActionListener(Application.menuItemListener) @@ -155,6 +162,10 @@ actionCommand = "Edit.Troff" addActionListener(Application.menuItemListener) })) + add(Application.styledRequired.add(JMenuItem("Make Plain").apply { + actionCommand = "Edit.Plain" + addActionListener(Application.menuItemListener) + })) add(Application.styledRequired.add(JMenuItem("Coerce…").apply { actionCommand = "Edit.Coerce" addActionListener(Application.menuItemListener) @@ -162,6 +173,18 @@ } } +fun makePlain(item: PasteboardItem): Unit { + val plain = when (item) { + is PasteboardItem.Plain -> + item.plain + is PasteboardItem.HTML -> + item.plain + is PasteboardItem.RTF -> + item.plain + } + PasteboardItem.write(PasteboardItem.Plain(plain)) +} + /** * Show an About dialog. */