mirror of
https://github.com/wneessen/apg-go.git
synced 2024-11-09 15:52:54 +01:00
Refactor variable names in mode.go
Renamed variables in the MaskSetMode, MaskClearMode, MaskToggleMode, and MaskHasMode functions as well as within ModesFromFlags function to improve clarity and readability of their functionality. These changes ensure that the purpose of each variable is immediately identifiable, enhancing maintainability of the codebase.
This commit is contained in:
parent
61ca9af22a
commit
b6f91459c5
1 changed files with 19 additions and 19 deletions
38
mode.go
38
mode.go
|
@ -46,48 +46,48 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
// MaskSetMode sets a specific Mode to a given Mode bitmask
|
// MaskSetMode sets a specific Mode to a given Mode bitmask
|
||||||
func MaskSetMode(ma ModeMask, mo Mode) ModeMask { return ModeMask(uint8(ma) | uint8(mo)) }
|
func MaskSetMode(mask ModeMask, mode Mode) ModeMask { return ModeMask(uint8(mask) | uint8(mode)) }
|
||||||
|
|
||||||
// MaskClearMode clears a specific Mode from a given Mode bitmask
|
// MaskClearMode clears a specific Mode from a given Mode bitmask
|
||||||
func MaskClearMode(ma ModeMask, mo Mode) ModeMask { return ModeMask(uint8(ma) &^ uint8(mo)) }
|
func MaskClearMode(mask ModeMask, mode Mode) ModeMask { return ModeMask(uint8(mask) &^ uint8(mode)) }
|
||||||
|
|
||||||
// MaskToggleMode toggles a specific Mode in a given Mode bitmask
|
// MaskToggleMode toggles a specific Mode in a given Mode bitmask
|
||||||
func MaskToggleMode(ma ModeMask, mo Mode) ModeMask { return ModeMask(uint8(ma) ^ uint8(mo)) }
|
func MaskToggleMode(mask ModeMask, mode Mode) ModeMask { return ModeMask(uint8(mask) ^ uint8(mode)) }
|
||||||
|
|
||||||
// MaskHasMode returns true if a given Mode bitmask holds a specific Mode
|
// MaskHasMode returns true if a given Mode bitmask holds a specific Mode
|
||||||
func MaskHasMode(ma ModeMask, mo Mode) bool { return uint8(ma)&uint8(mo) != 0 }
|
func MaskHasMode(mask ModeMask, mode Mode) bool { return uint8(mask)&uint8(mode) != 0 }
|
||||||
|
|
||||||
func ModesFromFlags(ms string) ModeMask {
|
func ModesFromFlags(maskString string) ModeMask {
|
||||||
cl := strings.Split(ms, "")
|
cl := strings.Split(maskString, "")
|
||||||
var mm ModeMask
|
var modeMask ModeMask
|
||||||
for _, m := range cl {
|
for _, m := range cl {
|
||||||
switch m {
|
switch m {
|
||||||
case "C":
|
case "C":
|
||||||
mm = MaskSetMode(mm, ModeLowerCase|ModeNumeric|ModeSpecial|ModeUpperCase)
|
modeMask = MaskSetMode(modeMask, ModeLowerCase|ModeNumeric|ModeSpecial|ModeUpperCase)
|
||||||
case "h":
|
case "h":
|
||||||
mm = MaskClearMode(mm, ModeHumanReadable)
|
modeMask = MaskClearMode(modeMask, ModeHumanReadable)
|
||||||
case "H":
|
case "H":
|
||||||
mm = MaskSetMode(mm, ModeHumanReadable)
|
modeMask = MaskSetMode(modeMask, ModeHumanReadable)
|
||||||
case "l":
|
case "l":
|
||||||
mm = MaskClearMode(mm, ModeLowerCase)
|
modeMask = MaskClearMode(modeMask, ModeLowerCase)
|
||||||
case "L":
|
case "L":
|
||||||
mm = MaskSetMode(mm, ModeLowerCase)
|
modeMask = MaskSetMode(modeMask, ModeLowerCase)
|
||||||
case "n":
|
case "n":
|
||||||
mm = MaskClearMode(mm, ModeNumeric)
|
modeMask = MaskClearMode(modeMask, ModeNumeric)
|
||||||
case "N":
|
case "N":
|
||||||
mm = MaskSetMode(mm, ModeNumeric)
|
modeMask = MaskSetMode(modeMask, ModeNumeric)
|
||||||
case "s":
|
case "s":
|
||||||
mm = MaskClearMode(mm, ModeSpecial)
|
modeMask = MaskClearMode(modeMask, ModeSpecial)
|
||||||
case "S":
|
case "S":
|
||||||
mm = MaskSetMode(mm, ModeSpecial)
|
modeMask = MaskSetMode(modeMask, ModeSpecial)
|
||||||
case "u":
|
case "u":
|
||||||
mm = MaskClearMode(mm, ModeUpperCase)
|
modeMask = MaskClearMode(modeMask, ModeUpperCase)
|
||||||
case "U":
|
case "U":
|
||||||
mm = MaskSetMode(mm, ModeUpperCase)
|
modeMask = MaskSetMode(modeMask, ModeUpperCase)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return mm
|
return modeMask
|
||||||
}
|
}
|
||||||
|
|
||||||
// String satisfies the fmt.Stringer interface for the Mode type
|
// String satisfies the fmt.Stringer interface for the Mode type
|
||||||
|
|
Loading…
Reference in a new issue