mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-09 14:34:05 +02:00
Redesign Edit CSS dialog, add 'Open Dev Tools' button and better editor
This commit is contained in:
parent
f9cf582306
commit
0ec227da52
@ -412,6 +412,10 @@ public void ApplyROT13(){
|
||||
AnalyticsFile.UsedROT13.Trigger();
|
||||
}
|
||||
|
||||
public void OpenDevTools(){
|
||||
browser.OpenDevTools();
|
||||
}
|
||||
|
||||
// callback handlers
|
||||
|
||||
public void OnIntroductionClosed(bool showGuide, bool allowDataCollection){
|
||||
|
@ -42,7 +42,7 @@ public FormSettings(FormBrowser browser, PluginManager plugins, UpdateHandler up
|
||||
AddButton("Notifications", () => new TabSettingsNotifications(new FormNotificationExample(this.browser, this.plugins)));
|
||||
AddButton("Sounds", () => new TabSettingsSounds(this.browser.PlaySoundNotification));
|
||||
AddButton("Feedback", () => new TabSettingsFeedback(analytics, AnalyticsReportGenerator.ExternalInfo.From(this.browser), this.plugins));
|
||||
AddButton("Advanced", () => new TabSettingsAdvanced(this.browser.ReinjectCustomCSS));
|
||||
AddButton("Advanced", () => new TabSettingsAdvanced(this.browser.ReinjectCustomCSS, this.browser.OpenDevTools));
|
||||
|
||||
SelectTab(tabs[startTab ?? typeof(TabSettingsGeneral)]);
|
||||
}
|
||||
|
@ -27,33 +27,30 @@ private void InitializeComponent() {
|
||||
this.textBoxBrowserCSS = new System.Windows.Forms.TextBox();
|
||||
this.btnCancel = new System.Windows.Forms.Button();
|
||||
this.btnApply = new System.Windows.Forms.Button();
|
||||
this.splitContainer = new System.Windows.Forms.SplitContainer();
|
||||
this.labelBrowser = new System.Windows.Forms.Label();
|
||||
this.labelNotification = new System.Windows.Forms.Label();
|
||||
this.textBoxNotificationCSS = new System.Windows.Forms.TextBox();
|
||||
this.labelWarning = new System.Windows.Forms.Label();
|
||||
this.btnOpenWiki = new System.Windows.Forms.Button();
|
||||
this.btnOpenDevTools = new System.Windows.Forms.Button();
|
||||
this.timerTestBrowser = new System.Windows.Forms.Timer(this.components);
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
|
||||
this.splitContainer.Panel1.SuspendLayout();
|
||||
this.splitContainer.Panel2.SuspendLayout();
|
||||
this.splitContainer.SuspendLayout();
|
||||
this.tabPanel = new System.Windows.Forms.TabControl();
|
||||
this.tabPageBrowser = new System.Windows.Forms.TabPage();
|
||||
this.tabPageNotification = new System.Windows.Forms.TabPage();
|
||||
this.tabPanel.SuspendLayout();
|
||||
this.tabPageBrowser.SuspendLayout();
|
||||
this.tabPageNotification.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// textBoxBrowserCSS
|
||||
//
|
||||
this.textBoxBrowserCSS.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.textBoxBrowserCSS.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.textBoxBrowserCSS.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.textBoxBrowserCSS.Location = new System.Drawing.Point(0, 16);
|
||||
this.textBoxBrowserCSS.Location = new System.Drawing.Point(3, 3);
|
||||
this.textBoxBrowserCSS.Margin = new System.Windows.Forms.Padding(0, 3, 0, 0);
|
||||
this.textBoxBrowserCSS.Multiline = true;
|
||||
this.textBoxBrowserCSS.Name = "textBoxBrowserCSS";
|
||||
this.textBoxBrowserCSS.ScrollBars = System.Windows.Forms.ScrollBars.Both;
|
||||
this.textBoxBrowserCSS.Size = new System.Drawing.Size(378, 251);
|
||||
this.textBoxBrowserCSS.TabIndex = 1;
|
||||
this.textBoxBrowserCSS.Size = new System.Drawing.Size(426, 332);
|
||||
this.textBoxBrowserCSS.TabIndex = 0;
|
||||
this.textBoxBrowserCSS.WordWrap = false;
|
||||
this.textBoxBrowserCSS.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBoxCSS_KeyDown);
|
||||
this.textBoxBrowserCSS.KeyUp += new System.Windows.Forms.KeyEventHandler(this.textBoxBrowserCSS_KeyUp);
|
||||
//
|
||||
// btnCancel
|
||||
@ -61,7 +58,7 @@ private void InitializeComponent() {
|
||||
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnCancel.AutoSize = true;
|
||||
this.btnCancel.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.btnCancel.Location = new System.Drawing.Point(657, 285);
|
||||
this.btnCancel.Location = new System.Drawing.Point(337, 384);
|
||||
this.btnCancel.Name = "btnCancel";
|
||||
this.btnCancel.Padding = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
this.btnCancel.Size = new System.Drawing.Size(57, 25);
|
||||
@ -75,7 +72,7 @@ private void InitializeComponent() {
|
||||
this.btnApply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnApply.AutoSize = true;
|
||||
this.btnApply.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.btnApply.Location = new System.Drawing.Point(720, 285);
|
||||
this.btnApply.Location = new System.Drawing.Point(400, 384);
|
||||
this.btnApply.Name = "btnApply";
|
||||
this.btnApply.Padding = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
this.btnApply.Size = new System.Drawing.Size(52, 25);
|
||||
@ -84,117 +81,94 @@ private void InitializeComponent() {
|
||||
this.btnApply.UseVisualStyleBackColor = true;
|
||||
this.btnApply.Click += new System.EventHandler(this.btnApply_Click);
|
||||
//
|
||||
// splitContainer
|
||||
//
|
||||
this.splitContainer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.splitContainer.Location = new System.Drawing.Point(12, 12);
|
||||
this.splitContainer.Name = "splitContainer";
|
||||
//
|
||||
// splitContainer.Panel1
|
||||
//
|
||||
this.splitContainer.Panel1.Controls.Add(this.labelBrowser);
|
||||
this.splitContainer.Panel1.Controls.Add(this.textBoxBrowserCSS);
|
||||
this.splitContainer.Panel1MinSize = 64;
|
||||
//
|
||||
// splitContainer.Panel2
|
||||
//
|
||||
this.splitContainer.Panel2.Controls.Add(this.labelNotification);
|
||||
this.splitContainer.Panel2.Controls.Add(this.textBoxNotificationCSS);
|
||||
this.splitContainer.Panel2MinSize = 64;
|
||||
this.splitContainer.Size = new System.Drawing.Size(760, 267);
|
||||
this.splitContainer.SplitterDistance = 378;
|
||||
this.splitContainer.SplitterWidth = 5;
|
||||
this.splitContainer.TabIndex = 0;
|
||||
//
|
||||
// labelBrowser
|
||||
//
|
||||
this.labelBrowser.AutoSize = true;
|
||||
this.labelBrowser.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.labelBrowser.Location = new System.Drawing.Point(-3, 0);
|
||||
this.labelBrowser.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);
|
||||
this.labelBrowser.Name = "labelBrowser";
|
||||
this.labelBrowser.Size = new System.Drawing.Size(49, 15);
|
||||
this.labelBrowser.TabIndex = 0;
|
||||
this.labelBrowser.Text = "Browser";
|
||||
//
|
||||
// labelNotification
|
||||
//
|
||||
this.labelNotification.AutoSize = true;
|
||||
this.labelNotification.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.labelNotification.Location = new System.Drawing.Point(-3, 0);
|
||||
this.labelNotification.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);
|
||||
this.labelNotification.Name = "labelNotification";
|
||||
this.labelNotification.Size = new System.Drawing.Size(70, 15);
|
||||
this.labelNotification.TabIndex = 0;
|
||||
this.labelNotification.Text = "Notification";
|
||||
//
|
||||
// textBoxNotificationCSS
|
||||
//
|
||||
this.textBoxNotificationCSS.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.textBoxNotificationCSS.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.textBoxNotificationCSS.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.textBoxNotificationCSS.Location = new System.Drawing.Point(0, 16);
|
||||
this.textBoxNotificationCSS.Location = new System.Drawing.Point(3, 3);
|
||||
this.textBoxNotificationCSS.Margin = new System.Windows.Forms.Padding(0, 3, 0, 0);
|
||||
this.textBoxNotificationCSS.Multiline = true;
|
||||
this.textBoxNotificationCSS.Name = "textBoxNotificationCSS";
|
||||
this.textBoxNotificationCSS.ScrollBars = System.Windows.Forms.ScrollBars.Both;
|
||||
this.textBoxNotificationCSS.Size = new System.Drawing.Size(372, 251);
|
||||
this.textBoxNotificationCSS.TabIndex = 1;
|
||||
this.textBoxNotificationCSS.Size = new System.Drawing.Size(426, 332);
|
||||
this.textBoxNotificationCSS.TabIndex = 0;
|
||||
this.textBoxNotificationCSS.WordWrap = false;
|
||||
this.textBoxNotificationCSS.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBoxCSS_KeyDown);
|
||||
//
|
||||
// labelWarning
|
||||
// btnOpenDevTools
|
||||
//
|
||||
this.labelWarning.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.labelWarning.AutoSize = true;
|
||||
this.labelWarning.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.labelWarning.Location = new System.Drawing.Point(94, 290);
|
||||
this.labelWarning.Name = "labelWarning";
|
||||
this.labelWarning.Size = new System.Drawing.Size(373, 15);
|
||||
this.labelWarning.TabIndex = 3;
|
||||
this.labelWarning.Text = "The code is not validated, please make sure there are no syntax errors.";
|
||||
//
|
||||
// btnOpenWiki
|
||||
//
|
||||
this.btnOpenWiki.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.btnOpenWiki.AutoSize = true;
|
||||
this.btnOpenWiki.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.btnOpenWiki.Location = new System.Drawing.Point(12, 285);
|
||||
this.btnOpenWiki.Name = "btnOpenWiki";
|
||||
this.btnOpenWiki.Padding = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
this.btnOpenWiki.Size = new System.Drawing.Size(76, 25);
|
||||
this.btnOpenWiki.TabIndex = 4;
|
||||
this.btnOpenWiki.Text = "Open Wiki";
|
||||
this.btnOpenWiki.UseVisualStyleBackColor = true;
|
||||
this.btnOpenWiki.Click += new System.EventHandler(this.btnOpenWiki_Click);
|
||||
this.btnOpenDevTools.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.btnOpenDevTools.AutoSize = true;
|
||||
this.btnOpenDevTools.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.btnOpenDevTools.Location = new System.Drawing.Point(12, 384);
|
||||
this.btnOpenDevTools.Name = "btnOpenDevTools";
|
||||
this.btnOpenDevTools.Padding = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
this.btnOpenDevTools.Size = new System.Drawing.Size(104, 25);
|
||||
this.btnOpenDevTools.TabIndex = 3;
|
||||
this.btnOpenDevTools.Text = "Open Dev Tools";
|
||||
this.btnOpenDevTools.UseVisualStyleBackColor = true;
|
||||
this.btnOpenDevTools.Click += new System.EventHandler(this.btnOpenDevTools_Click);
|
||||
//
|
||||
// timerTestBrowser
|
||||
//
|
||||
this.timerTestBrowser.Interval = 500;
|
||||
this.timerTestBrowser.Interval = 400;
|
||||
this.timerTestBrowser.Tick += new System.EventHandler(this.timerTestBrowser_Tick);
|
||||
//
|
||||
// tabPanel
|
||||
//
|
||||
this.tabPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.tabPanel.Controls.Add(this.tabPageBrowser);
|
||||
this.tabPanel.Controls.Add(this.tabPageNotification);
|
||||
this.tabPanel.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.tabPanel.Location = new System.Drawing.Point(12, 12);
|
||||
this.tabPanel.Name = "tabPanel";
|
||||
this.tabPanel.SelectedIndex = 0;
|
||||
this.tabPanel.Size = new System.Drawing.Size(440, 366);
|
||||
this.tabPanel.TabIndex = 0;
|
||||
this.tabPanel.SelectedIndexChanged += new System.EventHandler(this.tabPanel_SelectedIndexChanged);
|
||||
//
|
||||
// tabPageBrowser
|
||||
//
|
||||
this.tabPageBrowser.Controls.Add(this.textBoxBrowserCSS);
|
||||
this.tabPageBrowser.Location = new System.Drawing.Point(4, 24);
|
||||
this.tabPageBrowser.Name = "tabPageBrowser";
|
||||
this.tabPageBrowser.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPageBrowser.Size = new System.Drawing.Size(432, 338);
|
||||
this.tabPageBrowser.TabIndex = 0;
|
||||
this.tabPageBrowser.Text = "Browser";
|
||||
this.tabPageBrowser.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// tabPageNotification
|
||||
//
|
||||
this.tabPageNotification.Controls.Add(this.textBoxNotificationCSS);
|
||||
this.tabPageNotification.Location = new System.Drawing.Point(4, 24);
|
||||
this.tabPageNotification.Name = "tabPageNotification";
|
||||
this.tabPageNotification.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPageNotification.Size = new System.Drawing.Size(432, 338);
|
||||
this.tabPageNotification.TabIndex = 1;
|
||||
this.tabPageNotification.Text = "Notification";
|
||||
this.tabPageNotification.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// DialogSettingsCSS
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(784, 322);
|
||||
this.Controls.Add(this.btnOpenWiki);
|
||||
this.Controls.Add(this.labelWarning);
|
||||
this.Controls.Add(this.splitContainer);
|
||||
this.ClientSize = new System.Drawing.Size(464, 421);
|
||||
this.Controls.Add(this.tabPanel);
|
||||
this.Controls.Add(this.btnOpenDevTools);
|
||||
this.Controls.Add(this.btnApply);
|
||||
this.Controls.Add(this.btnCancel);
|
||||
this.MinimumSize = new System.Drawing.Size(620, 160);
|
||||
this.MinimumSize = new System.Drawing.Size(320, 240);
|
||||
this.Name = "DialogSettingsCSS";
|
||||
this.ShowIcon = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.splitContainer.Panel1.ResumeLayout(false);
|
||||
this.splitContainer.Panel1.PerformLayout();
|
||||
this.splitContainer.Panel2.ResumeLayout(false);
|
||||
this.splitContainer.Panel2.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
|
||||
this.splitContainer.ResumeLayout(false);
|
||||
this.tabPanel.ResumeLayout(false);
|
||||
this.tabPageBrowser.ResumeLayout(false);
|
||||
this.tabPageBrowser.PerformLayout();
|
||||
this.tabPageNotification.ResumeLayout(false);
|
||||
this.tabPageNotification.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@ -205,12 +179,11 @@ private void InitializeComponent() {
|
||||
private System.Windows.Forms.TextBox textBoxBrowserCSS;
|
||||
private System.Windows.Forms.Button btnCancel;
|
||||
private System.Windows.Forms.Button btnApply;
|
||||
private System.Windows.Forms.SplitContainer splitContainer;
|
||||
private System.Windows.Forms.TextBox textBoxNotificationCSS;
|
||||
private System.Windows.Forms.Label labelBrowser;
|
||||
private System.Windows.Forms.Label labelNotification;
|
||||
private System.Windows.Forms.Label labelWarning;
|
||||
private System.Windows.Forms.Button btnOpenWiki;
|
||||
private System.Windows.Forms.Button btnOpenDevTools;
|
||||
private System.Windows.Forms.Timer timerTestBrowser;
|
||||
private System.Windows.Forms.TabControl tabPanel;
|
||||
private System.Windows.Forms.TabPage tabPageBrowser;
|
||||
private System.Windows.Forms.TabPage tabPageNotification;
|
||||
}
|
||||
}
|
@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Utils;
|
||||
@ -9,19 +11,108 @@ sealed partial class DialogSettingsCSS : Form{
|
||||
public string NotificationCSS => textBoxNotificationCSS.Text;
|
||||
|
||||
private readonly Action<string> reinjectBrowserCSS;
|
||||
private readonly Action openDevTools;
|
||||
|
||||
public DialogSettingsCSS(Action<string> reinjectBrowserCSS){ // TODO high dpi breaks scaling of things inside the panel...
|
||||
public DialogSettingsCSS(Action<string> reinjectBrowserCSS, Action openDevTools){
|
||||
InitializeComponent();
|
||||
|
||||
Text = Program.BrandName+" Options - CSS";
|
||||
|
||||
this.reinjectBrowserCSS = reinjectBrowserCSS;
|
||||
this.openDevTools = openDevTools;
|
||||
|
||||
textBoxBrowserCSS.EnableMultilineShortcuts();
|
||||
textBoxBrowserCSS.Text = Program.UserConfig.CustomBrowserCSS ?? "";
|
||||
|
||||
textBoxNotificationCSS.EnableMultilineShortcuts();
|
||||
textBoxNotificationCSS.Text = Program.UserConfig.CustomNotificationCSS ?? "";
|
||||
|
||||
if (!BrowserUtils.HasDevTools){
|
||||
btnOpenDevTools.Enabled = false;
|
||||
}
|
||||
|
||||
ActiveControl = textBoxBrowserCSS;
|
||||
textBoxBrowserCSS.Select(textBoxBrowserCSS.TextLength, 0);
|
||||
}
|
||||
|
||||
private void tabPanel_SelectedIndexChanged(object sender, EventArgs e){
|
||||
TextBox tb = tabPanel.SelectedTab.Controls.OfType<TextBox>().FirstOrDefault();
|
||||
|
||||
if (tb != null){
|
||||
tb.Focus();
|
||||
tb.Select(tb.TextLength, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private void textBoxCSS_KeyDown(object sender, KeyEventArgs e){
|
||||
TextBox tb = (TextBox)sender;
|
||||
string text = tb.Text;
|
||||
|
||||
if (e.KeyCode == Keys.Back && e.Modifiers == Keys.Control){
|
||||
e.SuppressKeyPress = true;
|
||||
|
||||
int deleteTo = tb.SelectionStart;
|
||||
|
||||
if (deleteTo > 0){
|
||||
char initialChar = text[--deleteTo];
|
||||
bool shouldDeleteAlphanumeric = char.IsLetterOrDigit(initialChar);
|
||||
|
||||
while(--deleteTo >= 0){
|
||||
if ((shouldDeleteAlphanumeric && !char.IsLetterOrDigit(text[deleteTo])) ||
|
||||
(!shouldDeleteAlphanumeric && text[deleteTo] != initialChar)){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(deleteTo < text.Length-1 && text[deleteTo] == '\r' && text[deleteTo+1] == '\n')){
|
||||
++deleteTo;
|
||||
}
|
||||
|
||||
tb.Select(deleteTo, tb.SelectionLength+tb.SelectionStart-deleteTo);
|
||||
tb.SelectedText = string.Empty;
|
||||
}
|
||||
}
|
||||
else if (e.KeyCode == Keys.Back && e.Modifiers == Keys.None){
|
||||
int deleteTo = tb.SelectionStart;
|
||||
|
||||
if (deleteTo > 1 && text[deleteTo-1] == ' ' && text[deleteTo-2] == ' '){
|
||||
e.SuppressKeyPress = true;
|
||||
|
||||
tb.Select(deleteTo-2, 2);
|
||||
tb.SelectedText = string.Empty;
|
||||
}
|
||||
}
|
||||
else if (e.KeyCode == Keys.Enter && e.Modifiers == Keys.None && tb.SelectionLength == 0){
|
||||
int insertAt = tb.SelectionStart, cursorOffset = 0;
|
||||
string insertText;
|
||||
|
||||
if (insertAt == 0){
|
||||
return;
|
||||
}
|
||||
else if (text[insertAt-1] == '{'){
|
||||
insertText = Environment.NewLine+" ";
|
||||
|
||||
int nextBracket = insertAt < text.Length ? text.IndexOfAny(new char[]{ '{', '}' }, insertAt+1) : -1;
|
||||
|
||||
if (nextBracket == -1 || text[nextBracket] == '{'){
|
||||
string insertExtra = Environment.NewLine+"}";
|
||||
insertText += insertExtra;
|
||||
cursorOffset -= insertExtra.Length;
|
||||
}
|
||||
}
|
||||
else{
|
||||
int lineStart = text.LastIndexOf('\n', tb.SelectionStart-1);
|
||||
|
||||
Match match = Regex.Match(text.Substring(lineStart == -1 ? 0 : lineStart+1), "^([ \t]+)");
|
||||
insertText = match.Success ? Environment.NewLine+match.Groups[1].Value : null;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(insertText)){
|
||||
e.SuppressKeyPress = true;
|
||||
tb.Text = text.Insert(insertAt, insertText);
|
||||
tb.SelectionStart = insertAt+cursorOffset+insertText.Length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void textBoxBrowserCSS_KeyUp(object sender, KeyEventArgs e){
|
||||
@ -34,8 +125,8 @@ private void timerTestBrowser_Tick(object sender, EventArgs e){
|
||||
timerTestBrowser.Stop();
|
||||
}
|
||||
|
||||
private void btnOpenWiki_Click(object sender, EventArgs e){
|
||||
BrowserUtils.OpenExternalBrowser("https://github.com/chylex/TweetDuck/wiki");
|
||||
private void btnOpenDevTools_Click(object sender, EventArgs e){
|
||||
openDevTools();
|
||||
}
|
||||
|
||||
private void btnApply_Click(object sender, EventArgs e){
|
||||
|
@ -13,11 +13,13 @@ sealed partial class TabSettingsAdvanced : BaseTabSettings{
|
||||
private static SystemConfig SysConfig => Program.SystemConfig;
|
||||
|
||||
private readonly Action<string> reinjectBrowserCSS;
|
||||
private readonly Action openDevTools;
|
||||
|
||||
public TabSettingsAdvanced(Action<string> reinjectBrowserCSS){
|
||||
public TabSettingsAdvanced(Action<string> reinjectBrowserCSS, Action openDevTools){
|
||||
InitializeComponent();
|
||||
|
||||
this.reinjectBrowserCSS = reinjectBrowserCSS;
|
||||
this.openDevTools = openDevTools;
|
||||
|
||||
toolTip.SetToolTip(btnOpenAppFolder, "Opens the folder where the app is located.");
|
||||
toolTip.SetToolTip(btnOpenDataFolder, "Opens the folder where your profile data is located.");
|
||||
@ -116,7 +118,7 @@ private void btnEditCefArgs_Click(object sender, EventArgs e){
|
||||
}
|
||||
|
||||
private void btnEditCSS_Click(object sender, EventArgs e){
|
||||
DialogSettingsCSS form = new DialogSettingsCSS(reinjectBrowserCSS);
|
||||
DialogSettingsCSS form = new DialogSettingsCSS(reinjectBrowserCSS, openDevTools);
|
||||
|
||||
form.VisibleChanged += (sender2, args2) => {
|
||||
form.MoveToCenter(ParentForm);
|
||||
|
@ -270,5 +270,9 @@ public void ApplyROT13(){
|
||||
public void ShowUpdateNotification(string versionTag, string releaseNotes){
|
||||
browser.ExecuteScriptAsync("TDUF_displayNotification", versionTag, Convert.ToBase64String(Encoding.GetEncoding("iso-8859-1").GetBytes(releaseNotes)));
|
||||
}
|
||||
|
||||
public void OpenDevTools(){
|
||||
browser.ShowDevTools();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user