473,387 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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.text.DefaultStyledDocument.setCharacte rAttributes (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.die () 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 2070

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

Similar topics

4
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...
3
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,...
0
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...
4
by: N.RATNAKAR | last post by:
hai, what is abstract class and abstract method
5
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...
8
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...
0
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.