aboutsummaryrefslogtreecommitdiffstats
path: root/vncviewer/fltk_layout.h
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2011-05-23 12:21:21 +0000
committerPierre Ossman <ossman@cendio.se>2011-05-23 12:21:21 +0000
commitc628ba44c1a98cdee6580587bc50380b6cbc46e2 (patch)
tree9aa1b58bf0b1831218e77480a64909593ee38034 /vncviewer/fltk_layout.h
parentbf1f26417247c2b9c794b3a25507a5a20107deab (diff)
downloadtigervnc-c628ba44c1a98cdee6580587bc50380b6cbc46e2.tar.gz
tigervnc-c628ba44c1a98cdee6580587bc50380b6cbc46e2.zip
We need to be careful about feeding FLTK @:s when they will be used in a
label as that is a formatting character. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4440 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'vncviewer/fltk_layout.h')
-rw-r--r--vncviewer/fltk_layout.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/vncviewer/fltk_layout.h b/vncviewer/fltk_layout.h
index 5119188c..61dea211 100644
--- a/vncviewer/fltk_layout.h
+++ b/vncviewer/fltk_layout.h
@@ -33,6 +33,40 @@ static inline int gui_str_len(const char *str)
return (int)(len + 0.5f);
}
+/* Escapes all @ in text as those have special meaning in labels */
+static inline int fltk_escape(const char *in, char *out, size_t maxlen)
+{
+ int len;
+
+ len = 0;
+
+ while (*in != '\0') {
+ if (*in == '@') {
+ if (maxlen >= 3) {
+ *out++ = '@';
+ *out++ = '@';
+ maxlen -= 2;
+ }
+
+ len += 2;
+ } else {
+ if (maxlen >= 2) {
+ *out++ = *in;
+ maxlen--;
+ }
+
+ len += 1;
+ }
+
+ in++;
+ }
+
+ if (maxlen)
+ *out = '\0';
+
+ return len;
+}
+
/**** MARGINS ****/
#define OUTER_MARGIN 10