diff --git a/ui/widgets/input_fields.cpp b/ui/widgets/input_fields.cpp index 067c6bc1..e0640422 100644 --- a/ui/widgets/input_fields.cpp +++ b/ui/widgets/input_fields.cpp @@ -959,6 +959,17 @@ const InstantReplaces &InstantReplaces::TextOnly() { return result; } +const InstantReplaces &InstantReplaces::Custom() { + static const auto result = [] { + auto result = InstantReplaces(); + for (auto i = customReplacesMap.constBegin(), e = customReplacesMap.constEnd(); i != e; ++i) { + result.add(i.key(), i.value()); + } + return result; + }(); + return result; +} + FlatInput::FlatInput( QWidget *parent, const style::FlatInput &st, @@ -1473,6 +1484,14 @@ void InputField::setInstantReplaces(const InstantReplaces &replaces) { _mutableInstantReplaces = replaces; } +void InputField::setInstantReplaces(rpl::producer producer) { + std::move( + producer + ) | rpl::start_with_next([=](InstantReplaces replaces) { + _mutableInstantReplaces = replaces; + }, lifetime()); +} + void InputField::setInstantReplacesEnabled(rpl::producer enabled) { std::move( enabled diff --git a/ui/widgets/input_fields.h b/ui/widgets/input_fields.h index 3617e65a..28170d31 100644 --- a/ui/widgets/input_fields.h +++ b/ui/widgets/input_fields.h @@ -43,6 +43,7 @@ struct InstantReplaces { static const InstantReplaces &Default(); static const InstantReplaces &TextOnly(); + static const InstantReplaces &Custom(); int maxLength = 0; Node reverseMap; @@ -250,6 +251,7 @@ class InputField : public RpWidget { void setAdditionalMargin(int margin); void setInstantReplaces(const InstantReplaces &replaces); + void setInstantReplaces(rpl::producer producer); void setInstantReplacesEnabled(rpl::producer enabled); void setMarkdownReplacesEnabled(rpl::producer enabled); void setExtendedContextMenu(rpl::producer value);