<commit_before>import os
from cudatext import *
from random import randint


def callback_main_close(id_dlg, id_ctl, data='', info=''):
    print('callback_main_close')

    dlg_proc(id_dlg, DLG_HIDE)

    #hide tab added to sidebar
    app_proc(PROC_SIDEPANEL_REMOVE, 'Side dialog')
    app_proc(PROC_SIDEPANEL_ACTIVATE, 'Tree')

def callback_main_menu(id_dlg, id_ctl, data='', info=''):
    print('callback_main_menu')
    nctl = dlg_proc(id_dlg, DLG_CTL_FIND, prop='btn_menu')
    d = dlg_proc(id_dlg, DLG_CTL_PROP_GET, index=nctl)

    nx = d['x']
    ny = d['y']+d['h']
    nx, ny = dlg_proc(id_dlg, DLG_COORD_LOCAL_TO_SCREEN, index=nx, index2=ny)

    h_menu = menu_proc(0, MENU_CREATE)
    menu_proc(h_menu, MENU_ADD, command=2700, caption='About1')
    menu_proc(h_menu, MENU_ADD, command=2700, caption='About2')
    menu_proc(h_menu, MENU_ADD, command=2700, caption='About3')
    menu_proc(h_menu, MENU_SHOW, command='%d,%d'%(nx, ny))


class Command:
    border = True

    def run_modal(self):
        print('run_modal begin')
        h = self.init_maindlg()
        dlg_proc(h, DLG_SHOW_MODAL)
        self.show_form_prop(h)
        dlg_proc(h, DLG_FREE)
        print('run_modal end')

    def run_nonmodal(self):
        h = self.init_maindlg()
        dlg_proc(h, DLG_SHOW_NONMODAL)

    def run_dlgcustom(self):
        dlg_custom('TestDlg', 200, 100, 'type=label\1pos=6,6,200,0\1cap=Test')

    def callback_linklabel_click(self, id_dlg, id_ctl, data='', info=''):
        msg_box('Linklabel clicked', MB_OK)

    def callback_buttondlg(self, id_dlg, id_ctl, data='', info=''):
        h = id_dlg
        n_btn_border = dlg_proc(h, DLG_CTL_FIND, prop='btn_border')
        n_btn_icon = dlg_proc(h, DLG_CTL_FIND, prop='btn_icon')

        if id_ctl==n_btn_border:
            self.border = not self.border
            val = DBORDER_DIALOG if self.border else DBORDER_NONE
            dlg_proc(h, DLG_PROP_SET, prop={'border': val} )

        if id_ctl==n_btn_icon:
            #toggle button's checked
            id_btn = dlg_proc(h, DLG_CTL_HANDLE, name='btn_icon')
            b = button_proc(id_btn, BTN_GET_CHECKED)
            button_proc(id_btn, BTN_SET_CHECKED, not b)
            button_proc(id_btn, BTN_SET_BOLD, not b)

            #set imagelist+icon for button
            id_imglist = app_proc(PROC_GET_TAB_IMAGELIST, '')
            button_proc(id_btn, BTN_SET_KIND, BTNKIND_TEXT_ICON_VERT)
            button_proc(id_btn, BTN_SET_IMAGELIST, id_imglist)
            button_proc(id_btn, BTN_SET_IMAGEINDEX, int(b))

    def callback_splitter_left(self, id_dlg, id_ctl, data='', info=''):
        h = id_dlg
        print('callback_splitter_left')

    def callback_combo_change(self, id_dlg, id_ctl, data='', info=''):
        print('combo on_change')

    def callback_combo_change2(self, id_dlg, id_ctl, data='', info=''):
        print('combo2 on_change')

    def callback_maindlg(self, id_dlg, id_ctl, data='', info=''):
        print('callback_maindlg(info=%s)' % repr(info))
        h = id_dlg

        n_chk_panel = dlg_proc(h, DLG_CTL_FIND, prop='chk_panel')<commit_msg>improve plug Testing Dialog API<commit_after>import os
from cudatext import *
from random import randint


def callback_main_close(id_dlg, id_ctl, data='', info=''):
    print('callback_main_close')

    dlg_proc(id_dlg, DLG_HIDE)

    #hide tab added to sidebar
    app_proc(PROC_SIDEPANEL_REMOVE, 'Side dialog')
    app_proc(PROC_SIDEPANEL_ACTIVATE, 'Tree')

def callback_main_menu(id_dlg, id_ctl, data='', info=''):
    print('callback_main_menu')
    nctl = dlg_proc(id_dlg, DLG_CTL_FIND, prop='btn_menu')
    d = dlg_proc(id_dlg, DLG_CTL_PROP_GET, index=nctl)

    nx = d['x']
    ny = d['y']+d['h']
    nx, ny = dlg_proc(id_dlg, DLG_COORD_LOCAL_TO_SCREEN, index=nx, index2=ny)

    h_menu = menu_proc(0, MENU_CREATE)
    menu_proc(h_menu, MENU_ADD, command=2700, caption='About1')
    menu_proc(h_menu, MENU_ADD, command=2700, caption='About2')
    menu_proc(h_menu, MENU_ADD, command=2700, caption='About3')
    menu_proc(h_menu, MENU_SHOW, command='%d,%d'%(nx, ny))


class Command:
    border = True

    def run_modal(self):
        print('run_modal begin')
        h = self.init_maindlg()
        dlg_proc(h, DLG_SHOW_MODAL)
        self.show_form_prop(h)
        dlg_proc(h, DLG_FREE)
        print('run_modal end')

    def run_nonmodal(self):
        h = self.init_maindlg()
        dlg_proc(h, DLG_SHOW_NONMODAL)

    def run_dlgcustom(self):
        dlg_custom('TestDlg', 200, 100, 'type=label\1pos=6,6,200,0\1cap=Test')

    def callback_linklabel_click(self, id_dlg, id_ctl, data='', info=''):
        msg_box('Linklabel clicked', MB_OK)

    def callback_buttondlg(self, id_dlg, id_ctl, data='', info=''):
        h = id_dlg
        n_btn_border = dlg_proc(h, DLG_CTL_FIND, prop='btn_border')
        n_btn_icon = dlg_proc(h, DLG_CTL_FIND, prop='btn_icon')

        if id_ctl==n_btn_border:
            self.border = not self.border
            val = DBORDER_DIALOG if self.border else DBORDER_NONE
            dlg_proc(h, DLG_PROP_SET, prop={'border': val} )

        if id_ctl==n_btn_icon:
            #toggle button's checked
            id_btn = dlg_proc(h, DLG_CTL_HANDLE, name='btn_icon')
            b = button_proc(id_btn, BTN_GET_CHECKED)
            button_proc(id_btn, BTN_SET_CHECKED, not b)
            button_proc(id_btn, BTN_SET_BOLD, not b)

            #set imagelist+icon for button
            id_imglist = app_proc(PROC_GET_TAB_IMAGELIST, '')
            button_proc(id_btn, BTN_SET_KIND, BTNKIND_TEXT_ICON_VERT)
            button_proc(id_btn, BTN_SET_IMAGELIST, id_imglist)
            button_proc(id_btn, BTN_SET_IMAGEINDEX, int(b))

    def callback_splitter_left(self, id_dlg, id_ctl, data='', info=''):
        h = id_dlg
        print('callback_splitter_left')

    def callback_combo_change(self, id_dlg, id_ctl, data='', info=''):
        
        p = dlg_proc(id_dlg, DLG_CTL_PROP_GET, name='c1')
        text = p['val']
        dlg_proc(id_dlg, DLG_PROP_SET, prop={'cap': 'text: '+text})

    def callback_combo_change2(self, id_dlg, id_ctl, data='', info=''):
    
        p = dlg_proc(id_dlg, DLG_CTL_PROP_GET, name='c2')
        index = p['val']
        dlg_proc(id_dlg, DLG_PROP_SET, prop={'cap': 'index: '+str(index)})

    def callback_maindlg(self, id_dlg, id_ctl, data='', info=''):
        print('callback_maindlg(info=%s)' % repr(info))
        h = id_dlg

        n_chk_panel = dlg_proc(h, DLG_CTL_FIND, prop='chk_panel')
{'fraction_non_alphanumeric': 0.12663688183638885, 'fraction_numerical': 0.010321984285934371, 'mean_word_length': 3.3953960731211916, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1445230', 'n_tokens_mistral': 2620, 'n_tokens_neox': 2531, 'n_words': 447}