|
|
@ -24,20 +24,52 @@ History::History() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Actions
|
|
|
|
// Actions
|
|
|
|
void History::back() |
|
|
|
bool History::back( |
|
|
|
|
|
|
|
Memory & match, |
|
|
|
|
|
|
|
bool follow |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
try |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (has_memory_back()) |
|
|
|
match = memory.at( |
|
|
|
|
|
|
|
index - 1 |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (follow) |
|
|
|
{ |
|
|
|
{ |
|
|
|
index--; |
|
|
|
index--; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void History::forward() |
|
|
|
catch (std::out_of_range) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (has_memory_forward()) |
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool History::forward( |
|
|
|
|
|
|
|
Memory & match, |
|
|
|
|
|
|
|
bool follow |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
try |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
match = memory.at( |
|
|
|
|
|
|
|
index + 1 |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (follow) |
|
|
|
{ |
|
|
|
{ |
|
|
|
index++; |
|
|
|
index++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
catch (std::out_of_range) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void History::push( |
|
|
|
void History::push( |
|
|
@ -61,82 +93,19 @@ void History::push( |
|
|
|
|
|
|
|
|
|
|
|
void History::refresh() |
|
|
|
void History::refresh() |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
Memory match; |
|
|
|
|
|
|
|
|
|
|
|
historyBack->set_sensitive( |
|
|
|
historyBack->set_sensitive( |
|
|
|
has_memory_back() |
|
|
|
back( |
|
|
|
|
|
|
|
match, |
|
|
|
|
|
|
|
false |
|
|
|
|
|
|
|
) |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
historyForward->set_sensitive( |
|
|
|
historyForward->set_sensitive( |
|
|
|
has_memory_forward() |
|
|
|
forward( |
|
|
|
); |
|
|
|
match, |
|
|
|
} |
|
|
|
false |
|
|
|
|
|
|
|
) |
|
|
|
// Getters
|
|
|
|
|
|
|
|
bool History::has_memory_back() // @TODO & MEMORY
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
try |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
const History::Memory & MEMORY = get_memory_back(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
catch (const std::out_of_range & EXCEPTION) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool History::has_memory_forward() // @TODO & MEMORY
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
try |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
const History::Memory & MEMORY = get_memory_forward(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
catch (const std::out_of_range & EXCEPTION) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Copying getters
|
|
|
|
|
|
|
|
Glib::ustring History::make_memory_back_request() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Glib::ustring request; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (has_memory_back()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
request = get_memory_back().request; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return request; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Glib::ustring History::make_memory_forward_request() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Glib::ustring request; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (has_memory_forward()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
request = get_memory_forward().request; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return request; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Private helpers
|
|
|
|
|
|
|
|
History::Memory & History::get_memory_back() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return memory.at( |
|
|
|
|
|
|
|
index - 1 |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
History::Memory & History::get_memory_forward() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return memory.at( |
|
|
|
|
|
|
|
index + 1 |
|
|
|
|
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |