2017-12-28 13:06:06 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2017-12-28 13:06:06 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2017-12-28 13:06:06 +00:00
|
|
|
*/
|
2020-10-10 09:15:37 +00:00
|
|
|
#include "ui/text/text_options.h"
|
|
|
|
|
2018-12-18 13:56:38 +00:00
|
|
|
#include "styles/style_window.h"
|
2020-10-10 09:15:37 +00:00
|
|
|
#include "styles/style_chat.h"
|
2017-12-28 13:06:06 +00:00
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
TextParseOptions HistoryTextOptions = {
|
|
|
|
TextParseLinks
|
|
|
|
| TextParseMentions
|
|
|
|
| TextParseHashtags
|
|
|
|
| TextParseMultiline
|
|
|
|
| TextParseMarkdown, // flags
|
|
|
|
0, // maxw
|
|
|
|
0, // maxh
|
|
|
|
Qt::LayoutDirectionAuto, // dir
|
|
|
|
};
|
|
|
|
|
|
|
|
TextParseOptions HistoryBotOptions = {
|
|
|
|
TextParseLinks
|
|
|
|
| TextParseMentions
|
|
|
|
| TextParseHashtags
|
|
|
|
| TextParseBotCommands
|
|
|
|
| TextParseMultiline
|
|
|
|
| TextParseMarkdown, // flags
|
|
|
|
0, // maxw
|
|
|
|
0, // maxh
|
|
|
|
Qt::LayoutDirectionAuto, // dir
|
|
|
|
};
|
|
|
|
|
|
|
|
TextParseOptions HistoryServiceOptions = {
|
|
|
|
TextParseLinks
|
|
|
|
| TextParseMentions
|
|
|
|
//| TextParseMultiline
|
2022-01-07 03:50:06 +00:00
|
|
|
| TextParseHashtags, // flags
|
2017-12-28 13:06:06 +00:00
|
|
|
0, // maxw
|
|
|
|
0, // maxh
|
|
|
|
Qt::LayoutDirectionAuto, // lang-dependent
|
|
|
|
};
|
|
|
|
|
|
|
|
TextParseOptions HistoryTextNoMonoOptions = {
|
|
|
|
TextParseLinks
|
|
|
|
| TextParseMentions
|
|
|
|
| TextParseHashtags
|
2022-01-07 03:50:06 +00:00
|
|
|
| TextParseMultiline, // flags
|
2017-12-28 13:06:06 +00:00
|
|
|
0, // maxw
|
|
|
|
0, // maxh
|
|
|
|
Qt::LayoutDirectionAuto, // dir
|
|
|
|
};
|
|
|
|
|
|
|
|
TextParseOptions HistoryBotNoMonoOptions = {
|
|
|
|
TextParseLinks
|
|
|
|
| TextParseMentions
|
|
|
|
| TextParseHashtags
|
|
|
|
| TextParseBotCommands
|
2022-01-07 03:50:06 +00:00
|
|
|
| TextParseMultiline, // flags
|
2017-12-28 13:06:06 +00:00
|
|
|
0, // maxw
|
|
|
|
0, // maxh
|
|
|
|
Qt::LayoutDirectionAuto, // dir
|
|
|
|
};
|
|
|
|
|
|
|
|
TextParseOptions TextNameOptions = {
|
|
|
|
0, // flags
|
|
|
|
4096, // maxw
|
|
|
|
1, // maxh
|
|
|
|
Qt::LayoutDirectionAuto, // lang-dependent
|
|
|
|
};
|
|
|
|
|
|
|
|
TextParseOptions TextDialogOptions = {
|
2021-12-26 17:17:26 +00:00
|
|
|
TextParsePlainLinks, // flags
|
2017-12-28 13:06:06 +00:00
|
|
|
0, // maxw is style-dependent
|
|
|
|
1, // maxh
|
|
|
|
Qt::LayoutDirectionAuto, // lang-dependent
|
|
|
|
};
|
|
|
|
|
|
|
|
TextParseOptions WebpageTitleOptions = {
|
2022-01-07 03:50:06 +00:00
|
|
|
TextParseMultiline, // flags
|
2017-12-28 13:06:06 +00:00
|
|
|
0, // maxw
|
|
|
|
0, // maxh
|
|
|
|
Qt::LayoutDirectionAuto, // dir
|
|
|
|
};
|
|
|
|
|
|
|
|
TextParseOptions WebpageDescriptionOptions = {
|
|
|
|
TextParseLinks
|
|
|
|
| TextParseMentions
|
|
|
|
| TextParseHashtags
|
|
|
|
| TextParseMultiline
|
|
|
|
| TextParseMarkdown, // flags
|
|
|
|
0, // maxw
|
|
|
|
0, // maxh
|
|
|
|
Qt::LayoutDirectionAuto, // dir
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
void InitTextOptions() {
|
|
|
|
HistoryServiceOptions.dir
|
|
|
|
= TextNameOptions.dir
|
|
|
|
= TextDialogOptions.dir
|
2020-10-10 09:15:37 +00:00
|
|
|
= Qt::LeftToRight;
|
2017-12-28 13:06:06 +00:00
|
|
|
TextDialogOptions.maxw = st::columnMaximalWidthLeft * 2;
|
|
|
|
WebpageTitleOptions.maxh = st::webPageTitleFont->height * 2;
|
|
|
|
WebpageTitleOptions.maxw
|
|
|
|
= WebpageDescriptionOptions.maxw
|
|
|
|
= st::msgMaxWidth
|
|
|
|
- st::msgPadding.left()
|
|
|
|
- st::webPageLeft
|
|
|
|
- st::msgPadding.right();
|
|
|
|
WebpageDescriptionOptions.maxh = st::webPageDescriptionFont->height * 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
const TextParseOptions &ItemTextDefaultOptions() {
|
|
|
|
return HistoryTextOptions;
|
|
|
|
}
|
|
|
|
|
|
|
|
const TextParseOptions &ItemTextBotDefaultOptions() {
|
|
|
|
return HistoryBotOptions;
|
|
|
|
}
|
|
|
|
|
|
|
|
const TextParseOptions &ItemTextNoMonoOptions() {
|
|
|
|
return HistoryTextNoMonoOptions;
|
|
|
|
}
|
|
|
|
|
|
|
|
const TextParseOptions &ItemTextBotNoMonoOptions() {
|
|
|
|
return HistoryBotNoMonoOptions;
|
|
|
|
}
|
|
|
|
|
|
|
|
const TextParseOptions &ItemTextServiceOptions() {
|
|
|
|
return HistoryServiceOptions;
|
|
|
|
}
|
|
|
|
|
|
|
|
const TextParseOptions &WebpageTextTitleOptions() {
|
|
|
|
return WebpageTitleOptions;
|
|
|
|
}
|
|
|
|
|
2020-06-16 15:10:39 +00:00
|
|
|
const TextParseOptions &WebpageTextDescriptionOptions() {
|
2017-12-28 13:06:06 +00:00
|
|
|
return WebpageDescriptionOptions;
|
|
|
|
}
|
|
|
|
|
|
|
|
const TextParseOptions &NameTextOptions() {
|
|
|
|
return TextNameOptions;
|
|
|
|
}
|
|
|
|
|
|
|
|
const TextParseOptions &DialogTextOptions() {
|
|
|
|
return TextDialogOptions;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Ui
|