Loading ...
Sorry, an error occurred while loading the content.

fontpanel.diff

Expand Messages
  • Rain Dog
    OK then, how about a patch that adds a font selection panel to Carbon Vim? This patches gui_mac.c, CVS version 1.39, and has only been tested on OSX 10.2.2. I
    Message 1 of 10 , Dec 15, 2002
    • 0 Attachment
      OK then, how about a patch that adds a font selection panel to
      Carbon Vim?

      This patches gui_mac.c, CVS version 1.39, and has only been
      tested on OSX 10.2.2. I have no idea if it will work on a
      non-OSX Carbon system.

      ":set guifont=*" to invoke the Font Panel. Close the panel
      to set the selected font.

      Limitations:

      o Doesn't restrict the font selection to monospaced fonts.

      There doesn't seem to be a way to do this using the
      default Font Panel.

      o Boldface, italics, etc. are not supported.

      They never were; ":set guifont=Monaco:b" doesn't work either.

      o After a font is selected, guifont remains set to "*".

      This shouldn't be hard to fix, but I'm not sure exactly where
      to fix it. In any case, this behavior is consistent with
      ":set guifont=", which selects the default font and leaves
      guifont set to "", instead of the name of the default font.

      ---------- 8< ---------- 8< ---------- 8< ---------- 8< ----------

      *** gui_mac.c Sun Dec 15 18:08:38 2002
      --- gui_mac.c Sun Dec 15 18:03:40 2002
      ***************
      *** 193,198 ****
      --- 193,209 ----
      /* Keeping track of which scrollbar is being dragged */
      static ControlHandle dragged_sb = NULL;

      + #ifdef USE_CARBONIZED
      + static struct
      + {
      + FMFontFamily family;
      + FMFontSize size;
      + FMFontStyle style;
      + Boolean isPanelVisible;
      + }
      + gFontPanelInfo = { 0, 0, 0, false };
      + #endif
      +
      /*
      * The Quickdraw global is predefined in CodeWarior
      * but is not in Apple MPW
      ***************
      *** 1397,1402 ****
      --- 1408,1502 ----
      }
      #endif /* USE_AEVENT */

      +
      + #ifdef USE_CARBONIZED
      + /*
      + * Callback function, installed by InstallFontPanelHandler(), below,
      + * to handle Font Panel events.
      + */
      + static OSStatus
      + FontPanelHandler(EventHandlerCallRef inHandlerCallRef, EventRef
      inEvent,
      + void *inUserData)
      + {
      + if (GetEventKind(inEvent) == kEventFontPanelClosed)
      + {
      + gFontPanelInfo.isPanelVisible = false;
      + return noErr;
      + }
      +
      + if (GetEventKind(inEvent) == kEventFontSelection)
      + {
      + OSStatus status;
      + FMFontFamily newFamily;
      + FMFontSize newSize;
      + FMFontStyle newStyle;
      +
      + /* Retrieve the font family ID number. */
      + status = GetEventParameter(inEvent, kEventParamFMFontFamily,
      + /*inDesiredType=*/typeFMFontFamily, /*outActualType=*/NULL,
      + /*inBufferSize=*/sizeof(FMFontFamily), /*outActualSize=*/NULL,
      + &newFamily);
      + if (status == noErr) gFontPanelInfo.family = newFamily;
      +
      + /* Retrieve the font size. */
      + status = GetEventParameter(inEvent, kEventParamFMFontSize,
      + typeFMFontSize, NULL, sizeof(FMFontSize), NULL, &newSize);
      + if (status == noErr) gFontPanelInfo.size = newSize;
      +
      + /* Retrieve the font style (bold, etc.). Currently unused. */
      + status = GetEventParameter(inEvent, kEventParamFMFontStyle,
      + typeFMFontStyle, NULL, sizeof(FMFontStyle), NULL, &newStyle);
      + if (status == noErr) gFontPanelInfo.style = newStyle;
      + }
      + return noErr;
      + }
      +
      +
      + static void
      + InstallFontPanelHandler()
      + {
      + EventTypeSpec eventTypes[2];
      + EventHandlerUPP handlerUPP;
      + /* EventHandlerRef handlerRef; */
      +
      + eventTypes[0].eventClass = kEventClassFont;
      + eventTypes[0].eventKind = kEventFontSelection;
      + eventTypes[1].eventClass = kEventClassFont;
      + eventTypes[1].eventKind = kEventFontPanelClosed;
      +
      + handlerUPP = NewEventHandlerUPP(FontPanelHandler);
      +
      + InstallApplicationEventHandler(handlerUPP, /*numTypes=*/2,
      eventTypes,
      + /*userData=*/NULL, /*handlerRef=*/NULL);
      + }
      +
      +
      + /*
      + * Fill the buffer pointed to by outName with the name and size
      + * of the font currently selected in the Font Panel.
      + */
      + static void
      + GetFontPanelSelection(char* outName)
      + {
      + Str255 buf;
      + Boolean isBold = false, isItalic = false;
      +
      + if (!outName) return;
      +
      + (void)FMGetFontFamilyName(gFontPanelInfo.family, buf);
      + p2cstrcpy(outName, buf);
      +
      + #if 0 /* TODO: enable when styles are supported in
      gui_mac_find_font() */
      + isBold = (gFontPanelInfo.style & bold);
      + isItalic = (gFontPanelInfo.style & italic);
      + #endif
      +
      + sprintf(&outName[buf[0]], ":h%d%s%s", gFontPanelInfo.size,
      + (isBold ? ":b" : ""), (isItalic ? ":i" : ""));
      + }
      + #endif
      +
      +
      /*
      * ------------------------------------------------------------
      * Unfiled yet
      ***************
      *** 2738,2743 ****
      --- 2838,2848 ----
      gScrollDrag = NewControlActionProc (gui_mac_drag_thumb);
      #endif

      + #ifdef USE_CARBONIZED
      + /* Install Carbon event callbacks. */
      + (void)InstallFontPanelHandler();
      + #endif
      +
      /* Getting a handle to the Help menu */
      #ifdef USE_HELPMENU
      # ifdef USE_CARBONIZED
      ***************
      *** 2956,2961 ****
      --- 3061,3098 ----
      }
      font = (suggestedSize << 16) + ((long) font_id & 0xFFFF);
      }
      + #ifdef USE_CARBONIZED
      + else if (STRCMP(font_name, "*") == 0)
      + {
      + OSStatus status;
      +
      + font = NOFONT;
      +
      + /* Pop up the Font Panel. */
      + status = FPShowHideFontPanel();
      + if (status == noErr)
      + {
      + char font_name[512];
      +
      + /*
      + * The Font Panel is modeless, but we really need it to be modal,
      + * so we spin in an event loop until the panel is closed.
      + */
      + gFontPanelInfo.isPanelVisible = true;
      + while (gFontPanelInfo.isPanelVisible)
      + {
      + EventRecord e;
      + WaitNextEvent(everyEvent, &e, /*sleep=*/20, /*mouseRgn=*/NULL);
      + }
      +
      + GetFontPanelSelection(font_name);
      + font = gui_mac_find_font(font_name);
      + }
      +
      + if (font == NOFONT)
      + return FAIL;
      + }
      + #endif
      else
      {
      font = gui_mac_find_font (font_name);
    • Benji Fisher
      ... [snip] Thanks for all the patches. I am in the middle of some work for the vim-latex project, so I do not have time to test them now. As soon as I do, I
      Message 2 of 10 , Dec 16, 2002
      • 0 Attachment
        Rain Dog wrote:
        > OK then, how about a patch that adds a font selection panel to
        > Carbon Vim?
        >
        > This patches gui_mac.c, CVS version 1.39, and has only been
        > tested on OSX 10.2.2. I have no idea if it will work on a
        > non-OSX Carbon system.
        >
        > ":set guifont=*" to invoke the Font Panel. Close the panel
        > to set the selected font.
        >
        > Limitations:
        >
        > o Doesn't restrict the font selection to monospaced fonts.
        >
        > There doesn't seem to be a way to do this using the
        > default Font Panel.
        >
        > o Boldface, italics, etc. are not supported.
        >
        > They never were; ":set guifont=Monaco:b" doesn't work either.
        >
        > o After a font is selected, guifont remains set to "*".
        >
        > This shouldn't be hard to fix, but I'm not sure exactly where
        > to fix it. In any case, this behavior is consistent with
        > ":set guifont=", which selects the default font and leaves
        > guifont set to "", instead of the name of the default font.
        >
        > ---------- 8< ---------- 8< ---------- 8< ---------- 8< ----------
        [snip]

        Thanks for all the patches. I am in the middle of some work for
        the vim-latex project, so I do not have time to test them now. As soon
        as I do, I will post the patches, and an updated binary, on the web.

        --Benji Fisher
      • Bram Moolenaar
        ... Sounds like a very nice addition. ... That s disappointing, since the user will get himself into trouble when selecting a wrong font... ... Ideally
        Message 3 of 10 , Dec 30, 2002
        • 0 Attachment
          Rain Dog wrote:

          > OK then, how about a patch that adds a font selection panel to
          > Carbon Vim?
          >
          > This patches gui_mac.c, CVS version 1.39, and has only been
          > tested on OSX 10.2.2. I have no idea if it will work on a
          > non-OSX Carbon system.
          >
          > ":set guifont=*" to invoke the Font Panel. Close the panel
          > to set the selected font.

          Sounds like a very nice addition.

          > Limitations:
          >
          > o Doesn't restrict the font selection to monospaced fonts.
          >
          > There doesn't seem to be a way to do this using the
          > default Font Panel.

          That's disappointing, since the user will get himself into trouble when
          selecting a wrong font...

          > o After a font is selected, guifont remains set to "*".
          >
          > This shouldn't be hard to fix, but I'm not sure exactly where
          > to fix it. In any case, this behavior is consistent with
          > ":set guifont=", which selects the default font and leaves
          > guifont set to "", instead of the name of the default font.

          Ideally 'guifont' would be set to a font name that works the same way
          when setting it to this value manually. The Win32 code does this (with
          some extra work to add font attributes to 'guifont').

          I'm not including Mac patches myself, since I cannot test them. I'll
          await the "Mac workers" to try it out, fix any problems and send me the
          big Mac patch later :-).

          Thanks for making this patch (and also the patches for scrollbars and
          Quarz fonts).

          --
          hundred-and-one symptoms of being an internet addict:
          226. You sit down at the computer right after dinner and your spouse
          says "See you in the morning."

          /// Bram Moolenaar -- Bram@... -- http://www.moolenaar.net \\\
          /// Creator of Vim - Vi IMproved -- http://www.vim.org \\\
          \\\ Project leader for A-A-P -- http://www.a-a-p.org ///
          \\\ Lord Of The Rings helps Uganda - http://iccf-holland.org/lotr.html ///
        • Rain Dog
          ... I ll have another look, but I m not too hopeful that this can be done (that is, that the default font panel can be customized to show only monospaced
          Message 4 of 10 , Jan 1, 2003
          • 0 Attachment
            On Monday, December 30, 2002, at 01:36 PM, Bram Moolenaar wrote:

            > Rain Dog wrote:
            >> how about a patch that adds a font selection panel to Carbon Vim?
            >
            > Sounds like a very nice addition.
            >
            >> o Doesn't restrict the font selection to monospaced fonts.
            >> There doesn't seem to be a way to do this using the
            >> default Font Panel.
            >
            > That's disappointing, since the user will get himself into trouble when
            > selecting a wrong font...

            I'll have another look, but I'm not too hopeful that this can be done
            (that is,
            that the default font panel can be customized to show only monospaced
            fonts).
            An alternative might be to ignore the command if the selected font is
            not
            monospaced. That doesn't seem too user-friendly either, though.

            >> o After a font is selected, guifont remains set to "*".
            >
            > Ideally 'guifont' would be set to a font name that works the same way
            > when setting it to this value manually. The Win32 code does this (with
            > some extra work to add font attributes to 'guifont').

            Ah, I see how to do it now--I wasn't sure how to safely set p_guifont.
            Thanks for the pointer!

            I'll post a new version of the patch once I've fixed this and made a few
            other improvements.


            Peter
          • Benji Fisher
            I have finally found time to try out the latest patches: scroll.diff, quartz.diff, and fontpanel.diff . (I did not miss any, did I?) I have two technical
            Message 5 of 10 , Jan 31, 2003
            • 0 Attachment
              I have finally found time to try out the latest patches:
              scroll.diff, quartz.diff, and fontpanel.diff . (I did not miss any, did
              I?) I have two technical requests:

              1. Please make patches from the vim61/ directory (or vim/ if you are
              using CVS) so that they refer to src/gui_mac.c etc.

              2. Please send patches as attachments.

              Rain Dog wrote:
              > On Monday, December 30, 2002, at 01:36 PM, Bram Moolenaar wrote:
              >
              >> Rain Dog wrote:
              >>
              >>> how about a patch that adds a font selection panel to Carbon Vim?
              >>
              >>
              >> Sounds like a very nice addition.
              >>
              >>> o Doesn't restrict the font selection to monospaced fonts.
              >>> There doesn't seem to be a way to do this using the
              >>> default Font Panel.
              >>
              >>
              >> That's disappointing, since the user will get himself into trouble when
              >> selecting a wrong font...

              Yes, big trouble.

              > I'll have another look, but I'm not too hopeful that this can be done
              > (that is,
              > that the default font panel can be customized to show only monospaced
              > fonts).
              > An alternative might be to ignore the command if the selected font is not
              > monospaced. That doesn't seem too user-friendly either, though.

              I will not use this patch in the binaries I distribute until there
              is some sort of solution to this problem. Instead of ignoring a
              variable-spaced font, can you give an error message (and leave 'gfn'
              unchanged)?

              >>> o After a font is selected, guifont remains set to "*".
              >>
              >> Ideally 'guifont' would be set to a font name that works the same way
              >> when setting it to this value manually. The Win32 code does this (with
              >> some extra work to add font attributes to 'guifont').
              >
              > Ah, I see how to do it now--I wasn't sure how to safely set p_guifont.
              > Thanks for the pointer!
              >
              > I'll post a new version of the patch once I've fixed this and made a few
              > other improvements.

              I have not yet compiled with the patches separately, so I cannot
              be sure where this problem cones from, but I suspect it is from one of
              the other patches (maybe quartz.diff). When I enter

              :version

              the "Hit ENTER" prompt gets messed up: the word "continue" at the end
              is repeated, overlapping itself a little.

              Keep trying!

              --Benji Fisher
            • Benji Fisher
              ... P.S. It would be nice to have an OK button and a Cancel button. I do not like the idea of closing the panel to choose the selected font. --Benji
              Message 6 of 10 , Jan 31, 2003
              • 0 Attachment
                Rain Dog wrote:
                >
                > ":set guifont=*" to invoke the Font Panel. Close the panel
                > to set the selected font.

                P.S. It would be nice to have an "OK" button and a "Cancel" button. I
                do not like the idea of closing the panel to choose the selected font.

                --Benji Fisher
              • Bob Ippolito
                This may be of interest to someone, but assuming you use black-background grey-text terminals, it changes all of the highlights to look be entirely consistent
                Message 7 of 10 , Feb 19, 2003
                • 0 Attachment
                  This may be of interest to someone, but assuming you use
                  black-background grey-text terminals, it changes all of the highlights
                  to look be entirely consistent between gvim and colored terminal vim.

                  -bob
                • Benji Fisher
                  ... Er, did you mean to attach a colorscheme file? --Benji Fisher
                  Message 8 of 10 , Feb 21, 2003
                  • 0 Attachment
                    Bob Ippolito wrote:
                    > This may be of interest to someone, but assuming you use
                    > black-background grey-text terminals, it changes all of the highlights
                    > to look be entirely consistent between gvim and colored terminal vim.
                    >
                    > -bob

                    Er, did you mean to attach a colorscheme file?

                    --Benji Fisher
                  • Bob Ippolito
                    I m pretty sure I did.. perhaps a problem with my mailserver? I ll try again.
                    Message 9 of 10 , Feb 21, 2003
                    • 0 Attachment
                      I'm pretty sure I did.. perhaps a problem with my mailserver? I'll
                      try again.
                    • Benji Fisher
                      I got it this time. Thanks. --Benji Fisher
                      Message 10 of 10 , Feb 21, 2003
                      • 0 Attachment
                        I got it this time. Thanks.

                        --Benji Fisher

                        Bob Ippolito wrote:
                        > I'm pretty sure I did.. perhaps a problem with my mailserver? I'll try
                        > again.
                        >
                        > On Friday, Feb 21, 2003, at 10:35 America/New_York, Benji Fisher wrote:
                        >
                        >> Bob Ippolito wrote:
                        >>
                        >>> This may be of interest to someone, but assuming you use
                        >>> black-background grey-text terminals, it changes all of the
                        >>> highlights to look be entirely consistent between gvim and colored
                        >>> terminal vim.
                        >>> -bob
                        >>
                        >>
                        >> Er, did you mean to attach a colorscheme file?
                        >>
                        >> --Benji Fisher
                      Your message has been successfully submitted and would be delivered to recipients shortly.