mirror of
https://github.com/hexedtech/codemp-intellij.git
synced 2024-11-21 14:44:49 +01:00
fix: others people cursors are now visible
This commit is contained in:
parent
bbc2eb447a
commit
b486c2c581
2 changed files with 14 additions and 14 deletions
|
@ -36,7 +36,7 @@ public class CursorEventListener implements CaretListener {
|
||||||
startPos.line, startPos.column, endPos.line, endPos.column
|
startPos.line, startPos.column, endPos.line, endPos.column
|
||||||
);
|
);
|
||||||
|
|
||||||
new Thread(() -> { // kys
|
new Thread(() -> {
|
||||||
ApplicationManager.getApplication().runReadAction(() -> {
|
ApplicationManager.getApplication().runReadAction(() -> {
|
||||||
Editor editor = event.getEditor();
|
Editor editor = event.getEditor();
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -108,7 +108,7 @@ public class InteractionUtil {
|
||||||
eventMulticaster.addCaretListener(new CursorEventListener()); // TODO disposable
|
eventMulticaster.addCaretListener(new CursorEventListener()); // TODO disposable
|
||||||
|
|
||||||
CodeMP.getActiveWorkspace().getCursor().callback(controller -> {
|
CodeMP.getActiveWorkspace().getCursor().callback(controller -> {
|
||||||
ApplicationManager.getApplication().invokeLater(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
while(true) {
|
while(true) {
|
||||||
Optional<Cursor> c = controller.tryRecv();
|
Optional<Cursor> c = controller.tryRecv();
|
||||||
|
@ -118,20 +118,20 @@ public class InteractionUtil {
|
||||||
CodeMP.LOGGER.debug(
|
CodeMP.LOGGER.debug(
|
||||||
"Cursor moved by user {}! Start pos: {}x {}y; end pos: {}x {}y in buffer {}!",
|
"Cursor moved by user {}! Start pos: {}x {}y; end pos: {}x {}y in buffer {}!",
|
||||||
event.user,
|
event.user,
|
||||||
event.startCol, event.startRow,
|
event.startCol,
|
||||||
event.endCol, event.endRow,
|
event.startRow,
|
||||||
|
event.endCol,
|
||||||
|
event.endRow,
|
||||||
event.buffer
|
event.buffer
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ApplicationManager.getApplication().invokeLater(() -> {
|
ApplicationManager.getApplication().runReadAction(() -> {
|
||||||
Editor editor = FileUtil.getActiveEditorByPath(this.myProject, event.buffer);
|
Editor editor = FileUtil.getActiveEditorByPath(this.myProject, event.buffer);
|
||||||
if(editor == null) return;
|
if(editor == null) return;
|
||||||
|
|
||||||
int startOffset = editor.getDocument()
|
int startOffset = editor.getDocument().getLineStartOffset(event.startRow) + event.startCol;
|
||||||
.getLineStartOffset(event.startRow) + event.startCol;
|
int endOffset = editor.getDocument().getLineStartOffset(event.endRow) + event.endCol;
|
||||||
int endOffset = editor.getDocument()
|
|
||||||
.getLineStartOffset(event.startRow) + event.startCol;
|
|
||||||
|
|
||||||
int documentLength = editor.getDocument().getTextLength();
|
int documentLength = editor.getDocument().getTextLength();
|
||||||
if(startOffset > documentLength || endOffset > documentLength) {
|
if(startOffset > documentLength || endOffset > documentLength) {
|
||||||
|
@ -153,19 +153,19 @@ public class InteractionUtil {
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
Font.PLAIN
|
Font.PLAIN
|
||||||
), HighlighterTargetArea.EXACT_RANGE
|
),
|
||||||
|
HighlighterTargetArea.EXACT_RANGE
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if(previous != null)
|
if(previous != null) previous.dispose();
|
||||||
previous.dispose();
|
|
||||||
});
|
});
|
||||||
} catch(IndexOutOfBoundsException ignored) {}
|
} catch(IndexOutOfBoundsException ignored) {} // don't crash over a bad cursor event
|
||||||
}
|
}
|
||||||
} catch(ControllerException ex) {
|
} catch(ControllerException ex) {
|
||||||
notifyError(project, "Error receiving change", ex);
|
notifyError(project, "Error receiving change", ex);
|
||||||
}
|
}
|
||||||
});
|
}).start();
|
||||||
});
|
});
|
||||||
|
|
||||||
if(after != null) after.run();
|
if(after != null) after.run();
|
||||||
|
|
Loading…
Reference in a new issue