Commit 91d989fa authored by Stephan Kreutzer's avatar Stephan Kreutzer

text_position_retriever_1: More details added about the current selection.

parent 965d11e9
......@@ -92,12 +92,19 @@ class MouseEventListener extends MouseAdapter
{
if (!SwingUtilities.isRightMouseButton(event))
{
int startPosition = textArea.getSelectionStart();
int endPosition = textArea.getSelectionEnd();
int startPosition = this.textArea.getSelectionStart();
int endPosition = this.textArea.getSelectionEnd();
String selectedText = this.textArea.getSelectedText();
if (selectedText == null)
{
selectedText = new String();
}
MessageFormat formatter = new MessageFormat("");
formatter.applyPattern(this.positionFormatString);
Object positions[] = { startPosition, endPosition - startPosition, endPosition };
// start position (zero-based), end position (zero-based) / end character (one-based), start character (one-based), character after end character (one-based), length, text.
Object positions[] = { startPosition, endPosition, startPosition + 1, endPosition + 1, endPosition - startPosition, selectedText };
positionField.setText(formatter.format(positions));
}
......@@ -133,5 +140,5 @@ class MouseEventListener extends MouseAdapter
protected JPopupMenu contextMenuCopy = null;
protected JMenuItem contextMenuCopyItem = null;
protected String positionFormatString = "{0,number,#}, {1,number,#}";
protected String positionFormatString = "{0,number,#}, {4,number,#}";
}
......@@ -20,9 +20,10 @@ along with text_position_retriever_1. If not, see <http://www.gnu.org/licenses/>
<text-position-retriever-1-jobfile>
<input-file path="input.txt"/>
<font-size point="16"/>
<position-format-string format=",start={0,number,#},length={1,number,#}"/>
<position-format-string format=",start={0,number,#},length={4,number,#}"/>
<!--
https://www.w3.org/TR/annotation-model/#text-position-selector:
<position-format-string format="&lt;selector&gt;&lt;type&gt;TextPositionSelector&lt;/type&gt;&lt;start&gt;{0,number,#}&lt;/start&gt;&lt;end&gt;{2,number,#}&lt;/end&gt;&lt;/selector&gt;"/>
<position-format-string format="&lt;selector&gt;&lt;type&gt;TextPositionSelector&lt;/type&gt;&lt;start&gt;{0,number,#}&lt;/start&gt;&lt;end&gt;{1,number,#}&lt;/end&gt;&lt;/selector&gt;"/>
-->
<!-- <position-format-string format="&lt;span&gt;{5}&lt;/span&gt;"/> -->
</text-position-retriever-1-jobfile>
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2014-2017 Stephan Kreutzer
Copyright (C) 2014-2019 Stephan Kreutzer
This file is part of text_position_retriever_1 workflow, a submodule of the
digital_publishing_workflow_tools package.
......@@ -21,5 +21,5 @@ along with text_position_retriever_1 workflow. If not, see <http://www.gnu.org/l
<start-directory path="."/>
<!-- file-type extension="txt">Plain text file (.txt)</file-type -->
<font-size point="16"/>
<position-format-string format=",start={0,number,#},length={1,number,#}"/>
<position-format-string format=",start={0,number,#},length={4,number,#}"/>
</text-position-retriever-1-workflow-jobfile>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment