LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-23-2010, 07:25 AM   #16
johnsfine
Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,051

Rep: Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100

Quote:
Originally Posted by anishakaul View Post
Does the below design make sense ?
Sorry, not to me.
Quote:
The first linked list is the read only file containing the original text of the file in question. Each node contains 80 characters (a line)
What do you mean by a linked list is a file? Why are you implying 80 characters is a line?
I think the designs you might have read for keeping the original separate from the edits are not intended for undo (as you seem to have assumed) but for efficiency in reducing the original processing and storage costs of reading in the initial file. It appears you are defeating that purpose by breaking the original into nodes.

Quote:
The last linked list is the one in which user will append the changes or the new text.
I am unable to even guess what you meant by the rest of the design. Efficiently representing just the changes is not likely to be practical. Storing the text of only the changes is practical, but it should require a unified structure of pointers into changed and unchanged text that represents the current state of the partially edited file.
 
1 members found this post helpful.
Old 11-23-2010, 10:03 PM   #17
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,619
Blog Entries: 29

Original Poster
Rep: Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896
Thanks again for bothering to reply, John.

Quote:
Originally Posted by johnsfine View Post
Sorry, not to me.
I am sorry that I didn't state clearly what I meant.

Quote:
Originally Posted by johnsfine View Post
What do you mean by a linked list is a file?
This meant that the original contents of the file would be read into the first link list.

Quote:
Originally Posted by johnsfine View Post
I think the designs you might have read for keeping the original separate from the edits are not intended for undo (as you seem to have assumed) but for efficiency in reducing the original processing and storage costs of reading in the initial file. It appears you are defeating that purpose by breaking the original into nodes.
Yes, absolutely, I had a wrong understanding of that data structure. Now I do realize there is no need to break the first linklist into nodes!

Quote:
Originally Posted by johnsfine View Post
I am unable to even guess what you meant by the rest of the design. Efficiently representing just the changes is not likely to be practical. Storing the text of only the changes is practical, but it should require a unified structure of pointers into changed and unchanged text that represents the current state of the partially edited file.
The middle link list showing the pointers is not the actual design. In the actual design, of course, sets/groups of pointers would be made to represent different tasks. I am sorry for that confusion now.

Quote:
Originally Posted by johnsfine View Post
Why are you implying 80 characters is a line?
I had started a thread for knowing the maximum number number of characters which can be displayed in a screen: http://www.linuxquestions.org/questi...screen-844325/

and now I am thinking that if I denote new lines by keeping a pointer on the start of each line, then:
  • When the user wants to move one line up, we just have to jump to the next pointer, skipping the characters in between.
  • If according to that thread I take 80 chars maximum for a line, and the user shrinks the window, I'll just have to adjust the pointers to denote new lines rather than moving data.

Thanks again for your reply, I shall post here the final data structure design in a short duration.
 
Old 01-22-2011, 08:34 AM   #18
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,619
Blog Entries: 29

Original Poster
Rep: Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896
Does the following structure now makes sense?
Code:
struct deletionHandler
{
    /* 'ptrFirst' points to the character on the left of the character(s) to be deleted */
    char *ptrFirst;
    /* 'ptrSecond' points to the character on the right of the character(s) to be deleted */
    char *ptrSecond;
};

struct insertionHandler
{
    /* 'ptrFirst' points to the character on the left of the left of the cursor */
    char *ptrFirst;
    /* 'ptrSecond' points to the character to be inserted */
    char *ptrSecond;
    /* 'ptrThird' points to the character on the right of the left of the cursor */
    char *ptrThird;
};

/* The vectors acts as a stack (stack is used for maintaining undo's and redo's) to store the deletionHandler's/insertionHandler's objects */
vector <deletionHandler> deletionPointerStack;
vector <insertionHandler> insertionPointerStack;
The line pointers kept in another structure will point to the new line characters entered by user. Line numbers will be displayed according to those new line characters.
 
  


Reply

Tags
text editor


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ - Store a text file in a Data Structure nilly16 Programming 3 05-26-2009 06:42 AM
text selection question in text editor olin Linux - Software 1 09-25-2007 01:25 PM
Text Editor on Fedora Core 4 in Text Mode blong4life Linux - Software 5 07-31-2006 09:07 PM
Which light text editor can copy text from file and paste in browser? davidas Linux - Software 9 03-06-2006 11:28 AM


All times are GMT -5. The time now is 04:41 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration