X-Git-Url: http://ncurses.scripts.mit.edu/?a=blobdiff_plain;f=c%2B%2B%2Fcursslk.cc;h=7b898cefff7d78e88c9d7d1ec7ad2d191c9137ae;hb=aef6681d538d4bd02cfdf9f52aeefec62488efd6;hp=23785dfca8286038461f005b22f42d085484ef43;hpb=8b06e371ed1bce3dd6f37138e6becb5e1a562fe0;p=ncurses.git diff --git a/c++/cursslk.cc b/c++/cursslk.cc index 23785dfc..7b898cef 100644 --- a/c++/cursslk.cc +++ b/c++/cursslk.cc @@ -1,6 +1,7 @@ // * this is for making emacs happy: -*-Mode: C++;-*- /**************************************************************************** - * Copyright (c) 1998-2005,2012 Free Software Foundation, Inc. * + * Copyright 2019-2022,2023 Thomas E. Dickey * + * Copyright 1998-2005,2012 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -35,7 +36,7 @@ #include "cursslk.h" #include "cursesapp.h" -MODULE_ID("$Id: cursslk.cc,v 1.16 2012/02/23 10:41:56 tom Exp $") +MODULE_ID("$Id: cursslk.cc,v 1.21 2023/02/25 23:36:06 tom Exp $") Soft_Label_Key_Set::Soft_Label_Key& Soft_Label_Key_Set::Soft_Label_Key::operator=(char *text) @@ -55,7 +56,11 @@ Soft_Label_Key_Set::Label_Layout void Soft_Label_Key_Set::init() { - slk_array = new Soft_Label_Key[num_labels]; + if (num_labels > 12) + num_labels = 12; + if (num_labels < 0) + num_labels = 0; + slk_array = new Soft_Label_Key[num_labels + 1]; for(int i=0; i < num_labels; i++) { slk_array[i].num = i+1; } @@ -88,7 +93,7 @@ Soft_Label_Key_Set::Soft_Label_Key_Set(Soft_Label_Key_Set::Label_Layout fmt) init(); } -Soft_Label_Key_Set::~Soft_Label_Key_Set() { +Soft_Label_Key_Set::~Soft_Label_Key_Set() THROWS(NCursesException) { if (!::isendwin()) clear(); delete[] slk_array; @@ -101,6 +106,10 @@ Soft_Label_Key_Set::Soft_Label_Key& Soft_Label_Key_Set::operator[](int i) { return slk_array[i-1]; } +int Soft_Label_Key_Set::labels() const { + return num_labels; +} + void Soft_Label_Key_Set::activate_label(int i, bool bf) { if (!b_attrInit) { NCursesApplication* A = NCursesApplication::getApplication();