Last Updated: July 3, 2019

Absolute Cursor Position in Statusbar

Macro Monday – a new macro to dig into every Monday!

Ever wanted to easily see where in the document your current cursor position is
relative to the first character? [@JustMe]( was [asking just this on our forums](,
and it turns out it’s quite easy to override a built-in Komodo function to update
your statusbar and show this information.

## The Macro

The function that edits the Komodo statusbar to add the byte & char positions

function addByteCharPos() {

var scimoz = ko.views.manager.currentView.scimoz; // Get scintilla

var bytePos = scimoz.currentPos; // Get byte pos of cursor
var charPos = scimoz.charPosAtPosition(bytePos); // Get char pos of cursor

// Get the statusbar line and column section to append new stats
var lineColWidget = document.getElementById(‘statusbar-line-col’);

// If these mis-match then there are mutliple byte chars in the doc.
// Give the char position rather than the byte/absolute position.
if (bytePos == charPos) {
var lineColText = lineColWidget.getAttribute(“label”) +
” Byte: ” + bytePos;
} else {
var lineColText = lineColWidget.getAttribute(“label”) +
” Char: ” + charPos;
// Attach new string
lineColWidget.setAttribute(‘label’, lineColText);

Create a namespace to save your function and ensure it’s not triggered too early

if (typeof(extensions) == “undefined”) {
extensions = {};

extensions.addByteCharPos = function(){
setTimeout(addByteCharPos, 1);

There just happens to be an event ready for us to use, [current_view_linecol_changed](

// Make sure you don’t add it twice so remove
window.removeEventListener(‘current_view_linecol_changed’, extensions.addByteCharPos, false);
window.addEventListener(‘current_view_linecol_changed’,extensions.addByteCharPos, false);

See the completed macro with comments on github: [add_byte_char_pos_statusbar.js](

### Installation

To install the macro simply hit the download button below, then drag the downloaded
file into your [Komodo toolbox](
Once in your toolbox double click the macro to activate it. The macro will
automatically activate itself the next time you start Komodo, you only need to
do this manually the first time.

Carey Hoffman

Carey Hoffman

Carey made the logical switch from snowboard instructing and treeplanting to the technology industry in 2009, taking database and network administration at Vancouver BC's BCIT college. Having started out on the technical support and QA team for ActiveState he now works on the Komodo development team as a front and backend software engineer.