jEdit Community - Resources for users of the jEdit Text Editor
How to delete a marker from a buffer in a macro?
Submitted by mabra on Wednesday, 5 July, 2006 - 13:32
Hi All,

I insert a marker into a buffer, before I make some modifications to it;Just to remember my starting position. After I finish my task, I will remove the marker, but this fails.

My code[snippet] is as follows:

char mc = 'X';
buffer.addMarker(mc, 6);

... my buffer-modies here ...

Marker m = buffer.getMarker(mc);
buffer.removeMarker(m.getPosition());

The marker is stil there [and "m" is NOT null!]

Any help would be really very welcome.
Thanks,
Manfred
Comment viewing options
Select your preferred way to display the comments and click 'Save settings' to activate your changes.
Help
by fixedsys on Tue, 18/07/2006 - 14:05
The position for addMarker is an offset from start of the buffer. It is not a line number.

The position for removeMarker is a line number.

char mc = 'X';
buffer.addMarker(mc, 6);
Marker m = buffer.getMarker(mc);

// ... my buffer-modies here ...

buffer.removeMarker(buffer.getLineOfOffset(m.getPosition()));

Hope it helps,
Lars
 
Thanks:Solved
by mabra on Tue, 18/07/2006 - 20:28
Hello fixedsys!

My "buffer.add(..)" statement, was just a sample;I gave it the current caret position, not the line.
My fault was, that I misinterpreted the

>>getPosition()           Returns the position of this marker.<<

statement from the API. I misinterpreted this as the line number Sad

Your codeline so works perfectly!

Many thanks!

Best regards,
Manfred
User login
Browse archives
« March 2024  
MoTuWeThFrSaSu
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Poll
Are you interested in language packs for jEdit?
Yes, and I could help maintain translations
26%
Yes, I'd like to have translations
32%
Indifferent
35%
No, that'd be bad (please comment)
7%
Total votes: 1093
Syndication
file   ver   dls
German Localization light   4.4.2.1   82339
Context Free Art (*.cfdg)   0.31   46046
JBuilder scheme   .001   18487
BBEdit scheme   1.0   18108
ColdFusion scheme   1.0   18016
R Edit Mode - extensive version   0.1   17465
Advanced HTML edit mode   1.0   16198
Matlab Edit Mode   1.0   16060
jEdit XP icons   1.0   15221
XP icons for jEdit   1.1   14285