aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main.cpp
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2013-03-28 18:33:13 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2014-02-15 15:21:52 +0100
commitc6b6aefd36d49aaf873bca20175b929f828589df (patch)
tree47e46a9e6c869d9d50c27e0d436911cb8bd63ab9 /src/main.cpp
parentd374448af8ab690c810757f73ba44f208db96f30 (diff)
downloadsciteco-c6b6aefd36d49aaf873bca20175b929f828589df.tar.gz
String::get_coord() calculates line and column of a string position
* use to get line and column into a stack frame
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
index d0dfd84..d6b8ab3 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -111,6 +111,29 @@ Interface::process_notify(SCNotification *notify)
#endif
}
+void
+String::get_coord(const gchar *str, gint pos,
+ gint &line, gint &column)
+{
+ line = column = 1;
+
+ for (gint i = 0; i < pos; i++) {
+ switch (str[i]) {
+ case '\r':
+ if (str[i+1] == '\n')
+ i++;
+ /* fall through */
+ case '\n':
+ line++;
+ column = 1;
+ break;
+ default:
+ column++;
+ break;
+ }
+ }
+}
+
#ifdef G_OS_WIN32
/*