Skip to content
This repository has been archived by the owner on Feb 12, 2018. It is now read-only.

Commit

Permalink
Serializable themes
Browse files Browse the repository at this point in the history
  • Loading branch information
trishume committed Jun 13, 2016
1 parent bbf58cf commit 2a46c06
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub struct ScopeRepository {
atom_index_map: HashMap<String, usize>,
}

#[derive(Debug, Clone, PartialEq, Eq, Default)]
#[derive(Debug, Clone, PartialEq, Eq, Default, RustcEncodable, RustcDecodable)]
pub struct ScopeStack {
scopes: Vec<Scope>,
}
Expand Down
4 changes: 2 additions & 2 deletions src/theme/selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
use scope::*;
use std::str::FromStr;

#[derive(Debug, Clone, PartialEq, Eq, Default)]
#[derive(Debug, Clone, PartialEq, Eq, Default, RustcEncodable, RustcDecodable)]
pub struct ScopeSelector {
path: ScopeStack,
exclude: Option<ScopeStack>,
}

#[derive(Debug, Clone, PartialEq, Eq, Default)]
#[derive(Debug, Clone, PartialEq, Eq, Default, RustcEncodable, RustcDecodable)]
pub struct ScopeSelectors {
pub selectors: Vec<ScopeSelector>,
}
Expand Down
7 changes: 4 additions & 3 deletions src/theme/style.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// Code based on https://github.com/defuz/sublimate/blob/master/src/core/syntax/style.rs
/// released under the MIT license by @defuz
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable)]
pub struct Style {
/// Foreground color.
pub foreground: Color,
Expand All @@ -10,7 +10,7 @@ pub struct Style {
pub font_style: FontStyle,
}

#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable)]
pub struct StyleModifier {
/// Foreground color.
pub foreground: Option<Color>,
Expand All @@ -33,7 +33,7 @@ pub const WHITE: Color = Color {
a: 0xFF,
};

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable)]
pub struct Color {
pub r: u8,
pub g: u8,
Expand All @@ -42,6 +42,7 @@ pub struct Color {
}

bitflags! {
#[derive(RustcEncodable, RustcDecodable)]
flags FontStyle: u8 {
const FONT_STYLE_BOLD = 1,
const FONT_STYLE_UNDERLINE = 2,
Expand Down
8 changes: 4 additions & 4 deletions src/theme/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ use scope::ParseScopeError;

use self::ParseThemeError::*;

#[derive(Debug, Default)]
#[derive(Debug, Default, RustcEncodable, RustcDecodable)]
pub struct Theme {
pub name: Option<String>,
pub author: Option<String>,
pub settings: ThemeSettings,
pub scopes: Vec<ThemeItem>,
}

#[derive(Debug, Default)]
#[derive(Debug, Default, RustcEncodable, RustcDecodable)]
pub struct ThemeSettings {
/// Foreground color for the view.
pub foreground: Option<Color>,
Expand Down Expand Up @@ -89,14 +89,14 @@ pub struct ThemeSettings {
pub highlight_foreground: Option<Color>,
}

#[derive(Debug, Default)]
#[derive(Debug, Default, RustcEncodable, RustcDecodable)]
pub struct ThemeItem {
/// Target scope name.
pub scope: ScopeSelectors,
pub style: StyleModifier,
}

#[derive(Debug)]
#[derive(Debug, RustcEncodable, RustcDecodable)]
pub enum UnderlineOption {
None,
Underline,
Expand Down

0 comments on commit 2a46c06

Please sign in to comment.