srctree

Robin Linden parent 7cd96bd2 038d02d0
browser/gui: Add support for simple navigation history

inlinesplit
browser/BUILD added: 38, removed: 3, total 35
@@ -37,6 +37,7 @@ cc_binary(
"//protocol",
"//render",
"//uri",
"//util:history",
"@fmt",
"@imgui",
"@imgui-sfml",
 
browser/gui/app.cpp added: 38, removed: 3, total 35
@@ -180,6 +180,35 @@ int App::run() {
switch_canvas();
break;
}
case sf::Keyboard::Key::Left: {
if (!event.key.alt) {
break;
}
 
auto entry = browse_history_.previous();
if (!entry) {
break;
}
 
browse_history_.pop();
url_buf_ = entry->uri;
navigate();
break;
}
case sf::Keyboard::Key::Right: {
if (!event.key.alt) {
break;
}
 
auto entry = browse_history_.next();
if (!entry) {
break;
}
 
url_buf_ = entry->uri;
navigate();
break;
}
default:
break;
}
@@ -269,6 +298,7 @@ void App::navigate() {
return;
}
 
browse_history_.push(*uri);
engine_.navigate(std::move(*uri));
 
// Make sure the displayed url is still correct if we followed any redirects.
 
browser/gui/app.h added: 38, removed: 3, total 35
@@ -11,6 +11,8 @@
#include "gfx/sfml_canvas.h"
#include "layout/layout.h"
#include "protocol/handler_factory.h"
#include "uri/uri.h"
#include "util/history.h"
 
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/System/Clock.hpp>
@@ -62,6 +64,8 @@ private:
 
unsigned scale_{1};
 
util::History<uri::Uri> browse_history_;
 
void on_navigation_failure(protocol::Error);
void on_page_loaded();
void on_layout_updated();