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

11
LINES

< > BotCompany Repo | #1014785 // charIndexToUserLandLineNr (line counted from 1)

JavaX fragment (include)

static int charIndexToUserLandLineNr(S text, int charIndex) {
  int i = 0, row = 1;
  charIndex = min(charIndex, l(text));
  while (i < charIndex) {
    i = smartIndexOf(text, '\n', i)+1;
    if (charIndex < i) break;
    ++row;
    if (charIndex == i) break;
  }
  ret row;
}

Author comment

Began life as a copy of #1012342

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1014785
Snippet name: charIndexToUserLandLineNr (line counted from 1)
Eternal ID of this version: #1014785/3
Text MD5: 1be7f2cea76e446be61b87a18a0a4f3b
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-07 14:42:12
Source code size: 286 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 255 / 312
Version history: 2 change(s)
Referenced in: [show references]