[−][src]Struct weechat::Weechat
Main Weechat struct that encapsulates common weechat API functions. It has a similar API as the weechat script API.
Implementations
impl Weechat
[src]
pub unsafe fn weechat() -> &'static mut Weechat
[src]
Get the Weechat plugin.
Safety
It is generally safe to call this method, the plugin pointer is valid for the durration of the plugin lifetime. The problem is that many Weechat objects need to have a lifetime bound to a Weechat context object that is only valid for the duration of a callback.
Since this one will have a static lifetime, objects that are fetched from this object may have a longer lifetime than they should.
pub fn log(msg: &str)
[src]
Write a message in WeeChat log file (weechat.log).
Panics
Panics if the method is not called from the main Weechat thread.
pub fn print(msg: &str)
[src]
Display a message on the core weechat buffer.
Panics
Panics if the method is not called from the main Weechat thread.
pub fn color(color_name: &str) -> &str
[src]
Return a string color code for display.
Arguments
color_name
- name of the color
Panics
Panics if the method is not called from the main Weechat thread.
pub fn color_pair(foreground_color: &str, background_color: &str) -> String
[src]
Return a string color pair for display.
Arguments
foreground_color
- Name of the color that should be used for the
foreground.
background_color
- Name of the color that should be used for the
background.
Panics
Panics if the method is not called from the main Weechat thread.
pub fn prefix(prefix: &str) -> &str
[src]
Retrieve a prefix value
Arguments:
prefix
- The name of the prefix.
Valid prefixes are:
- error
- network
- action
- join
- quit
An empty string will be returned if the prefix is not found
Panics
Panics if the method is not called from the main Weechat thread.
pub fn info_get(name: &str, arguments: &str) -> Option<String>
[src]
Get some info from Weechat or a plugin.
Arguments
-
name
- name the info -
arguments
- arguments for the info
pub fn remove_color(string: &str) -> String
[src]
Remove WeeChat colors from a string.
Arguments
string
- The string that should be stripped from Weechat colors.
Panics
Panics if the method is not called from the main Weechat thread.
pub fn eval_string_expression(expression: &str) -> Result<String, ()>
[src]
Evaluate a Weechat expression and return the result.
Arguments
expression
- The expression that should be evaluated.
Panics
Panics if the method is not called from the main Weechat thread.
pub fn home_dir() -> PathBuf
[src]
Get the Weechat homedir.
pub fn execute_modifier(
modifier: &str,
modifier_data: &str,
input_string: &str
) -> Result<String, ()>
[src]
modifier: &str,
modifier_data: &str,
input_string: &str
) -> Result<String, ()>
Execute a modifier.
A modifier takes a string and modifies it in some way, Weechat has a list of defined modifiers. For example to parse a string with some color format (ansi, irc...) and to convert it to another format.
Returns the modified string or an empty error if the string couldn't be modified.
Arguments
-
modifier
- The name of a modifier. The list of modifiers can be found in the official Weechat documentation. -
modifier_data
- Data that will be passed to the modifier, this depends on the modifier that was chosen, consult the list of modifiers in the Weechat documentation. -
input_string
- The string that should be modified.
Panics
Panics if the method is not called from the main Weechat thread.
pub fn bar_item_update(name: &str)
[src]
Update the content of a bar item, by calling its build callback.
Arguments
name
- The name of the bar item that should be updated.
pub fn spawn<F>(future: F) -> Task<F::Output>ⓘ where
F: Future + 'static,
F::Output: 'static,
[src]
F: Future + 'static,
F::Output: 'static,
async
only.Spawn a new Future
on the main Weechat thread.
Panics
Panics if the method is not called from the main Weechat thread.
Example
use weechat::Weechat; use async_std::sync::{channel, Receiver}; use futures::executor::block_on; pub async fn task(receiver: Receiver<String>) { loop { match receiver.recv().await { Ok(m) => { Weechat::print(&format!("Received message: {}", m)); }, Err(e) => { Weechat::print( &format!("Error receiving on channel {:?}", e) ); return; } } } } let (tx, rx) = channel(1000); Weechat::spawn(task(rx)); block_on(tx.send("Hello wordl".to_string()));
pub fn spawn_from_thread<F>(future: F) where
F: Future<Output = ()> + Send + 'static,
[src]
F: Future<Output = ()> + Send + 'static,
async
only.Spawn a new Future
on the main Weechat thread.
This can be called from any thread and will execute the future on the main Weechat thread.
impl Weechat
[src]
pub fn buffer_search(
&self,
plugin_name: &str,
buffer_name: &str
) -> Option<Buffer<'_>>
[src]
&self,
plugin_name: &str,
buffer_name: &str
) -> Option<Buffer<'_>>
Search a buffer by plugin and/or name.
Returns a Buffer if one is found, otherwise None.
Arguments
-
plugin_name
- name of a plugin, the following special value is allowed: "==", the buffer name used is the buffers full name. -
buffer_name
- name of a buffer, if this is an empty string, the current buffer is returned (buffer displayed by current window); if the name starts with (?i), the search is case insensitive.
pub fn current_buffer(&self) -> Buffer<'_>
[src]
Get the currently open buffer
impl Weechat
[src]
pub fn config_get(&self, option_name: &str) -> Option<ConfigOption<'_>>
[src]
Search an option with a full name.
Arguments
option_name
- The full name of the option that should be searched for (format: "file.section.option").
pub fn get_plugin_option(&self, option: &str) -> Option<Cow<'_, str>>
[src]
Get value of a plugin option
pub fn set_plugin_option(&self, option: &str, value: &str) -> OptionChanged
[src]
Set the value of a plugin option
impl Weechat
[src]
pub fn hook_signal_send<'a, D: Into<SignalData<'a>>>(
signal_name: &str,
data: D
) -> ReturnCode
[src]
signal_name: &str,
data: D
) -> ReturnCode
Send a signal.
This will send out a signal and callbacks that are registered with a
SignalHook
to listen to that signal wil get called.
Arguments
-
signal_name
- The name of the signal that should be sent out. Common signals can be found in the Weechat plugin API reference. -
data
- Data that should be provided to the signal callback. This can be a string, an i32 number, or a buffer.
// Fetch the chat history for the buffer. Weechat::hook_signal_send("logger_backlog", &buffer); // Signal that the input text changed. Weechat::hook_signal_send("input_text_changed", "");
impl Weechat
[src]
pub fn get_infolist(
&self,
infolist_name: &str,
arguments: Option<&str>
) -> Result<Infolist<'_>, ()>
[src]
&self,
infolist_name: &str,
arguments: Option<&str>
) -> Result<Infolist<'_>, ()>
Get the infolist with the given name.
Arguments
-
infolist_name
- The name of the infolist to fetch, valid values for this can be found in the Weechat documentation. -
arguments
- Arguments that should be passed to Weechat while fetching the infolist, the format of this will depend on the infolist that is being fetched. A list of infolists and their accompanying arguments can be found in the Weechat documentation.
Example
let infolist = weechat.get_infolist("logger_buffer", None).unwrap(); for item in infolist { let info_buffer = if let Some(buffer) = item.get("buffer") { buffer } else { continue; }; if let InfolistVariable::Buffer(info_buffer) = info_buffer { info_buffer.print("Hello world"); } }
Auto Trait Implementations
impl RefUnwindSafe for Weechat
impl !Send for Weechat
impl !Sync for Weechat
impl Unpin for Weechat
impl UnwindSafe for Weechat
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,