Skip to content

Commit

Permalink
Version 9.1-dev: add feature suggested by @Christianlm
Browse files Browse the repository at this point in the history
* Add a combo box to choose the browseable text format to show the clipboard text. Available formats are: preformatted HTML, HTML as shown in a web browser, and raw text.
nvdaes committed Mar 7, 2019
1 parent aff306d commit 4147412
Showing 3 changed files with 29 additions and 4 deletions.
29 changes: 27 additions & 2 deletions addon/globalPlugins/clipContentsDesigner/__init__.py
Original file line number Diff line number Diff line change
@@ -34,10 +34,22 @@
"confirmToCopy": "boolean(default=False)",
"confirmToCut": "boolean(default=False)",
"confirmationRequirement": "integer(default=0)",
"browseableTextFormat": "integer(default=0)",
"maxLengthForBrowseableText": "integer(default=100000)",
}
config.conf.spec["clipContentsDesigner"] = confspec

### Constants

BROWSEABLETEXT_FORMATS = [
# Translators: label of a dialog.
_("Preformatted text in HTML"),
# Translators: label of a dialog.
_("HTML as shown in a web browser"),
# Translators: label of a dialog.
_("Raw text"),
]

def getBookmark():
try:
separator = config.conf["clipContentsDesigner"]["separator"]
@@ -289,9 +301,17 @@ def script_showClipboardText(self, gesture):
ui.message(_("Clipboard is empty"))
else:
maxLength = config.conf["clipContentsDesigner"]["maxLengthForBrowseableText"] if config.conf["clipContentsDesigner"]["maxLengthForBrowseableText"] <= len(text) else len(text)
browseableText = "<pre>%s</pre>" % text[:maxLength]
format = config.conf["clipContentsDesigner"]["browseableTextFormat"]
html = True
if format == 0:
browseableText = "<pre>%s</pre>" % text.strip()[:maxLength]
elif format == 1:
browseableText = text.strip()[:maxLength]
else:
browseableText = text[:maxLength]
html = False
# Translators: title of a browseable message.
ui.browseableMessage(browseableText, _("Clipboard text (%d/%d)" % (maxLength, len(text))), True)
ui.browseableMessage(browseableText, _("Clipboard text ({max}/{current} - {formatForTitle})".format(max=maxLength, current=len(text), formatForTitle=BROWSEABLETEXT_FORMATS[format])), html)
script_showClipboardText.__doc__ = _("Shows the clipboard text in browse mode")

__gestures = {
@@ -354,6 +374,10 @@ def makeSettings(self, settingsSizer):
self.confirmRequirementChoices = sHelper.addLabeledControl(confirmRequirementsLabel, wx.Choice, choices=requirementChoices)
self.confirmRequirementChoices.SetSelection(config.conf["clipContentsDesigner"]["confirmationRequirement"])
# Translators: label of a dialog.
formatLabel = _("&Format to show the clipboard text in browse mode:")
self.formatChoices = sHelper.addLabeledControl(formatLabel, wx.Choice, choices=BROWSEABLETEXT_FORMATS)
self.formatChoices.SetSelection(config.conf["clipContentsDesigner"]["browseableTextFormat"])
# Translators: label of a dialog.
maxLengthLabel=wx.StaticText(self,-1,label=_("&Maximum number of characters when showing clipboard text in browse mode"))
self.maxLengthEdit=gui.nvdaControls.SelectOnFocusSpinCtrl(self, min=1, max=1000000, initial=config.conf["clipContentsDesigner"]["maxLengthForBrowseableText"])

@@ -368,4 +392,5 @@ def onSave(self):
config.conf["clipContentsDesigner"]["confirmToCopy"] = self.confirmList.IsChecked(2)
config.conf["clipContentsDesigner"]["confirmToCut"] = self.confirmList.IsChecked(3)
config.conf["clipContentsDesigner"]["confirmationRequirement"] = self.confirmRequirementChoices.GetSelection()
config.conf["clipContentsDesigner"]["browseableTextFormat"] = self.formatChoices.GetSelection()
config.conf["clipContentsDesigner"]["maxLengthForBrowseableText"] = self.maxLengthEdit.GetValue()
2 changes: 1 addition & 1 deletion buildVars.py
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@
# Translators: Long description to be shown for this add-on on add-on information from add-ons manager
"addon_description" : _("""Add-on for managing clipboard text."""),
# version
"addon_version" : "9.0-dev",
"addon_version" : "9.1-dev",
# Author(s)
"addon_author" : u"Noelia Ruiz Martínez <[email protected]>",
# URL for the add-on documentation support
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ Note: The above commands can be changed from NVDA menu, Preferences submenu, Inp
## Preferences Menu ##
* Clip Contents Designer settings: Allows to set a separator which can be used to find the text segments once the entire added text is pasted.
It's also possible to choose if the added text will be appended or prepended, if available actions (add, clear clipboard, emulate copy and emulate cut) should be performed inmediately or after confirmation, and if confirmations will be requested always, just if text is contained in the clipboard, or if clipboard is not empty.
Furthermore, it's possible to change the maximum number of characters of the clipboard text which will be shown in browse mode. Please, be aware that increasing this limit may produce issues if the clipboard contains large strings of text. The default limit is 100000 characters.
Furthermore, it's possible to change the format and maximum number of characters of the clipboard text which will be shown in browse mode. Please, be aware that increasing this limit may produce issues if the clipboard contains large strings of text. The default limit is 100000 characters.

Notes:

0 comments on commit 4147412

Please sign in to comment.