Commit 4fd4dd8340

4fd4dd8340aea77e34d74acb9e15519d24676785

parent: 7d85b9d61b

Unsigned

Damir Jelić <poljar@termina.org.uk> · 2020-11-21 15:24 UTC

weechat-matrix: Update for the new prefix enum.

Layout: unified · split

Cargo.lock +1 −3
@@ -1269,6 +1269,7 @@ version = "0.1.0"
12691269dependencies = [
12701270 "async-trait",
12711271 "dashmap",
1272 "futures",
12721273 "futures-timer",
12731274 "http",
12741275 "matrix-sdk-base",
@@ -2883,7 +2884,6 @@ dependencies = [
28832884[[package]]
28842885name = "weechat"
28852886version = "0.4.0"
2886source = "git+https://github.com/poljar/rust-weechat#a418b770a4bfa70457792f9817bc966f61cb9be1"
28872887dependencies = [
28882888 "async-task",
28892889 "async-trait",
@@ -2899,7 +2899,6 @@ dependencies = [
28992899[[package]]
29002900name = "weechat-macro"
29012901version = "0.4.0"
2902source = "git+https://github.com/poljar/rust-weechat#a418b770a4bfa70457792f9817bc966f61cb9be1"
29032902dependencies = [
29042903 "libc",
29052904 "proc-macro2",
@@ -2932,7 +2931,6 @@ dependencies = [
29322931[[package]]
29332932name = "weechat-sys"
29342933version = "0.4.0"
2935source = "git+https://github.com/poljar/rust-weechat#a418b770a4bfa70457792f9817bc966f61cb9be1"
29362934dependencies = [
29372935 "bindgen",
29382936 "libc",
Cargo.toml +1 −1
@@ -26,7 +26,7 @@ chrono = "0.4.19"
2626serde_json = "1.0.59"
2727
2828[dependencies.weechat]
29git = "https://github.com/poljar/rust-weechat"
29path = "/home/poljar/werk/misc/rust-weechat/weechat"
3030features = ["async", "config_macro"]
3131
3232[dependencies.matrix-sdk]
src/commands/devices.rs +2 −2
@@ -7,7 +7,7 @@ use matrix_sdk::identifiers::DeviceIdBox;
77use weechat::{
88 buffer::Buffer,
99 hooks::{Command, CommandCallback, CommandSettings},
10 Args, Weechat,
10 Args, Prefix, Weechat,
1111};
1212
1313use super::parse_and_run;
@@ -86,7 +86,7 @@ impl DevicesCommand {
8686 }
8787 _ => Weechat::print(&format!(
8888 "{}Subcommand isn't implemented",
89 Weechat::prefix("error")
89 Weechat::prefix(Prefix::Error)
9090 )),
9191 }
9292 }
src/commands/matrix.rs +2 −2
@@ -7,7 +7,7 @@ use url::Url;
77use weechat::{
88 buffer::Buffer,
99 hooks::{Command, CommandCallback, CommandSettings},
10 Args, Weechat,
10 Args, Prefix, Weechat,
1111};
1212
1313use super::parse_and_run;
@@ -174,7 +174,7 @@ Use /matrix [command] help to find out more.\n",
174174 fn server_not_found(&self, server_name: &str) {
175175 Weechat::print(&format!(
176176 "{}{}: Server \"{}{}{}\" not found.",
177 Weechat::prefix("error"),
177 Weechat::prefix(Prefix::Error),
178178 PLUGIN_NAME,
179179 Weechat::color("chat_server"),
180180 server_name,
src/commands/mod.rs +2 −2
@@ -6,17 +6,17 @@ use weechat::{
66
77use crate::{config::ConfigHandle, Servers};
88
9mod buffer_clear;
910mod devices;
1011mod keys;
1112mod matrix;
1213mod page_up;
13mod buffer_clear;
1414
15use buffer_clear::BufferClearCommand;
1516use devices::DevicesCommand;
1617use keys::KeysCommand;
1718use matrix::MatrixCommand;
1819use page_up::PageUpCommand;
19use buffer_clear::BufferClearCommand;
2020
2121pub struct Commands {
2222 _matrix: Command,
src/render.rs +12 −10
@@ -20,7 +20,7 @@ use matrix_sdk::{
2020 uuid::Uuid,
2121};
2222
23use weechat::Weechat;
23use weechat::{Prefix, Weechat};
2424
2525use crate::room::WeechatRoomMember;
2626
@@ -173,7 +173,7 @@ impl Render for EmoteMessageEventContent {
173173 type RenderContext = WeechatRoomMember;
174174
175175 fn prefix(&self, _: &WeechatRoomMember) -> String {
176 Weechat::prefix("action").to_owned()
176 Weechat::prefix(Prefix::Action).to_owned()
177177 }
178178
179179 fn render(&self, sender: &Self::RenderContext) -> RenderedContent {
@@ -195,7 +195,7 @@ impl Render for LocationMessageEventContent {
195195 type RenderContext = WeechatRoomMember;
196196
197197 fn prefix(&self, _: &WeechatRoomMember) -> String {
198 Weechat::prefix("action").to_owned()
198 Weechat::prefix(Prefix::Action).to_owned()
199199 }
200200
201201 fn render(&self, sender: &Self::RenderContext) -> RenderedContent {
@@ -223,7 +223,7 @@ impl Render for NoticeMessageEventContent {
223223 type RenderContext = WeechatRoomMember;
224224
225225 fn prefix(&self, _: &WeechatRoomMember) -> String {
226 Weechat::prefix("action").to_owned()
226 Weechat::prefix(Prefix::Action).to_owned()
227227 }
228228
229229 fn render(&self, sender: &Self::RenderContext) -> RenderedContent {
@@ -233,7 +233,7 @@ impl Render for NoticeMessageEventContent {
233233 {color_delim}({color_reset}{}{color_delim}){color_reset}: {}",
234234 sender.nick.borrow(),
235235 self.body,
236 prefix = Weechat::prefix("network"),
236 prefix = Weechat::prefix(Prefix::Network),
237237 color_notice = Weechat::color("irc.color.notice"),
238238 color_delim = Weechat::color("chat_delimiters"),
239239 color_reset = Weechat::color("reset"),
@@ -253,7 +253,7 @@ impl Render for ServerNoticeMessageEventContent {
253253 type RenderContext = WeechatRoomMember;
254254
255255 fn prefix(&self, _: &WeechatRoomMember) -> String {
256 Weechat::prefix("action").to_owned()
256 Weechat::prefix(Prefix::Action).to_owned()
257257 }
258258
259259 fn render(&self, sender: &Self::RenderContext) -> RenderedContent {
@@ -262,7 +262,7 @@ impl Render for ServerNoticeMessageEventContent {
262262 {color_delim}({color_reset}{}{color_delim}){color_reset}: {}",
263263 sender.nick.borrow(),
264264 self.body,
265 prefix = Weechat::prefix("network"),
265 prefix = Weechat::prefix(Prefix::Network),
266266 color_notice = Weechat::color("irc.color.notice"),
267267 color_delim = Weechat::color("chat_delimiters"),
268268 color_reset = Weechat::color("reset"),
@@ -472,9 +472,11 @@ pub fn render_membership(
472472 }
473473
474474 let (prefix, color_action) = match change_op {
475 Joined => ("join", "green"),
476 Banned | ProfileChanged { .. } | Invited => ("network", "magenta"),
477 _ => ("quit", "red"),
475 Joined => (Prefix::Join, "green"),
476 Banned | ProfileChanged { .. } | Invited => {
477 (Prefix::Network, "magenta")
478 }
479 _ => (Prefix::Quit, "red"),
478480 };
479481
480482 let color_action = Weechat::color(color_action);
src/server.rs +3 −3
@@ -75,7 +75,7 @@ use matrix_sdk::{
7575use weechat::{
7676 buffer::{BufferBuilder, BufferHandle},
7777 config::{BooleanOptionSettings, ConfigSection, StringOptionSettings},
78 Weechat,
78 Prefix, Weechat,
7979};
8080
8181use crate::{
@@ -794,12 +794,12 @@ impl InnerServer {
794794
795795 /// Print an network message to the server buffer.
796796 pub fn print_network(&self, message: &str) {
797 self.print_with_prefix(Weechat::prefix("network"), message);
797 self.print_with_prefix(&Weechat::prefix(Prefix::Network), message);
798798 }
799799
800800 /// Print an error message to the server buffer.
801801 pub fn print_error(&self, message: &str) {
802 self.print_with_prefix(Weechat::prefix("error"), message);
802 self.print_with_prefix(&Weechat::prefix(Prefix::Error), message);
803803 }
804804
805805 /// Is the server connected.