Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc56386c

Browse files
committed
Switch to compose the style of style classes
1 parentf1074b9 commitc56386c

File tree

5 files changed

+32
-15
lines changed

5 files changed

+32
-15
lines changed

‎src/display_list/annotation.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ impl<'d> Annotation<'d> {
1313
pubfnfmt_with_style(
1414
&self,
1515
f:&mut fmt::Formatter<'_>,
16-
style:&implStylesheet,
16+
_style:&implStylesheet,
1717
) -> fmt::Result{
18-
style.format(f,&self.annotation_type,self.label)
19-
//f.write_str(self.label)
18+
//style.format(f, &self.annotation_type, self.label)
19+
f.write_str(self.label)
2020
}
2121
}
2222

‎src/display_list/line.rs‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::fmt::Write;
33

44
usesuper::annotation::Annotation;
55
usecrate::annotation::AnnotationType;
6-
usecrate::styles::Stylesheet;
6+
usecrate::styles::{StyleClass,Stylesheet};
77

88
#[derive(Debug,Clone)]
99
pubenumDisplayLine<'d>{
@@ -116,7 +116,14 @@ impl<'d> DisplayRawLine<'d> {
116116
f.write_char('\n')
117117
}
118118
Self::Annotation{ annotation, ..} =>{
119-
style.format(f,&annotation.annotation_type,&annotation.annotation_type)?;
119+
style.format(
120+
f,
121+
&[
122+
StyleClass::TitleLineAnnotationType,
123+
StyleClass::AnnotationTypeError,
124+
],
125+
&annotation.annotation_type,
126+
)?;
120127
ifletSome(id) = annotation.id{
121128
write!(f,"[{}]", id)?;
122129
}

‎src/styles/color.rs‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
usesuper::Stylesheet;
1+
usesuper::{StyleClass,Stylesheet};
22
usecrate::AnnotationType;
33
use std::fmt;
44
use std::fmt::Display;
55

66
use ansi_term::Colour::{Red,Yellow};
7+
use ansi_term::Style;
78

89
#[derive(Default)]
910
pubstructStylesheetColor{}
@@ -12,13 +13,17 @@ impl Stylesheet for StylesheetColor {
1213
fnformat(
1314
&self,
1415
f:&mut fmt::Formatter,
15-
annotation_type:&AnnotationType,
16+
styles:&[StyleClass],
1617
value:implDisplay,
1718
) -> fmt::Result{
18-
match annotation_type{
19-
AnnotationType::Error =>write!(f,"{}",Red.paint(value.to_string()).to_string()),
20-
AnnotationType::Warning =>write!(f,"{}",Yellow.paint(value.to_string()).to_string()),
21-
_ =>write!(f,"{}", value),
19+
letmut style =Style::new();
20+
for sin styles{
21+
match s{
22+
StyleClass::TitleLineAnnotationType => style = style.bold(),
23+
StyleClass::TitleLine => style = style.bold(),
24+
StyleClass::AnnotationTypeError => style = style.fg(Red),
25+
}
2226
}
27+
write!(f,"{}", style.paint(value.to_string()))
2328
}
2429
}

‎src/styles/mod.rs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,17 @@ use std::fmt::Display;
66
pubmod color;
77
pubmod plain;
88

9+
pubenumStyleClass{
10+
TitleLineAnnotationType,
11+
TitleLine,
12+
AnnotationTypeError,
13+
}
14+
915
pubtraitStylesheet{
1016
fnformat(
1117
&self,
1218
f:&mut fmt::Formatter,
13-
annotation_type:&AnnotationType,
19+
style:&[StyleClass],
1420
value:implDisplay,
1521
) -> fmt::Result;
1622
}

‎src/styles/plain.rs‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
usesuper::Stylesheet;
2-
usecrate::AnnotationType;
1+
usesuper::{StyleClass,Stylesheet};
32
use std::fmt;
43
use std::fmt::Display;
54

@@ -10,7 +9,7 @@ impl Stylesheet for StylesheetPlain {
109
fnformat(
1110
&self,
1211
f:&mut fmt::Formatter,
13-
_annotation_type:&AnnotationType,
12+
_style:&[StyleClass],
1413
value:implDisplay,
1514
) -> fmt::Result{
1615
write!(f,"{}", value)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp