Skip to content

Instantly share code, notes, and snippets.

@Asmageddon
Created May 19, 2015 20:42
Show Gist options
  • Save Asmageddon/ae55148bf06adc475dbc to your computer and use it in GitHub Desktop.
Save Asmageddon/ae55148bf06adc475dbc to your computer and use it in GitHub Desktop.
Browser concept
// Syntax notes:
// Blah!Int is generic type application, equivalent to C++'s Blah<Int>
// Ptr!Type is a pointer to a Type object
// Type? is Option!Type, e.g. either a Type object, or None
// Semantics notes:
// struct is a C-style struct
// union is a typed union, e.g. union!(A, B) can be either A, or B, but not at the same time
// Type notes:
// Splashmap is a map with multiple key and value types, where keys map to only some of the types
// For example, in Splashmap!((A, A), (A, B), (B, B)):
// A can map to either A or B, in other words union!(A, B)
// B can map only to B
// None is both null and nullptr.
Browser = {
// Workspaces are groups of tabs and groups, displayed on the side of the screen, as vertical tabs,
// with each workspace's tabs and groups shown as horizontal tabs
workspaces: OrderedSet!Workspace
// The browser's view - rendered page, address bar, etc.
view: BrowserView
}
Workspace = GroupView
GroupView = struct {
actual_group: Ptr!Group
view_options: GroupViewOptions
}
GroupViewOptions = struct {
// Is this group view compacted, to occupy as much space as a single tab?
compacted: Bool
}
TabOrGroup = union {
tab: Tab;
group: Group
}
Group = struct {
// The set of tabs and subgroup in this group, ordered
content: OrderedSet!TabOrGroup
// Views(with individual view options) for tabs and groups
views: Splashmap!(
(Tab, TabView),
(Group, GroupView)
)
}
TabView = struct {
actual_tab: Ptr!Tab
view_options: TabViewOptions
}
Tab = struct {
// Actual page content, None if tab is not currently loaded
actual_content: PageContent?
// Tags, primarily for bookmarking, but could be used to, e.g.
// display all "homework"-tagged tabs in a group
tags: Set!Tag
options: TabOptions
}
TabOptions = struct {
// If closed, only unload it from memory, reopen on click
persistent: Bool
// Only show an icon, no title, for compacting
minimized: Bool
// Is it currently loaded into memory?
loaded: Bool
// If closed, it will still be stored as a bookmark
bookmarked: Bool
// Is it open in any view right now? Only applicable to bookmarked tabs as they are not moved into history when closed
open: Bool
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment