public static void notifyInputKey( final boolean isBackspace, final KeyEvent event, final char inputChar) { if (currentTabBlock != null) { if (L.isInWorkshop) { System.out.println("---------notifyInputKey char : " + inputChar); } if (isBackspace) { } else if (inputChar == '\t' || event.isActionKey()) { if (L.isInWorkshop) { System.out.println( "-----isActionKey : " + event.isActionKey() + ", isTab : " + (inputChar == '\t')); } return; } final int keyCode = event.getKeyCode(); if (keyCode == KeyEvent.VK_LEFT || keyCode == KeyEvent.VK_RIGHT) { return; } final boolean snapIsFocusFull = isFocusFullParameter; if (snapIsFocusFull) { isFocusFullParameter = false; try { final int removeLen = currFocusHighlightEndIdx - currFocusHighlightStartIdx; scriptPanel .getDocument() .remove(currFocusHighlightStartIdx, removeLen - (isBackspace ? 1 : 0)); inputShiftOffset -= removeLen; currFocusHighlightEndIdx = currFocusHighlightStartIdx; currentTabBlock.parameterEndOffsetIdx[parameterIdx] = 0; } catch (final BadLocationException e) { ExceptionReporter.printStackTrace(e); } } if (isBackspace) { if (snapIsFocusFull == false) { currentTabBlock.parameterEndOffsetIdx[parameterIdx]--; currFocusHighlightEndIdx--; inputShiftOffset--; } } else { currentTabBlock.parameterEndOffsetIdx[parameterIdx]++; currFocusHighlightEndIdx++; inputShiftOffset++; } SwingUtilities.invokeLater(refreshLightParameter); } }
private static void focusParameter() { calculateIdx(); clearHighlight(); try { currFocusHighlight = scriptPanel .getHighlighter() .addHighlight(currFocusHighlightStartIdx, currFocusHighlightEndIdx, CODE_LIGHTER); } catch (final BadLocationException e) { ExceptionReporter.printStackTrace(e); } scriptPanel.setSelectionStart(currFocusHighlightStartIdx); scriptPanel.setSelectionEnd(currFocusHighlightEndIdx); scriptPanel.setCaretPosition(currFocusHighlightEndIdx); isFocusFullParameter = true; }
@Override public void run() { clearHighlight(); try { // if(L.isInWorkshop){ // System.out.println("lighter startIdx : " + currFocusHighlightStartIdx + ", endIdx // : " + currFocusHighlightEndIdx); // } if (currFocusHighlightEndIdx > currFocusHighlightStartIdx) { currFocusHighlight = scriptPanel .getHighlighter() .addHighlight( currFocusHighlightStartIdx, currFocusHighlightEndIdx, CODE_LIGHTER); } } catch (final BadLocationException e) { ExceptionReporter.printStackTrace(e); } }
private final void actionJSInputInUser(final byte[] bs, final int offset, final int len) { if (isSimu) { try { L.V = L.O ? false : LogManager.log( "action JS input : " + new String(bs, offset, len, IConstant.UTF_8)); } catch (final Throwable e1) { e1.printStackTrace(); } } // ------------------------------------------------------- // 重要 // 如果以下增加事件接收,请同步CodeItem.AnonymousClass // ------------------------------------------------------- try { if (matchCmd(JSCore.actionExt, bs, offset)) { final String cmd = getOneValue(JSCore.actionExt, bs, offset, len); actionExt(cmd); return; } else if (matchCmd(JSCore.clickJButton, bs, offset)) { final String id = getOneValue(JSCore.clickJButton, bs, offset, len); clickJButton(Integer.parseInt(id)); return; } else if (matchCmd(JSCore.selectComboBox, bs, offset)) { final String[] values = getTwoValue(JSCore.selectComboBox, bs, offset, len); selectComboBox(Integer.parseInt(values[0]), Integer.parseInt(values[1])); return; } else if (matchCmd(JSCore.selectSlider, bs, offset)) { final String[] values = getTwoValue(JSCore.selectSlider, bs, offset, len); selectSlider(Integer.parseInt(values[0]), Integer.parseInt(values[1])); return; } else if (matchCmd(JSCore.notifyTextFieldValue, bs, offset)) { final String[] values = getTwoValue(JSCore.notifyTextFieldValue, bs, offset, len); notifyTextFieldValue(Integer.parseInt(values[0]), values[1]); return; } else if (matchCmd(JSCore.notifyTextAreaValue, bs, offset)) { final String[] values = getTwoValue(JSCore.notifyTextAreaValue, bs, offset, len); notifyTextAreaValue(Integer.parseInt(values[0]), values[1]); return; } else if (matchCmd(JSCore.clickJRadioButton, bs, offset)) { final String id = getOneValue(JSCore.clickJRadioButton, bs, offset, len); clickJRadioButton(Integer.parseInt(id)); return; } else if (matchCmd(JSCore.clickJCheckbox, bs, offset)) { final String id = getOneValue(JSCore.clickJCheckbox, bs, offset, len); clickJCheckbox(Integer.parseInt(id)); return; } else if (matchCmd(JSCore.mouseReleased, bs, offset)) { final String[] values = getThreeValue(JSCore.mouseReleased, bs, offset, len); notifyMouseReleased( Integer.parseInt(values[0]), Integer.parseInt(values[1]), Integer.parseInt(values[2])); return; } else if (matchCmd(JSCore.mousePressed, bs, offset)) { final String[] values = getThreeValue(JSCore.mousePressed, bs, offset, len); notifyMousePressed( Integer.parseInt(values[0]), Integer.parseInt(values[1]), Integer.parseInt(values[2])); return; } else if (matchCmd(JSCore.mouseExited, bs, offset)) { final String[] values = getThreeValue(JSCore.mouseExited, bs, offset, len); notifyMouseExited( Integer.parseInt(values[0]), Integer.parseInt(values[1]), Integer.parseInt(values[2])); return; } else if (matchCmd(JSCore.mouseEntered, bs, offset)) { final String[] values = getThreeValue(JSCore.mouseEntered, bs, offset, len); notifyMouseEntered( Integer.parseInt(values[0]), Integer.parseInt(values[1]), Integer.parseInt(values[2])); return; } else if (matchCmd(JSCore.mouseClicked, bs, offset)) { final String[] values = getThreeValue(JSCore.mouseClicked, bs, offset, len); notifyMouseClicked( Integer.parseInt(values[0]), Integer.parseInt(values[1]), Integer.parseInt(values[2])); return; } else if (matchCmd(JSCore.mouseDragged, bs, offset)) { final String[] values = getThreeValue(JSCore.mouseDragged, bs, offset, len); notifyMouseDragged( Integer.parseInt(values[0]), Integer.parseInt(values[1]), Integer.parseInt(values[2])); return; } } catch (final Exception e) { ExceptionReporter.printStackTrace(e); } try { final String cmds = new String(bs, offset, len, IConstant.UTF_8); final String[] splits = StringUtil.splitToArray(cmds, StringUtil.SPLIT_LEVEL_2_JING); LogManager.err("unknow JS input event : " + splits[0] + ", cmd : " + cmds); } catch (final Exception e) { ExceptionReporter.printStackTrace(e); } }