1 | static int getContext_n = 3; |
2 | |
3 | static S getContext(S text, int lineNr) {
|
4 | new L<S> l; |
5 | L<S> lines = toLines(text); |
6 | int from = max(0, lineNr-1-getContext_n); |
7 | int to = min(l(lines), lineNr+getContext_n); |
8 | for (int i = from; i < to; i++) |
9 | l.add((i == lineNr-1 ? "* " : ". ") + lines.get(i)); |
10 | ret fromLines(l); |
11 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1003909 |
| Snippet name: | getContext - get a few lines above and below a given line |
| Eternal ID of this version: | #1003909/1 |
| Text MD5: | 77a24f50fe928e9fccce92e541531318 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2016-07-30 16:22:10 |
| Source code size: | 329 bytes / 11 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 698 / 744 |
| Referenced in: | [show references] |