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

x33g5p2x  于2022-01-30 转载在 其他  
字(5.1k)|赞(0)|评价(0)|浏览(121)

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

Segment.setIndex介绍

暂无

代码示例

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

/**
 * Removes any spaces or tabs from the end of the segment.
 *
 * @param segment The segment from which to remove tailing whitespace.
 * @return <code>segment</code> with trailing whitespace removed.
 */
private static Segment removeEndingWhitespace(Segment segment) {
  int toTrim = 0;
  char currentChar = segment.setIndex(segment.getEndIndex()-1);
  while ((currentChar==' ' || currentChar=='\t') && currentChar!=Segment.DONE) {
    toTrim++;
    currentChar = segment.previous();
  }
  String stringVal = segment.toString();
  String newStringVal = stringVal.substring(0,stringVal.length()-toTrim);
  return new Segment(newStringVal.toCharArray(), 0, newStringVal.length());
}

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

seg.setIndex(firstIndex);
char ch = seg.current();
char nextCh = offs==end ? 0 : seg.array[seg.getIndex() + 1];

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

seg.setIndex(firstIndex);
char ch = seg.current();

代码示例来源:origin: net.sf.jazzy/jazzy

/** This helper method will return the start character of the next
 * word in the buffer from the start position
 */
private static int getNextWordStart(Segment text, int startPos) {
 if (startPos <= text.getEndIndex())
  for (char ch = text.setIndex(startPos); ch != Segment.DONE; ch = text.next()) {
   if (Character.isLetterOrDigit(ch)) {
    return text.getIndex();
   }
  }
 return -1;
}

代码示例来源:origin: org.codehaus.jtstand/jtstand-editor

/**
 * Removes any spaces or tabs from the end of the segment.
 *
 * @param segment The segment from which to remove tailing whitespace.
 * @return <code>segment</code> with trailing whitespace removed.
 */
private static Segment removeEndingWhitespace(Segment segment) {
  int toTrim = 0;
  char currentChar = segment.setIndex(segment.getEndIndex()-1);
  while ((currentChar==' ' || currentChar=='\t') && currentChar!=Segment.DONE) {
    toTrim++;
    currentChar = segment.previous();
  }
  String stringVal = segment.toString();
  String newStringVal = stringVal.substring(0,stringVal.length()-toTrim);
  return new Segment(newStringVal.toCharArray(), 0, newStringVal.length());
}

代码示例来源:origin: com.fifesoft/rsyntaxtextarea

/**
 * Removes any spaces or tabs from the end of the segment.
 *
 * @param segment The segment from which to remove tailing whitespace.
 * @return <code>segment</code> with trailing whitespace removed.
 */
private static Segment removeEndingWhitespace(Segment segment) {
  int toTrim = 0;
  char currentChar = segment.setIndex(segment.getEndIndex()-1);
  while ((currentChar==' ' || currentChar=='\t') && currentChar!=Segment.DONE) {
    toTrim++;
    currentChar = segment.previous();
  }
  String stringVal = segment.toString();
  String newStringVal = stringVal.substring(0,stringVal.length()-toTrim);
  return new Segment(newStringVal.toCharArray(), 0, newStringVal.length());
}

代码示例来源:origin: org.nuiton.thirdparty/rsyntaxtextarea

/**
 * Removes any spaces or tabs from the end of the segment.
 *
 * @param segment The segment from which to remove tailing whitespace.
 * @return <code>segment</code> with trailing whitespace removed.
 */
private static Segment removeEndingWhitespace(Segment segment) {
  int toTrim = 0;
  char currentChar = segment.setIndex(segment.getEndIndex()-1);
  while ((currentChar==' ' || currentChar=='\t') && currentChar!=Segment.DONE) {
    toTrim++;
    currentChar = segment.previous();
  }
  String stringVal = segment.toString();
  String newStringVal = stringVal.substring(0,stringVal.length()-toTrim);
  return new Segment(newStringVal.toCharArray(), 0, newStringVal.length());
}

代码示例来源:origin: net.sf.jazzy/jazzy

/** This helper method will return the end of the next word in the buffer.
 *
 */
private static int getNextWordEnd(Segment text, int startPos) {
 for (char ch = text.setIndex(startPos); ch != Segment.DONE; ch = text.next()) {
  if (!Character.isLetterOrDigit(ch)) {
   if (ch == '-' || ch == '\'') { // handle ' and - inside words
    char ch2 = text.next();
    text.previous();
    if (ch2 != Segment.DONE && Character.isLetterOrDigit(ch2))
     continue;
   }
   return text.getIndex();
  }
 }
 return text.getEndIndex();
}

代码示例来源:origin: org.nuiton.thirdparty/rsyntaxtextarea

seg.setIndex(firstIndex);
char ch = seg.current();
char nextCh = offs==end ? 0 : seg.array[seg.getIndex() + 1];

代码示例来源:origin: net.sf.jazzy/jazzy

/**
 * Sets the current word position at the start of the word containing
 * the char at position pos. This way a call to nextWord() will return
 * this word.
 * 
 * @param pos position in the word we want to set as current.
 */
public void posStartFullWordFrom(int pos){
  currentWordPos=text.getBeginIndex();
  if(pos>text.getEndIndex())
    pos=text.getEndIndex();
  for (char ch = text.setIndex(pos); ch != Segment.DONE; ch = text.previous()) {
    if (!Character.isLetterOrDigit(ch)) {
      if (ch == '-' || ch == '\'') { // handle ' and - inside words
        char ch2 = text.previous();
        text.next();
        if (ch2 != Segment.DONE && Character.isLetterOrDigit(ch2))
          continue;
      }
      currentWordPos=text.getIndex()+1;
      break;
    }
  }
  //System.out.println("CurPos:"+currentWordPos);
  if(currentWordPos==0)
    first=true;
  moreTokens=true;
  currentWordEnd = getNextWordEnd(text, currentWordPos);
  nextWordPos = getNextWordStart(text, currentWordEnd + 1);
}

代码示例来源:origin: com.fifesoft/rsyntaxtextarea

seg.setIndex(firstIndex);
char ch = seg.current();

代码示例来源:origin: com.fifesoft/rsyntaxtextarea

seg.setIndex(firstIndex);
char ch = seg.current();
char nextCh = offs==end ? 0 : seg.array[seg.getIndex() + 1];

相关文章