Page 1 of 1

PB-IDE Opensource developer helper tools

Posted: Fri Jan 21, 2022 5:07 pm
by mk-soft
Convert the exported colours from the PB-IDE into DataSection code.

Code: Select all

;-TOP

; Comment : Convert exported IDE Colors to PB-Code for Preferences.pb
; Author  : mk-soft
; Version : v1.01.0
;
; Insert to DataSection DefaultColorSchemes:
; First value is total number of defined schemes 

Global NewList Colors.s()
Global file.s

Procedure LoadColorPref(FileName.s, Schema.s)
  Protected keyName.s, keyValue.s, comment.s
  Protected temp.s, red.s, green.s, blue.s
  
  If OpenPreferences(FileName)
    PreferenceGroup("Colors")
    ExaminePreferenceKeys()
    While NextPreferenceKey()
      keyName = PreferenceKeyName()
      keyValue = PreferenceKeyValue()
      If Not FindString(keyName, "_Used")
        keyValue = RemoveString(keyValue, "RGB(")
        keyValue = RemoveString(keyValue, ")")
        keyValue = RemoveString(keyValue, " ")
        red = RSet(Hex(Val(StringField(keyValue, 1, ","))), 2, "0")
        green = RSet(Hex(Val(StringField(keyValue, 2, ","))), 2, "0")
        blue = RSet(Hex(Val(StringField(keyValue, 3, ","))), 2, "0")
        If Not FindString(keyName, "ToolsPanel")
          comment = RemoveString(keyName, "_") 
          comment = RemoveString(comment, "Color")
          comment = " ; #COLOR_" + comment
        Else
          comment = " ;  " + keyName
        EndIf
        temp = "  Data.l $" + blue + green + red + comment
        AddElement(Colors())
        Colors() = temp
      EndIf
    Wend
    LastElement(Colors())
    MoveElement(Colors(), #PB_List_First)
    FirstElement(Colors())
    LastElement(Colors())
    MoveElement(Colors(), #PB_List_First)
    FirstElement(Colors())
    InsertElement(Colors())
    Colors() = "  Data$ " + #DQUOTE$ + Schema + #DQUOTE$
  EndIf
  
EndProcedure

file = OpenFileRequester("PB Color Preferences", "", "", 0)
If file
  LoadColorPref(file, "Dark Mode")
  ForEach Colors()
    Debug Colors()
  Next
EndIf

Re: PB-IDE Opensource developer helper tools

Posted: Sun Jan 23, 2022 7:06 pm
by Kwai chang caine
Works nice
Thanks for sharing 8)