Browse Source

Add info about how to display text...

pull/620/head
Chris Smith 8 years ago
parent
commit
4991209d9d
1 changed files with 25 additions and 1 deletions
  1. 25
    1
      README.md

+ 25
- 1
README.md View File

13
 Development information
13
 Development information
14
 --------------------------------------------------------------------------------
14
 --------------------------------------------------------------------------------
15
 
15
 
16
+### Displaying text
17
+
18
+Text shown in windows (channels, servers, etc) is generated automatically from
19
+certain types of events passed on the DMDirc event bus. Any event that subclasses
20
+`DisplayableEvent` can potentially be formatted.
21
+
22
+DisplayableEvents are listened for by each window's [`BackBuffer`](https://github.com/DMDirc/DMDirc/blob/master/src/com/dmdirc/ui/messages/BackBuffer.java)
23
+instance. A format is then applied to the event to transform it into one or more strings. Formats
24
+are specified in [a YAML file included in the DMDirc jar](https://github.com/DMDirc/DMDirc/blob/master/res/com/dmdirc/ui/messages/format.yml),
25
+and can be overridden by the user by putting a `format.yml` file in their DMDirc config directory.
26
+
27
+A couple of typical formatting entries looks like this:
28
+
29
+```yaml
30
+ChannelMessageEvent:
31
+  format: "<{{client.modePrefixedNickname}}> {{message}}"
32
+ChannelModeNoticeEvent:
33
+  format: "-{{client.modePrefixedNickname}}:{{prefix}}{{channel.name}}- {{message}}"
34
+  colour: 5
35
+```
36
+
37
+The `{{..}}` templates retrieve properties from the event itself. `{{client.modePrefixedNickname}}`
38
+is the equivalent of calling `getClient().getModePrefixedNickname().toString()` on the event object.
39
+
16
 ### Error handling
40
 ### Error handling
17
 
41
 
18
 DMDirc has a user interface for displaying details of errors to users. It also
42
 DMDirc has a user interface for displaying details of errors to users. It also
21
 manually clicks on send).
45
 manually clicks on send).
22
 
46
 
23
 Errors should be logged using a [Slf4j](http://www.slf4j.org/) logger, and
47
 Errors should be logged using a [Slf4j](http://www.slf4j.org/) logger, and
24
-marked with one markers defined in [LogUtils](https://github.com/DMDirc/DMDirc/blob/master/src/com/dmdirc/util/LogUtils.java).
48
+marked with one markers defined in [`LogUtils`](https://github.com/DMDirc/DMDirc/blob/master/src/com/dmdirc/util/LogUtils.java).
25
 These markers allow developers to specify whether an error is an "Application"
49
 These markers allow developers to specify whether an error is an "Application"
26
 error (which will get reported and should ultimately be fixed), or a "User"
50
 error (which will get reported and should ultimately be fixed), or a "User"
27
 error (which is due to a problem with the user's config, environment, etc),
51
 error (which is due to a problem with the user's config, environment, etc),

Loading…
Cancel
Save