Searching for blank line in .txt file with ^$

Get help with the installation and running of the Zeus IDE. Please do not post bug reports or feature requests here. When in doubt post your question here.
Post Reply
BradMarshall
Posts: 3
Joined: Wed Apr 19, 2006 1:15 am

Searching for blank line in .txt file with ^$

Post by BradMarshall »

I am editing a .txt file under Windows XP Pro. I have blank lines in my file (0D.0A in the hex dump, as I would expect). A search for ^$ wirh regular expressions enabled does not find the blank line. Searches including \n or \r do not return results anywhere in the file. A search for ^.*$ will find any non-blank line.

Why isn't my search on ^$ finding the blank line?
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

Hi Brad,
A search for ^$ with regular expressions enabled does not find the blank line.
Unfortunately it looks like you have found a bug with the Zeus searching engine :(

I suspect this bug will be a fairly easy to fix so with any luck, expect to see a new Zeus patch in the the next week or two :)
Searches including \n or \r do not return results anywhere in the file
Currently there is no way to search for the \n or \r characters. This is a known limitation of the Zeus search engine :(

In the mean time, the only other solution I can suggest is using a Zeus macro to do the search. As an example of what I mean, here is a quick and dirty macro that finds the next blank line in the current document.

Code: Select all

function key_macro()
  -- macro only works for documents
  local document = is_document()

  if (document == 0) then
    -- can't run astyle.exe on current document
    message("This macro can only be run with an open document.")
    beep()
    return
  end

  local line_current = get_line_pos()

  -- get the length of the current line
  local len = string.len(get_line_text(line_current))

  if len == 0 then
    -- check if the file was found last time
    local line_last = get_global_string("LineSearch")

    if (line_last ~= nil) then
      if (line_current == tonumber(line_last)) then
        line_current = line_current + 1
      end
    end
  end

  local line_total = get_line_count()

  -- search the current file for the empty lines
  while line_current < line_total do
      -- get the length of the current line
      local len = string.len(get_line_text(line_current))

      if len == 0 then
        -- place the cursor on the empty line
        set_line_pos(line_current, 0)

        -- save the last line found to the global variable
        set_global_string("LineSearch", line_current)

        message("Found an empty line.")
        return
      end

      -- next line
      line_current = line_current + 1
  end

  -- reset the global variable
  set_global_string("LineSearch", "")

  message("No empty line found.")
end

key_macro() -- run the macro
Thank you for taking the time to posting this bug report ;)

Cheers Jussi
BradMarshall
Posts: 3
Joined: Wed Apr 19, 2006 1:15 am

Searching for blank line in .txt file with ^$

Post by BradMarshall »

Thanks, Jussi. I'll keep a sharp eye out for the patch.
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

Why isn't my search on ^$ finding the blank line?
The latest Zeus patch found here:

http://www.zeusedit.com/forum/viewtopic.php?t=533

can now search for the ^$ regular expression.

Cheers Jussi
BradMarshall
Posts: 3
Joined: Wed Apr 19, 2006 1:15 am

Thanks!

Post by BradMarshall »

Thanks for taking care of this, Jussij.

Best regards,

Brad
Post Reply