mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 08:12:43 +00:00 
			
		
		
		
	 395e4210ef
			
		
	
	
		395e4210ef
		
	
	
	
	
		
			
			This also adds a toolbar and a menu which allow you to navigate back and forth through history ^)
		
			
				
	
	
		
			33 lines
		
	
	
	
		
			577 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
	
		
			577 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| #include "History.h"
 | |
| 
 | |
| void History::push(const StringView& history_item)
 | |
| {
 | |
|     m_items.shrink(m_current_history_item + 1);
 | |
|     m_items.append(history_item);
 | |
|     m_current_history_item++;
 | |
| }
 | |
| 
 | |
| String History::current()
 | |
| {
 | |
|     if (m_current_history_item == -1)
 | |
|         return {};
 | |
|     return m_items[m_current_history_item];
 | |
| }
 | |
| 
 | |
| void History::go_back()
 | |
| {
 | |
|     ASSERT(can_go_back());
 | |
|     m_current_history_item--;
 | |
| }
 | |
| 
 | |
| void History::go_forward()
 | |
| {
 | |
|     ASSERT(can_go_forward());
 | |
|     m_current_history_item++;
 | |
| }
 | |
| 
 | |
| void History::clear()
 | |
| {
 | |
|     m_items = {};
 | |
|     m_current_history_item = -1;
 | |
| }
 |