本文整理汇总了Java中com.vladsch.flexmark.util.sequence.BasedSequence类的典型用法代码示例。如果您正苦于以下问题:Java BasedSequence类的具体用法?Java BasedSequence怎么用?Java BasedSequence使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BasedSequence类属于com.vladsch.flexmark.util.sequence包,在下文中一共展示了BasedSequence类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: process
import com.vladsch.flexmark.util.sequence.BasedSequence; //导入依赖的package包/类
@Override
public void process(NodeTracker state, Node node) {
if (node instanceof Link) {
Node previous = node.getPrevious();
if (previous instanceof Text) {
final BasedSequence chars = previous.getChars();
//Se o nó anterior termina com '#' e é seguido pelo Link
if (chars.endsWith("#") && chars.isContinuedBy(node.getChars())) {
//Remove o caractere '#' do nó anterior.
previous.setChars(chars.subSequence(0, chars.length() - 1));
Twitter videoLink = new Twitter((Link) node);
videoLink.takeChildren(node);
node.unlink();
previous.insertAfter(videoLink);
state.nodeRemoved(node);
state.nodeAddedWithChildren(videoLink);
}
}
}
}
开发者ID:tiagohm,项目名称:MarkdownView,代码行数:23,代码来源:TwitterNodePostProcessor.java
示例2: process
import com.vladsch.flexmark.util.sequence.BasedSequence; //导入依赖的package包/类
@Override
public void process(NodeTracker state, Node node) {
if (node instanceof Link) {
Node previous = node.getPrevious();
if (previous instanceof Text) {
final BasedSequence chars = previous.getChars();
//Se o nó anterior termina com 'B' e é seguido pelo Link
if (chars.endsWith("B") && chars.isContinuedBy(node.getChars())) {
//Remove o caractere 'B' do nó anterior.
previous.setChars(chars.subSequence(0, chars.length() - 1));
Button btn = new Button((Link) node);
btn.takeChildren(node);
node.unlink();
previous.insertAfter(btn);
state.nodeRemoved(node);
state.nodeAddedWithChildren(btn);
}
}
}
}
开发者ID:tiagohm,项目名称:MarkdownView,代码行数:23,代码来源:ButtonNodePostProcessor.java
示例3: process
import com.vladsch.flexmark.util.sequence.BasedSequence; //导入依赖的package包/类
@Override
public void process(NodeTracker state, Node node) {
if (node instanceof Link) {
Node previous = node.getPrevious();
if (previous instanceof Text) {
final BasedSequence chars = previous.getChars();
//Se o nó anterior termina com '@' e é seguido pelo Link
if (chars.endsWith("@") && chars.isContinuedBy(node.getChars())) {
//Remove o caractere '@' do nó anterior.
previous.setChars(chars.subSequence(0, chars.length() - 1));
VideoLink videoLink = new VideoLink((Link) node);
videoLink.takeChildren(node);
node.unlink();
previous.insertAfter(videoLink);
state.nodeRemoved(node);
state.nodeAddedWithChildren(videoLink);
}
}
}
}
开发者ID:tiagohm,项目名称:MarkdownView,代码行数:23,代码来源:VideoLinkNodePostProcessor.java
示例4: isLineCommented
import com.vladsch.flexmark.util.sequence.BasedSequence; //导入依赖的package包/类
public boolean isLineCommented(final int startOfLineOffset, final int endOfLineOffset) {
Commenter commenter = getCommenterRange(startOfLineOffset, endOfLineOffset);
if (commenter != null) {
String lineCommentPrefix = commenter.getLineCommentPrefix();
String blockCommentPrefix = commenter.getCommentedBlockCommentPrefix();
if (blockCommentPrefix == null) blockCommentPrefix = commenter.getBlockCommentPrefix();
String blockCommentSuffix = commenter.getCommentedBlockCommentSuffix();
if (blockCommentSuffix == null) blockCommentSuffix = commenter.getBlockCommentSuffix();
BasedSequence chars = myChars.subSequence(startOfLineOffset, endOfLineOffset);
BasedSequence trimmed = chars.trim();
return lineCommentPrefix != null && trimmed.startsWith(lineCommentPrefix)
|| blockCommentPrefix != null && blockCommentSuffix != null && trimmed.startsWith(blockCommentPrefix) && trimmed.endsWith(blockCommentSuffix);
} else {
return false;
}
}
开发者ID:vsch,项目名称:MissingInActions,代码行数:18,代码来源:LineCommentProcessor.java
示例5: insertSeparators
import com.vladsch.flexmark.util.sequence.BasedSequence; //导入依赖的package包/类
private static void insertSeparators(StringBuilder sb, @NotNull CharSequence number, int digitPos, @Nullable String separator, int separatorFrequency) {
int pos;
BasedSequence sequence = BasedSequenceImpl.of(number);
pos = number.length() - digitPos;
String out = "";
while (pos > separatorFrequency && separatorFrequency > 0) {
out = number.subSequence(pos - separatorFrequency, pos) + out;
pos -= separatorFrequency;
if (sequence.subSequence(0, pos).isBlank()) break;
out = separator + out;
}
if (pos > 0) {
out = number.subSequence(0, pos) + out;
}
sb.append(out);
}
开发者ID:vsch,项目名称:MissingInActions,代码行数:21,代码来源:NumberSequenceGenerator.java
示例6: findSequences
import com.vladsch.flexmark.util.sequence.BasedSequence; //导入依赖的package包/类
@Override
public List<Range> findSequences(int startOffset, int endOffset) {
ArrayList<Range> sequences = new ArrayList<>();
Node astRoot = toAstRoot();
if (astRoot == null)
return sequences;
NodeVisitor visitor = new NodeVisitor(Collections.emptyList()) {
@Override
public void visit(Node node) {
BasedSequence chars = node.getChars();
if (isInSequence(startOffset, endOffset, chars))
sequences.add(new Range(chars.getStartOffset(), chars.getEndOffset()));
for (BasedSequence segment : node.getSegments()) {
if (isInSequence(startOffset, endOffset, segment))
sequences.add(new Range(segment.getStartOffset(), segment.getEndOffset()));
}
visitChildren(node);
}
};
visitor.visit(astRoot);
return sequences;
}
开发者ID:JFormDesigner,项目名称:markdown-writer-fx,代码行数:27,代码来源:FlexmarkPreviewRenderer.java
示例7: setTextChars
import com.vladsch.flexmark.util.sequence.BasedSequence; //导入依赖的package包/类
@Override
public void setTextChars(BasedSequence textChars) {
int textCharsLength = textChars.length();
textOpeningMarker = textChars.subSequence(0, 1);
text = textChars.subSequence(1, textCharsLength - 1).trim();
textClosingMarker = textChars.subSequence(textCharsLength - 1, textCharsLength);
}
开发者ID:tiagohm,项目名称:MarkdownView,代码行数:8,代码来源:Twitter.java
示例8: Label
import com.vladsch.flexmark.util.sequence.BasedSequence; //导入依赖的package包/类
public Label(int type, BasedSequence openingMarker, BasedSequence text, BasedSequence closingMarker) {
super(openingMarker.baseSubSequence(openingMarker.getStartOffset(), closingMarker.getEndOffset()));
this.type = type;
this.openingMarker = openingMarker;
this.text = text;
this.closingMarker = closingMarker;
}
开发者ID:tiagohm,项目名称:MarkdownView,代码行数:8,代码来源:Label.java
示例9: process
import com.vladsch.flexmark.util.sequence.BasedSequence; //导入依赖的package包/类
@Override
public void process(Delimiter opener, Delimiter closer, int delimitersUsed) {
// Normal case, wrap nodes between delimiters in emoji node.
// don't allow any spaces between delimiters
if (opener.getInput().subSequence(opener.getEndIndex(), closer.getStartIndex()).indexOfAny(BasedSequence.WHITESPACE_CHARS) == -1) {
Emoji emoji = new Emoji(opener.getTailChars(delimitersUsed), BasedSequence.NULL, closer.getLeadChars(delimitersUsed));
opener.moveNodesBetweenDelimitersTo(emoji, closer);
} else {
opener.convertDelimitersToText(delimitersUsed, closer);
}
}
开发者ID:tiagohm,项目名称:MarkdownView,代码行数:12,代码来源:EmojiDelimiterProcessor.java
示例10: process
import com.vladsch.flexmark.util.sequence.BasedSequence; //导入依赖的package包/类
@Override
public void process(Delimiter opener, Delimiter closer, int delimitersUsed) {
// Normal case, wrap nodes between delimiters in emoji node.
// don't allow any spaces between delimiters
if (opener.getInput().subSequence(opener.getEndIndex(), closer.getStartIndex()).indexOfAny(BasedSequence.WHITESPACE_CHARS) == -1) {
EmojiNode emoji = new EmojiNode(opener.getTailChars(delimitersUsed), BasedSequence.NULL, closer.getLeadChars(delimitersUsed));
opener.moveNodesBetweenDelimitersTo(emoji, closer);
} else {
opener.convertDelimitersToText(delimitersUsed, closer);
}
}
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:12,代码来源:EmojiDelimiterProcessor.java
示例11: processProceedingCharacters
import com.vladsch.flexmark.util.sequence.BasedSequence; //导入依赖的package包/类
private void processProceedingCharacters(BasedSequence passedOver) {
for (char c : passedOver.toString().toCharArray()) {
if (c == '\r' || c == '\n') {
if (inParagraph) {
builder.addText(" ");
} else {
builder.addText(new String(new char[]{c}));
}
} else {
builder.addMarkup(new String(new char[]{c}));
}
}
}
开发者ID:adamvoss,项目名称:languagetool-languageserver,代码行数:14,代码来源:AnnotatedTextBuildingVisitor.java
示例12: nextMatch
import com.vladsch.flexmark.util.sequence.BasedSequence; //导入依赖的package包/类
@Override
@Nullable
final protected CaretMatch nextMatch(RegExMatcher matcher, BasedSequence chars, @NotNull Range range, @Nullable CaretMatch previousMatch) {
CaretMatch match = null;
boolean found;
found = previousMatch == null || matcher.find();
if (found) {
int start = matcher.start();
int end = matcher.end();
if (range.contains(start, end)) {
// see if there are captured groups, then we select the spanning range of the groups
int selStart = myBackwards ? end : start;
int selEnd = selStart;
int groupCount = matcher.groupCount();
if (groupCount > 0) {
selStart = matcher.end();
selEnd = matcher.start();
for (int i = 1; i <= groupCount; i++) {
if (selStart > matcher.start(i)) selStart = matcher.start(i);
if (selEnd < matcher.end(i)) selEnd = matcher.end(i);
}
}
match = getCaretMatch(matcher, selStart, selEnd);
} else {
int tmp = 0;
}
}
return match;
}
开发者ID:vsch,项目名称:MissingInActions,代码行数:34,代码来源:RegExCaretSearchHandler.java
示例13: perform
import com.vladsch.flexmark.util.sequence.BasedSequence; //导入依赖的package包/类
protected boolean perform(@NotNull LineSelectionManager manager, @NotNull Caret caret, @NotNull Range range, @NotNull ArrayList<CaretState> createCarets) {
Editor editor = caret.getEditor();
final BasedSequence chars = BasedSequenceImpl.of(editor.getDocument().getCharsSequence());
boolean keepCaret = !isMoveFirstMatch();
T matcher = prepareMatcher(manager, caret, range, chars);
if (matcher != null) {
// forward search withing range in document
CaretMatch lastMatch = null;
while (true) {
CaretMatch match = nextMatch(matcher, chars, range, lastMatch);
if (match == null) break;
// found it, create or move caret here
if (!keepCaret) {
keepCaret = true;
if (isMoveFirstMatch()) {
caret.moveToOffset(match.caretOffset);
caret.setSelection(match.selectionStart, match.selectionEnd);
}
} else {
// create a new position if caret moved
LogicalPosition offset = editor.offsetToLogicalPosition(match.caretOffset);
LogicalPosition startOffset = editor.offsetToLogicalPosition(match.selectionStart);
LogicalPosition endOffset = editor.offsetToLogicalPosition(match.selectionEnd);
CaretState caretState = new CaretState(offset, startOffset, endOffset);
createCarets.add(caretState);
}
if (isSingleMatch() || match.caretOffset + match.matchLength >= chars.length()) break;
lastMatch = match;
}
}
return keepCaret || isSingleMatch();
}
开发者ID:vsch,项目名称:MissingInActions,代码行数:37,代码来源:PatternSearchCaretHandler.java
示例14: InsertedRangeContext
import com.vladsch.flexmark.util.sequence.BasedSequence; //导入依赖的package包/类
public InsertedRangeContext(@NotNull BasedSequence charSequence, int beforeOffset, int afterOffset, int separators) {
this.charSequence = charSequence;
mySeparators = separators;
this.textLength = charSequence.length();
if (beforeOffset < 0) beforeOffset = 0;
if (afterOffset > textLength) afterOffset = textLength;
if (beforeOffset > afterOffset) beforeOffset = afterOffset;
if (afterOffset < beforeOffset) afterOffset = beforeOffset;
this.beforeOffset = beforeOffset;
this.afterOffset = afterOffset;
TextRange range = EditHelpers.getWordRangeAtOffsets(charSequence, beforeOffset, afterOffset, WORD_IDENTIFIER, false, true);
this.expandedBeforeOffset = range.getStartOffset();
this.expandedAfterOffset = range.getEndOffset();
this.expandedPrefix = expandedBeforeOffset > beforeOffset ? "" : charSequence.subSequence(expandedBeforeOffset, beforeOffset).toString();
this.expandedSuffix = expandedAfterOffset < afterOffset ? "" : charSequence.subSequence(afterOffset, expandedAfterOffset).toString();
this.inserted = charSequence.subSequence(beforeOffset, afterOffset).toString();
this.charBefore = beforeOffset > 0 && beforeOffset - 1 < textLength ? charSequence.charAt(beforeOffset - 1) : ' ';
this.charAfter = afterOffset < textLength ? charSequence.charAt(afterOffset) : ' ';
this.sBefore = String.valueOf(charBefore);
this.sAfter = String.valueOf(charAfter);
this.isWordStartAtStart = isWordStart(charSequence, beforeOffset, false);
this.isWordEndAtStart = isWordEnd(charSequence, beforeOffset, false);
this.isWordStartAtEnd = isWordStart(charSequence, afterOffset, false);
this.isWordEndAtEnd = isWordEnd(charSequence, afterOffset, false);
myWord = inserted;
myStudiedWord = StudiedWord.of(myWord, mySeparators);
myCaretDelta = 0;
myPrefixRemoved = false;
}
开发者ID:vsch,项目名称:MissingInActions,代码行数:36,代码来源:InsertedRangeContext.java
示例15: extractNumber
import com.vladsch.flexmark.util.sequence.BasedSequence; //导入依赖的package包/类
/**
* Extract a number from given sequence based on prefix/suffix, base and template
*
* @param charSequence character sequence from which to extract a number
* @return number or null if unable to extract
*/
@Nullable
public Long extractNumber(@NotNull CharSequence charSequence) {
BasedSequence chars = BasedSequenceImpl.of(charSequence);
if (!myOptions.getPrefix().isEmpty()) chars = chars.removePrefix(myOptions.getPrefix());
if (!myOptions.getSuffix().isEmpty()) chars = chars.removeSuffix(myOptions.getSuffix());
// see if we have a template and it matches somewhat
return null;
}
开发者ID:vsch,项目名称:MissingInActions,代码行数:17,代码来源:NumberSequenceGenerator.java
示例16: getNumber
import com.vladsch.flexmark.util.sequence.BasedSequence; //导入依赖的package包/类
@NotNull
public String getNumber() {
if (myNext != null) {
long next = myNext;
BasedSequence number = convertNumber(next, myOptions.getNumberingBase(), false);
if (!myOptions.isUpperCase()) number = number.toLowerCase();
return templateNumber(number);
}
return "";
}
开发者ID:vsch,项目名称:MissingInActions,代码行数:11,代码来源:NumberSequenceGenerator.java
示例17: highlightSequence
import com.vladsch.flexmark.util.sequence.BasedSequence; //导入依赖的package包/类
private boolean highlightSequence(BasedSequence sequence, String language) {
SyntaxHighlighter.HighlightConsumer highlighter = new SyntaxHighlighter.HighlightConsumer() {
private int index = sequence.getStartOffset();
@Override
public void accept(int length, String style) {
if (style != null)
addStyledRange(styleRanges, index, index + length, StyleClass.custom(style, "token"));
index += length;
}
};
return SyntaxHighlighter.highlight(sequence.toString(), language, highlighter);
}
开发者ID:JFormDesigner,项目名称:markdown-writer-fx,代码行数:14,代码来源:MarkdownSyntaxHighlighter.java
示例18: surroundSelectionAndReplaceMarker
import com.vladsch.flexmark.util.sequence.BasedSequence; //导入依赖的package包/类
private void surroundSelectionAndReplaceMarker(String leading, String trailing, String hint,
DelimitedNode node, String newOpeningMarker, String newClosingMarker)
{
IndexRange selection = textArea.getSelection();
int start = selection.getStart();
int end = selection.getEnd();
String selectedText = textArea.getSelectedText();
// remove leading and trailing whitespaces from selected text
String trimmedSelectedText = selectedText.trim();
if (trimmedSelectedText.length() < selectedText.length()) {
start += selectedText.indexOf(trimmedSelectedText);
end = start + trimmedSelectedText.length();
}
BasedSequence openingMarker = node.getOpeningMarker();
BasedSequence closingMarker = node.getClosingMarker();
int selStart = start + leading.length() + (newOpeningMarker.length() - openingMarker.length());
int selEnd = selStart + trimmedSelectedText.length();
// insert hint text if selection is empty
if (hint != null && trimmedSelectedText.isEmpty()) {
trimmedSelectedText = hint;
selEnd = selStart + hint.length();
}
// replace text and update selection
// Note: using single textArea.replaceText() to avoid multiple changes in undo history
String before = textArea.getText(openingMarker.getEndOffset(), start);
String after = textArea.getText(end, closingMarker.getStartOffset());
replaceText(textArea, openingMarker.getStartOffset(), closingMarker.getEndOffset(),
newOpeningMarker + before + leading + trimmedSelectedText + trailing + after + newClosingMarker );
selectRange(textArea, selStart, selEnd);
}
开发者ID:JFormDesigner,项目名称:markdown-writer-fx,代码行数:37,代码来源:SmartEdit.java
示例19: findNodeAtSelection
import com.vladsch.flexmark.util.sequence.BasedSequence; //导入依赖的package包/类
/**
* Find single node that completely encloses the current selection and match a predicate.
*/
private <T extends Node> T findNodeAtSelection(FindNodePredicate predicate) {
IndexRange selection = textArea.getSelection();
int start = selection.getStart();
int end = selection.getEnd();
List<T> nodes = findNodes(start, end, predicate, false, false);
if (nodes.size() != 1)
return null;
T node = nodes.get(0);
BasedSequence text = (node instanceof DelimitedNode) ? ((DelimitedNode)node).getText() : node.getChars();
return (start >= text.getStartOffset() && end <= text.getEndOffset()) ? node : null;
}
开发者ID:JFormDesigner,项目名称:markdown-writer-fx,代码行数:16,代码来源:SmartEdit.java
示例20: renderIndentedCodeBlock
import com.vladsch.flexmark.util.sequence.BasedSequence; //导入依赖的package包/类
private void renderIndentedCodeBlock(IndentedCodeBlock indentedCodeBlock, NodeRendererContext context, HtmlWriter htmlWriter) {
StringBuilder builder = new StringBuilder();
for (BasedSequence line : indentedCodeBlock.getContentLines()) {
builder.append(line.toString());
}
String code = builder.toString();
// confluence defaults to java
write(code, "java", htmlWriter);
}
开发者ID:borisdiakur,项目名称:marked,代码行数:13,代码来源:ConfluenceCodeBlockExtension.java
注:本文中的com.vladsch.flexmark.util.sequence.BasedSequence类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论