Setting static Codepage in Far3-Editor.

Something is missing in Far Manager? You have a great idea that should be heard? Write here.
Far3c
Posts: 14
Joined: Mon 04 Feb, 2013 15:27

Setting static Codepage in Far3-Editor.

Post by Far3c »

I would need to set for Far3-Editor any static Codepage, not only "Use ANSI code page by default".
"Autodetect code page" not working right.
I am editing files in Codepage=28592 (ISO 8859-2 Latin 2).
User avatar
HaRT
Moderator
Posts: 10823
Joined: Tue 30 Aug, 2005 17:21
Has thanked: 221 times
Been thanked: 358 times

Re: Setting static Codepage in Far3-Editor.

Post by HaRT »

Do you have this codepage installed in Windows?
You might with to choose it manually from the list available in the Editor by ShiftF8. If the list is short, try pressing CtrlH there to reveal all installed codepages.
Фар есть инструмент, а не нянька. © 2009 DrKnS
Far3c
Posts: 14
Joined: Mon 04 Feb, 2013 15:27

Re: Setting static Codepage in Far3-Editor.

Post by Far3c »

Yes I have this Codepage in list.
I know, it is posible change Codepage manualy, but I am editing a lot of files every day with this Codepage, and it is very tiring for me change Codepage for every new file.
User avatar
t-rex
Страшный и ужасный
Posts: 4910
Joined: Tue 15 Mar, 2005 16:17
Location: Tel-Aviv
Has thanked: 1 time
Been thanked: 8 times
Contact:

Re: Setting static Codepage in Far3-Editor.

Post by t-rex »

You can always record a macro that selects whatever you need.
2useven10
Posts: 5205
Joined: Mon 07 Sep, 2009 10:40
Has thanked: 18 times
Been thanked: 310 times

Re: Setting static Codepage in Far3-Editor.

Post by 2useven10 »

There is example for latest far3.

Code: Select all

Macro {
  area="Shell"; key="AltF4"; flags="DisableOutput"; description="Edit file with favorite CP";
  action = function()
    Keys('ShiftF4')
    if Area.Dialog then
      Keys('Tab CtrlDown Down Down Down Down Down Down Down Down Enter ShiftTab')
      if not APanel.Folder then
        Keys('ShiftHome'); print(APanel.Current); Keys('Enter') --Keys('Home ShiftEnd')
      end
    end
  end
}
I suppose that 852 28592 is the first favorite codepage (F9 -> Options -> Codepages ... ).
Last edited by 2useven10 on Tue 05 Feb, 2013 10:48, edited 1 time in total.
Shmuel
Posts: 6819
Joined: Thu 23 Mar, 2006 21:36
Location: Israel
Has thanked: 41 times
Been thanked: 528 times

Re: Setting static Codepage in Far3-Editor.

Post by Shmuel »

Another suggestion:

Code: Select all

Macro {
  description="Set 28592 codepage";
  area="Editor"; key="CtrlF8"; flags="DisableOutput";
  action=function()
    Keys("ShiftF8 CtrlAltF 2 8 5 9 2")
    if Menu.GetValue():match("^28592") then Keys("Enter")
    else Keys("Esc")
    end
  end;
}
Copy this code into a file with extension "lua", e.g. 28592.lua
Place this file into your %FARPROFILE%\Macros\scripts directory and restart Far.
Then, any time you press CtrlF8 in Editor, the codepage will be set to 28592.
Far3c
Posts: 14
Joined: Mon 04 Feb, 2013 15:27

Re: Setting static Codepage in Far3-Editor.

Post by Far3c »

Thank you, it is very nice. I'm not very experienced in writing macros.
My question is:
Is posible this macro write so, when I open all files "*.4gl" in Far-Editor,
automaticaly change Codepage to 28592 (without pressing any key)?
User avatar
HaRT
Moderator
Posts: 10823
Joined: Tue 30 Aug, 2005 17:21
Has thanked: 221 times
Been thanked: 358 times

Re: Setting static Codepage in Far3-Editor.

Post by HaRT »

Far3c wrote:Is posible this macro write so, when I open all files "*.4gl" in Far-Editor,
automaticaly change Codepage to 28592 (without pressing any key)?
Try the [ESC] plugin.
Фар есть инструмент, а не нянька. © 2009 DrKnS
Far3c
Posts: 14
Joined: Mon 04 Feb, 2013 15:27

Re: Setting static Codepage in Far3-Editor.

Post by Far3c »

I don't know what I am doing bad, but in my Far3 doesn't work this ESC-Plugin.
I would like ask again:
Is there any way to run Makto when I open the editor with some file automaticaly?
2useven10
Posts: 5205
Joined: Mon 07 Sep, 2009 10:40
Has thanked: 18 times
Been thanked: 310 times

Re: Setting static Codepage in Far3-Editor.

Post by 2useven10 »

1) ESC version in Downloads is not compatible with latest far (rebuild from sources can help).
2) Yes it is possible. I can't write such macro in couple of minutes. Maybe later if somebody else will not help...
Last edited by 2useven10 on Tue 05 Feb, 2013 19:39, edited 1 time in total.
2useven10
Posts: 5205
Joined: Mon 07 Sep, 2009 10:40
Has thanked: 18 times
Been thanked: 310 times

Re: Setting static Codepage in Far3-Editor.

Post by 2useven10 »

Example:

Code: Select all

Macro {
  area="Shell"; key="F4"; flags="DisableOutput"; description="Edit CP-28592";
  condition = function()
    return not APanel.Folder and mf.fsplit(APanel.Current,8) == '.4gl'
  end;
  action = function()
    Keys('ShiftF4'); print(APanel.Current); Keys('Tab CtrlDown')
    if Menu.Select(28592,1) > 0 then Keys('Enter Enter') end
  end;
}
Last edited by 2useven10 on Wed 06 Feb, 2013 11:18, edited 3 times in total.
2useven10
Posts: 5205
Joined: Mon 07 Sep, 2009 10:40
Has thanked: 18 times
Been thanked: 310 times

Re: Setting static Codepage in Far3-Editor.

Post by 2useven10 »

for next nightly build:

Code: Select all

Macro {
  area="Shell"; key="F4"; flags="DisableOutput"; description="Edit CP-28592"; filemask="*.4gl";
  action = function()
    Keys('ShiftF4'); print(APanel.Current); Keys('Tab CtrlDown CtrlAltF 2 8 5 9 2')
    Keys(Dlg.GetValue():match('^28592') and 'Enter Enter' or 'CtrlAltF Home')
  end;
}
[/s]
Last edited by 2useven10 on Tue 05 Feb, 2013 19:28, edited 1 time in total.
Shmuel
Posts: 6819
Joined: Thu 23 Mar, 2006 21:36
Location: Israel
Has thanked: 41 times
Been thanked: 528 times

Re: Setting static Codepage in Far3-Editor.

Post by Shmuel »

2useven10 wrote:for next nightly build:
No, it won't work. "filemask" field works (at the moment) only for Editor and Viewer areas, not for Shell.
2useven10
Posts: 5205
Joined: Mon 07 Sep, 2009 10:40
Has thanked: 18 times
Been thanked: 310 times

Re: Setting static Codepage in Far3-Editor.

Post by 2useven10 »

But it works :) For any files :(
User avatar
ur4ltz
Posts: 76
Joined: Fri 08 Jan, 2010 14:07
Location: Харьков
Has thanked: 1 time

Re: Setting static Codepage in Far3-Editor.

Post by ur4ltz »

Far3c wrote:I don't know what I am doing bad, but in my Far3 doesn't work this ESC-Plugin.
I would like ask again:
Is there any way to run Makto when I open the editor with some file automaticaly?
This version ESC compatible with latest Far3 build 3156.
ESC-v2.9x32.7z
ESC-v2.9x32.7z
(70.33 KiB) Downloaded 334 times
Post Reply

Return to “Suggestions and Ideas”