Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

8
LINES

< > BotCompany Repo | #1031181 // printLineWithContext

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3017L/18K).

// line starts at 1
svoid printLineWithContext(S text, int line) {
  print();
  L<S> lines = lines(text);
  for (int i = max(1, line-5); i <= min(l(lines), line+5); i++)
    print((i == line ? "* " : "  ") + "LINE " + i + ": " + lines.get(i-1));
  print();
}

Author comment

Began life as a copy of #1015769

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1031181
Snippet name: printLineWithContext
Eternal ID of this version: #1031181/4
Text MD5: 98acaa61982702cdea66c0ac83facd66
Transpilation MD5: da7b0cfbe6b3537210b6d3e6f6c0d0f6
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-05-19 19:41:32
Source code size: 265 bytes / 8 lines
Pitched / IR pitched: No / No
Views / Downloads: 102 / 147
Version history: 3 change(s)
Referenced in: [show references]