summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--core/bind/core_bind.cpp7
-rw-r--r--core/bind/core_bind.h4
-rw-r--r--core/os/os.h4
-rw-r--r--doc/base/classes.xml36
-rw-r--r--drivers/unix/os_unix.cpp3
-rw-r--r--platform/nacl/os_nacl.cpp6
-rw-r--r--scene/gui/text_edit.cpp24
-rw-r--r--scene/gui/text_edit.h1
9 files changed, 64 insertions, 24 deletions
diff --git a/.gitignore b/.gitignore
index bf5be79d55..15ca139916 100644
--- a/.gitignore
+++ b/.gitignore
@@ -65,6 +65,9 @@ platform/android/libs/play_licensing/gen/*
.deps/*
.dirstamp
+# Vim temp files
+*.swo
+*.swp
# QT project files
*.config
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index bf611f89c9..915cbc0578 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -508,11 +508,11 @@ Dictionary _OS::get_time(bool utc) const {
}
/**
- * Get a dictionary of time values when given epoc time
+ * Get a dictionary of time values when given epoch time
*
* Dictionary Time values will be a union if values from #get_time
* and #get_date dictionaries (with the exception of dst =
- * day light standard time, as it cannot be determined from epoc)
+ * day light standard time, as it cannot be determined from epoch)
*/
Dictionary _OS::get_time_from_unix_time( uint64_t unix_time_val) const {
@@ -552,7 +552,8 @@ Dictionary _OS::get_time_from_unix_time( uint64_t unix_time_val) const {
imonth++;
}
- date.month = static_cast<OS::Month>(imonth);
+ /// Add 1 to month to make sure months are indexed starting at 1
+ date.month = static_cast<OS::Month>(imonth+1);
date.day = dayno + 1;
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index ab11c4804c..db5ff42cfe 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -81,7 +81,9 @@ public:
};
enum Month {
- MONTH_JANUARY,
+ /// Start at 1 to follow Windows SYSTEMTIME structure
+ /// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724950(v=vs.85).aspx
+ MONTH_JANUARY = 1,
MONTH_FEBRUARY,
MONTH_MARCH,
MONTH_APRIL,
diff --git a/core/os/os.h b/core/os/os.h
index 73726feb37..160c0495bb 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -224,7 +224,9 @@ public:
};
enum Month {
- MONTH_JANUARY,
+ /// Start at 1 to follow Windows SYSTEMTIME structure
+ /// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724950(v=vs.85).aspx
+ MONTH_JANUARY = 1,
MONTH_FEBRUARY,
MONTH_MARCH,
MONTH_APRIL,
diff --git a/doc/base/classes.xml b/doc/base/classes.xml
index 04e08f166e..bc8bec4bbf 100644
--- a/doc/base/classes.xml
+++ b/doc/base/classes.xml
@@ -20639,6 +20639,18 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8)
<description>
</description>
</method>
+ <method name="get_time_from_unix_time" qualifiers="const">
+ <return type="Dictionary">
+ </return>
+ <argument index="0" name="unix_time_val" type="int">
+ </argument>
+ <description>
+ Get a dictionary of time values when given epoch time.
+ Dictionary Time values will be a union of values from [method get_time]
+ and [method get_date] dictionaries (with the exception of dst =
+ day light standard time, as it cannot be determined from epoc)
+ </description>
+ </method>
<method name="get_time_zone_info" qualifiers="const">
<return type="Dictionary">
</return>
@@ -20922,29 +20934,29 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8)
</constant>
<constant name="DAY_SATURDAY" value="6">
</constant>
- <constant name="MONTH_JANUARY" value="0">
+ <constant name="MONTH_JANUARY" value="1">
</constant>
- <constant name="MONTH_FEBRUARY" value="1">
+ <constant name="MONTH_FEBRUARY" value="2">
</constant>
- <constant name="MONTH_MARCH" value="2">
+ <constant name="MONTH_MARCH" value="3">
</constant>
- <constant name="MONTH_APRIL" value="3">
+ <constant name="MONTH_APRIL" value="4">
</constant>
- <constant name="MONTH_MAY" value="4">
+ <constant name="MONTH_MAY" value="5">
</constant>
- <constant name="MONTH_JUNE" value="5">
+ <constant name="MONTH_JUNE" value="6">
</constant>
- <constant name="MONTH_JULY" value="6">
+ <constant name="MONTH_JULY" value="7">
</constant>
- <constant name="MONTH_AUGUST" value="7">
+ <constant name="MONTH_AUGUST" value="8">
</constant>
- <constant name="MONTH_SEPTEMBER" value="8">
+ <constant name="MONTH_SEPTEMBER" value="9">
</constant>
- <constant name="MONTH_OCTOBER" value="9">
+ <constant name="MONTH_OCTOBER" value="10">
</constant>
- <constant name="MONTH_NOVEMBER" value="10">
+ <constant name="MONTH_NOVEMBER" value="11">
</constant>
- <constant name="MONTH_DECEMBER" value="11">
+ <constant name="MONTH_DECEMBER" value="12">
</constant>
<constant name="SCREEN_ORIENTATION_LANDSCAPE" value="0">
</constant>
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp
index a004a116e0..84b6dc24dc 100644
--- a/drivers/unix/os_unix.cpp
+++ b/drivers/unix/os_unix.cpp
@@ -251,6 +251,9 @@ OS::Date OS_Unix::get_date(bool utc) const {
lt=localtime(&t);
Date ret;
ret.year=1900+lt->tm_year;
+ // Index starting at 1 to match OS_Unix::get_date
+ // and Windows SYSTEMTIME and tm_mon follows the typical structure
+ // of 0-11, noted here: http://www.cplusplus.com/reference/ctime/tm/
ret.month=(Month)(lt->tm_mon + 1);
ret.day=lt->tm_mday;
ret.weekday=(Weekday)lt->tm_wday;
diff --git a/platform/nacl/os_nacl.cpp b/platform/nacl/os_nacl.cpp
index de6a15525b..e2a92ee8c7 100644
--- a/platform/nacl/os_nacl.cpp
+++ b/platform/nacl/os_nacl.cpp
@@ -249,7 +249,11 @@ OS::Date OSNacl::get_date(bool utc) const {
lt=localtime(&t);
Date ret;
ret.year=lt->tm_year;
- ret.month=(Month)lt->tm_mon;
+
+ // Index starting at 1 to match OS_Unix::get_date
+ // and Windows SYSTEMTIME and tm_mon follows the typical structure
+ // of 0-11, noted here: http://www.cplusplus.com/reference/ctime/tm/
+ ret.month=(Month)(lt->tm_mon+1);
ret.day=lt->tm_mday;
ret.weekday=(Weekday)lt->tm_wday;
ret.dst=lt->tm_isdst;
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 32f4be5d17..05e49a5104 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -2515,6 +2515,7 @@ void TextEdit::_insert_text(int p_line, int p_char,const String& p_text,int *r_e
//see if it shold just be set as current op
if (current_op.type!=op.type) {
+ op.prev_version = get_version();
_push_current_op();
current_op=op;
@@ -2522,6 +2523,7 @@ void TextEdit::_insert_text(int p_line, int p_char,const String& p_text,int *r_e
}
//see if it can be merged
if (current_op.to_line!=p_line || current_op.to_column!=p_char) {
+ op.prev_version = get_version();
_push_current_op();
current_op=op;
return; //set as current op, return
@@ -2565,6 +2567,7 @@ void TextEdit::_remove_text(int p_from_line, int p_from_column,int p_to_line,int
//see if it shold just be set as current op
if (current_op.type!=op.type) {
+ op.prev_version = get_version();
_push_current_op();
current_op=op;
return; //set as current op, return
@@ -2585,6 +2588,7 @@ void TextEdit::_remove_text(int p_from_line, int p_from_column,int p_to_line,int
//return; //update current op
}
+ op.prev_version = get_version();
_push_current_op();
current_op=op;
@@ -3418,11 +3422,15 @@ void TextEdit::undo() {
else
undo_stack_pos=undo_stack_pos->prev();
- _do_text_op( undo_stack_pos->get(),true);
+ TextOperation op = undo_stack_pos->get();
+ _do_text_op(op, true);
+ current_op.version=op.prev_version;
if(undo_stack_pos->get().chain_backward) {
do {
undo_stack_pos = undo_stack_pos->prev();
- _do_text_op(undo_stack_pos->get(), true);
+ op = undo_stack_pos->get();
+ _do_text_op(op, true);
+ current_op.version = op.prev_version;
} while(!undo_stack_pos->get().chain_forward);
}
@@ -3438,15 +3446,19 @@ void TextEdit::redo() {
if (undo_stack_pos==NULL)
return; //nothing to do.
- _do_text_op(undo_stack_pos->get(), false);
+ TextOperation op = undo_stack_pos->get();
+ _do_text_op(op, false);
+ current_op.version = op.version;
if(undo_stack_pos->get().chain_forward) {
do {
undo_stack_pos=undo_stack_pos->next();
- _do_text_op(undo_stack_pos->get(), false);
+ op = undo_stack_pos->get();
+ _do_text_op(op, false);
+ current_op.version = op.version;
} while(!undo_stack_pos->get().chain_backward);
}
- cursor_set_line(undo_stack_pos->get().from_line);
- cursor_set_column(undo_stack_pos->get().from_column);
+ cursor_set_line(undo_stack_pos->get().to_line);
+ cursor_set_column(undo_stack_pos->get().to_column);
undo_stack_pos=undo_stack_pos->next();
update();
}
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index 2eff8e89c7..207d6eb131 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -156,6 +156,7 @@ class TextEdit : public Control {
int from_line,from_column;
int to_line, to_column;
String text;
+ uint32_t prev_version;
uint32_t version;
bool chain_forward;
bool chain_backward;