javax.swing.text.Caret.getMark()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(5.2k)|赞(0)|评价(0)|浏览(151)

本文整理了Java中javax.swing.text.Caret.getMark()方法的一些代码示例,展示了Caret.getMark()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Caret.getMark()方法的具体详情如下:
包路径:javax.swing.text.Caret
类名称:Caret
方法名:getMark

Caret.getMark介绍

暂无

代码示例

代码示例来源:origin: JetBrains/ideavim

Caret caret = target.getCaret();
int dot = caret.getDot();
int mark = caret.getMark();
if (dot != mark) {
 doc.remove(Math.min(dot, mark), Math.abs(dot - mark));

代码示例来源:origin: stackoverflow.com

final int mark = field.getCaret().getMark();
if ( field.isEnabled() && field.isEditable() ) {
 SwingUtilities.invokeLater( new Runnable() {

代码示例来源:origin: bobbylight/RSyntaxTextArea

/**
 * Makes the caret's dot and mark the same location so that, for the
 * next search in the specified direction, a match will be found even
 * if it was within the original dot and mark's selection.
 *
 * @param textArea The text area.
 * @param forward Whether the search will be forward through the
 *        document (<code>false</code> means backward).
 * @return The new dot and mark position.
 */
private static int makeMarkAndDotEqual(JTextArea textArea,
                  boolean forward) {
  Caret c = textArea.getCaret();
  int val = forward ? Math.min(c.getDot(), c.getMark()) :
          Math.max(c.getDot(), c.getMark());
  c.setDot(val);
  return val;
}

代码示例来源:origin: bobbylight/RSyntaxTextArea

@Override
public void mouseDragged(MouseEvent e) {
  // WORKAROUND:  Since JTextComponent only updates the caret
  // location on mouse clicked and released, we'll do it on dragged
  // events when the left mouse button is clicked.
  if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) {
    Caret caret = getCaret();
    dot = caret.getDot();
    mark = caret.getMark();
    fireCaretUpdate(this);
  }
}

代码示例来源:origin: bobbylight/RSyntaxTextArea

@Override
public void mousePressed(MouseEvent e) {
  if (e.isPopupTrigger()) { // OS X popup triggers are on pressed
    showPopup(e);
  }
  else if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) {
    Caret caret = getCaret();
    dot = caret.getDot();
    mark = caret.getMark();
    fireCaretUpdate(this);
  }
}

代码示例来源:origin: ron190/jsql-injection

@Override
public void actionPerformed(ActionEvent e) {
  JTextComponent target = this.getTextComponent(e);
  if (Objects.nonNull(target) && target.isEditable()) {
    Caret caret = target.getCaret();
    int dot  = caret.getDot();
    int mark = caret.getMark();
    if (DefaultEditorKit.deletePrevCharAction.equals(this.getValue(Action.NAME))) {
      // @see javax/swing/text/DefaultEditorKit.java DeletePrevCharAction
      if (dot == 0 && mark == 0) {
        return;
      }
    } else {
      // @see javax/swing/text/DefaultEditorKit.java DeleteNextCharAction
      Document doc = target.getDocument();
      if (dot == mark && doc.getLength() == dot) {
        return;
      }
    }
  }
  this.deleteAction.actionPerformed(e);
}

代码示例来源:origin: ron190/jsql-injection

Caret caret = target.getCaret();
int dot = caret.getDot();
int mark = caret.getMark();
if (dot != mark) {
  doc.remove(Math.min(dot, mark), Math.abs(dot - mark));

代码示例来源:origin: ron190/jsql-injection

Caret caret = target.getCaret();
int dot = caret.getDot();
int mark = caret.getMark();
if (dot != mark) {
  doc.remove(Math.min(dot, mark), Math.abs(dot - mark));

代码示例来源:origin: bobbylight/RSyntaxTextArea

Caret caret = textArea.getCaret();
int dot = caret.getDot();
int mark = caret.getMark();
if (dot != mark) {
  doc.remove(Math.min(dot, mark), Math.abs(dot - mark));

代码示例来源:origin: bobbylight/RSyntaxTextArea

Caret caret = textArea.getCaret();
int dot = caret.getDot();
int mark = caret.getMark();
if (dot != mark) {
  doc.remove(Math.min(dot, mark), Math.abs(dot - mark));

代码示例来源:origin: bobbylight/RSyntaxTextArea

if (caret.getDot()==caret.getMark()) {

代码示例来源:origin: bobbylight/RSyntaxTextArea

@Override
public void focusGained(FocusEvent e) {
  Caret c = getCaret();
  boolean enabled = c.getDot()!=c.getMark();
  cutAction.setEnabled(enabled);
  copyAction.setEnabled(enabled);
  undoManager.updateActions(); // To reflect this text area.
}

代码示例来源:origin: bobbylight/RSyntaxTextArea

/**
 * Sets whether the edges of selections are rounded in this text area.
 * This method fires a property change of type
 * {@link #ROUNDED_SELECTION_PROPERTY}.
 *
 * @param rounded Whether selection edges should be rounded.
 * @see #getRoundedSelectionEdges()
 */
public void setRoundedSelectionEdges(boolean rounded) {
  if (roundedSelectionEdges!=rounded) {
    roundedSelectionEdges = rounded;
    Caret c = getCaret();
    if (c instanceof ConfigurableCaret) {
      ((ConfigurableCaret)c).setRoundedSelectionEdges(rounded);
      if (c.getDot()!=c.getMark()) { // e.g., there's is a selection
        repaint();
      }
    }
    firePropertyChange(ROUNDED_SELECTION_PROPERTY, !rounded,
                    rounded);
  }
}

代码示例来源:origin: bobbylight/RSyntaxTextArea

int mark = c.getMark();
int p0 = Math.min(dot, mark);
int p1 = Math.max(dot, mark);

代码示例来源:origin: bobbylight/RSyntaxTextArea

if (caretPos==caret.getMark() && caretPos!=curLineEnd) {
  if (curLine==lastLine) {
    caretPos = Math.min(caretPos+text.length(), curLineEnd);

代码示例来源:origin: bobbylight/RSyntaxTextArea

int mark = textArea.getCaret().getMark();
Document doc = textArea.getDocument();
Element root = doc.getDefaultRootElement();

代码示例来源:origin: bobbylight/RSyntaxTextArea

Caret c = textArea.getCaret();
int dot = c.getDot();
int mark = c.getMark();
int line1 = map.getElementIndex(dot);
int tabSize = textArea.getTabSize();
    if (Math.max(c.getDot(),c.getMark())!=start) {
      handleDecreaseIndent(elem, document, tabSize);

代码示例来源:origin: bobbylight/RSyntaxTextArea

Caret c = textArea.getCaret();
int dot = c.getDot();
int mark = c.getMark();
int line1 = map.getElementIndex(dot);
int line2 = map.getElementIndex(mark);

代码示例来源:origin: bobbylight/RSyntaxTextArea

boolean selection = c.getDot()!=c.getMark();
rsta.replaceSelection("/");

代码示例来源:origin: bobbylight/RSyntaxTextArea

if (c.getDot()!=c.getMark()) {
  return;

相关文章