[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Beaver-devel] Search algorithms
From: |
Michael Terry |
Subject: |
[Beaver-devel] Search algorithms |
Date: |
Mon, 10 Mar 2003 23:02:05 -0500 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3b) Gecko/20030224 |
Hello again, Leslie. I was thinking about how I wanted to implement the
new search stuff, and I thought I'd run my ideas past you, to get some
feedback.
I'd like to allow searching in this file, searching in all open buffers,
and searching on a set of files (matched by a regexp, like
/home/foo/bar*.txt). Now, ideally, we would support all sorts of
options, like case sensitive or not, match whole word, regular
expressions, etc.
I figure this is a lot of new code to add, especially since there is a
tool that we know we can depend on existing that does all this for us --
grep. So, I was thinking we could just call grep and handle the output,
mapping it to whatever is open.
What I have in mind for output is similar to how UltraEdit for Windows
handles things, if you've used it.
So, for example, i want to search in all files matching
/home/foo/bar*.txt for the string 'dood'. We could call "grep dood
/home/foo/bar*.txt" with appropriate output modifying flags and display
this to the user.
The user is presented (in a view that appears in the main window (by
default under the notebook, I guess)) with a tree list of lines that
matched the query. So, if bar1.txt exists and bar2.txt exists, there
would be a little tree view on the bottom that looks like:
V bar1.txt
-- this line matches the dood token
-- doodle on the paper
V bar2.txt
-- cradle dood
Where you could collapse or expand each file's matches (i.e., the user
could make it look like:
> bar1.txt
V bar2.txt
-- cradle dood
). Double clicking (or single-clicking?) on the matching line would
take you to the line in the file. To do so, we would scan through the
open buffers, and if one of them is the same file and also has not been
modified, then we use it. Otherwise, if there is no unmodified versions
of the file open, we open a new file for it. And, we would go to the line.
Ok. That's for searching on files that match a pattern. If we search
on an open buffer or buffers, we would pass the text to grep via
standard input and parse the output like normal.
In either case, we would use GtkTextMark's to mark where each line
starts so that if a user changes the number of lines, our places
wouldn't be lost. If the search was on an unopened file, we would wait
to place the marks until it was open.
In the case of replacing, we could probably use sed in a similar fashion.
I think the idea of outsourcing our searching algorithms to grep is a
reasonable choice. It would give us a lot of power at little
programming cost, would avoid duplication of work, and avoid bugs. We
can rely on it being present on any platform we need (if we were going
to autotool Beaver, they promise that any platform that autotools
support will have certain programs; among them are grep and sed).
What do you think?
-mt
pgpuiinBsXBy5.pgp
Description: PGP signature
- [Beaver-devel] Search algorithms,
Michael Terry <=