Controlling the editor

A place where plug-in developers can share their knowledge and experience.
Post Reply
pepak
Posts: 330
Joined: Sun 13 Jul, 2008 11:18
Has thanked: 3 times
Been thanked: 9 times

Controlling the editor

Post by pepak » Wed 26 Jun, 2013 07:13

FAR3 build 3367: I am trying to open a file in the editor and get its EditorID for future use. I thought I would use this sequence:

Code: Select all

  Flags := EF_NONMODAL or EF_IMMEDIATERETURN or EF_DELETEONLYFILEONCLOSE;
  if FarApi.Editor(FileName, Title, 0, 0, -1, -1, Flags, 0, 1, CP_UTF8) = EEC_MODIFIED then
    if FarApi.EditorControl(-1, ECTL_GETINFO, 0, @EditorInfo) <> 0 then
      EditorID := EditorInfo.EditorID;
Unfortunately, the FarApi.EditorControl call always returns a zero (FALSE). So what is the correct way of opening an editor and getting its ID? Thanks.
Last edited by pepak on Wed 26 Jun, 2013 07:57, edited 1 time in total.

pepak
Posts: 330
Joined: Sun 13 Jul, 2008 11:18
Has thanked: 3 times
Been thanked: 9 times

Re: Controlling the editor

Post by pepak » Wed 26 Jun, 2013 07:28

On an unrelated note: If I open an editor in this way and intercept EE_CLOSE in ProcessEditorEventW, can I either:
a) Stop the close and keep the file in the editor, or
b) Override the EF_DELETEONLYFILEONCLOSE so that the file doesn't get deleted?
Thanks.

Shmuel
Posts: 5231
Joined: Thu 23 Mar, 2006 21:36
Location: Israel
Has thanked: 16 times
Been thanked: 151 times

Re: Controlling the editor

Post by Shmuel » Wed 26 Jun, 2013 13:11

pepak wrote:FAR3 build 3367: I am trying to open a file in the editor and get its EditorID for future use. I thought I would use this sequence:

Code: Select all

  Flags := EF_NONMODAL or EF_IMMEDIATERETURN or EF_DELETEONLYFILEONCLOSE;
  if FarApi.Editor(FileName, Title, 0, 0, -1, -1, Flags, 0, 1, CP_UTF8) = EEC_MODIFIED then
    if FarApi.EditorControl(-1, ECTL_GETINFO, 0, @EditorInfo) <> 0 then
      EditorID := EditorInfo.EditorID;
Unfortunately, the FarApi.EditorControl call always returns a zero (FALSE). So what is the correct way of opening an editor and getting its ID? Thanks.
This same code translated to Lua works correctly, I get different ID's every time the code is run.
Check whether "or" is a bitwise operator in your version of Pascal (it's not so for all Pascal implementations).
pepak wrote:On an unrelated note: If I open an editor in this way and intercept EE_CLOSE in ProcessEditorEventW, can I either:
a) Stop the close and keep the file in the editor, or
b) Override the EF_DELETEONLYFILEONCLOSE so that the file doesn't get deleted?
Thanks.
As far as I know: NO to both questions.

pepak
Posts: 330
Joined: Sun 13 Jul, 2008 11:18
Has thanked: 3 times
Been thanked: 9 times

Re: Controlling the editor

Post by pepak » Wed 26 Jun, 2013 13:19

Shmuel wrote:This same code translated to Lua works correctly, I get different ID's every time the code is run.
The problem was that I was using an uninitialized EditorInfo. Apparently I need to set its StructSize correctly.

Post Reply

Return to “Plug-In Developers”