Finding changed lines

8 views
Skip to first unread message

Eric Pement

unread,
Jul 4, 2024, 10:50:30 AM (yesterday) Jul 4
to SemWare TSE Pro text editor
Is there a way within TSE to find lines that have been changed and not saved to the disk? 

Specifically, I am looking for a command that can be assigned to a key to move forward (or backward) to the next line in the file that has been changed since the last save.

The use case is that before I write my changes to disk, saving the file, I can press a key and move the cursor forward to the next line down that has been changed but not saved. Pressing the same key take me forward to the next such line. 

Conversely, I would also like to have a key that will move me back (up toward the top of file) that will repeatedly locate the next unsaved line. An option to toggle the direction of the search would do just as fine.

I want to be able to quickly look at all the lines that have been altered before I press the File-Save command.

Is there a key that does this already, or a macro that can be assigned to a key? I did try looking, but didn't find anything.

Fred H Olson

unread,
Jul 4, 2024, 11:54:29 AM (yesterday) Jul 4
to SemWare TSE Pro text editor
Hi Eric,

Below is a macro I use from time to time that, I think, does what you want.
It uses the TSE macro cmpfiles to compare the changed file to a copy
of that file from disk.

--- Manual compare ----
Note that this can be done manually fairly easily .
1) Make and save temporary copy of changed file from copy still on
disk. ( Note: doing this external to TSE from command line or with
file browser will assure you that you are getting copy from disk.)

2) Use TSE macro cmp2disk.s to compare files (note: if the disk copy
and changed copy are open in two TSE windows, TSE compares them
without having to enter their file names)

--- Fred's cmp2disk.s macro ---

I created it a long time ago and there are details I dont recall
without more study than I have done recently... Also I would do some things
differently if I were writing it today...

I use the Linux version of TSE and there are some Linux specific aspects...
I have a file ~/l/tmp/on-disk-file that gets overwritten by a copy of the
file that has been changed from disk. There is a symlink called ~/c2d
to ~/l/tmp/on-disk-file I think that this was to give a short
path/filename of the copy from disk.

Maybe you could modify it for your system.
Sorry, it it surely wont work for you as is.

I've appended a copy of the short macro at the end.

Fred
// --- Fred Olson's macto cmp2disk.s
// Steps:
// fetch filename of current file
//open ~/l/tmp/on-disk-file, delete all , insert prev current file, save
//call cmpfiles macro and compare file to c2d
//If diff wanted, should be kept, save file manually.
// Else close file w/o saving

proc main()
string curfile[80]
integer filebuf
if FileChanged()
Warn('Current file has changed, locate changes, compare it to "c2d" ')
curfile=CurrFilename()
filebuf=GetBufferID() BegFile()
// Open temporary file:
editfile("/home/fholson/l/tmp/on-disk-file.txt")
// delete any contents in temporary file:
BegFile() MarkLine() EndFile() BegLine() MarkLine() Cut()
// Put contents of unchanged file in disk in temporary file:
InsertFile(CurFile) unmarkBlock() savefile()
// go back to changed file and compare it to temp file:
GotoBufferID(filebuf)
if FileExists("/home/fholson/c2d")
pushkeystr("/home/fholson/c2d")
// pushkey(<d>) pushkey(<2>) pushkey(<c>)
execMacro("cmpfiles")
// Note. if changes show by cmpfiles macro are desired, save file
// If none of changes are desired, abandon file
// If some are and some aren't, fix one of them.
else warn("Link ~/c2d does not exist ")
warn("Create it now by copy/pasting command below and try again. ")
warn("ln -s ~/l/tmp/on-disk-file.txt ~/c2d ")
endif
else Warn("Current file has not changed from copy on disk")
endif
end


--
Fred H. Olson Minneapolis,MN 55411 USA (near north Mpls)
Email: fholson at cohousing.org 612-588-9532
My Link Pg: http://fholson.cohousing.org
Reply all
Reply to author
Forward
0 new messages