Created
          December 25, 2016 00:01 
        
      - 
      
- 
        Save hbt/74586d1ff130a3cd00477835352a14f5 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <!-- view ruby vrome --> | |
| <textarea onkeyup="getLineNumberAndColumnIndex(this);" id="txt" rows="14" cols="60" style="background-color: black; color: white;"> | |
| asdsadh | |
| das | |
| d | |
| d | |
| as | |
| dsa | |
| d | |
| asdas | |
| </textarea> | |
| <script> | |
| function setSelectionRange(input, selectionStart, selectionEnd) { | |
| if (input.setSelectionRange) { | |
| input.focus(); | |
| input.setSelectionRange(selectionStart, selectionEnd); | |
| } | |
| else if (input.createTextRange) { | |
| var range = input.createTextRange(); | |
| range.collapse(true); | |
| range.moveEnd('character', selectionEnd); | |
| range.moveStart('character', selectionStart); | |
| range.select(); | |
| } | |
| } | |
| function setCaretToPos (input, pos) { | |
| setSelectionRange(input, pos, pos); | |
| } | |
| function getLineNumberAndColumnIndex(textarea){ | |
| var textLines = textarea.value.substr(0, textarea.selectionStart).split("\n"); | |
| var currentLineNumber = textLines.length; | |
| var currentColumnIndex = textLines[textLines.length-1].length; | |
| console.log("Current Line Number "+ currentLineNumber+" Current Column Index "+currentColumnIndex ); | |
| } | |
| setCaretToPos(document.getElementById('txt'), 14, 10); | |
| </script> | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment