Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
29 user(s) are online (22 user(s) are browsing Forums)

Members: 4
Guests: 25

VooDoo, sailor, NinjaCyborg, smf, more...

Support us!

Headlines

 
  Register To Post  

« 1 (2)
Re: texteditor.gadget and copy/paste
Home away from home
Home away from home


See User information
With window class windows you need to add a idcmphook, WINDOW_IDCMPHook or similar (away from any amiga to check) search window class auto doc.

You might need to set the gadgets ICA_TARGET to the window, check includes for correct values, should be obvious

Go to top
Re: texteditor.gadget and copy/paste
Home away from home
Home away from home


See User information
@broadblues
Quote:

should be obvious


Not sure if it all that obvious, but while i got it, still will share some info as maybe someday someone else will search amigans.net for that info.

So, i was told today by Dan that we do have actually 2 methods of using ICA_*. After some digging and testing that indeed few ways : One is just when you create a map, like:

struct TagItem button_to_string_map[] = {
    {
GA_SelectedMYTAG_UPDATE},
    {
MYTAG_UPDATE, (ULONG)"Button Fucked !"},
    {
TAG_END0}
};


and then:

/* Create String gadget */
    
Object *string_gadget IIntuition->NewObject(StringClassNULL,
        
GA_IDGID_STRING,
        
GA_RelVerifyTRUE,
        
STRINGA_TextVal"Initial Text",
        
STRINGA_MaxChars256,
        
TAG_END);

    if (!
string_gadget) {
        
IDOS->Printf("Failed to create String gadget.\n");
        goto 
cleanup;
    }

    
/* Create Button gadget with ICA_TARGET and ICA_MAP */
    
Object *button_gadget IIntuition->NewObject(ButtonClassNULL,
        
GA_IDGID_BUTTON,
        
GA_RelVerifyTRUE,
        
GA_Text"Click Me",
        
ICA_TARGETstring_gadget/* Send OM_UPDATE to String gadget */
        
ICA_MAPbutton_to_string_map/* Map GA_Selected to MYTAG_UPDATE */
        
TAG_END);



This way winObj have no needs to have any IDCMP_IDCMPUPDATE/WINDOW_IDCMPHook/etc flags, and it works as OM_UPDATE.


Then, another way is like you say : creating an IDCMPHook, via adding to main window object like:

WINDOW_IDCMPHook,&idcmphook,
WINDOW_IDCMPHookBits,IDCMP_IDCMPUPDATE,


And then while our main loop is still reaction based with != WMHI_LASTMSG, we in the hook do:

switch (imsg->Class)
        {
    case 
IDCMP_IDCMPUPDATE:
        switch (
GetTagData (GA_ID,0,imsg->IAddress))
            {
        case 
GID_blablba:
                           .......

            break;
            }
        break;
        }



Surely first way give not much control , just an information, but maybe that also enough ?

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: texteditor.gadget and copy/paste
Just can't stay away
Just can't stay away


See User information
@kas1e

Not sure what you are trying to do, but if it's just connecting a vertical scroller to a texteditor you can just do:

SetAttrs(textEditorObject,
         
GA_TEXTEDITOR_VertScrollerscrollerObject,
         
TAG_END);


and the text editor class will handle updating the scroller as necessary, as well as setting ICA_TARGET and ICA_MAP so that it gets updates from the scroller when it's moved.

Go to top
Re: texteditor.gadget and copy/paste
Home away from home
Home away from home


See User information
@salas00
Turns out that was it :) Went through custom scrollbar logic, ICA_* attributes, and hook setup — only to realize it all boiled down to a single string of code..

@all
Any ideas on properly loading large binary files (more than 100mb) into texteditor.gadget? Issue is that null bytes (0x00) get treated as string terminators, so content gets truncated. Notepad and MultiEdit seem to handle this: they not only skip 0x00 but also appear to skip something else too, and that no isprint() from ctype.h.

I currently just skip 00 but curious how Notepad do. It's more than isprint() filtering for sure — they skip additional chars.

Also, what’s the proper way to load a file via DOS these days? I mean modern with all the things way. Currently use:

IDOS->FOpen
IDOS->GetFileSize
IDOS->Read

But maybe that all dated already..

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: texteditor.gadget and copy/paste
Home away from home
Home away from home


See User information
@kas1e
Quote:
Also, what’s the proper way to load a file via DOS these days? I mean modern with all the things way. Currently use:

IDOS->FOpen
IDOS->GetFileSize
IDOS->Read
Don't mix buffered and unbuffered dos.library I/O functions.
Either use IDOS->Open(), IDOS->Read() and IDOS->Close() (unbuffered, faster if you only do large reads, slow for small reads, it's similar to the POSIX low-level open(), read() and close() functions), or IDOS->FOpen(), IDOS->FRead() and IDOS->FClose() (buffered, faster for small reads, more like the C library fopen(), fread() and fclose() functions).
For your case check the IDOS->FGets() and IDOS->FReadLine() function as well, the 2nd one can read single lines like FGets() (default) or with ADO_TermChar, -1 the complete file into a single buffer.

Go to top
Re: texteditor.gadget and copy/paste
Home away from home
Home away from home


See User information
@kas1e

Quote:

Any ideas on properly loading large binary files (more than 100mb) into texteditor.gadget? Issue is that null bytes (0x00) get treated as string terminators, so content gets truncated. Notepad and MultiEdit seem to handle this: they not only skip 0x00 but also appear to skip something else too, and that no isprint() from ctype.h.


1. You probably shouldn't as it's a text editor

but

2. JUst use

SetAttrs((Object *)EditorGadget,
GA_TEXTEDITOR_Length,Size,
GA_TEXTEDITOR_Contents,Data,
TAG_DONE);

Go to top
Re: texteditor.gadget questions
Home away from home
Home away from home


See User information
@Andy
As i aware WMHI_RAWKEY are eaten up by the texteditor if it active, is there any way to still add support of my keys while editor active ? Maybe via idcmp or something ?

@All
Is anyone know about how to deal with ?

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: texteditor.gadget questions
Home away from home
Home away from home


See User information
I were able to catch my own keys with active texteditor, but by some hardcore way: i installed input handler:

/* Allocate and initialize interrupt */
    
DEBUG_PRINTF("Attempting to allocate input handler...\n");
    
inputHandler IExec->AllocSysObjectTags(ASOT_INTERRUPT,
        
ASOINTR_CodeinputHandlerFunc,
        
ASOINTR_DataNULL,
        
ASOINTR_Pri51// 50 and less didn't work
        
ASOINTR_Name"DumbPad Input Handler",        
        
TAG_END);
    if (!
inputHandler)
    {
        
DEBUG_PRINTF("Failed to allocate input handler.\n");
        goto 
cleanup;
    }

    
/* Add handler */
    
inputReq->io_Data = (APTR)inputHandler;
    
inputReq->io_Command IND_ADDHANDLER;
    if (
IExec->DoIO((struct IORequest *)inputReq))
    {
        
DEBUG_PRINTF("Failed to add input handler (DoIO error: %ld)\n", (long)inputReq->io_Error);
        goto 
cleanup;
    }
    
DEBUG_PRINTF("Input handler added successfully.\n");




In which (in inputHandlerFunc() ) just catch for event->ie_Class == IECLASS_RAWKEY for keys i need : once key is pressed, i set a BOOL flag shared across with main app, and IExec->Signal(inputPort->mp_SigTask, 1L << inputPort->mp_SigBit).

In the main while loop i had of course to change my original "sigGot = IExec->Wait(sigMask | SIGBREAKF_CTRL_C);" to "sigGot = IExec->Wait(sigMask | SIGBREAKF_CTRL_C | (1L << inputPort->mp_SigBit));" , so to retrieve signal from inputPort.


And then:

if (sigGot & (1L << inputPort->mp_SigBit))
{
    while (
IExec->GetMsg(inputPort)) { /* Clear messages */ }
    if (
my_key_pressed)
    {
        
DEBUG_PRINTF("my key pressed...\n");
        
DidTheThing();
        
my_key__pressed FALSE;
    }
}



The code works fine, but there are a few points to address:

1). I had to set ASOINTR_Pri higher than 50 (51 works, but 50 does not). Otherwise, the handler didn't catch any events. Initially, I thought the TextEditor.gadget's input handler was consuming all events, but then I tested a plain window without any objects, using a standard Reaction application's WM_HANDLEINPUT loop, and observed the same behavior. It seems that any priority below 51 is overridden by the WM_HANDLEINPUT loop. Regardless, I'm still unsure how safe this is for the system or what potential issues this "priority juggling" might cause if I use a priority of at least 51.

2). I'm not fond of using a BOOL "flag" for handling my key events. It feels clunky, and I think it would be cleaner to handle it through events or something like a case MYHANDLER: block with switches inside the main loop. This would make the while loop look more organized and elegant.

3). I need the handler to send signals only when my window/app is active, to avoid processing key events when another application is in focus. I'm not sure how to properly implement this, as some applications (e.g., commodities or background tasks) might also handle the same key, but I need to ensure that my general-purpose handler sends signals only to my task when my window/app is active.


Edited by kas1e on 2025/6/5 7:01:06
Edited by kas1e on 2025/6/5 7:06:13
Edited by kas1e on 2025/6/5 7:32:50
Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: texteditor.gadget questions
Home away from home
Home away from home


See User information
@All
Fixed the usage of the BOOL flag to be an event sent by a signal. Also fixed the interrupt to only trigger for my active window. (The interrupt is, of course, global, but events are now sent to the main app only when my app's window is active.)

Tested with Capehill's Tequila: it shows no overhead at all. The app consumes resources as before, with no additional load.

However, I noticed an interesting detail: as mentioned, I had to set ANOINTR_Pri higher than 50, or the interrupt wouldn't catch anything. Thanks to Tequila, I found that input.device runs at priority 20. So why can't I go below 50 in my app? Is WM_INPUTHANDLER, which sits on top of input.device, taking an additional 30 priority levels? Or is something else happening? Initially, I thought texteditor.gadget might be taking up priority levels up to 50. But then I created a simple Reaction-based app with no objects, just the main WM_INPUTHANDLER loop, and I still couldn't set the priority below 50. So, is it likely window.class causing this? Or is something else happening?

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: texteditor.gadget questions
Home away from home
Home away from home


See User information
@kas1e
Quote:
However, I noticed an interesting detail: as mentioned, I had to set ANOINTR_Pri higher than 50, or the interrupt wouldn't catch anything. Thanks to Tequila, I found that input.device runs at priority 20. So why can't I go below 50 in my app?
Task priorities aren't related to interrupt priorities in any way.
Check with tools like Ranger, Scout, etc. which other input.device input handler interrupts are installed, there seems to be one with priority 50 eating up all input events (returning nothing instead of the original, or some modified, input events), making all input handler interrupts with a lower priority fail.

Go to top
Re: texteditor.gadget questions
Home away from home
Home away from home


See User information
@joerg
(click open in new tab for fullsize):

Resized Image

So, that intuition.. Funny that commodities 53.
ps. shouldn't i fill any data , so to not be 0x000000, or that doesn't matter? I just did ASOINTR_Data, NULL, as i have no needs in data to send to handler, i only need return from which is ok with data = NULL, but just when i see 0x0000000 anywhere i fear of crashes and null pointer acceses :)

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: texteditor.gadget questions
Home away from home
Home away from home


See User information
@kas1e
Quote:
ps. shouldn't i fill any data , so to not be 0x000000, or that doesn't matter?
It's internal data for your function only, just like h_Data in Hook functions.
As long as you don't try to access it in your own code there is no problem with NULL data.

Go to top

  Register To Post
« 1 (2)

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project