Page 1 of 1

Backspace when text is marked

Posted: Mon Dec 18, 2006 2:22 pm
by dmaon
Hi Jussi,

I did not know if to put it under "bugs" or "suggestions":

If you mark with the mouse several characters and then press the "Backspace" key the character left to the marked text is also deleted. :o :shock:
This is not very intuitive. I tried to replace the Backspace key by a macro - but it slows down the backspace key and as this key is very often used - it is unacceptable as a solution.
Please either change the backspace behaviour or add a new function Backspace2 with the corrected functionality.

David

Posted: Mon Dec 18, 2006 10:45 pm
by jussij
Hi David,
If you mark with the mouse several characters and then press the "Backspace" key the character left to the marked text is also deleted.
If I highlight a word with a double click and then use the BackspaceSmart function the character to the left of the cursor is deleted but the marked area is left untouched.

If I then repeat this, but instead use the Backspace or BackspaceEx functions the marked area is deleted and the character to the left also deleted.

To me if anything the BackspaceSmart is broken but the Backspace or BackspaceEx functions seem to be working as expect.
I tried to replace the Backspace key by a macro - but it slows down the backspace key
What does your Backspace macro do to make it run slow :?

Could you post the macro source to this thread :?:
Please either change the backspace behaviour or add a new function Backspace2 with the corrected functionality.

I'm really not sure what defines correct backspace behaviour in this instance :?

How do you see the backspace working in this instance :?:

But in any case, I really don't want to add yet a third backspace function to Zeus when it should be possible to customise this behaviour using a macro.

Cheers Jussi

Posted: Tue Dec 19, 2006 7:30 am
by dmaon
Hi Jussi,

I am used to deleting the marked text left of the cursor using the "backspace" key. In Word or any editor I know only the marked text is deleted and not the character at left of it. But after testing my macro again I decided that the speed is OK - the last time I checked it I had to many programs loaded in memory - I think this why it was slow.
Thanks for your answer.

David

Posted: Tue Dec 19, 2006 10:48 pm
by jussij
Below is a Lua macro that implements this backspace functionality (ie backspace.lua):

Code: Select all

function WordBackspace()

  -- check for markings
  local marked = is_marked()

  if (marked == 0) then
    -- let the backspace handle the normal case
    Backspace()
    return
  end

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

  -- macro only works for read/write documents.
  local locked = is_read_only()

  if (locked == 1) or (document == 0) then
    -- let the backspace handle the unexpected cases
    Backspace()
    return
  else
    -- delete the text
    MarkDelete()
  end
end

WordBackspace() -- run the macro
I would expect, since this macro is so simple, it should run as fast as any Zeus builtin function.

Also here is a Small C version of the same macro (ie backspace.zm):

Code: Select all

int WordBackspace()
{
  /* check for markings */
  int marked = is_marked();

  if (marked == 0)
  {
    /* let the backspace handle the normal case */
    Backspace();
    return;
  }

  /* macro only works for documents */
  int document = is_document();

  /* macro only works for read/write documents */
  int locked = is_read_only();

  if ((locked == 1) || (document == 0))
  {
    /* let the backspace handle the unexpected cases */
    Backspace();
    return;
  }

  /* delete the text */
  MarkDelete();
}
The Small C macro language is probably the fastest of all the macro languages, so it's response time should be even better ;)

Note: The Small C was the first ever Zeus scripting language, written inhouse, but it's error handling and syntax checking is no where near as good as the other mature scripting language options. This also makes Small C one of the most difficult scripting language to use :(