Package org.qdl_lang.gui
Class LineUtil
- java.lang.Object
- 
- org.qdl_lang.gui.LineUtil
 
- 
 public class LineUtil extends Object Do line operations on a text area. This allows you to insert a line, cut, copy or paste a line and move lines. This is generally intended to be used as a utility for theSwingTerminal.Created by Jeff Gaynor 
 on 3/17/23 at 7:39 AM
- 
- 
Constructor SummaryConstructors Constructor Description LineUtil()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description protected static booleancheckPosition(List<String> lines, int position)Checks that the position of the caret is in the list of lines.protected static booleancheckString(String out)protected static ArrayList<String>doClipboardCopyorCut(ArrayList<String> lines, int position, boolean isCut)static StringdoOperation(String text, int lineNumber, String operation)protected static ArrayList<String>duplicateLine(ArrayList<String> lines, int position)static ClipboardgetClipboard()static intgetFirstNonwhitespaceIndex(String string)protected static booleanhasClipboard()static voidmain(String[] args)protected static ArrayList<String>pasteLines(ArrayList<String> lines, int position)protected static voidtestInputForm()protected static voidtestLineModes()protected static ArrayList<String>toggleComment(ArrayList<String> lines, int lineNumber)static StringtoInputForm(String in, boolean isLongForm)Converts a string (from the clipboard) to input form.static ArrayList<String>toLines(String text)Has to be an array list to get remove() and other methods.
 
- 
- 
- 
Field Detail- 
COPY_LINEpublic static final String COPY_LINE - See Also:
- Constant Field Values
 
 - 
DUPLICATE_LINEpublic static final String DUPLICATE_LINE - See Also:
- Constant Field Values
 
 - 
PASTE_LINESpublic static final String PASTE_LINES - See Also:
- Constant Field Values
 
 - 
CUT_LINEpublic static final String CUT_LINE - See Also:
- Constant Field Values
 
 - 
UP_LINEpublic static final String UP_LINE - See Also:
- Constant Field Values
 
 - 
DOWN_LINEpublic static final String DOWN_LINE - See Also:
- Constant Field Values
 
 - 
TOGGLE_COMMENT_LINEpublic static final String TOGGLE_COMMENT_LINE - See Also:
- Constant Field Values
 
 - 
JOIN_LINEpublic static final String JOIN_LINE - See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
doOperationpublic static String doOperation(String text, int lineNumber, String operation) throws IOException, UnsupportedFlavorException 
 - 
toLinespublic static ArrayList<String> toLines(String text) Has to be an array list to get remove() and other methods.- Parameters:
- text-
- Returns:
 
 - 
checkPositionprotected static boolean checkPosition(List<String> lines, int position) Checks that the position of the caret is in the list of lines. True if ok, false otherwise.- Parameters:
- lines-
- position-
- Returns:
 
 - 
getClipboardpublic static Clipboard getClipboard() 
 - 
hasClipboardprotected static boolean hasClipboard() 
 - 
doClipboardCopyorCutprotected static ArrayList<String> doClipboardCopyorCut(ArrayList<String> lines, int position, boolean isCut) throws IOException, UnsupportedFlavorException 
 - 
duplicateLineprotected static ArrayList<String> duplicateLine(ArrayList<String> lines, int position) 
 - 
pasteLinesprotected static ArrayList<String> pasteLines(ArrayList<String> lines, int position) throws IOException, UnsupportedFlavorException 
 - 
toggleCommentprotected static ArrayList<String> toggleComment(ArrayList<String> lines, int lineNumber) 
 - 
getFirstNonwhitespaceIndexpublic static int getFirstNonwhitespaceIndex(String string) 
 - 
toInputFormpublic static String toInputForm(String in, boolean isLongForm) Converts a string (from the clipboard) to input form. This checks if it is a string and if not just returns it. If it is, then shoirt form is a single line of input form, long form break it up into lines and formats each one as a concatenation. The latter is really useful when pasting things like long formatted JSON blobs.- Parameters:
- in-
- isLongForm-
- Returns:
 
 - 
checkStringprotected static boolean checkString(String out) 
 
- 
 
-