Mercurial > cgi-bin > hgweb.cgi > ClipMan
comparison src/name/blackcap/clipman/Menus.kt @ 62:c56a0747c256 default tip
Add make plain feature.
author | David Barts <n5jrn@me.com> |
---|---|
date | Thu, 28 Apr 2022 20:53:39 -0700 |
parents | c6cccbe2f393 |
children |
comparison
equal
deleted
inserted
replaced
61:fd93b545db4d | 62:c56a0747c256 |
---|---|
26 "File.Preferences" -> Application.settingsDialog.setVisible(true) | 26 "File.Preferences" -> Application.settingsDialog.setVisible(true) |
27 "Edit.Clone" -> onlyIfSelected { PasteboardItem.write(it.contents) } | 27 "Edit.Clone" -> onlyIfSelected { PasteboardItem.write(it.contents) } |
28 "Edit.Coerce" -> onlyIfSelected { Application.coerceDialog.setVisible(true) } | 28 "Edit.Coerce" -> onlyIfSelected { Application.coerceDialog.setVisible(true) } |
29 "Edit.Find" -> Application.searchDialog.setVisible(true) | 29 "Edit.Find" -> Application.searchDialog.setVisible(true) |
30 "Edit.FindAgain" -> Application.searchDialog.find() | 30 "Edit.FindAgain" -> Application.searchDialog.find() |
31 "Edit.Plain" -> onlyIfSelected { if (suitedForCoercing(it)) { makePlain(it.contents) } } | |
31 "Edit.Troff" -> onlyIfSelected { if (suitedForCoercing(it)) { troffize(it.contents) } } | 32 "Edit.Troff" -> onlyIfSelected { if (suitedForCoercing(it)) { troffize(it.contents) } } |
32 "Help.About" -> showAboutDialog() | 33 "Help.About" -> showAboutDialog() |
33 else -> throw RuntimeException("unexpected actionCommand!") | 34 else -> throw RuntimeException("unexpected actionCommand!") |
34 } | 35 } |
35 } | 36 } |
107 setEnabled(false) | 108 setEnabled(false) |
108 actionCommand = "Edit.Troff" | 109 actionCommand = "Edit.Troff" |
109 addActionListener(Application.menuItemListener) | 110 addActionListener(Application.menuItemListener) |
110 makeShortcut(KeyEvent.VK_T) | 111 makeShortcut(KeyEvent.VK_T) |
111 })) | 112 })) |
113 add(Application.styledRequired.add(JMenuItem("Make Plain").apply { | |
114 setEnabled(false) | |
115 actionCommand = "Edit.Plain" | |
116 addActionListener(Application.menuItemListener) | |
117 makeShortcut(KeyEvent.VK_P) | |
118 })) | |
112 add(JMenuItem("Find…").apply { | 119 add(JMenuItem("Find…").apply { |
113 actionCommand = "Edit.Find" | 120 actionCommand = "Edit.Find" |
114 addActionListener(Application.menuItemListener) | 121 addActionListener(Application.menuItemListener) |
115 makeShortcut(KeyEvent.VK_F) | 122 makeShortcut(KeyEvent.VK_F) |
116 }) | 123 }) |
153 })) | 160 })) |
154 add(Application.styledRequired.add(JMenuItem("Convert to Troff").apply { | 161 add(Application.styledRequired.add(JMenuItem("Convert to Troff").apply { |
155 actionCommand = "Edit.Troff" | 162 actionCommand = "Edit.Troff" |
156 addActionListener(Application.menuItemListener) | 163 addActionListener(Application.menuItemListener) |
157 })) | 164 })) |
165 add(Application.styledRequired.add(JMenuItem("Make Plain").apply { | |
166 actionCommand = "Edit.Plain" | |
167 addActionListener(Application.menuItemListener) | |
168 })) | |
158 add(Application.styledRequired.add(JMenuItem("Coerce…").apply { | 169 add(Application.styledRequired.add(JMenuItem("Coerce…").apply { |
159 actionCommand = "Edit.Coerce" | 170 actionCommand = "Edit.Coerce" |
160 addActionListener(Application.menuItemListener) | 171 addActionListener(Application.menuItemListener) |
161 })) | 172 })) |
162 } | 173 } |
174 } | |
175 | |
176 fun makePlain(item: PasteboardItem): Unit { | |
177 val plain = when (item) { | |
178 is PasteboardItem.Plain -> | |
179 item.plain | |
180 is PasteboardItem.HTML -> | |
181 item.plain | |
182 is PasteboardItem.RTF -> | |
183 item.plain | |
184 } | |
185 PasteboardItem.write(PasteboardItem.Plain(plain)) | |
163 } | 186 } |
164 | 187 |
165 /** | 188 /** |
166 * Show an About dialog. | 189 * Show an About dialog. |
167 */ | 190 */ |