static int getContext_n = 3; static S getContext(S text, int lineNr) { new L<S> l; L<S> lines = toLines(text); int from = max(0, lineNr-1-getContext_n); int to = min(l(lines), lineNr+getContext_n); for (int i = from; i < to; i++) l.add((i == lineNr-1 ? "* " : ". ") + lines.get(i)); ret fromLines(l); }
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: | 481 / 518 |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |