473,804 Members | 3,548 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Abstract Styled Document and undo

Hi all,

I'm extending an Abstract Styled Document associated with a JTextPanel to
implement a syntax highlighting editor. This is all working just fine -
except for undo / redo.

The problem is that the undo manager is recording my highlighting that
occurs as a result of keystrokes. So whenever the user performs undo, the
last operation (a colour highlight operation) is undone. Since I need to
refresh the highlighting when the undo is performed, the highlighting is
captured by the undo manager and this is the next undo operation in the undo
queue. Similar issue for redo. The colour highlighting is performed using:
javax.swing.tex t.DefaultStyled Document.setCha racterAttribute s (int offset,
int length, AttributeSet s, boolean replace);

What I've done to work around the problem is to remove the undomanager from
my document just before I perform the syntax scan then re add it immediately
afterwards. This effectively disables the capture of the syntax highlighting
changes. However ....

I'm not entirely sure that removing and adding the undo manager is the best
approach as, for various reasons, the syntax highlighting is performed in a
background thread. If the user happened to make a keystroke during that
time, then the keystroke also would not be captured by the undo manager.

So, is there a better way to prevent these colour highlights from being
registered in the undo manager's list?
I've looked at the UndoableEdit.di e () method, but am not certain that I can
reliably distinguish between user actions and my internal syntax
highlighting changes.

TIA
woz

Jun 27 '08 #1
0 2095

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3711
by: muesliflakes | last post by:
I am using styled buttons which look really good, my problem is that the 1st button on the page has an ugly black square arround it. I think this might indicate the default button when enter is pressed. How can I remove this square. HTML <input type="submit" name="btnShowCurrent" value="Show Current" id="btnShowCurrent" class="btn" onMouseover="btnHov(this, 'btn btnHov'); return;" onMouseout="btnHov(this, 'btn'); return;"
3
4510
by: Patrick S | last post by:
I am using IE 6.0. On a page, I have placed a contenteditable div which I want to use as a Rich Text Area. I am using the execCommand method of the document to control bold, italics, underlining, and undo for this div. I have placed an input element on the page to. All but the undo, are restricted to working only on the div. How can I restrict the undo to working on only the div? Below is the complete page so you can see what I am...
0
1280
by: Wiktor Zychla | last post by:
I am still trying to get the Undo function work on Internet Explorer editor hosted as activex in my c# application. Some time ago I've found a note at msdn that says "undo is not supported". I gave up. But lately I've downloaded LutzRoeder Writer that makes use of undo function. I've looked at the code and it turns out that it uses IOleCommandTarget interface to invoke this command.
4
3207
by: N.RATNAKAR | last post by:
hai, what is abstract class and abstract method
5
3019
by: =?Utf-8?B?UmljaA==?= | last post by:
Greetings, I am actually a VB.Net guy, but I have worked somewhat with C++ and C#. I just want to ask about the relationship between Abstract Classes and Interfaces. My first question is if C# even has Iinterfaces. I took some Java programming classes and Interfaces are a main staple of Java. And in VB.Net I use interfaces for setting up definitions of classes. I am guessing that Abstract classes in C# do the same thing as...
8
7112
by: Mateusz Viste | last post by:
Hi, I am trying make some multimedia files playable from my website. So far, I am able to generate dynamically a new page containing the right <embed> section. However, when I load my script, it overwrites the current page. Is there any way I could load a new tab or window, and put the new content into it? Here is the script I am using right now:
0
1245
by: PJ6 | last post by:
OK this is annoying... after I installed VS2008 to try it out, apparently an update was made to the behavior VS2005. Now when I close and reopen a document I'm working on, the Undo history is remembered. I was used to the history being cleared when I closed a document. I used this behavior as a way of checkpointing my progress... now that the history is not reset, it's actually screwing me up. If I want to revert back to the last time I...
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10326
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10317
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9143
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7615
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5520
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.