Skip to content

Commit 505d0bd

Browse files
committed
Code cleanup - CancelEventArgs
1 parent 1476154 commit 505d0bd

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

Terminal.Gui/View/CancelEventArgs.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,16 @@ public CancelEventArgs (ref readonly T currentValue, ref T newValue, bool cancel
2727
NewValue = newValue;
2828
}
2929

30-
protected CancelEventArgs () { }
30+
/// <summary>
31+
/// Initializes a new instance of the <see cref="CancelEventArgs{T}"/> class.
32+
/// </summary>
33+
/// <param name="currentValue">The current (old) value of the property.</param>
34+
/// <param name="newValue">The value the property will be set to if the event is not cancelled.</param>
35+
protected CancelEventArgs (T currentValue, T newValue)
36+
{
37+
CurrentValue = currentValue;
38+
NewValue = newValue;
39+
}
3140

3241
/// <summary>The current value of the property.</summary>
3342
public T CurrentValue { get; }

Terminal.Gui/Views/HexView.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -431,10 +431,10 @@ public override void OnDrawContent (Rectangle viewport)
431431
Driver.SetAttribute (current);
432432
Move (0, 0);
433433

434-
int nblocks = BytesPerLine / NUM_BYTES_PER_HEX_COLUMN;
435-
var data = new byte [nblocks * NUM_BYTES_PER_HEX_COLUMN * viewport.Height];
434+
int nBlocks = BytesPerLine / NUM_BYTES_PER_HEX_COLUMN;
435+
var data = new byte [nBlocks * NUM_BYTES_PER_HEX_COLUMN * viewport.Height];
436436
Source.Position = _displayStart;
437-
int n = _source.Read (data, 0, data.Length);
437+
int n = _source!.Read (data, 0, data.Length);
438438

439439
Attribute activeColor = GetHotNormalColor ();
440440
Attribute trackingColor = GetHotFocusColor ();
@@ -451,7 +451,7 @@ public override void OnDrawContent (Rectangle viewport)
451451
Move (0, line);
452452
currentAttribute = GetHotNormalColor ();
453453
Driver.SetAttribute (currentAttribute);
454-
var address = $"{_displayStart + line * nblocks * NUM_BYTES_PER_HEX_COLUMN:x8}";
454+
var address = $"{_displayStart + line * nBlocks * NUM_BYTES_PER_HEX_COLUMN:x8}";
455455
Driver.AddStr ($"{address.Substring (8 - AddressWidth)}");
456456

457457
if (AddressWidth > 0)
@@ -461,11 +461,11 @@ public override void OnDrawContent (Rectangle viewport)
461461

462462
SetAttribute (GetNormalColor ());
463463

464-
for (var block = 0; block < nblocks; block++)
464+
for (var block = 0; block < nBlocks; block++)
465465
{
466466
for (var b = 0; b < NUM_BYTES_PER_HEX_COLUMN; b++)
467467
{
468-
int offset = line * nblocks * NUM_BYTES_PER_HEX_COLUMN + block * NUM_BYTES_PER_HEX_COLUMN + b;
468+
int offset = line * nBlocks * NUM_BYTES_PER_HEX_COLUMN + block * NUM_BYTES_PER_HEX_COLUMN + b;
469469
byte value = GetData (data, offset, out bool edited);
470470

471471
if (offset + _displayStart == Address || edited)
@@ -482,12 +482,12 @@ public override void OnDrawContent (Rectangle viewport)
482482
Driver.AddRune (_spaceCharRune);
483483
}
484484

485-
Driver.AddStr (block + 1 == nblocks ? " " : $"{_columnSeparatorRune} ");
485+
Driver.AddStr (block + 1 == nBlocks ? " " : $"{_columnSeparatorRune} ");
486486
}
487487

488-
for (var bitem = 0; bitem < nblocks * NUM_BYTES_PER_HEX_COLUMN; bitem++)
488+
for (var bitem = 0; bitem < nBlocks * NUM_BYTES_PER_HEX_COLUMN; bitem++)
489489
{
490-
int offset = line * nblocks * NUM_BYTES_PER_HEX_COLUMN + bitem;
490+
int offset = line * nBlocks * NUM_BYTES_PER_HEX_COLUMN + bitem;
491491
byte b = GetData (data, offset, out bool edited);
492492
Rune c;
493493

0 commit comments

Comments
 (0)