MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / showLinePos

Method showLinePos

ij/src/main/java/ij/plugin/frame/Editor.java:1174–1197  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1172 }
1173
1174 private void showLinePos() { // show line numbers in status bar (Norbert Vischer)
1175 char[] chars = ta.getText().toCharArray();
1176 if(chars.length > 1e6)
1177 return;
1178 int selStart = ta.getSelectionStart();
1179 int selEnd = ta.getSelectionEnd();
1180 int line=0;
1181 int startLine = 1;
1182 int endLine = 1;
1183 for (int i=1; i<=chars.length; i++) {
1184 if (chars[i-1]=='\n') line++;
1185 if (i==selStart)
1186 startLine=line + 1;
1187 if (i<=selEnd)
1188 endLine=line + 1;
1189 if (i>=selEnd)
1190 break;
1191 }
1192 String msg = "Line " + startLine;
1193 if (startLine != endLine) {
1194 msg += "-" + endLine;
1195 }
1196 IJ.showStatus(msg);
1197 }
1198
1199 public void keyReleased(KeyEvent e) {
1200 int pos = ta.getCaretPosition();

Callers 3

mouseReleasedMethod · 0.95
mouseClickedMethod · 0.95
selectAllMethod · 0.95

Calls 4

showStatusMethod · 0.95
getTextMethod · 0.45
getSelectionStartMethod · 0.45
getSelectionEndMethod · 0.45

Tested by

no test coverage detected