Orion9

|
Posted: Thu Jul 09, 2026 13:53 Post subject: |
|
|
Сделал два новых, пока эксперементальных пункта меню, один для добавления кнопок из других панелей, второй для удаления кнопок после разрыва. Если кто-то хочет попробовать, можно добавить эти пункты меню к основному меню
 Hidden text | Code: | txt &= 'MENUITEM "Отладочная информация", em_aucmd ' & (gHBarDbg ? "/C" : "") & ' -1 HBarDebugInfo' & auCRLF
txt &= 'MENUITEM SEPARATOR' & auCRLF
txt &= 'POPUP "Загрузить панель"' & auCRLF
txt &= HBarAddBarMenu() & auCRLF
txt &= 'END_POPUP' & auCRLF
txt &= 'MENUITEM SEPARATOR' & auCRLF
txt &= 'POPUP "Удалить кнопки за разрывом"' & auCRLF
txt &= HBarBreakMenu() & auCRLF
txt &= 'END_POPUP' & auCRLF
txt &= 'MENUITEM SEPARATOR' & auCRLF
txt &= 'MENUITEM "Отменить действие", em_aucmd ' & (gHBarUndo ? "" : "/D") & ' -1 HBarUndo' & auCRLF
|
фрагмент можно добавить в конец модуля
 Hidden text | Code: | gHBarBars = list()
Func HBarAddBarMenu()
Local sBars = FileFind(COMMANDER_PATH, "*.bar", -1, 1)
#sBars = StrTrim(sBars)
Local text
gHBarBars.Count = 0
gHBarBars.Text = sBars
For i = 0 To gHBarBars.Count - 1
text = text & 'MENUITEM "' & gHBarBars[i] & '", em_aucmd -1 HBarMergeOne ' & i & auCRLF
Next
Return text
EndFunc
Func HBarMergeOne(FileIndex)
Local bar = gHBarBars[FileIndex]
c = IniRead(bar, "Buttonbar", "Buttoncount", 0)
If c = 0 Then
MsgBox("Файл не содержит данных о кнопках" & auCRLF & auCRLF & bar, "Autorun", 0+48)
Return
EndIf
If FileGetTime(gHBarFile) <> gHBarFileTs Then
MsgBox("Операция невозможна. Файл главной панели изменился.")
Return
Endif
Local text = FileRead(bar), count = gHBarMap.Count + 1
Local rext = 'button' & count & '=' & auCRLF & _
'cmd' & count & '=-2' & auCRLF & 'iconic' & count & '=0' & auCRLF
Local i = 0
Local rex = RegExp('(?i)(button|cmd|param|path|menu|iconic)(\d+?)=(.*?)\R', text)
If rex.Exec() Then
Do
#If StrLower(rex.Match[2]) = 'button' Then i += 1
rext &= rex.Match[1] & rex.Match[2]+count & '=' & rex.Match[3] & auCRLF
Until not rex.ExecNext()
EndIf
Free(rex)
#If i < 1 Then Return MsgBox("Error: the number of buttons can't be zero")
#rext = StrTrim(rext)
# сохранение панели
Local txt = gHBarList.Text
gHBarUndoLoad = txt
If Not gHBarCancel Then
gHBarCancel = true
gHBarCancelLoad = txt
EndIf
txt &= auCRLF & rext
# обновление панели
gHBarList.Text = txt
gHBarList.SaveToFile(gHBarFile, gHBarCP)
IniWrite(gHBarFile, "Buttonbar", "Buttoncount", count+c)
gHBarUndoTs = FileGetTime(gHBarFile)
gHBarFileTs = FileGetTime(gHBarFile)
If gHBarUndoTs Then
gHBarUndo = true
Else
gHBarUndo = false
gHBarUndoLoad = ""
EndIf
HBarLoad()
#SendCommand(2945) # cm_ReloadBarIcons
SendMessage(AUTORUN_TCHANDLE, 11, 0, 0)
SendCommand(2901, 0, 1)
SendCommand(2901, 0, 1)
Sleep(10)
SendMessage(AUTORUN_TCHANDLE, 11, 1, 0)
WinRedraw(2)
EndFunc
Func HBarBreakMenu()
Local text
For i = 0 To gHBarMap.Count - 1
If gHBarMap[i] = -2 Then
text = text & 'MENUITEM "Индекс разрыва: ' & i+1 & '", em_aucmd -1 HBarBreakErase ' & i+1 & auCRLF
EndIf
Next
If text = "" Then text = 'MENUITEM "Нет разрывов", em_aucmd /D -1'
Return text
EndFunc
Func HBarBreakErase(BreakIndex)
If FileGetTime(gHBarFile) <> gHBarFileTs Then
MsgBox("Операция невозможна. Файл главной панели изменился.")
Return
Endif
If BreakIndex < 1 Then
MsgBox("Индекс разрыва не может быть меньше 2")
Return
Endif
Local text = gHBarList.Text, rext = ""
Local rex = RegExp('(?i)(button|cmd|param|path|menu|iconic)(\d+?)=(.*?)\R', text)
If rex.Exec() Then
Do
If rex.Match[2] < BreakIndex Then
rext &= rex.Match[1] & rex.Match[2] & '=' & rex.Match[3] & auCRLF
EndIf
Until not rex.ExecNext()
EndIf
Free(rex)
If rext = "" Then Return MsgBox("Ошибка удаления. Buttoncount=0, BreakIndex=" & BreakIndex)
Local txt = gHBarList.Text
gHBarUndoLoad = txt
If Not gHBarCancel Then
gHBarCancel = true
gHBarCancelLoad = txt
EndIf
# обновление панели
gHBarList.Text = "[Buttonbar]" & auCRLF & "Buttoncount=" & BreakIndex-1 & auCRLF & rext
gHBarList.SaveToFile(gHBarFile, gHBarCP)
gHBarUndoTs = FileGetTime(gHBarFile)
gHBarFileTs = FileGetTime(gHBarFile)
If gHBarUndoTs Then
gHBarUndo = true
Else
gHBarUndo = false
gHBarUndoLoad = ""
EndIf
HBarLoad()
SendMessage(AUTORUN_TCHANDLE, 11, 0, 0)
SendCommand(2901, 0, 1)
SendCommand(2901, 0, 1)
Sleep(10)
SendMessage(AUTORUN_TCHANDLE, 11, 1, 0)
WinRedraw(2)
EndFunc |
Поскольку используются функции для работы с регулярными выражениями, в autorun.cfg должен быть подключен субплагин
| Code: | LoadLibrary Plugins\Autorun_RegExp.dll |
Если коротко о функционале, можно открыть несколько доролнительных панелей и перетаскивать значки на главной панели. Пока только для теста, могут быть ошибки. По этой причине не стал обновлять модуль на первой странице. Есть планы сделать удаление кнопок с панели и копирование только значка при переносе, ради чего, собственно, это все и задумывалось. |
|