aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2016-06-05 18:24:12 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2016-06-05 18:24:12 -0400
commitcb14f5f5765a71630ea3c4bd2143fcc1cd4a2e57 (patch)
treec77118e96612dad70c00d4c0528b4f3815105b04
parentMerge pull request #697 from zandrmartin/assign-command (diff)
parentCommon: Readline: Ignore newline on '\' escaped line ends. (diff)
downloadsway-cb14f5f5765a71630ea3c4bd2143fcc1cd4a2e57.tar.gz
sway-cb14f5f5765a71630ea3c4bd2143fcc1cd4a2e57.tar.zst
sway-cb14f5f5765a71630ea3c4bd2143fcc1cd4a2e57.zip
Merge pull request #699 from roosemberth/master
Sway: Configuration: Support for escaping line breaks.
-rw-r--r--common/readline.c7
-rw-r--r--sway/sway.5.txt6
2 files changed, 13 insertions, 0 deletions
diff --git a/common/readline.c b/common/readline.c
index 76ed6926..5106172c 100644
--- a/common/readline.c
+++ b/common/readline.c
@@ -5,17 +5,24 @@
5char *read_line(FILE *file) { 5char *read_line(FILE *file) {
6 size_t length = 0, size = 128; 6 size_t length = 0, size = 128;
7 char *string = malloc(size); 7 char *string = malloc(size);
8 char lastChar = '\0';
8 if (!string) { 9 if (!string) {
9 return NULL; 10 return NULL;
10 } 11 }
11 while (1) { 12 while (1) {
12 int c = getc(file); 13 int c = getc(file);
14 if (c == '\n' && lastChar == '\\'){
15 --length; // Ignore last character.
16 lastChar = '\0';
17 continue;
18 }
13 if (c == EOF || c == '\n' || c == '\0') { 19 if (c == EOF || c == '\n' || c == '\0') {
14 break; 20 break;
15 } 21 }
16 if (c == '\r') { 22 if (c == '\r') {
17 continue; 23 continue;
18 } 24 }
25 lastChar = c;
19 if (length == size) { 26 if (length == size) {
20 char *new_string = realloc(string, size *= 2); 27 char *new_string = realloc(string, size *= 2);
21 if (!new_string) { 28 if (!new_string) {
diff --git a/sway/sway.5.txt b/sway/sway.5.txt
index bd2de12d..397b6d87 100644
--- a/sway/sway.5.txt
+++ b/sway/sway.5.txt
@@ -16,6 +16,12 @@ on startup. These commands usually consist of setting your preferences and
16setting key bindings. An example config is likely present in /etc/sway/config 16setting key bindings. An example config is likely present in /etc/sway/config
17for you to check out. 17for you to check out.
18 18
19Lines in the configuration file might be extended through multiple lines by
20adding a '\' character at the end of line. e.g.:
21
22 bindsym Shift+XF86AudioRaiseVolume exec pactl set-sink-volume \
23 $(pactl list sinks | grep -B 1 RUNNING | sed '1q;d' | sed 's/[^0-9]\+//g') +5%
24
19These commands can be executed in your config file, via **sway-msg**(1), or via 25These commands can be executed in your config file, via **sway-msg**(1), or via
20the bindsym command. 26the bindsym command.
21 27