Skip to content

Commit

Permalink
Add function to move to given line, TSV column.
Browse files Browse the repository at this point in the history
  • Loading branch information
craigsapp committed Aug 18, 2024
1 parent 9a34fa0 commit 01d31dc
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
37 changes: 37 additions & 0 deletions _includes/vhv-scripts/utility-ace.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,40 @@ function humdrumDataNoteIntoView(event) {
}




//////////////////////////////
//
// gotoLineFieldInEditor --
//

function gotoLineFieldInEditor(row, field) {
let linecontent = EDITOR.session.getLine(row-1);

let col = 0;
if (field > 1) {
let tabcount = 0;
for (let i=0; i<linecontent.length; i++) {
col++;
if (linecontent[i] == '\t') {
if ((i > 0) && (linecontent[i-1] != '\t')) {
tabcount++;
}
}
if (tabcount == field - 1) {
break;
}
}
}

EDITOR.gotoLine(row, col);

// 0.5 = center the cursor vertically:
EDITOR.renderer.scrollCursorIntoView({row: row-1, column: col}, 0.5);
centerCursorHorizontallyInEditor();

}




2 changes: 0 additions & 2 deletions _includes/vhv-scripts/utility-svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -930,5 +930,3 @@ function highlightIdInEditor(id, source) {

}



0 comments on commit 01d31dc

Please sign in to comment.