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

18
LINES

< > BotCompany Repo | #1008514 // _PrintIndent

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

Libraryless. Click here for Pure Java version (2506L/16K).

sclass _PrintIndent extends F1<S, Bool> {
  S prefix;
  bool beginningOfLine = true;
  
  *() {}
  *(S *prefix) {}
  
  Bool get(S s) {
    if (empty(s)) false;
    bool nl = s.endsWith("\n");
    if (nl) s = dropLast(s);
    s = s.replace("\n", "\n" + prefix);
    print_raw(beginningOfLine ? prefix + s : s);
    if (nl) print_raw("\n");
    beginningOfLine = nl;
    false;
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1008514
Snippet name: _PrintIndent
Eternal ID of this version: #1008514/4
Text MD5: 194c8ef2a4cce849d4a1279c6dd11a92
Transpilation MD5: d09ecb84eb57346170d94a76dbff4877
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-09-18 19:02:33
Source code size: 399 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 660 / 1316
Version history: 3 change(s)
Referenced in: [show references]