column editing

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
jbroome
Posts: 2
Joined: Sun Sep 24, 2006 6:54 pm

column editing

Post by jbroome »

Does zeus allow column editing?

Sample Text

open c:\test\testfile1.htm
open c:\test\testfile1.htm
open c:\test\testfile1.htm
open c:\test\testfile1.htm
open c:\test\testfile1.htm

There's two things I want to be able to do here:

1. column-select the text: \test\ in each row and then type \example\ and have the Sample text now look like:

open c:\example\testfile1.htm
open c:\example\testfile1.htm
open c:\example\testfile1.htm
open c:\example\testfile1.htm
open c:\example\testfile1.htm

So far, all I can get zeus to do is this:

open c:\example\testfile1.htm
open c:testfile1.htm
open c:testfile1.htm
open c:testfile1.htm
open c:testfile1.htm

Not very intuitive to me.

2. I'd like to be able to column-select the 1 in each row, and replace it with numbers, so my sample would now look like:

open c:\example\testfile1.htm
open c:\example\testfile2.htm
open c:\example\testfile3.htm
open c:\example\testfile4.htm
open c:\example\testfile5.htm

I've found other editors that do both of these, but there's enough about them that I don't like that I'm giving zeus a try.

Thanks
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

Does zeus allow column editing?
Zeus does Column, Line and Block marking via the MarkColumnToggle, MarkLineToggle, MarkBlockToggle keyboard functions.

For example with the Brief keyboard mapping enabled these keyboard functions are bound to the Alt+C, Alt+L and Alt+M key combinations.

Zeus also can do column, block or line mouse marking. To set the required marking mode use the Options, Editor Options menu and in the General section select the default mouse marking mode. The installer sets the default mouse marking mode to Block (ie Column) mode.

You can also override the current mouse marking mode by holding down the Alt or Ctrl or Shift keys while using the mouse to do the marking.
1. column-select the text: \test\ in each row and then type \example\ and have the Sample text now look like:
There are at least two ways to do this in Zeus:

Search and Replace

1) Select the block of text containing the \test\ for each of the row to be changed.
2) Use the Edit, Replace menu and replace test for example. Zeus will have automatically select the Market text only option.

Using a Keyboard macro

1) Macros Record Start Stop menu to start recording
2) Type in the required changes for the first line
3) Macros Record Start Stop menu to stop recording
4) Macros Record Playback run the macro and edit the second line
So far, all I can get zeus to do is this:
I suspect what might be going wrong is the \ is being translated into the \t tab character. If you leave out the \ or type in \\t this should fix this. The \\ translates to a \ character ;)
2. I'd like to be able to column-select the 1 in each row, and replace it with numbers, so my sample would now look like:
The only way this can be done in Zeus is by using a macro. For example the following numbers.lua should do something like this:

Code: Select all

function key_macro()
  -- macro only works for read/write documents.
  if (is_read_only() == 1) or (is_document() == 0) then
    message("This macro can only be used with a writable document.")
    beep()
    return
  end

  -- macro only works for marked documents
  if is_marked() == 0 then
    message("This macro needs a column marked area.")
    beep()
    return
  end

  -- get the marked text details
  local top   = get_marked_top()
  local range = get_marked_bottom() - top + 1

  -- disable screen updates
  screen_update_disable()

  -- delete the marked area
  MarkDeleteEx()

  -- comment the lines selected
  for i = 1, range, 1 do
    -- build the number
    local number = string.format("%d", i)

    -- save the current cursor
    cursor_save()

    -- write out the number
    write(number)

    -- restore cursor
    cursor_restore()

    -- move to the next line
    MoveLineDown()
  end

  -- restore screen updates
  screen_update_enable()
end

key_macro() -- run the macro
Save the macro to the zScript\numbers.lua file, column mark the numbers to be replaced and then run the macro using the Macros, Load, Macros Execute menu.

Cheers Jussi
jbroome
Posts: 2
Joined: Sun Sep 24, 2006 6:54 pm

column editing

Post by jbroome »

Thanks for the reply. The line numbering macro looks pretty useful.

That column editing thing though is something I do pretty frequently, and search/replace won't always get the job done - the text in each row selected could be different. Creating a macro to repeat the change seems clunky. I wouldn't want to create a new macro for each one-off occurrence of an edit like this.

Is there any chance of getting a column edit option added to zeus (default the option "off" so it's consistent with current behavior) so that any text changes made while a column is highlighted occur on every row of the selection?

Thanks again.
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

Is there any chance of getting a column edit option added to zeus (default the option "off" so it's consistent with current behavior) so that any text changes made while a column is highlighted occur on every row of the selection?
I have added this feature request to the Zeus todo list ;)

In the mean time all I can suggest is the following Lua macro as an alternative method to do the text replacement:

Code: Select all

function key_macro()
  -- macro only works for read/write documents.
  if (is_read_only() == 1) or (is_document() == 0) then
    message("This macro can only be used with a writable document.")
    beep()
    return
  end

  -- macro only works for marked documents
  if is_marked() == 0 then
    message("This macro needs a column marked area.")
    beep()
    return
  end

  local default = ""

  -- ask for a user for the replacement text
  local text = user_input("Replacement Text:", default)

  if (string.len(text) == 0) then
    message("Macro cancelled by user.")
    return
  end

  -- get the marked text details
  local top   = get_marked_top()
  local range = get_marked_bottom() - top + 1

  -- disable screen updates
  screen_update_disable()

  -- delete the marked area
  MarkDeleteEx()

  -- do the text replacement
  for i = 1, range, 1 do
    -- save the current cursor
    cursor_save()

    -- write out the replacement text
    write(text)

    -- restore cursor
    cursor_restore()

    -- move to the next line
    MoveLineDown()
  end

  -- restore screen updates
  screen_update_enable()
end

key_macro() -- run the macro
To use the macro column mark the area to be adjusted, run the macro and enter the text to be applied to all the marked lines.

Cheers Jussi
amif2000
Posts: 14
Joined: Sun Dec 10, 2006 3:14 pm

Post by amif2000 »

Instead of a replace you could do an insert:

just add the line

Code: Select all

local left = get_marked_left()
after

Code: Select all

local top = get_marked_top()
and replace

Code: Select all

MarkDeleteEx()
with

Code: Select all

set_line_pos(top)
set_cursor_pos(left)
Amit
Post Reply