()
| 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(); |
no test coverage detected