Negotiate EOR and display prompts.
This commit is contained in:
parent
26c50e8ab3
commit
bd107f4325
@ -322,6 +322,16 @@ pub fn install_lua_globals(
|
||||
register_stateless_class_function!(mud_class_table, "new", new_mud);
|
||||
register_class_function!(mud_class_table, "term_resized", mud_term_resized);
|
||||
register_class_function!(mud_class_table, local_naws_enabled);
|
||||
register_stateless_class_function!(
|
||||
mud_class_table,
|
||||
"local_termtype_enabled",
|
||||
opt_enabled_noop
|
||||
);
|
||||
register_stateless_class_function!(
|
||||
mud_class_table,
|
||||
"remote_eor_enabled",
|
||||
opt_enabled_noop
|
||||
);
|
||||
|
||||
macro_rules! register_class_nop {
|
||||
($class_table: ident, $sym: ident) => {
|
||||
|
@ -4,7 +4,7 @@ use piccolo::{
|
||||
self, async_sequence, Callback, CallbackReturn, Context, FromValue, Function, IntoValue,
|
||||
SequenceReturn, StashedTable, StashedUserData, StashedValue, Table, UserData, Value,
|
||||
};
|
||||
use telopt::TERMTYPE_TELOPT;
|
||||
use telopt::{EOR_TELOPT, TERMTYPE_TELOPT};
|
||||
use wasm_bindgen::JsValue;
|
||||
use web_sys::{console, window};
|
||||
use yew::UseStateSetter;
|
||||
@ -241,6 +241,7 @@ pub(super) fn connect_mud<'gc>(
|
||||
set_option_supported(ctx, &conntab, &NAWS_TELOPT, &Side::Us);
|
||||
}
|
||||
set_option_supported(ctx, &conntab, &TERMTYPE_TELOPT, &Side::Us);
|
||||
set_option_supported(ctx, &conntab, &EOR_TELOPT, &Side::Him);
|
||||
|
||||
// Call conntab:new...
|
||||
let seq = async_sequence(&ctx, |locals, mut seq| {
|
||||
@ -361,6 +362,10 @@ pub(super) fn mudoutput<'gc>(ctx: Context<'gc>, _global_memo: &GlobalMemoCell) -
|
||||
.collect();
|
||||
async move {
|
||||
for (func_name, params) in fns {
|
||||
console::log_1(&JsValue::from_str(&format!(
|
||||
"Calling {}",
|
||||
func_name
|
||||
)));
|
||||
call_checking_metatable::<StashedTable, _>(
|
||||
&mut seq,
|
||||
conntab.clone(),
|
||||
@ -478,7 +483,48 @@ pub(super) fn mudoutput_prompt<'gc>(
|
||||
ctx: Context<'gc>,
|
||||
_global_memo: &GlobalMemoCell,
|
||||
) -> Callback<'gc> {
|
||||
Callback::from_fn(&ctx, move |_ctx, _ex, _stack| Ok(CallbackReturn::Return))
|
||||
Callback::from_fn(&ctx, move |ctx, _ex, mut stack| {
|
||||
let mud = Table::from_value(
|
||||
ctx,
|
||||
stack
|
||||
.pop_front()
|
||||
.ok_or_else(|| anyhow::Error::msg("Missing muds:mudoutput_line self"))?,
|
||||
)?;
|
||||
let prompt = piccolo::String::from_value(
|
||||
ctx,
|
||||
stack
|
||||
.pop_front()
|
||||
.ok_or_else(|| anyhow::Error::msg("Missing muds:mudoutput_line line"))?,
|
||||
)?;
|
||||
|
||||
let frameroutes: Table = mud.get(ctx, "frameroutes")?;
|
||||
|
||||
let seq = async_sequence(&ctx, |locals, mut seq| {
|
||||
let frameroutes: Vec<StashedTable> = frameroutes
|
||||
.iter()
|
||||
.filter_map(|fr| {
|
||||
Table::from_value(ctx, fr.1)
|
||||
.ok()
|
||||
.map(|v| locals.stash(&ctx, v))
|
||||
})
|
||||
.collect();
|
||||
let line = locals.stash(&ctx, prompt.into_value(ctx));
|
||||
async move {
|
||||
for frameroute in frameroutes {
|
||||
call_checking_metatable::<StashedTable, _>(
|
||||
&mut seq,
|
||||
frameroute,
|
||||
"route",
|
||||
&[line.clone()],
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
Ok(SequenceReturn::Return)
|
||||
}
|
||||
});
|
||||
|
||||
Ok(CallbackReturn::Sequence(seq))
|
||||
})
|
||||
}
|
||||
|
||||
fn name_telopt(ctx: Context, optno: u8) -> anyhow::Result<String> {
|
||||
@ -933,6 +979,10 @@ pub(super) fn local_naws_enabled<'gc>(
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) fn opt_enabled_noop<'gc>(ctx: Context<'gc>) -> Callback<'gc> {
|
||||
Callback::from_fn(&ctx, move |_ctx, _ex, _stack| Ok(CallbackReturn::Return))
|
||||
}
|
||||
|
||||
fn name_mud<'gc>(ctx: Context<'gc>, mud: &Table<'gc>) -> String {
|
||||
fn name_mud_internal<'gc>(ctx: Context<'gc>, mud: &Table<'gc>) -> anyhow::Result<String> {
|
||||
let socket: Value<'gc> = mud.get(ctx, "socket")?;
|
||||
|
@ -428,6 +428,7 @@ pub fn handle_incoming_dont<'gc, T: SendOptNeg>(
|
||||
}
|
||||
|
||||
pub const TERMTYPE_TELOPT: Telopt = Telopt(24);
|
||||
pub const EOR_TELOPT: Telopt = Telopt(25);
|
||||
pub const NAWS_TELOPT: Telopt = Telopt(31);
|
||||
pub const GMCP_TELOPT: Telopt = Telopt(201);
|
||||
|
||||
@ -523,6 +524,9 @@ pub fn configure_telopt_table<'gc>(ctx: Context<'gc>, table: &Table<'gc>) {
|
||||
table
|
||||
.set(ctx, "naws", NAWS_TELOPT.0)
|
||||
.expect("Can't set NAWS in telopt table");
|
||||
table
|
||||
.set(ctx, "eor", EOR_TELOPT.0)
|
||||
.expect("Can't set EOR in telopt table");
|
||||
table
|
||||
.set(ctx, "gmcp", GMCP_TELOPT.0)
|
||||
.expect("Can't set GMCP in telopt table");
|
||||
|
Loading…
Reference in New Issue
Block a user