display.rc
changeset 5 420e4af41733
parent 3 04da04464d43
child 7 57c09d1b7f69
equal deleted inserted replaced
4:bf0b63015196 5:420e4af41733
     1 "*
     1 "*
     2  * $Header$
     2  * $Header$
     3  * display related configuration
     3  *
     4  * first do some common setup, then try to find a
     4  * DONT add site specific things here - use your own d_xxx.rc file instead
     5  * display specific initialization file.
     5  *
       
     6  * display related configuration:
       
     7  *   first do some common setup, then try to find a
       
     8  *   display specific initialization file.
     6  *"
     9  *"
     7 
    10 
     8 "*
    11 "*
     9  * key bindings common to all display types
    12  * key bindings common to all display types
       
    13  * use event monitor, to see what the Xserver sends us;
       
    14  * put display-specific stuff into a d_hostName.rc file.
    10  *"
    15  *"
    11 |map|
    16 |map|
    12 
    17 
    13 map := Display keyboardMap.
    18 map := Display keyboardMap.
    14 
    19 
    25 map bindValue:#FindPrev  to:#Cmdb.
    30 map bindValue:#FindPrev  to:#Cmdb.
    26 map bindValue:#SelectAll to:#CmdA.      "that is cmd-shift-a"
    31 map bindValue:#SelectAll to:#CmdA.      "that is cmd-shift-a"
    27 
    32 
    28 map bindValue:#Accept    to:#Cmda.
    33 map bindValue:#Accept    to:#Cmda.
    29 map bindValue:#Explain   to:#Cmde.
    34 map bindValue:#Explain   to:#Cmde.
       
    35 map bindValue:#Explain   to:#Cmdh.
    30 
    36 
    31 map bindValue:#BeginOfLine to:#Ctrla.
    37 map bindValue:#BeginOfLine to:#Ctrla.
    32 map bindValue:#EndOfLine   to:#Ctrle.
    38 map bindValue:#EndOfLine   to:#Ctrle.
    33 
    39 
    34 map bindValue:#SearchMatchingParent to:#Ctrlm.
    40 map bindValue:#SearchMatchingParent to:#Ctrlm.
    35 map bindValue:#SelectMatchingParents to:#Cmdm.
    41 map bindValue:#SelectMatchingParents to:#Cmdm.
    36 map bindValue:#SelectMatchingParents to:#Cmd.
    42 map bindValue:#SelectMatchingParents to:#Cmd.
    37 
    43 
    38 map bindValue:#SelectToEnd to:#CtrlE.           "that is ctrl-shift-e"
    44 map bindValue:#SelectToEnd to:#CtrlE.           "that is ctrl-shift-e"
    39 map bindValue:#SelectFromBeginning to:#CtrlA.   "that is ctrl-shift-a"
    45 map bindValue:#SelectFromBeginning to:#CtrlA.   "that is ctrl-shift-a"
       
    46 
       
    47 "
       
    48  * on some german keyboards, the x-server does NOT correctly
       
    49  * xlate characters ....
       
    50  *"
       
    51 "
       
    52 map bindValue:$[ to:#'Alt['.
       
    53 map bindValue:$] to:#'Alt]'.
       
    54 map bindValue:${ to:#'Alt{'.
       
    55 map bindValue:$} to:#'Alt}'.
       
    56 map bindValue:$\ to:#'Alt\'.
       
    57 map bindValue:$| to:#'Alt|'.
       
    58 "
    40 
    59 
    41 "*
    60 "*
    42  * international characters - map to iso8859 values
    61  * international characters - map to iso8859 values
    43  *"
    62  *"
    44 map bindValue:(Character value:16rFC) to:#udiaeresis.
    63 map bindValue:(Character value:16rFC) to:#udiaeresis.
    59 map bindValue:(Character value:16rA7) to:#section.
    78 map bindValue:(Character value:16rA7) to:#section.
    60 map bindValue:(Character value:16rB0) to:#degree.
    79 map bindValue:(Character value:16rB0) to:#degree.
    61 map bindValue:(Character value:16rB2) to:#twosuperior.
    80 map bindValue:(Character value:16rB2) to:#twosuperior.
    62 map bindValue:(Character value:16rB3) to:#threesuperior.
    81 map bindValue:(Character value:16rB3) to:#threesuperior.
    63 map bindValue:(Character value:16rB5) to:#mu.
    82 map bindValue:(Character value:16rB5) to:#mu.
       
    83 !
       
    84 
       
    85 "*
       
    86  * mouse-button translation
       
    87  *
       
    88  * the default translation is #(1 2 3) (i.e. identity).
       
    89  * If you dont want the 3rd button (some x-servers dont produce button2-
       
    90  * but button3-events instead), uncomment the following line:
       
    91  * (this translates the 3rd button into 2nd button).
       
    92  *"
       
    93 "/ XWorkstation buttonTranslation:#(1 2 2)
       
    94 
       
    95 "*
       
    96  * lefthanders can uncomment this:
       
    97  *"
       
    98 "/ XWorkstation buttonTranslation:#(3 2 1)
       
    99 
       
   100 "*
       
   101  * or:
       
   102  * (notice, that this is usually already done for you in the Xserver's configuration).
       
   103  *"
       
   104 "/ XWorkstation buttonTranslation:#(2 2 1)
       
   105 
       
   106 "*
       
   107  * you can also use symbolic buttons:
       
   108  * (allowed are #select #menu and #paste)
       
   109  *
       
   110  * the following line puts paste onto the right button (as in xterm):
       
   111  *"
       
   112 XWorkstation buttonTranslation:#(select #menu #paste)
       
   113 
       
   114 "*
       
   115  * while that one puts the pop-up menu both on the middle and right buttons:
       
   116  *"
       
   117 "/ XWorkstation buttonTranslation:#(select #menu #menu)
       
   118 !
       
   119 
       
   120 
       
   121 "*
       
   122  * define extensions for image files
       
   123  * moved this from code to here (from Image-class), for more flexibility
       
   124  * actually since this is not display- but host specific (naming conventions)
       
   125  * it should be moved into the host.rc or h_xxx.rc file
       
   126  *"
       
   127 |formats|
       
   128 
       
   129 formats := Image fileFormats.
       
   130 formats at:'.xbm'  put:XBMReader.
       
   131 formats at:'.tiff' put:TIFFReader.
       
   132 formats at:'.tif'  put:TIFFReader.
       
   133 formats at:'.gif'  put:GIFReader.
       
   134 formats at:'.img'  put:IMGReader.
       
   135 "formats at:'.pcx'  put:PCXReader.      "
       
   136 "formats at:'.mac'  put:MacPaintReader. "
       
   137 formats at:'.im8'  put:SunRasterReader.
       
   138 formats at:'.icon' put:SunRasterReader.
       
   139 formats at:'.face' put:FaceReader.
       
   140 "formats at:'.g3'   put:G3FileReader.   "
       
   141 formats at:'.bmp'  put:WindowsIconReader.
       
   142 formats at:'.ico'  put:WindowsIconReader.
       
   143 formats at:'.BMP'  put:WindowsIconReader.
       
   144 formats at:'.ICO'  put:WindowsIconReader.
       
   145 formats at:'.jpg'  put:JPEGReader.
       
   146 formats at:'.jpeg' put:JPEGReader.
       
   147 formats at:'.ppm'  put:PBMReader.
       
   148 formats at:'.pbm'  put:PBMReader.
       
   149 formats at:'.pgm'  put:PBMReader.
       
   150 formats at:'.form' put:ST80FormReader.
       
   151 formats at:'.bm'   put:XBMReader.
       
   152 formats at:'.pm'   put:XPMReader.
       
   153 formats at:'.xpm'  put:XPMReader.
       
   154 !
       
   155 
       
   156 "*
       
   157  * find out, on what type of display we run
       
   158  * (they should have added this to the x-protocol)
       
   159  *
       
   160  * look for a file named 'd_<displays-hostname>.rc' and file it in
       
   161  *"
       
   162 
       
   163 |displayVar display displayType s idx|
       
   164 
       
   165 "find display name from environment or -display argument"
       
   166 
       
   167 idx := Arguments indexOf:'-display'.
       
   168 idx ~~ 0 ifTrue:[
       
   169     displayVar := Arguments at:idx + 1.
       
   170 ] ifFalse:[
       
   171     displayVar := OperatingSystem getEnvironment:'DISPLAY'.
       
   172 ].
       
   173 display := displayVar.
       
   174 
       
   175 displayVar notNil ifTrue:[
       
   176     ((displayVar startsWith:':0') or:[displayVar startsWith:'unix:0'])  ifTrue:[
       
   177         display := OperatingSystem getHostName.
       
   178     ] ifFalse:[
       
   179         (displayVar endsWith:':0') ifTrue:[
       
   180             display := displayVar copyTo:(displayVar size - 2)
       
   181         ] ifFalse:[
       
   182             (displayVar endsWith:':0.0') ifTrue:[
       
   183                 display := displayVar copyTo:(displayVar size - 4)
       
   184             ]
       
   185         ]
       
   186     ].
       
   187     display isNil ifTrue:[
       
   188         'cannot determine display I am running on' errorPrintNL.
       
   189     ] ifFalse:[
       
   190         "if there is a corresponding file ..."
       
   191 
       
   192         s := Smalltalk systemFileStreamFor:('d_' , display , '.rc').
       
   193         s notNil ifTrue:[
       
   194             displayType := display.
       
   195             s close.
       
   196         ].
       
   197         "otherwise ..."
       
   198         displayType isNil ifTrue:[
       
   199             "just an example - stuff could also be hardwired here ..."
       
   200             display notNil ifTrue:[
       
   201                 (display startsWith:'clam') ifTrue:[
       
   202                     displayType := 'next'
       
   203                 ].
       
   204                 (display startsWith:'porty') ifTrue:[
       
   205                     displayType := 'portable'
       
   206                 ].
       
   207                 (display startsWith:'blue') ifTrue:[
       
   208                     displayType := 'iris'
       
   209                 ].
       
   210                 (display startsWith:'sun') ifTrue:[
       
   211                     displayType := 'sun'
       
   212                 ].
       
   213                 (display startsWith:'hp') ifTrue:[
       
   214                     displayType := 'hpux'
       
   215                 ].
       
   216                 (display startsWith:'slsv') ifTrue:[
       
   217                     "all those machines here at SEL are suns"
       
   218                     displayType := 'sun'
       
   219                 ].
       
   220             ].
       
   221         ].
       
   222     ].
       
   223 
       
   224     displayType isNil ifTrue:[
       
   225         "use type of machine smalltalk is running on as default ..."
       
   226 
       
   227         (displayVar startsWith:':0') ifTrue:[
       
   228             displayType := OperatingSystem getSystemType.
       
   229         ] ifFalse:[
       
   230             (displayVar startsWith:(OperatingSystem getHostName , ':0')) ifTrue:[
       
   231                 displayType := OperatingSystem getSystemType.
       
   232             ]
       
   233         ]
       
   234     ]
       
   235 ].
       
   236 
       
   237 "now, if the above mess found something, we have it in displayType;
       
   238  fileIn d_<displayType>.rc"
       
   239 
       
   240 displayType notNil ifTrue:[
       
   241     (Smalltalk at:#'_ImageDisplayName') ~= displayType ifTrue:[
       
   242         ('trying display setup d_' , displayType , '.rc ...') errorPrintNewline.
       
   243         Smalltalk fileIn:('d_' , displayType , '.rc')
       
   244     ].
       
   245     Smalltalk at:#'_ImageDisplayName' put:displayType
       
   246 ]
       
   247 !
       
   248 
       
   249 "*
       
   250  * set a default style, if not been set by rc-file
       
   251  * this is set according the system we are running on.
       
   252  * Notice: normally, the below is not needed, since the style
       
   253  *         is always set by the d_xxx.rc file.
       
   254  *         Except, when the d_xxx.rc is not present.
       
   255  *"
       
   256 |type|
       
   257 
       
   258 View defaultStyle isNil ifTrue:[
       
   259     type := OperatingSystem getSystemType.
       
   260     type = 'sunos' ifTrue:[
       
   261         View defaultStyle:#openwin
       
   262     ].
       
   263     type = 'next' ifTrue:[
       
   264         View defaultStyle:#next
       
   265     ].
       
   266     type = 'iris' ifTrue:[
       
   267         View defaultStyle:#iris
       
   268     ].
       
   269     type = 'linux' ifTrue:[
       
   270         View defaultStyle:#iris 
       
   271     ].
       
   272     type = 'hpux' ifTrue:[
       
   273         View defaultStyle:#motif 
       
   274     ].
       
   275 ]
    64 !
   276 !
    65 
   277 
    66 "*
   278 "*
    67  * take a smaller font on small (i.e. vga) screens
   279  * take a smaller font on small (i.e. vga) screens
    68  *"
   280  *"
    90         SelectionInListView defaultFont:(Font family:'helvetica' face:'medium' style:'roman' size:sz).
   302         SelectionInListView defaultFont:(Font family:'helvetica' face:'medium' style:'roman' size:sz).
    91         Launcher defaultFont:(Font family:'helvetica' face:'bold' style:'oblique' size:sz).
   303         Launcher defaultFont:(Font family:'helvetica' face:'bold' style:'oblique' size:sz).
    92     ] ifFalse:[
   304     ] ifFalse:[
    93         MenuView defaultFont:(Font family:'helvetica' face:'bold' style:'roman' size:sz).
   305         MenuView defaultFont:(Font family:'helvetica' face:'bold' style:'roman' size:sz).
    94         Launcher defaultFont:(Font family:'helvetica' face:'bold' style:'roman' size:sz).
   306         Launcher defaultFont:(Font family:'helvetica' face:'bold' style:'roman' size:sz).
    95     ]
   307         (View defaultStyle == #mswindows) ifTrue:[
    96 ].
   308             SelectionInListView defaultFont:(Font family:'courier' face:'bold' style:'roman' size:sz).
    97 
       
    98 "*
       
    99  * this defines the default font for code views
       
   100  *"
       
   101 CodeView defaultFont:(Font family:'courier' face:'medium' style:'roman' size:sz).
       
   102 
       
   103 ' '
       
   104 !
       
   105 
       
   106 "*
       
   107  * find out, on what type of display we run
       
   108  * (they should have added this to the x-protocol)
       
   109  *
       
   110  * look for a file named 'd_<displays-hostname>.rc' and file it in
       
   111  *"
       
   112 
       
   113 |displayVar display displayType s idx|
       
   114 
       
   115 "find display name from environment or -display argument"
       
   116 
       
   117 idx := Arguments indexOf:'-display'.
       
   118 idx ~~ 0 ifTrue:[
       
   119     displayVar := Arguments at:idx + 1.
       
   120 ] ifFalse:[
       
   121     displayVar := OperatingSystem getEnvironment:'DISPLAY'.
       
   122 ].
       
   123 display := displayVar.
       
   124 
       
   125 displayVar notNil ifTrue:[
       
   126     ((displayVar startsWith:':0') or:[displayVar startsWith:'unix:0'])  ifTrue:[
       
   127         display := OperatingSystem getHostName.
       
   128     ] ifFalse:[
       
   129         (displayVar endsWith:':0') ifTrue:[
       
   130             display := displayVar copyTo:(displayVar size - 2)
       
   131         ]
       
   132     ].
       
   133     display isNil ifTrue:[
       
   134         'cannot determine display I am running on' printNewline.
       
   135     ] ifFalse:[
       
   136         "if there is a corresponding file ..."
       
   137         s := Smalltalk systemFileStreamFor:('d_' , display , '.rc').
       
   138         s notNil ifTrue:[
       
   139             displayType := display.
       
   140             s close.
       
   141         ].
       
   142         "otherwise ..."
       
   143         displayType isNil ifTrue:[
       
   144             "just an example - stuff could also be hardwired here ..."
       
   145             display notNil ifTrue:[
       
   146                 (display startsWith:'clam') ifTrue:[
       
   147                     displayType := 'next'
       
   148                 ].
       
   149                 (display startsWith:'porty') ifTrue:[
       
   150                     displayType := 'portable'
       
   151                 ].
       
   152                 (display startsWith:'blue') ifTrue:[
       
   153                     displayType := 'iris'
       
   154                 ].
       
   155                 (display startsWith:'sun') ifTrue:[
       
   156                     displayType := 'sun'
       
   157                 ].
       
   158                 (display startsWith:'slsv') ifTrue:[
       
   159                     "all those machines here at SEL are suns"
       
   160                     displayType := 'sun'
       
   161                 ].
       
   162             ].
       
   163         ].
       
   164     ].
       
   165 
       
   166     displayType isNil ifTrue:[
       
   167         "use type of machine smalltalk is running on as default ..."
       
   168 
       
   169         (displayVar startsWith:':0') ifTrue:[
       
   170             displayType := OperatingSystem getSystemType.
       
   171         ]
   309         ]
   172     ]
   310     ]
   173 ].
   311 ].
   174 
   312 
   175 displayType notNil ifTrue:[
   313 "*
   176     ('reading display setup d_' , displayType , '.rc ...') printNewline.
   314  * this defines the default font for code views
   177     Smalltalk fileIn:('d_' , displayType , '.rc')
   315  *"
   178 ].
   316 CodeView defaultFont:(Font family:'courier' face:'medium' style:'roman' size:sz).
   179 !
   317 !
   180 
       
   181 "*
       
   182  * set a default style, if not been set by rc-file
       
   183  * this is set acc. the system we are running on
       
   184  *"
       
   185 |type|
       
   186 
       
   187 View defaultStyle isNil ifTrue:[
       
   188     type := OperatingSystem getSystemType.
       
   189     type = 'sunos' ifTrue:[
       
   190         View defaultStyle:#openwin
       
   191     ].
       
   192     type = 'next' ifTrue:[
       
   193         View defaultStyle:#next
       
   194     ].
       
   195     type = 'iris' ifTrue:[
       
   196         View defaultStyle:#iris
       
   197     ].
       
   198 ]
       
   199 !