[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth/src/widgets textbox.cpp
From: |
David White |
Subject: |
[Wesnoth-cvs-commits] wesnoth/src/widgets textbox.cpp |
Date: |
Mon, 30 May 2005 00:18:31 -0400 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: David White <address@hidden> 05/05/30 04:18:31
Modified files:
src/widgets : textbox.cpp
Log message:
fixed problems with pasting multi-line text into a textbox by making it
accept only the first line
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/widgets/textbox.cpp.diff?tr1=1.77&tr2=1.78&r1=text&r2=text
Patches:
Index: wesnoth/src/widgets/textbox.cpp
diff -u wesnoth/src/widgets/textbox.cpp:1.77
wesnoth/src/widgets/textbox.cpp:1.78
--- wesnoth/src/widgets/textbox.cpp:1.77 Fri Apr 22 22:47:25 2005
+++ wesnoth/src/widgets/textbox.cpp Mon May 30 04:18:31 2005
@@ -1,4 +1,4 @@
-/* $Id: textbox.cpp,v 1.77 2005/04/22 22:47:25 silene Exp $ */
+/* $Id: textbox.cpp,v 1.78 2005/05/30 04:18:31 Sirp Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -19,8 +19,10 @@
#include "../language.hpp"
#include "../log.hpp"
#include "../sdl_utils.hpp"
+#include "../serialization/string_utils.hpp"
#include "../util.hpp"
-#include "../video.hpp"
+#include "../video.hpp"
+
#include "SDL.h"
#include <algorithm>
@@ -74,6 +76,11 @@
if(text_image_.get() == NULL) {
set_text(text);
return;
+ }
+
+ //disallow adding multi-line text to a single-line text box
+ if(wrap_ == false &&
std::find_if(text.begin(),text.end(),utils::isnewline) != text.end()) {
+ return;
}
const wide_string& wtext = utils::string_to_wstring(text);
@@ -480,16 +487,23 @@
{
changed = true;
if(is_selection())
- erase_selection();
+ erase_selection();
+
+ std::string str = copy_from_clipboard();
+
+ //cut off anything after the first newline
+
str.erase(std::find_if(str.begin(),str.end(),utils::isnewline),str.end());
+
+ wide_string s = utils::string_to_wstring(str);
- wide_string s =
utils::string_to_wstring(copy_from_clipboard());
if(text_.size() < max_size_) {
if(s.size() + text_.size() > max_size_)
{
s.resize(max_size_ -
text_.size());
}
text_.insert(text_.begin()+cursor_,
s.begin(), s.end());
cursor_ += s.size();
- }
+ }
+
}
break;
- [Wesnoth-cvs-commits] wesnoth/src/widgets textbox.cpp,
David White <=