本文整理汇总了TypeScript中atom.DisplayMarkerLayer类的典型用法代码示例。如果您正苦于以下问题:TypeScript DisplayMarkerLayer类的具体用法?TypeScript DisplayMarkerLayer怎么用?TypeScript DisplayMarkerLayer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DisplayMarkerLayer类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: openIssueishFromCursorPosition
export function openIssueishFromCursorPosition(): void {
var current_editor = atom.workspace.getActiveTextEditor();
if (current_editor == undefined) {
console.log("No editor in focus.");
atom.notifications.addError("Minsky Link: No editor in focus!", {
description: "Please focus a text editor pane and tag, then try again.",
dismissable: true
});
return;
}
if (current_editor.hasMultipleCursors()) {
console.log("Dunno how to handle hasMultipleCursors!");
atom.notifications.addError("Minsky Link cannot handle multiple cursors!", {
description: "This may later be implemented.",
dismissable: true
});
return;
}
var current_minsky_marker_layer:
| DisplayMarkerLayer
| undefined = current_editor.getMarkerLayer(
map_TextEditors_DisplayMarkerLayerIds[current_editor.id]
);
if (current_minsky_marker_layer == undefined) {
console.log("Could not retrieve the marker layer!");
atom.notifications.addFatalError(
"Minsky Link encountered an unknown error.",
{
description: "Error: undefined current_minsky_marker_layer",
dismissable: true
}
);
return;
}
var current_cursor = current_editor.getLastCursor();
console.log("Current cursor position: " + current_cursor.getBufferPosition());
var potential_markers: DisplayMarker[] = current_minsky_marker_layer.findMarkers(
{
containsBufferPosition: current_cursor.getBufferPosition()
}
);
console.log("Found " + potential_markers.length + " potential_markers");
var target_marker: DisplayMarker | undefined;
for (var potential_marker of potential_markers) {
console.log(
"potential_marker has properties " +
Object.keys(potential_marker.getProperties())
);
if (potential_marker.getProperties().hasOwnProperty("minsky")) {
target_marker = potential_marker;
break;
}
}
if (target_marker == undefined) {
console.log("No minsky-link markers found under the cursor.");
atom.notifications.addWarning("Couldn't parse tag.", {
detail:
"Please place the text cursor on the issue tag and try again.\n\
You may need to change the Issue Tag Regex in the plugin settings if your tags are not being recognized.",
dismissable: false
});
return;
}
console.log("Found issue under cursor: " + target_marker.getBufferRange());
var target_properties = target_marker.getProperties() as any;
console.log("Lookup issue #" + target_properties["minsky"]);
var loading_notif = atom.notifications.addSuccess(
"Minsky-Link: Loading Issue #" + target_properties["minsky"],
{
description: "Opening pane for issue #" + target_properties["minsky"],
dismissable: false // will disappear on it's own
}
);
// XXX new idea: hijack github views
// for now since GH84 is in the way, let's just assume it's here
var reposlug = getRepoNames();
var current_repo = atom.project.getRepositories()[0];
var git_workdir = current_repo.getWorkingDirectory();
var new_uri_to_open =
"atom-github://issueish/" +
encodeURIComponent("https://api.github.com") +
"/" +
reposlug[0] +
"/" +
reposlug[1] +
"/" +
target_properties["minsky"] +
//.........这里部分代码省略.........
示例2: parseInt
textToSearch.scan(regex1_gh, scanResult => {
var issue_number: number = parseInt(scanResult.match[1]);
// console.log("Found issue tag: " + scanResult.matchText);
// check if there already exists a marker on this layer:
var existing_markers = issuetaglayer.findMarkers({
intersectsBufferRange: scanResult.range
});
for (var marker_to_check of existing_markers) {
if (marker_to_check.isValid() == true) {
// still is valid? don't bother
// console.log(
// "Issue tag #" +
// issue_number +
// " already known: " +
// marker_to_check.getBufferRange()
// );
return;
} else {
// destroy the invalid marker:
marker_to_check.destroy();
}
}
// console.log("Creating marker on " + scanResult.range);
var new_marker = issuetaglayer.markBufferRange(scanResult.range, {
invalidate: "touch"
});
new_marker.setProperties({
minsky: issue_number
});
console.log(
"Created marker for issue #" +
issue_number +
": " +
new_marker.getStartBufferPosition
);
});
示例3: findIssueTags
editor.onDidStopChanging(event_editorchanged => {
// event_editorchanged.changes.forEach(text_change => {
for (var text_change of event_editorchanged.changes) {
// console.log('Deleted: "' + text_change.oldText + '"');
// console.log('Added: "' + text_change.newText + '"');
// check if the change range is in any of our issue tags.
if (
text_change.newText.length > 0 || // if text was added, we need to rescan
issuetaglayer.findMarkers({
intersectsBufferRange: text_change.oldRange
}).length > 0
) {
// then we should re-scan
console.log("Re-scanning for issue tags...");
findIssueTags(editor, issuetaglayer);
break;
}
// else {
// // no need to re-scan
// console.log("No need to re-scan change: " + text_change.oldRange);
// }
} //);
})