Getting/Setting the caret position

Display customization and font issues

Getting/Setting the caret position

Postby NJKA » Thu Apr 16, 2009 6:25 am

If there a way to display the numeric position of the caret in a file. I know the status bar displays the line number and column, but I need the absolute caret position. Also is there a way to goto an absolute position in a file.

Thanks
Neal
NJKA
Newbie
 
Posts: 2
Joined: Thu Apr 16, 2009 6:08 am

Re: Getting/Setting the caret position

Postby pietzcker » Thu Apr 16, 2009 6:48 am

In Hex mode, the current byte offset is displayed in the status line.

If you don't want to leave normal editing mode, you could place the caret at the position you're interested in, press Ctrl+Shift+Home to mark all characters until TOF, and then press Alt+^ (Word Count) to count all the characters inside the selection.

For the other request (move to a certain position) I thought a Perl regex could do it: (?s)(?<=\A.{1000}) to find the position between the 1000th and 1001st character - which is a valid Perl regex but doesn't work in UE. Probably due to UE's line-based nature.
User avatar
pietzcker
Master
Master
 
Posts: 241
Joined: Sun Aug 22, 2004 11:00 pm

Re: Getting/Setting the caret position

Postby NJKA » Thu Apr 16, 2009 9:20 am

Thanks for your answer. Unfortunatly I need the text view rather than the hex view. Sadly using Shift home does not work as it does not return the absolute offset (in bytes). Instead it returns the number of visible characters.

Neal
NJKA
Newbie
 
Posts: 2
Joined: Thu Apr 16, 2009 6:08 am

Re: Getting/Setting the caret position

Postby Mofi » Thu Apr 16, 2009 9:48 am

Use Search - Character Properties. But take into consideration that you will not get the correct offset for UTF-8 or ASCII Escaped Unicode files because they are loaded with conversion to UTF-16 LE. Also a temporary conversion of UNIX/MAC line endings to DOS results in a wrong offset information in comparison to stored data.

In text edit mode it is not possible to go to a specific byte offset.

You can use also a script to get current position.

Code: Select all
var nPosition = UltraEdit.activeDocument.currentPos;
UltraEdit.messageBox("Current position is: "+nPosition);

But there is no command to go to a position in text edit mode, only in hex edit mode.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4055
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna


Return to Editor Display