[prev in list] [next in list] [prev in thread] [next in thread] 

List:       quanta-devel
Subject:    [quanta-devel] askSam/TWiki Hybrid Clone Project
From:       Randy Kramer <rhkramer () gmail ! com>
Date:       2005-09-22 16:42:34
Message-ID: 200509221241.27468.rhkramer () gmail ! com
[Download RAW message or body]

Hi!

(Note: I'm crossposting this to both quanta-devel and kwrite-devel (and my 
local lug).  I've already written to quanta-devel (and my local lug) about 
some parts of this project.  This post hopefully provides some background 
useful to anybody trying to answer my questions, and also includes some 
questions, some that are more applicable to kate and some that are more 
applicable to quanta, imho.  After this initial cross post, I intend/hope to 
deal with the kate related questions on the kwrite list and the quanta 
related questions on the quanta list.  Help from any source will be 
appreciated.) ;-)  

I apologize for the length of this post.

Finally, in case this is too confusing, I'll post individual questions 
(appropriate to each list) in a few days. 

Contents:
   * What I have now in Nedit
   * What I want in the next generation
   * Potential Alternates
      * Keep nedit, build an external filter and HTML rendering "thingie"
      * Modify Quanta Plus "minimally"
      * Modify (or recreate) Quanta Plus replacing kate with nedit   
   * More Discussion (and some questions) on Duplicating Existing 
Functionality
      * Searching for Records Matching Multiple Search Terms
      * Folding on TWiki headings
   * Final aside: Emacs not considered a solution      
      
---+ What I have now in Nedit

I currently have an "application" "written" in nedit (i.e., using nedit 
macros) that does the following:

   * Lets me create and maintain files containing multiple records.  Each 
record is, in essence, a (potential) TWiki (wiki) page.  The text of each 
page is plain ASCII with "TWiki markup".  
   
(Probably unnecessary explanation: If I transferred (e.g., by copy and paste) 
any of these pages to a TWiki, when the appropriate URL is invoked by a web 
browser, the TWiki markup is converted to (X)HTML, "sent" from a web server, 
and "rendered" in the browser.)

Aside: I currently have 12 such files, 2 of them are approaching 2000 
records/pages and 2,000,000 characters.  Also, with tongue-in-cheek, I call 
this (what I have working now in nedit) the third generation of the project, 
I expect quite a few more generations before I'm done. ;-)  

   * Lets me fold the text in the file on TWiki marked up headings ("\n---+ 
" (h1) thru "\n---++++++ " (h6)).  
   
Some details: This functionality is implemented via a set of macros--in Kate, 
I guess you'd call them scripts.  "Fold" may be slighly misleading--so far in 
nedit there is no good way to hide text (certainly not as of nedit version 
5.3 (when I created the folding macros), nor up through version 5.5).  
Therefore, what the macros do is replace the "\n"s ahead of text to be folded 
with "\f"s which has the effect of making all the affected text appear on one 
long line extending off to the right--as long as I work on the left, that 
text is out of my way, and I have a "pseudo"-folded document.  (The \f is 
invisible but does serve as a place holder to replace the "\n"s when I want 
to unfold the text.) 

   * Lets me search for (and select) single records satisfying multiple search 
criteria.  To give you a better idea of what I mean and how the macro does 
it, the algorithm works something like this:
   
An example: The user inputs, for example, three search words.  The macro 
starts with one of them (currently the last, on the assumption that it is the 
most rare), and finds an occurrence of that term.  It then selects the entire 
record containing that found search term by searching backward and forward 
for the next record separators (or BOF/EOF).  It then searches within that 
record (selection) for the other two search terms.  If it finds both, the 
search is successful and that record is displayed for the user.  If it fails, 
it resumes a search for the initial search term starting at the record after 
the failed record (or before, depending on whether the search direction is 
forward or backward).

Aside: The record separator is currently the TWiki markup for a 2nd level 
heading ("\n---++ "), but I will need to change this, and want to keep it 
easily changable in the future.  In the future I plan to use the same tool(s) 
on other multiple record files with a somewhat similar format, e.g., mbox 
files (using the From line as the record separator).

---+ What I want in the next generation

The primary goal for the next phase is a (very fast) local preview feature, 
without losing any of (or by recreating, if necessary) the existing 
functionality (described above).

---+ Potential Alternates

I've thought of a few (potential) ways to add the preview functionality:
   * Keep nedit, build an external filter and HTML rendering thingie
   * Modify Quanta Plus "minimally"
   * Modify (or "rewrite") Quanta Plus replacing kate with nedit

More discussion on each of these is below.

Currently my preferred approach is the second option, partly because I think 
it will create a more integrated/polished solution, and, afaict, will not 
preclude any of the future additional functionality I anticipate.

---++ Keep nedit, build an external filter and HTML rendering thingie

I could continue to use what I've already built in nedit, and build another 
"thingie" (an external program) that would accept input from nedit on stdin.  
(Nedit would pass a selection/record, corresponding to a TWiki marked-up 
page.)  That other thingie would filter the TWiki markup to HTML, then pass 
it on to an "instance" of khtml for display.  
   
Some "speculation" on how to do that: From reading I've done, it sounds like 
I'd want to instantiate khtml as a parent, from that instantiate the TWiki to 
HTML filter as a child, and then I could communicate from nedit to the filter 
on stdin and the filter could communicate to khtml via an iostream.  I don't 
want to sound like I know what I'm doing here, because I don't, I'm just 
reading and trying to understand.  I don't want a new filter (or khtml 
thingie) instantiated each time I send a new page for preview, I want the 
filter and khtml thingie to "persist" and simply update the preview.  I don't 
know how to do that at this point, but don't think it's impossible.

---++ Modify Quanta Plus

Quanta Plus has an internal preview that seems to work fairly similar to what 
I want (as far as a preview goes)--plain text with HTML markup is edited in a 
kate part (iiuc) and then previewed in a khtml part (iiuc), the missing 
functionality for my preview is the TWiki to HTML filter.  So, modifying 
Quanta Plus seems like a potential approach.  There are some things to work 
out:
   
   * Creating that filter (which, at least initially, could be done with regex 
search and replace--I might prefer to do it in Ruby just because I've started 
learning Ruby and started generating/collecting some of the regexs.  All of 
the regexes must exist in TWiki (in Perl), but last time I looked at that 
code (3-4 years ago), I couldn't make much sense of it (partly because I was 
trying to learn Perl and didn't have much knowledge of regexes, and partly 
because I believe even the developers consider the code at that time to have 
been rather disorganized (as evidenced by recent efforts to clean it up in 
various ways).))
      
   * Integrating that filter into Quanta Plus so that text from the Kate part 
is passed through it on the way to the Khtml part.  I'll need help with this, 
but I expect the best place to ask questions about this is on the 
quanta-devel mail list, which I've already joined and started asking some 
questions (but maybe not very specifically about this, yet).  So, an obvious 
early question for the quanta list is whether (and how) I can integrate a 
filter written in Ruby into Quanta as described in the previous bullet?

   * Duplicating the existing functionality from the nedit macros (i.e., 
folding on TWiki heading markup and searching for records containing multiple 
search terms) in the kate part (or, perhaps, replacing the kate part with 
nedit).  To get a little more specific:
      
      * Search for records matching multiple search terms (more discussion 
below)
      * Folding on TWiki headings (more discussion below)

---++ Modify (or recreate) Quanta Plus replacing kate with nedit

Or write something similar to Quanta Plus using nedit and khtml--I expect to 
only consider something like this if the 2nd option doesn't pan out.

---+ More Discussion (and some questions) on Duplicating Existing 
Functionality

---++ Searching for Records Matching Multiple Search Terms

I've learned (with some help from Brian Peterson on the quanta-devel list) 
that quanta/kate can search within a selection (he pointed me to the checkbox 
on the search dialog)), but its taken me a little while to find a dcop 
function corresponding to that.  In fact, I'm not sure I've found it--what I 
have found is the findStringAt function.  It looks I can use that to search 
within a record (selection), but, imho, in a somewhat convoluted (and 
potentially slower than I'd like) manner.  I'll explain the approach in more 
detail below.  My questions here are: 
	    
	    * Is there a better (dcop) function than findStringAt to search within a 
selection?
	    * I assume that dcop functions are the basis of scripting for kate?
	    * Can anybody point me to one or more examples of scripts for kate that 
use dcop functions?
	    * And, if I'm totally off base here, can anybody straighten me out?

After a little experimentation, it seems that findStringAt lets me start a 
search from a specified location.  Using that, I can search within a 
selection by starting a search at the beginning of a selection.  If the 
search is successful, I then check if the match is located before the end of 
the selection.  

It seems a little convoluted, and if I'm searching long files frequently 
(which I will be doing), it will probably be somewhat slower than a search 
that stopped searching at a specified location (the end of the selection).

Aside: I'm using a Mandrake 10 system with kde 3.2, Quanta Plus 3.2.1, and 
kate 2.2.  I always have trouble upgrading kde so I plan to continue working 
with these versions until I install a more up-to-date Mandrake.  If I'm 
missing significant functionality, let me know, and I'll consider upgrading 
the entire system to Mandriva05 (or 06) (which I do plan to do in the next 
months anyway).   

---++ Folding on TWiki headings
	 
In kate, iiuc, the "markers" for folding are specified with the 
"specification" for syntax highlighting.  I found one page that talks some 
about this, and I've done some experimentation.  From what I've seen/done so 
far, I'm afraid that kate requires a begin and end marker for folding.  (The 
example/experimenting I've done has been with "{" and "}" in a c or cpp 
file.)  In the TWiki markup, there is no explicit thing to mark the end of 
the fold--the end of a fold(ing region?) is marked by the next fold marker, 
either of the same or a different heading level.  

Below is an example of the folding I'd expect.

Must there be a begin and end marker for a folding region, or can kate use the 
occurrence of a new begin marker to signal the end of the previous fold 
region?

Do you see any other obstacles to accomplishing folding as shown in the 
example below?

Aside: I realize that in kate I may have to fold each heading by clicking on 
the "-" in front of the heading--at least initially I don't see that as an 
obstacle, although maybe in the future I'd try to fold larger areas of text 
to various levels with some kind of script invoked by a keyboard shortcut.
	 
Here's a simplified example:

Here's the unfolded version:

---+ Level 1 heading

text...

---++ Level 2 heading

text...

---+++ Level 3 heading

text...

---++ Another Level 2 heading

text...

---+ Another Level 1 heading

text...

---++ A Third Level 2 heading

text...

Here are some of the ways I'd like to fold it:

Show Level 1 headings:

---+ Level 1 heading
---+ Another Level 1 heading

Show Level 2 headings:

---+ Level 1 heading
---++ Level 2 heading
---++ Another Level 2 heading
---+ Another Level 1 heading
---++ A Third Level 2 heading

Show Level 3 headings:

---+ Level 1 heading
---++ Level 2 heading
---+++ Level 3 heading
---++ Another Level 2 heading
---+ Another Level 1 heading
---++ A Third Level 2 heading

---+ Final aside: Emacs not considered a solution

I am aware that emacs has some or all of this functionality available, 
including up to (iirc) eight different wiki modes.  I considered using emacs 
briefly, but don't think it would work very well for all of my/your 
grandparents, parents, spouses/siblings, children, and grandchildren.

Thanks,
Randy Kramer

_______________________________________________
quanta-devel mailing list
quanta-devel@kde.org
https://mail.kde.org/mailman/listinfo/quanta-devel

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic