summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d35bfe6)
raw | patch | inline | side by side (parent: d35bfe6)
author | Max Kellermann <max@duempel.org> | |
Wed, 10 Dec 2008 18:53:10 +0000 (19:53 +0100) | ||
committer | Max Kellermann <max@duempel.org> | |
Wed, 10 Dec 2008 18:53:10 +0000 (19:53 +0100) |
There is only strscroll() left in support.c. Give the source a better
name.
name.
src/Makefile.am | patch | blob | history | |
src/hscroll.c | [new file with mode: 0644] | patch | blob |
src/hscroll.h | [new file with mode: 0644] | patch | blob |
src/screen.c | patch | blob | history | |
src/screen_play.c | patch | blob | history | |
src/screen_utils.c | patch | blob | history | |
src/support.c | [deleted file] | patch | blob | history |
src/support.h | [deleted file] | patch | blob | history |
diff --git a/src/Makefile.am b/src/Makefile.am
index a53e5d0cadf4b3d8a0f83cb50a02cb0b71d2834c..02c7dc8e898d8b72917d570bff254575e8ce2ff1 100644 (file)
--- a/src/Makefile.am
+++ b/src/Makefile.am
screen_utils.h\
list_window.h\
colors.h\
- support.h\
+ hscroll.h \
charset.h \
match.h \
wreadln.h\
screen_file.c\
list_window.c\
colors.c\
- support.c\
+ hscroll.c \
charset.c \
match.c \
wreadln.c\
diff --git a/src/hscroll.c b/src/hscroll.c
--- /dev/null
+++ b/src/hscroll.c
@@ -0,0 +1,77 @@
+/*
+ * (c) 2004 by Kalle Wallin <kaw@linux.se>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include "hscroll.h"
+#include "charset.h"
+#include "config.h"
+
+#include <assert.h>
+#include <ctype.h>
+#include <string.h>
+
+#ifndef NCMPC_MINI
+
+// FIXME: utf-8 length
+char *
+strscroll(char *str, char *separator, int width, scroll_state_t *st)
+{
+ gchar *tmp, *buf;
+ gsize len, size;
+
+ assert(str != NULL);
+ assert(separator != NULL);
+ assert(st != NULL);
+
+ if( st->offset==0 ) {
+ st->offset++;
+ return g_strdup(str);
+ }
+
+ /* create a buffer containing the string and the separator */
+ size = strlen(str)+strlen(separator)+1;
+ tmp = g_malloc(size);
+ g_strlcpy(tmp, str, size);
+ g_strlcat(tmp, separator, size);
+ len = utf8_width(tmp);
+
+ if (st->offset >= len)
+ st->offset = 0;
+
+ /* create the new scrolled string */
+ size = width+1;
+ if (g_utf8_validate(tmp, -1, NULL) ) {
+ int ulen;
+ buf = g_malloc(size*6);// max length of utf8 char is 6
+ g_utf8_strncpy(buf, g_utf8_offset_to_pointer(tmp,st->offset), size);
+ if( (ulen = g_utf8_strlen(buf, -1)) < width )
+ g_utf8_strncpy(buf+strlen(buf), tmp, size - ulen - 1);
+ } else {
+ buf = g_malloc(size);
+ g_strlcpy(buf, tmp+st->offset, size);
+ if (strlen(buf) < (size_t)width)
+ g_strlcat(buf, tmp, size);
+ }
+ if( time(NULL)-st->t >= 1 ) {
+ st->t = time(NULL);
+ st->offset++;
+ }
+ g_free(tmp);
+ return buf;
+}
+
+#endif
diff --git a/src/hscroll.h b/src/hscroll.h
--- /dev/null
+++ b/src/hscroll.h
@@ -0,0 +1,38 @@
+/*
+ * (c) 2004-2008 The Music Player Daemon Project
+ * http://www.musicpd.org/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef HSCROLL_H
+#define HSCROLL_H
+
+#include "config.h"
+
+#include <glib.h>
+
+#ifndef NCMPC_MINI
+
+typedef struct {
+ gsize offset;
+ GTime t; /* GTime is equivalent to time_t */
+} scroll_state_t;
+
+char *strscroll(char *str, char *separator, int width, scroll_state_t *st);
+
+#endif
+
+#endif
diff --git a/src/screen.c b/src/screen.c
index 03e50faabd7e8cc478570c09508f702460e432c2..9c65e781236751e835ce728b727cc8a3eeb63cb0 100644 (file)
--- a/src/screen.c
+++ b/src/screen.c
#include "screen_utils.h"
#include "config.h"
#include "i18n.h"
-#include "support.h"
+#include "hscroll.h"
#include "charset.h"
#include "mpdclient.h"
#include "utils.h"
diff --git a/src/screen_play.c b/src/screen_play.c
index feff1f7ae08f5b60c1ea381f4e257447d9b89564..f8f65ba6255a9b1a8e1c4b446e5eb15a4e66ad9c 100644 (file)
--- a/src/screen_play.c
+++ b/src/screen_play.c
#include "i18n.h"
#include "charset.h"
#include "options.h"
-#include "support.h"
+#include "hscroll.h"
#include "mpdclient.h"
#include "utils.h"
#include "strfsong.h"
diff --git a/src/screen_utils.c b/src/screen_utils.c
index 20b4be1a408cd71eb0f6533d065c63be738397f3..89b364429df9f04f76976b6c9896aba6eecd2cb5 100644 (file)
--- a/src/screen_utils.c
+++ b/src/screen_utils.c
#include "mpdclient.h"
#include "config.h"
#include "i18n.h"
-#include "support.h"
#include "options.h"
#include "colors.h"
#include "wreadln.h"
diff --git a/src/support.c b/src/support.c
--- a/src/support.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * (c) 2004 by Kalle Wallin <kaw@linux.se>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-
-#include "support.h"
-#include "charset.h"
-#include "config.h"
-
-#include <assert.h>
-#include <ctype.h>
-#include <string.h>
-
-#ifndef NCMPC_MINI
-
-// FIXME: utf-8 length
-char *
-strscroll(char *str, char *separator, int width, scroll_state_t *st)
-{
- gchar *tmp, *buf;
- gsize len, size;
-
- assert(str != NULL);
- assert(separator != NULL);
- assert(st != NULL);
-
- if( st->offset==0 ) {
- st->offset++;
- return g_strdup(str);
- }
-
- /* create a buffer containing the string and the separator */
- size = strlen(str)+strlen(separator)+1;
- tmp = g_malloc(size);
- g_strlcpy(tmp, str, size);
- g_strlcat(tmp, separator, size);
- len = utf8_width(tmp);
-
- if (st->offset >= len)
- st->offset = 0;
-
- /* create the new scrolled string */
- size = width+1;
- if (g_utf8_validate(tmp, -1, NULL) ) {
- int ulen;
- buf = g_malloc(size*6);// max length of utf8 char is 6
- g_utf8_strncpy(buf, g_utf8_offset_to_pointer(tmp,st->offset), size);
- if( (ulen = g_utf8_strlen(buf, -1)) < width )
- g_utf8_strncpy(buf+strlen(buf), tmp, size - ulen - 1);
- } else {
- buf = g_malloc(size);
- g_strlcpy(buf, tmp+st->offset, size);
- if (strlen(buf) < (size_t)width)
- g_strlcat(buf, tmp, size);
- }
- if( time(NULL)-st->t >= 1 ) {
- st->t = time(NULL);
- st->offset++;
- }
- g_free(tmp);
- return buf;
-}
-
-#endif
diff --git a/src/support.h b/src/support.h
--- a/src/support.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * (c) 2004-2008 The Music Player Daemon Project
- * http://www.musicpd.org/
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-
-#ifndef SUPPORT_H
-#define SUPPORT_H
-
-#include "config.h"
-
-#include <glib.h>
-
-#ifndef NCMPC_MINI
-
-typedef struct {
- gsize offset;
- GTime t; /* GTime is equivalent to time_t */
-} scroll_state_t;
-
-char *strscroll(char *str, char *separator, int width, scroll_state_t *st);
-
-#endif
-
-#endif