Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Informations sur le Fuse
- FuRegisterClass("TextCaseModifier", CT_Modifier, {
- REGS_Category = "Fuses",
- REGID_DataType = "Text",
- REGID_InputDataType = "Text",
- REGS_OpIconString = "UTL",
- REGS_OpDescription = "",
- })
- function Create()
- -- Paramètre de sélection du mode de casse
- InCaseMode = self:AddInput("Case Mode", "CaseMode", {
- LINKID_DataType = "Number",
- INPID_InputControl = "ComboControl",
- INP_Default = 0,
- INP_Integer = true,
- { CCS_AddString = "Original" },
- { CCS_AddString = "UPPER CASE" },
- { CCS_AddString = "lower case" },
- { CCS_AddString = "Title Case" },
- })
- InText = self:AddInput("Input Text", "InputText", {
- LINKID_DataType = "Text",
- LINK_Main = 1,
- INPID_InputControl = "TextEditControl",
- TEC_Lines = 8,
- TEC_ReadOnly = false,
- INP_DoNotifyChanged = true,
- })
- OutText = self:AddOutput("Output Text", "OutputText", {
- LINKID_DataType = "Text",
- LINK_Main = 1,
- })
- --[[ -- Contrôle pour afficher le texte reçu (lecture seule)
- InDisplayText = self:AddInput("Received Text", "DisplayText", {
- LINKID_DataType = "Text",
- INPID_InputControl = "TextEditControl",
- TEC_Lines = 8,
- TEC_ReadOnly = false,
- INP_DoNotifyChanged = true,
- }) ]]
- end
- --[[ function SetSource(out, param, time)
- if out == OutText then
- -- Debug ce que SetSource reçoit
- if param then
- if param.Value and param.Value ~= "" then
- InStyledText:SetSource(param:Copy(), time)
- else
- InStyledText:SetSource(Text("DEBUG: PARAM VIDE"), time)
- end
- else
- InStyledText:SetSource(Text("DEBUG: PAS DE PARAM"), time)
- end
- end
- end ]]
- function SetSource(out, param, time) -- copies StyledText from Text+ into Modifier
- if out == OutText then
- InText:SetSource(param:Copy(), time)
- end
- end
- function Process(req)
- print(req.Time)
- local mode = InCaseMode:GetValue(req).Value
- -- Lire directement depuis InText (fonctionne avec Follower)
- local inputText = InText:GetValue(req)
- if not inputText or not inputText.Value then
- -- Effacer l'affichage si pas de texte
- -- InDisplayText:SetAttrs({INPS_DefaultText = ""})
- OutText:Set(req, Text(""))
- return
- end
- local textValue = inputText.Value
- -- Mettre à jour l'affichage avec le texte reçu
- --InDisplayText:SetSource(Text(textValue),0)
- local outputText = textValue
- if mode == 1 then
- outputText = string.upper(textValue)
- elseif mode == 2 then
- outputText = string.lower(textValue)
- elseif mode == 3 then
- outputText = string.lower(textValue)
- outputText = string.gsub(outputText, "(%a)([%w_']*)",
- function(first, rest)
- return string.upper(first) .. rest
- end)
- end
- OutText:Set(req, Text(outputText))
- end
Advertisement