The R Project SVN R-packages

Rev

Rev 3319 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3319 Rev 7971
Line -... Line 1...
-
 
1
# R GUI for macOS
-
 
2
 
-
 
3
This repository contains the R.app GUI for macOS. It is a Cocoa application that embeds R and provides a native Mac interface for R incuding a graphics device and an editor. It is shipped with R released from https://cran.R-project.org and by default installed in `/Applications`. However, it can be run from any place, including read-only images.
-
 
4
 
-
 
5
## Building
-
 
6
 
-
 
7
You will need Xcode and an R framework in `/Library/Frameworks`- any R release (or tar ball from https://mac.R-project.org) will do. The project can be built simply with
-
 
8
 
-
 
9
```
-
 
10
xcodebuild
-
 
11
```
-
 
12
 
-
 
13
from the repository. Two main configurations are `Release` and `Debug`. The `Debug` configuration enables debugging output and does not forward `stderr` to the console.
-
 
14
 
-
 
15
---
-
 
16
 
-
 
17
The following conent is directly from the original ReadMe.txt which dates back to 2004 when we frist released the gUI and is aimed at developers.
-
 
18
 
1
R app embedding R.
19
## R app embedding R.
2
 
20
 
3
This is a true Cocoa application that embeds R.
21
This is a true Cocoa application that embeds R.
4
 
22
 
5
The original code for embedding R in Cocoa is Simon's work.
23
The original code for embedding R in Cocoa is Simon's work.
6
 
24
 
7
You can consider this or any other derivative of this product a four-hand work of me and Simon.
25
You can consider this or any other derivative of this product a four-hand work of me and Simon.
8
 
26
 
9
R is started up with the option --gui=cocoa, this is temporarily needed because R_ProcessEvents is to be 
27
R is started up with the option `--gui=cocoa`, this is temporarily needed because `R_ProcessEvents` is to be 
10
called from libR.dylib into the Cocoa app, and --gui=cocoa simply set a flag to conditionalize the 
28
called from `libR.dylib` into the Cocoa app, and `--gui=cocoa` simply set a flag to conditionalize the 
11
R_ProcessEvents inside src/unix/aqua.c code. Once the aqua module will be declared "Defunct", --gui=aqua
29
`R_ProcessEvents` inside `src/unix/aqua.c` code. Once the aqua module will be declared "Defunct", `--gui=aqua`
12
would be enough
30
would be enough
13
 
31
 
14
There are several tricks I did and there are several things to take into account. In sparse order, here they are:
32
There are several tricks I did and there are several things to take into account. In sparse order, here they are:
15
1.  after awakefromnib, instead of blocking the main cocoa event loop directly calling  run_Rmainloop, a timer fires 
33
1.  after awakefromnib, instead of blocking the main cocoa event loop directly calling  run_Rmainloop, a timer fires 
16
	once to call this function. At this point the menu bar is correctly built and the GUI can respond to the related 
34
	once to call this function. At this point the menu bar is correctly built and the GUI can respond to the related 
17
	events.
35
	events.
18
 
36
 
19
2. to test x11/tcltk try the following:
37
2. to test x11/tcltk try the following:
20
	a)	run the X window server using the X11 icon int he toolbar
38
   1. run the X window server using the X11 icon in the toolbar
21
	b)	> library(tcltk)
39
   2. `> library(tcltk)`
22
	c)	> demo(tkdensity)
40
   3. `> demo(tkdensity)`
23
 
41
 
24
	it works! On the contrary AquaTclTk doesn't work at all, or at least is works as badly as it was for the Carbon RAqua.
42
   it works! On the contrary AquaTclTk doesn't work at all, or at least is works as badly as it was for the Carbon RAqua.
25
 
43
 
26
Note: to build the R for Mac OS X FAQ manually use the following command from the shell
44
Note: to build the R for Mac OS X FAQ manually use the following command from the shell
-
 
45
```
27
	makeinfo -D UseExternalXrefs --html --force --no-split RMacOSX-FAQ.texi
46
	makeinfo -D UseExternalXrefs --html --force --no-split RMacOSX-FAQ.texi
-
 
47
```
28
 
48
 
29
For everything else read the NEWS file 
49
For everything else read the NEWS file 
30
 
50
 
31
stefano
51
stefano
32
 
52
 
33
Milan and Augsburg, 2004-10-10
53
Milan and Augsburg, 2004-10-10
34
 
54
 
35
=== Note to developers ===
55
## Note to developers
36
 
56
 
37
If you intend to work on the source code of R.app, please adjust your editor to use tabs. Each indentation level
57
If you intend to work on the source code of R.app, please adjust your editor to use tabs. Each indentation level
38
should be exactly one tab. The preferred setting in Xcode is (in Preferences -> TextEditing)
58
should be exactly one tab. The preferred setting in Xcode is (in Preferences -> TextEditing)
-
 
59
```
39
  [X] Editor uses tabs
60
  [X] Editor uses tabs
40
  Tab width: [4] Indent width: [4]
61
  Tab width: [4] Indent width: [4]
-
 
62
```
41
 
63
 
42
This will give you the proper indenting behavior and fairly well readable code. You can replace the "4" in both fields by
64
This will give you the proper indenting behavior and fairly well readable code. You can replace the "4" in both fields by
43
any positive value you find pleasant, just make sure both entries are identical. Use Xcode-style indentation whenever possible.
65
any positive value you find pleasant, just make sure both entries are identical. Use Xcode-style indentation whenever possible.
44
The strict use of tabs as indentation marks makes it possible for everyone to view the code with the spacing s/he prefers.
66
The strict use of tabs as indentation marks makes it possible for everyone to view the code with the spacing s/he prefers.
45
 
67
 
-
 
68
For Emacs users the setting is
-
 
69
```
46
For Emacs users the setting is (setq c-basic-offset 4 tab-width 4
70
(setq c-basic-offset 4 tab-width 4
47
indent-tabs-mode t)
71
indent-tabs-mode t)
-
 
72
```
48
 
73
 
49
Other important note:
74
Other important note:
50
 * always commit NIB files individually and remove and .svn directories
75
 * always commit NIB files individually and remove and .svn directories
51
   before adding new NIB files: when IB copies NIBs it also copies .svn
76
   before adding new NIB files: when IB copies NIBs it also copies .svn
52
   directories, thus screwing up the SVN.
77
   directories, thus screwing up the SVN.
53
 
78
 
54
 About Localization - Quick Overview
79
## About Localization - Quick Overview
55
-------------------------------------
-
 
-
 
80
 
56
We have added new (experimental) support for localization of the GUI. Although this is great news for the users, this requires cooperation of the developer and some extra work. Please read "Localizing Obj-C code" amd "NIB localization" below!
81
We have added new (experimental) support for localization of the GUI. Although this is great news for the users, this requires cooperation of the developer and some extra work. Please read "Localizing Obj-C code" amd "NIB localization" below!
57
 
82
 
58
There is a script "update.localization" in the project directory that automatically updates localized NIBs to match changes made in the master 'English' versions. It is the aggressive form of NIB update (see nibtool) which means that it retains only sizes of existing components, but any other changes made to the localized NIB after translation will be lost. It also generates corresponding <nib>.<lang>.strings files that can be used for translation. Any existing files (localized NIBs and NIB-relased string files) will be overwritten.
83
There is a script `update.localization` in the project directory that automatically updates localized NIBs to match changes made in the master 'English' versions. It is the aggressive form of NIB update (see nibtool) which means that it retains only sizes of existing components, but any other changes made to the localized NIB after translation will be lost. It also generates corresponding `<nib>.<lang>.strings` files that can be used for translation. Any existing files (localized NIBs and NIB-relased string files) will be overwritten.
59
 
84
 
60
Analogously there is a script "update.strings" for automatic merging of newly added Obj-C strings. Again, read next sections for details.
85
Analogously there is a script `update.strings` for automatic merging of newly added Obj-C strings. Again, read next sections for details.
61
 
86
 
62
** I can't stress this often enough - make sure your editor is set to UTF-8 encoding when editing localization-related files! Even the default in Xcode is MacRoman, so make sure you set it to UTF-8 in your preferences! If you don't, then Xcode will open UTF-8 files as MacRoman thus ruining the file! All localization tools described here handle UTF-8 ONLY! **
87
** I can't stress this often enough - make sure your editor is set to UTF-8 encoding when editing localization-related files! Even the default in Xcode is MacRoman, so make sure you set it to UTF-8 in your preferences! If you don't, then Xcode will open UTF-8 files as MacRoman thus ruining the file! All localization tools described here handle UTF-8 ONLY! **
63
 
88
 
64
 How To - NIB localization:
89
 How To - NIB localization:
65
----------------------------
90
----------------------------
Line 82... Line 107...
82
	- run update.localization
107
	- run update.localization
83
	  this synchronizes the changes made in the master with other locales. This also generates a new set of Translated.strings files
108
	  this synchronizes the changes made in the master with other locales. This also generates a new set of Translated.strings files
84
	  
109
	  
85
	[the following is optional]
110
	[the following is optional]
86
	- edit the translation file. This is necessary if new widgets have been added and thus they need to be translated. Again, make sure you use UTF-8 encoding!
111
	- edit the translation file. This is necessary if new widgets have been added and thus they need to be translated. Again, make sure you use UTF-8 encoding!
87
	- run update.localization -t
112
	- run `update.localization -t`
-
 
113
	  
88
	  again, don't forget the -t option or your new translation file will be overwritten
114
	  again, don't forget the `-t` option or your new translation file will be overwritten
89
 
115
 
90
Some notes on NIB files:
116
Some notes on NIB files:
91
- It is a good idea to check the translation files even if you actually don't want to translate the NIB. The file will show you any inconsistencies in the strings used, such as trailing spaces or newlines.
117
- It is a good idea to check the translation files even if you actually don't want to translate the NIB. The file will show you any inconsistencies in the strings used, such as trailing spaces or newlines.
92
- When desigining a view, always keep in mind that many languages need more space for the same phrase than english. Keep sufficient space around/following a text such that the localized files don't need to be modified one by one. (I could probably remove this one if we used German as the master language ;)).
118
- When desigining a view, always keep in mind that many languages need more space for the same phrase than english. Keep sufficient space around/following a text such that the localized files don't need to be modified one by one. (I could probably remove this one if we used German as the master language ;)).
93
- Don't forget to re-run update.localization when you make non-GUI changes to the NIBs, such as new connections. It's easy to forget, because it has nothing to do with the GUI, but still, the localized NIBs need to be updated, too.
119
- Don't forget to re-run `update.localization` when you make non-GUI changes to the NIBs, such as new connections. It's easy to forget, because it has nothing to do with the GUI, but still, the localized NIBs need to be updated, too.
94
- Always run update.localization before a release
120
- Always run `update.localization` before a release
95
 
121
 
96
 Localizing Obj-C code
122
 Localizing Obj-C code
97
-----------------------
123
-----------------------
98
 
124
 
99
When writing code, keep in mind that all user-visible string constants should be localized. The Apple-documented way is to use NSLocalizedString macros (see Cocoa deocumentation), but to make it somewhat easier, there are NLS and NLSC macros in RGUI.h which should be used INSTEAD! They are equivalent to NSLocalizableString(xx,xx) with NLS passing an empty string as comment. The reason for the macros (beside reducing the typing effort) is that there are also some scripts that allow us to automate and simplify the process. Both macros can be used with Obj-C strings ONLY. Handling of C strings is not supported yet (use NSString whenever you can!).
125
When writing code, keep in mind that all user-visible string constants should be localized. The Apple-documented way is to use `NSLocalizedString` macros (see Cocoa deocumentation), but to make it somewhat easier, there are NLS and NLSC macros in `RGUI.h` which should be used INSTEAD! They are equivalent to `NSLocalizableString(xx,xx)` with NLS passing an empty string as comment. The reason for the macros (beside reducing the typing effort) is that there are also some scripts that allow us to automate and simplify the process. Both macros can be used with Obj-C strings ONLY. Handling of C strings is not supported yet (use NSString whenever you can!).
100
 
126
 
101
Macros:
127
Macros:
-
 
128
```
102
  NLS(@"text")
129
  NLS(@"text")
103
  NLSC(@"text", @"comment to clarify the context - not visible to user, only visible to the translator")
130
  NLSC(@"text", @"comment to clarify the context - not visible to user, only visible to the translator")
-
 
131
```
104
Examples:
132
Examples:
-
 
133
```ObjC
105
  NSString *message = NLS(@"Hello, world");
134
  NSString *message = NLS(@"Hello, world");
106
  [item setValue: [NSString stringWithFormat: NLS(@"Hello, %@"), name]];
135
  [item setValue: [NSString stringWithFormat: NLS(@"Hello, %@"), name]];
107
  [toolbar setLabel: NLSC(@"Add Col", @"Add column - toolbar entry, keep short!")];
136
  [toolbar setLabel: NLSC(@"Add Col", @"Add column - toolbar entry, keep short!")];
-
 
137
```
108
 
138
 
109
The most straight-forward way to localize existing code is to replace any (user-visible) @".." string constant with NLS(@".."). Note that NSLog messages and fixed strings (e.g. keys used in preferences) should not be translated.
139
The most straight-forward way to localize existing code is to replace any (user-visible) `@".."` string constant with `NLS(@"..")`. Note that `NSLog` messages and fixed strings (e.g. keys used in preferences) should not be translated.
110
 
140
 
111
Once the code is ready, run (in project directory)
141
Once the code is ready, run (in project directory)
-
 
142
```
112
./update.strings
143
./update.strings
-
 
144
```
113
this script generates Localized.strings from the sources and merges localization from each language into a new file, replacing old localization.  It relies on two other scripts: 'filterNLS' which filters all NLS/NLSC macros and generates Localized.strings (using genstrings and iconv) and 'mergeLS' which merges changes into a localized version of the strings. In addition, empty comments (i.e. all NLS entries) are replaced by @"From: <file> (<function>)" to provide some context. Warnings of multiple key use can be safely ignored if the meaning is consistent.
145
this script generates Localized.strings from the sources and merges localization from each language into a new file, replacing old localization.  It relies on two other scripts: `filterNLS` which filters all NLS/NLSC macros and generates `Localized.strings` (using genstrings and iconv) and `mergeLS` which merges changes into a localized version of the strings. In addition, empty comments (i.e. all NLS entries) are replaced by `@"From: <file> (<function>)"` to provide some context. Warnings of multiple key use can be safely ignored if the meaning is consistent.
114
 
146
 
115
Some practical notes:
147
Some practical notes:
116
- If you CHANGE the handle in the Obj-C code, the previous localization is lost. You should NEVER change the handle, unless you have really strong reason to do so. Note that changing the english text can be done through Localizable.strings, too! You don't have to change the handle to rephrase a given text.
148
- If you CHANGE the handle in the Obj-C code, the previous localization is lost. You should NEVER change the handle, unless you have really strong reason to do so. Note that changing the english text can be done through Localizable.strings, too! You don't have to change the handle to rephrase a given text.
117
- It is OK to change the comment part when using NLSC, because that information is not used for merging.
149
- It is OK to change the comment part when using NLSC, because that information is not used for merging.
118
- One handle can have one translation only. If you need the same text in two different contexts, use different handles and change the english text in the localization file.
150
- One handle can have one translation only. If you need the same text in two different contexts, use different handles and change the english text in the localization file.