Monday, December 28, 2009

Using Far Manager under Chinese XP

Far manager is an excellent orthodox file manager (aka Norton Commander clone for people who still remember DOS), the unicode version of which is open source. However, because it uses the console as the output, it suffers from text alignment and border display problems with Chinese, and presumably other DBCS, systems. Here are 2 methods to make it display properly:

Method 1: This is for v1.75 builds
Use a hex editor, open Far.exe, scan through it visually and patch the box characters to plain characters + - = |
The address of the box characters are unfortunately version dependent.
Install the addon FileCopyEx. Use this instead of Far's internal copy routine because Far's internal copy routine cannot handle certain Chinese names.
Create a shortcut for Far.exe and now right click on it to open the property tab of the shortcut. Now change the code page (Options tab) to Chinese, and add the /8 command line switch.
The example patch below works for v1.75 2616x86
Comparing files Far_original.exe and Far_patched.exe
000CA8C4: C5 2B
000CA8C5: B3 7C
000CA8C6: B3 7C
000CA8C7: B3 7C
000CA8C8: CF 2B
000CA8CC: D1 2B
000CA8CD: B3 7C
000CA8CE: B3 7C
000CA8CF: C1 2B
000D6F3C: B3 7C
000D6F3D: BA 7C
000D6F40: CD 3D
000D6F41: CD 3D
000D6F42: CD 3D
000D6F44: FB 3E
000D7050: C7 2B
000D7051: B6 2B
000D7052: C4 2D
000D7054: BA 7C
000D7055: BA 7C
000D7056: C4 2D
000D7058: C3 2B
000D7059: B4 2B
000D705A: C4 2D
000D705C: C3 2B
000D705D: B4 2B
000D705E: C4 2D
000D7060: CC 2B
000D7061: B9 2B
000D7062: CD 3D
000D7064: CC 2B
000D7065: B9 2B
000D7066: CD 3D
000D706A: B3 7C
000D706E: B3 7C
000D7070: D1 2B
000D7071: CF 2B
000D7072: B3 7C
000D7074: CD 3D
000D7075: CD 3D
000D7076: B3 7C
000D7078: C2 2B
000D7079: C1 2B
000D707A: B3 7C
000D707C: C2 2B
000D707D: C1 2B
000D707E: B3 7C
000D7080: CB 2B
000D7081: CA 2B
000D7082: BA 7C
000D7084: CB 2B
000D7085: CA 2B
000D7086: BA 7C
000D7088: C4 2D
000D7089: C4 2D
000D708A: C4 2D
000D708C: C4 2D
000D708D: C4 2D
000D708E: C4 2D
000D7090: CD 3D
000D7091: CD 3D
000D7092: CD 3D
000D7094: CD 3D
000D7095: CD 3D
000D7096: CD 3D
000D7098: B3 7C
000D7099: B3 7C
000D709A: B3 7C
000D709C: B3 7C
000D709D: B3 7C
000D709E: B3 7C
000D70A0: BA 7C
000D70A1: BA 7C
000D70A2: BA 7C
000D70A4: BA 7C
000D70A5: BA 7C
000D70A6: BA 7C
000D7309: B3 7C
000D730A: DA 2B
000D730B: C0 2B
000D730C: D9 2B
000D730D: BF 2B
000D730E: CD 3D
000D730F: BA 7C
000D7310: C9 2B
000D7311: C8 2B
000D7312: BC 2B
000D7313: BB 2B

Method 2: This is for v2.0 builds
Cut & paste lines below into a registry file e.g. boxchar.reg and import it

Create a shortcut for Far.exe and now right click on it to open the property tab of the shortcut. Now change the code page (Options tab) to Chinese, and change the Font to a true type font (細明體). Start Far now and under options > File mode > Full mode untick Align file extensions and use the following values:
Column types: T,D,S,N
Column widths: 5,8,8,0
Status line column types: S,NR
Status line column widths: 23,0

Method 3: This is for v2.0 builds
Download conemu from
Install conemu into same folder as far so conemu.exe is in the same folder as far.exe
Change Far's shortcut e.g. from c:\far2\far.exe to c:\far2\conemu.exe
Start Far (using the shortcut), right click and select settings
Change Font to 細明體
Change Charset to ANSI
Untick Monospace
Tick Fix FAR borders
And underneath it use Lucida Console, x0

Additional enhancements: conman can be used to start Far.exe (e.g. C:\Far\conman.exe C:\Far\Far.exe /8 /co -new_console_wx=170wy=50 ) to provide a scrollback buffer using the alternate console with the following registry file:

; registry settings for commands for console manager via Win+Key combination
; uncomment values which you want :)

"Console1" = hex:5b,31 ;win + 1
"Console2" = hex:5b,32 ;win + 2
"Console3" = hex:5b,33 ;win + 3
"Console4" = hex:5b,34 ;win + 4
"Console5" = hex:5b,35 ;win + 5
"Console6" = hex:5b,36 ;win + 6
"Console7" = hex:5b,37 ;win + 7
"Console8" = hex:5b,38 ;win + 8
"Console9" = hex:5b,39 ;win + 9
"Console10" = hex:5b,30 ;win + 0
;"Console11" = hex:5b,7a ;win + F11
;"Console12" = hex:5b,7b ;win + F12
"NewConsole" = hex:5b,57 ;win + w
;"ComSpec" = hex:5b,43 ;win + c
"Next" = hex:5b,51 ;win + q
"Prev" = hex:10,5b,51 ;shift + win + q
;"VertInc" = hex:5b,28 ;win + Down
;"VertDec" = hex:5b,26 ;win + Up
;"HorInc" = hex:5b,27 ;win + Right
;"HorDec" = hex:5b,25 ;win + Left

;"TerminateConsole" = hex:5b,2e ; Win + Del
;"MaximizeWindow" = hex:5b,78 ; Win + F9
;"MinimizeToTray" = hex:5b,22 ; Win + PgDn

"AlternativeConsole" = hex:5b,41 ; Win + A
"AlternativeConsoleUp" = hex:28
"AlternativeConsoleDn" = hex:26
"AlternativeConsolePgUp" = hex:22
"AlternativeConsolePgDn" = hex:21
"AlternativeConsoleHome" = hex:24
"AlternativeConsoleEnd" = hex:23
"AlternativeConsoleClear" = hex:2e
"AlternativeConsoleCopyAll" = hex:0x11,0x43 ;Ctrl+C
;"CloseAlternativeConsole" = hex:1b

;"TerminateAll" = hex:5b,11,44 ;Ctrl+Win+D ;by default not mapped

Method 4: This is for Far v3.0 builds

For Chinese filename display in Far v3.0 I do the following:
- Use Consolas (or other true type) font for Far Manager shortcut: this is so you can display Chinese
- Far > Options > File panel mode > Full mode: untick Align file extensions.
- Options > Colors > Panel > Border: change foreground or background color to a color scheme that differs from Normal text.
- Options > Panel Settings: untick Highlight column separators
- Options > Interface settings: tick ClearType friendly redraw

No comments:

Post a Comment