Skip to content

Commit

Permalink
Add new preference option for displaying hexadecimal content in lower…
Browse files Browse the repository at this point in the history
…case
  • Loading branch information
ansgarbecker committed Apr 23, 2021
1 parent 21f8d78 commit b271107
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 14 deletions.
5 changes: 4 additions & 1 deletion out/locale/en/LC_MESSAGES/default.po
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: HeidiSQL\n"
"POT-Creation-Date: 2012-11-05 21:40\n"
"PO-Revision-Date: 2021-04-22 08:38+0200\n"
"PO-Revision-Date: 2021-04-23 15:44+0200\n"
"Last-Translator: Ansgar Becker <anse@heidisql.com>\n"
"Language-Team: English (http://www.transifex.com/projects/p/heidisql/language/en/)\n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -6669,3 +6669,6 @@ msgstr "Logging disabled"

msgid "Editor commands"
msgstr "Editor commands"

msgid "Lowercase hexadecimal"
msgstr "Lowercase hexadecimal"
3 changes: 2 additions & 1 deletion source/apphelpers.pas
Expand Up @@ -141,7 +141,7 @@ TQueryThread = class(TThread)
TAppSettingDataType = (adInt, adBool, adString);
TAppSettingIndex = (asHiddenColumns, asFilter, asSort, asDisplayedColumnsSorted, asLastSessions,
asLastActiveSession, asAutoReconnect, asRestoreLastUsedDB, asLastUsedDB, asTreeBackground, asIgnoreDatabasePattern, asLogFileDdl, asLogFileDml, asLogFilePath,
asFontName, asFontSize, asTabWidth, asDataFontName, asDataFontSize, asDataLocalNumberFormat, asHintsOnResultTabs, asHightlightSameTextBackground,
asFontName, asFontSize, asTabWidth, asDataFontName, asDataFontSize, asDataLocalNumberFormat, asLowercaseHex, asHintsOnResultTabs, asHightlightSameTextBackground,
asLogsqlnum, asLogsqlwidth, asSessionLogsDirectory, asLogHorizontalScrollbar, asSQLColActiveLine,
asSQLColMatchingBraceForeground, asSQLColMatchingBraceBackground,
asMaxColWidth, asDatagridMaximumRows, asDatagridRowsPerStep, asGridRowLineCount, asReuseEditorConfiguration,
Expand Down Expand Up @@ -3390,6 +3390,7 @@ constructor TAppSettings.Create;
InitSetting(asDataFontName, 'DataFontName', 0, False, 'Tahoma');
InitSetting(asDataFontSize, 'DataFontSize', 8);
InitSetting(asDataLocalNumberFormat, 'DataLocalNumberFormat', 0, True);
InitSetting(asLowercaseHex, 'LowercaseHex', 0, True);
InitSetting(asHintsOnResultTabs, 'HintsOnResultTabs', 0, True);
InitSetting(asHightlightSameTextBackground, 'HightlightSameTextBackground', GetThemeColor(clInfoBk));
InitSetting(asLogsqlnum, 'logsqlnum', 300);
Expand Down
6 changes: 4 additions & 2 deletions source/dbconnection.pas
Expand Up @@ -766,7 +766,7 @@ TDBQuery = class(TComponent)
function Col(Column: Integer; IgnoreErrors: Boolean=False): String; overload; virtual; abstract;
function Col(ColumnName: String; IgnoreErrors: Boolean=False): String; overload;
function ColumnLengths(Column: Integer): Int64; virtual;
function HexValue(Column: Integer; IgnoreErrors: Boolean=False): String; overload;
function HexValue(Column: Integer; IgnoreErrors: Boolean=False; Lowercase: Boolean=False): String; overload;
function HexValue(BinValue: String): String; overload;
function HexValue(var ByteData: TBytes): String; overload;
function DataType(Column: Integer): TDBDataType;
Expand Down Expand Up @@ -7752,7 +7752,7 @@ function TDBQuery.ColumnLengths(Column: Integer): Int64;
end;


function TDBQuery.HexValue(Column: Integer; IgnoreErrors: Boolean=False): String;
function TDBQuery.HexValue(Column: Integer; IgnoreErrors: Boolean=False; Lowercase: Boolean=False): String;
var
baData: TBytes;
begin
Expand All @@ -7762,6 +7762,8 @@ function TDBQuery.HexValue(Column: Integer; IgnoreErrors: Boolean=False): String
Result := HexValue(baData);
end else
Result := HexValue(Col(Column, IgnoreErrors));
if Lowercase then
Result := Result.ToLowerInvariant;
end;


Expand Down
4 changes: 2 additions & 2 deletions source/main.pas
Expand Up @@ -7658,7 +7658,7 @@ procedure TMainForm.QFvaluesClick(Sender: TObject);
if Data.IsNull(ColName) then
Item.Hint := Conn.QuoteIdent(ColName)+' IS NULL'
else if ColType.Category in [dtcBinary, dtcSpatial] then
Item.Hint := Conn.QuoteIdent(ColName)+'='+Data.HexValue(0)
Item.Hint := Conn.QuoteIdent(ColName)+'='+Data.HexValue(0, False, AppSettings.ReadBool(asLowercaseHex))
else
Item.Hint := Conn.QuoteIdent(ColName)+'='+Conn.EscapeString(Data.Col(ColName));
Item.Caption := StrEllipsis(Item.Hint, 100) + ' (' + FormatNumber(Data.Col('c')) + ')';
Expand Down Expand Up @@ -9835,7 +9835,7 @@ procedure TMainForm.AnyGridGetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
if actBlobAsText.Checked then
CellText := Results.Col(Column)
else
CellText := Results.HexValue(Column);
CellText := Results.HexValue(Column, False, AppSettings.ReadBool(asLowercaseHex));
end;
else begin
CellText := Results.Col(Column);
Expand Down
25 changes: 17 additions & 8 deletions source/preferences.dfm
Expand Up @@ -385,7 +385,7 @@ object frmPreferences: TfrmPreferences
object lblQueryHistoryKeepDays: TLabel
Left = 438
Top = 247
Width = 257
Width = 209
Height = 13
Caption = 'days to keep queries before removing them'
end
Expand Down Expand Up @@ -908,7 +908,7 @@ object frmPreferences: TfrmPreferences
end
object lblLongSortRowNum: TLabel
Left = 8
Top = 303
Top = 326
Width = 127
Height = 13
Caption = 'Sort warning on grid rows:'
Expand Down Expand Up @@ -1059,12 +1059,12 @@ object frmPreferences: TfrmPreferences
end
object chkHintsOnResultTabs: TCheckBox
Left = 220
Top = 277
Top = 300
Width = 475
Height = 17
Anchors = [akLeft, akTop, akRight]
Caption = 'Pop up SQL text over result tabs'
TabOrder = 17
TabOrder = 18
OnClick = Modified
end
object cboxRowHighlightSameText: TColorBox
Expand All @@ -1087,22 +1087,31 @@ object frmPreferences: TfrmPreferences
end
object editLongSortRowNum: TEdit
Left = 220
Top = 300
Top = 323
Width = 145
Height = 21
TabOrder = 18
TabOrder = 19
Text = '0'
end
object updownLongSortRowNum: TUpDown
Left = 365
Top = 300
Top = 323
Width = 16
Height = 21
Associate = editLongSortRowNum
Max = 2147483647
TabOrder = 19
TabOrder = 20
OnChanging = anyUpDownLimitChanging
end
object chkLowercaseHex: TCheckBox
Left = 220
Top = 277
Width = 475
Height = 17
Anchors = [akLeft, akTop, akRight]
Caption = 'Lowercase hexadecimal'
TabOrder = 17
end
end
object tabDataEditors: TTabSheet
Caption = 'Data editors'
Expand Down
3 changes: 3 additions & 0 deletions source/preferences.pas
Expand Up @@ -173,6 +173,7 @@ TfrmPreferences = class(TExtForm)
updownLongSortRowNum: TUpDown;
HotKey1: THotKey;
HotKey2: THotKey;
chkLowercaseHex: TCheckBox;
procedure FormShow(Sender: TObject);
procedure Modified(Sender: TObject);
procedure Apply(Sender: TObject);
Expand Down Expand Up @@ -365,6 +366,7 @@ procedure TfrmPreferences.Apply(Sender: TObject);
AppSettings.WriteInt(asRowBackgroundOdd, cboxRowBackgroundOdd.Selected);
AppSettings.WriteInt(asHightlightSameTextBackground, cboxRowHighlightSameText.Selected);
AppSettings.WriteBool(asDataLocalNumberFormat, chkLocalNumberFormat.Checked);
AppSettings.WriteBool(asLowercaseHex, chkLowercaseHex.Checked);
AppSettings.WriteBool(asHintsOnResultTabs, chkHintsOnResultTabs.Checked);
AppSettings.WriteInt(asQueryGridLongSortRowNum, updownLongSortRowNum.Position);

Expand Down Expand Up @@ -719,6 +721,7 @@ procedure TfrmPreferences.FormShow(Sender: TObject);
cboxRowBackgroundOdd.Selected := AppSettings.ReadInt(asRowBackgroundOdd);
cboxRowHighlightSameText.Selected := AppSettings.ReadInt(asHightlightSameTextBackground);
chkLocalNumberFormat.Checked := AppSettings.ReadBool(asDataLocalNumberFormat);
chkLowercaseHex.Checked := AppSettings.ReadBool(asLowercaseHex);
chkHintsOnResultTabs.Checked := AppSettings.ReadBool(asHintsOnResultTabs);
updownLongSortRowNum.Position := AppSettings.ReadInt(asQueryGridLongSortRowNum);

Expand Down

0 comments on commit b271107

Please sign in to comment.